Skip to content

Commit

Permalink
first commit for ESP32-C6 test
Browse files Browse the repository at this point in the history
  • Loading branch information
unlogisch04 committed Dec 3, 2023
1 parent b744c53 commit 93fbb6d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 32 deletions.
16 changes: 10 additions & 6 deletions lib/i2cscan/i2cscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand Down Expand Up @@ -65,15 +69,15 @@ namespace I2CSCAN
{
for (size_t i = 0; i < arraySize; i++)
{
if (value == array[i])
if (value == array[i])
{
return true;
}
}

return false;
}

bool checkI2C(uint8_t i, uint8_t j)
{
bool found = false;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
30 changes: 20 additions & 10 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
Expand All @@ -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
1 change: 1 addition & 0 deletions src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
12 changes: 6 additions & 6 deletions src/defines_sensitivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/icm20948sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void ICM20948Sensor::motionLoop()
cntbuf = 0;
cntrounds = 0;
}
*/
*/
}

void ICM20948Sensor::readFIFOToEnd()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 93fbb6d

Please sign in to comment.