From 93fbb6d7409409e4a39eb990a58d7f873d214b0d Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Sun, 3 Dec 2023 03:38:29 +0100 Subject: [PATCH] first commit for ESP32-C6 test --- lib/i2cscan/i2cscan.cpp | 16 ++++++++++------ platformio.ini | 30 ++++++++++++++++++++---------- src/consts.h | 1 + src/defines.h | 22 +++++++++++++++------- src/defines_sensitivity.h | 12 ++++++------ src/main.cpp | 2 +- src/sensors/icm20948sensor.cpp | 4 ++-- 7 files changed, 55 insertions(+), 32 deletions(-) diff --git a/lib/i2cscan/i2cscan.cpp b/lib/i2cscan/i2cscan.cpp index a252caed7..8bc337347 100644 --- a/lib/i2cscan/i2cscan.cpp +++ b/lib/i2cscan/i2cscan.cpp @@ -10,6 +10,10 @@ String portMap[] = {"D0", "D1", "D2", "D4", "D5", "D6", "D7"}; uint8_t portArray[] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; uint8_t portExclude[] = {18, 19, 20, 21, LED_PIN}; String portMap[] = {"2", "3", "4", "5", "6", "7", "8", "9", "10"}; +#elif defined(ESP32C6) //TODO: Assign the correct ports +uint8_t portArray[] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; +uint8_t portExclude[] = {12, 13, 18, 19, 20, 21, LED_PIN}; +String portMap[] = {"2", "3", "4", "5", "6", "7", "8", "9", "10"}; #elif defined(ESP32) uint8_t portArray[] = {4, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 32, 33}; String portMap[] = {"4", "13", "14", "15", "16", "17", "18", "19", "21", "22", "23", "25", "26", "27", "32", "33"}; @@ -65,7 +69,7 @@ namespace I2CSCAN { for (size_t i = 0; i < arraySize; i++) { - if (value == array[i]) + if (value == array[i]) { return true; } @@ -73,7 +77,7 @@ namespace I2CSCAN return false; } - + bool checkI2C(uint8_t i, uint8_t j) { bool found = false; @@ -97,7 +101,7 @@ namespace I2CSCAN if (error == 0) { - Serial.printf("[DBG] I2C (@ %s(%d) : %s(%d)): I2C device found at address 0x%02x !\n", + Serial.printf("[DBG] I2C (@ %s(%d) : %s(%d)): I2C device found at address 0x%02x !\n", portMap[i].c_str(), portArray[i], portMap[j].c_str(), portArray[j], address); nDevices++; found = true; @@ -113,13 +117,13 @@ namespace I2CSCAN bool hasDevOnBus(uint8_t addr) { byte error; -#if ESP32C3 +#if ESP32C3 || defined(ESP32C6) int retries = 2; do { #endif Wire.beginTransmission(addr); error = Wire.endTransmission(); -#if ESP32C3 +#if ESP32C3 || defined(ESP32C6) } while (error != 0 && retries--); #endif @@ -152,7 +156,7 @@ namespace I2CSCAN pinMode(SCL, INPUT_PULLUP); boolean SCL_LOW = (digitalRead(SCL) == LOW); // Check is SCL is Low. - if (SCL_LOW) { //If it is held low Arduno cannot become the I2C master. + if (SCL_LOW) { //If it is held low Arduno cannot become the I2C master. return 1; //I2C bus error. Could not clear SCL clock line held low } diff --git a/platformio.ini b/platformio.ini index 01e6fdd65..10ad4eda8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -54,12 +54,12 @@ build_unflags = -Os -std=gnu++11 ; Settings for different boards -[env:esp12e] -platform = espressif8266 @ 4.2.0 -board = esp12e -; Comment out this line below if you have any trouble uploading the firmware -; and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed -upload_speed = 921600 +;[env:esp12e] +;platform = espressif8266 @ 4.2.0 +;board = esp12e +;; Comment out this line below if you have any trouble uploading the firmware +;; and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed +;upload_speed = 921600 ; Uncomment below if you want to build for ESP-01 ;[env:esp01_1m] @@ -76,10 +76,10 @@ upload_speed = 921600 ; Uncomment below if you want to build for esp32 ; Check your board name at https://docs.platformio.org/en/latest/platforms/espressif32.html#boards -; [env:esp32] -; platform = espressif32 @ 6.1.0 -; board = esp32dev -; Comment out this line below if you have any trouble uploading the firmware - and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed +;[env:esp32] +;platform = espressif32 @ 6.1.0 +;board = esp32dev +;; Comment out this line below if you have any trouble uploading the firmware - and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed ;upload_speed = 921600 ; If you want to use a ESP32C3, you can use this (experimental) @@ -97,3 +97,13 @@ upload_speed = 921600 ; ${env.build_flags} ; -DESP32C3 ;board = lolin_c3_mini + +[env:esp32c6] +platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 +build_flags = + ${env.build_flags} + -DESP32C6 +board = esp32-c6-devkitm-1 +;platform_packages = +; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git +upload_speed = 921600 diff --git a/src/consts.h b/src/consts.h index 3c09d1d26..9e2bd6a9f 100644 --- a/src/consts.h +++ b/src/consts.h @@ -54,6 +54,7 @@ #define BOARD_WRANGLER 14 // Only used by wrangler app #define BOARD_MOCOPI 15 // Used by mocopi/moslime #define BOARD_WEMOSWROOM02 16 +#define BOARD_ES32C6DEVKITM1 249 // only for dev #define BOARD_DEV_RESERVED 250 // Reserved, should not be used in any release firmware #define BAT_EXTERNAL 1 diff --git a/src/defines.h b/src/defines.h index 79f4d94b3..db1f1939a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -28,7 +28,7 @@ // Set parameters of IMU and board used #define IMU IMU_BNO085 #define SECOND_IMU IMU -#define BOARD BOARD_SLIMEVR +#define BOARD BOARD_ES32C6DEVKITM1 #define IMU_ROTATION DEG_270 #define SECOND_IMU_ROTATION DEG_270 @@ -53,8 +53,8 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #endif // Battery monitoring options (comment to disable): -// BAT_EXTERNAL for ADC pin, -// BAT_INTERNAL for internal - can detect only low battery, +// BAT_EXTERNAL for ADC pin, +// BAT_INTERNAL for internal - can detect only low battery, // BAT_MCP3021 for external ADC connected over I2C #define BATTERY_MONITOR BAT_EXTERNAL @@ -75,7 +75,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P // LED_PIN // - Number or Symbol (D1,..) of the Output // - To turn off the LED, set LED_PIN to LED_OFF -// LED_INVERTED +// LED_INVERTED // - false for output 3.3V on high // - true for pull down to GND on high @@ -91,7 +91,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 0 #endif - #ifndef BATTERY_SHIELD_R1 + #ifndef BATTERY_SHIELD_R1 #define BATTERY_SHIELD_R1 10 #endif #ifndef BATTERY_SHIELD_R2 @@ -108,7 +108,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 0 #endif - #ifndef BATTERY_SHIELD_R1 + #ifndef BATTERY_SHIELD_R1 #define BATTERY_SHIELD_R1 10 #endif #ifndef BATTERY_SHIELD_R2 @@ -125,7 +125,7 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #ifndef BATTERY_SHIELD_RESISTANCE #define BATTERY_SHIELD_RESISTANCE 180 #endif - #ifndef BATTERY_SHIELD_R1 + #ifndef BATTERY_SHIELD_R1 #define BATTERY_SHIELD_R1 100 #endif #ifndef BATTERY_SHIELD_R2 @@ -189,4 +189,12 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P #define PIN_BATTERY_LEVEL A0 #define LED_PIN 16 #define LED_INVERTED true +#elif BOARD == BOARD_ES32C6DEVKITM1 + #define PIN_IMU_SDA 6 + #define PIN_IMU_SCL 7 + #define PIN_IMU_INT 0 + #define PIN_IMU_INT_2 1 + #define PIN_BATTERY_LEVEL 2 + #define LED_PIN LED_BUILTIN // RGB LED Protocol would need to be implementetet did not brother for the test, because the board ideal for tracker ifself + #define LED_INVERTED false #endif diff --git a/src/defines_sensitivity.h b/src/defines_sensitivity.h index 77c5ac02a..7d7cc7d61 100644 --- a/src/defines_sensitivity.h +++ b/src/defines_sensitivity.h @@ -50,11 +50,11 @@ struct SensitivityOffsetXYZ { const char* mac; unsigned char sensorId; double spins; double x; double y; double z; }; const SensitivityOffsetXYZ sensitivityOffsets[] = { // example values - { "A4:E5:7C:B6:00:01", SENSORID_PRIMARY, .spins = 10, .x = 2.63, .y = 37.82, .z = 31.11 }, - { "A4:E5:7C:B6:00:02", SENSORID_PRIMARY, .spins = 10, .x = -2.38, .y = -26.8, .z = -42.78 }, - { "A4:E5:7C:B6:00:03", SENSORID_PRIMARY, .spins = 10, .x = 11, .y = 2.2, .z = -1 }, - { "A4:E5:7C:B6:00:04", SENSORID_PRIMARY, .spins = 10, .x = -7, .y = -53.7, .z = -57 }, - { "A4:E5:7C:B6:00:05", SENSORID_PRIMARY, .spins = 10, .x = -10.63, .y = -8.25, .z = -18.6 }, + { .mac = "A4:E5:7C:B6:00:01", .sensorId = SENSORID_PRIMARY, .spins = 10, .x = 2.63, .y = 37.82, .z = 31.11 }, + { .mac = "A4:E5:7C:B6:00:02", .sensorId = SENSORID_PRIMARY, .spins = 10, .x = -2.38, .y = -26.8, .z = -42.78 }, + { .mac = "A4:E5:7C:B6:00:03", .sensorId = SENSORID_PRIMARY, .spins = 10, .x = 11, .y = 2.2, .z = -1 }, + { .mac = "A4:E5:7C:B6:00:04", .sensorId = SENSORID_PRIMARY, .spins = 10, .x = -7, .y = -53.7, .z = -57 }, + { .mac = "A4:E5:7C:B6:00:05", .sensorId = SENSORID_PRIMARY, .spins = 10, .x = -10.63, .y = -8.25, .z = -18.6 }, }; -#endif \ No newline at end of file +#endif diff --git a/src/main.cpp b/src/main.cpp index b4a4dd8ee..ea199a466 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,7 +53,7 @@ void setup() Serial.begin(serialBaudRate); globalTimer = timer_create_default(); -#ifdef ESP32C3 +#if defined (ESP32C3) || defined(ESP32C6) // Wait for the Computer to be able to connect. delay(2000); #endif diff --git a/src/sensors/icm20948sensor.cpp b/src/sensors/icm20948sensor.cpp index 9e60914d8..34fee27c5 100644 --- a/src/sensors/icm20948sensor.cpp +++ b/src/sensors/icm20948sensor.cpp @@ -79,7 +79,7 @@ void ICM20948Sensor::motionLoop() cntbuf = 0; cntrounds = 0; } -*/ +*/ } void ICM20948Sensor::readFIFOToEnd() @@ -144,7 +144,7 @@ void ICM20948Sensor::startCalibrationAutoSave() void ICM20948Sensor::startDMP() { #ifdef ESP32 - #if ESP32C3 + #if ESP32C3 || defined(ESP32C6) #define ICM20948_ODRGYR 1 #define ICM20948_ODRAXL 1 #else