Added ESP32C6

This commit is contained in:
nopnop2002
2023-07-16 15:12:43 +09:00
parent 67dd8d8833
commit 5f58f5116f
5 changed files with 22 additions and 23 deletions
+4 -4
View File
@@ -8,8 +8,8 @@ It's purpose is to be a bridge between a CAN-Bus and a HTTP-Server.
# Software requirement # Software requirement
esp-idf v4.4/v5.0. ESP-IDF V4.4/V5.x.
This is because this version supports ESP32-C3. ESP-IDF V5.1 is required when using ESP32C6.
# Hardware requirements # Hardware requirements
- SN65HVD23x CAN-BUS Transceiver - SN65HVD23x CAN-BUS Transceiver
@@ -18,7 +18,7 @@ This is because this version supports ESP32-C3.
I used 150 ohms. I used 150 ohms.
# Wireing # Wireing
|SN65HVD23x||ESP32|ESP32-S2/S3|ESP32-C3|| |SN65HVD23x||ESP32|ESP32-S2/S3|ESP32-C3/C6||
|:-:|:-:|:-:|:-:|:-:|:-:| |:-:|:-:|:-:|:-:|:-:|:-:|
|D(CTX)|--|GPIO21|GPIO17|GPIO0|(*1)| |D(CTX)|--|GPIO21|GPIO17|GPIO0|(*1)|
|GND|--|GND|GND|GND|| |GND|--|GND|GND|GND||
@@ -77,7 +77,7 @@ Check [here](http://www.ti.com/lit/an/slla337/slla337.pdf).
``` ```
git clone https://github.com/nopnop2002/esp-idf-can2http git clone https://github.com/nopnop2002/esp-idf-can2http
cd esp-idf-can2http cd esp-idf-can2http
idf.py set-target {esp32/esp32s2/esp32s3/esp32c3} idf.py set-target {esp32/esp32s2/esp32s3/esp32c3/esp32c6}
idf.py menuconfig idf.py menuconfig
idf.py flash idf.py flash
``` ```
+4 -3
View File
@@ -6,6 +6,7 @@ menu "Application Configuration"
default 46 if IDF_TARGET_ESP32S2 default 46 if IDF_TARGET_ESP32S2
default 48 if IDF_TARGET_ESP32S3 default 48 if IDF_TARGET_ESP32S3
default 19 if IDF_TARGET_ESP32C3 default 19 if IDF_TARGET_ESP32C3
default 30 if IDF_TARGET_ESP32C6
menu "CAN Setting" menu "CAN Setting"
@@ -53,7 +54,7 @@ menu "Application Configuration"
range 0 GPIO_RANGE_MAX range 0 GPIO_RANGE_MAX
default 21 if IDF_TARGET_ESP32 default 21 if IDF_TARGET_ESP32
default 17 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 default 17 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 0 if IDF_TARGET_ESP32C3 default 0 # C3 and others
help help
GPIO number (IOxx) to CTX. GPIO number (IOxx) to CTX.
Some GPIOs are used for other purposes (flash connections, etc.). Some GPIOs are used for other purposes (flash connections, etc.).
@@ -64,7 +65,7 @@ menu "Application Configuration"
range 0 GPIO_RANGE_MAX range 0 GPIO_RANGE_MAX
default 22 if IDF_TARGET_ESP32 default 22 if IDF_TARGET_ESP32
default 18 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 default 18 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 1 if IDF_TARGET_ESP32C3 default 1 # C3 and others
help help
GPIO number (IOxx) to CRX. GPIO number (IOxx) to CRX.
Some GPIOs are used for other purposes (flash connections, etc.). Some GPIOs are used for other purposes (flash connections, etc.).
@@ -137,7 +138,7 @@ menu "Application Configuration"
config WEB_SERVER config WEB_SERVER
string "HTTP Server IP or mDNS" string "HTTP Server IP or mDNS"
default "httpserver.local" default "http-server.local"
help help
The host name or IP address of the HTTP server to use. The host name or IP address of the HTTP server to use.
+4 -5
View File
@@ -107,6 +107,7 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
static void http_rest_with_url(char * path, char * post_data) static void http_rest_with_url(char * path, char * post_data)
{ {
ESP_LOGI(TAG, "path=[%s]", path);
char local_response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0}; char local_response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
/** /**
* NOTE: All the configuration parameters for http_client must be spefied either in URL or as host and path parameters. * NOTE: All the configuration parameters for http_client must be spefied either in URL or as host and path parameters.
@@ -115,6 +116,7 @@ static void http_rest_with_url(char * path, char * post_data)
* *
* If URL as well as host and path parameters are specified, values of host and path will be considered. * If URL as well as host and path parameters are specified, values of host and path will be considered.
*/ */
#if 1
esp_http_client_config_t config = { esp_http_client_config_t config = {
.host = CONFIG_WEB_SERVER, .host = CONFIG_WEB_SERVER,
.port = CONFIG_WEB_PORT, .port = CONFIG_WEB_PORT,
@@ -123,11 +125,10 @@ static void http_rest_with_url(char * path, char * post_data)
.user_data = local_response_buffer, // Pass address of local buffer to get response .user_data = local_response_buffer, // Pass address of local buffer to get response
.disable_auto_redirect = true, .disable_auto_redirect = true,
}; };
#else
#if 0
// Same as above // Same as above
esp_http_client_config_t config = { esp_http_client_config_t config = {
.url = "http://192.168.10.43:8000/post", .url = "http://http-server.local:8000/post",
.event_handler = _http_event_handler, .event_handler = _http_event_handler,
.user_data = local_response_buffer, // Pass address of local buffer to get response .user_data = local_response_buffer, // Pass address of local buffer to get response
.disable_auto_redirect = true, .disable_auto_redirect = true,
@@ -142,8 +143,6 @@ static void http_rest_with_url(char * path, char * post_data)
esp_http_client_set_header(client, "Content-Type", "application/json"); esp_http_client_set_header(client, "Content-Type", "application/json");
esp_http_client_set_post_field(client, post_data, strlen(post_data)); esp_http_client_set_post_field(client, post_data, strlen(post_data));
esp_err_t err = esp_http_client_perform(client); esp_err_t err = esp_http_client_perform(client);
// ESP-IDF V4.4 int esp_http_client_get_content_length
// ESP-IDF V5.0 int64_t esp_http_client_get_content_length
if (err == ESP_OK) { if (err == ESP_OK) {
ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %lld", ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %lld",
esp_http_client_get_status_code(client), esp_http_client_get_status_code(client),
+3 -4
View File
@@ -10,6 +10,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "freertos/queue.h" #include "freertos/queue.h"
@@ -174,11 +175,9 @@ void wifi_init_sta()
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
* happened. */ * happened. */
if (bits & WIFI_CONNECTED_BIT) { if (bits & WIFI_CONNECTED_BIT) {
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
} else if (bits & WIFI_FAIL_BIT) { } else if (bits & WIFI_FAIL_BIT) {
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
} else { } else {
ESP_LOGE(TAG, "UNEXPECTED EVENT"); ESP_LOGE(TAG, "UNEXPECTED EVENT");
} }
+2 -2
View File
@@ -2,5 +2,5 @@
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x6000, nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000, phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M, factory, app, factory, 0x10000, 0x120000,
storage, data, spiffs, , 0xF0000, storage, data, spiffs, , 0xD0000,
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3 nvs, data, nvs, 0x9000, 0x6000,
4 phy_init, data, phy, 0xf000, 0x1000,
5 factory, app, factory, 0x10000, 1M, factory, app, factory, 0x10000, 0x120000,
6 storage, data, spiffs, , 0xF0000, storage, data, spiffs, , 0xD0000,