Skip to content

Commit 615ccf8

Browse files
committed
[nRF52] add some logic to distinguish M1, M3 and M6
1 parent 8b4987f commit 615ccf8

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

software/firmware/source/SoftRF/SoftRF.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ enum
282282
ACC_BMA423,
283283
ACC_ADXL362,
284284
ACC_QMA6100P,
285+
ACC_SC7A20H,
285286
IMU_MPU6886,
286287
IMU_MPU9250,
287288
IMU_BNO080,

software/firmware/source/SoftRF/src/platform/iomap/Elecrow_ThinkNode_M3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@
5959
#define SOC_GPIO_PIN_M3_VUSB_SEN _PINNUM(0, 31) // P0.31
6060
#define SOC_GPIO_PIN_M3_VGPS_SEN SOC_UNUSED_PIN // TBD
6161

62-
/* Sensors (ACC + AHT10) */
62+
/* Sensors (SC7A20H + AHT20) */
6363
#define SOC_GPIO_PIN_M3_ACC_EN _PINNUM(0, 2) // P0.02 active HIGH ?
6464
#define SOC_GPIO_PIN_M3_TEMP_EN _PINNUM(0, 3) // P0.03 active HIGH

software/firmware/source/SoftRF/src/platform/nRF52.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,34 @@ static void nRF52_setup()
925925
#endif /* EXCLUDE_IMU */
926926
}
927927

928+
if (nRF52_board == NRF52_ELECROW_TN_M1) { /* "ELECROWBOOT" */
929+
pinMode(SOC_GPIO_PIN_M3_TEMP_EN, INPUT_PULLUP);
930+
delay(5);
931+
932+
#if !defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_ZEPHYR)
933+
Wire.setPins(SOC_GPIO_PIN_M3_SDA, SOC_GPIO_PIN_M3_SCL);
934+
#endif /* ARDUINO_ARCH_MBED */
935+
Wire.begin();
936+
Wire.beginTransmission(AHT20_ADDRESS);
937+
if (Wire.endTransmission() == 0) { nRF52_board = NRF52_ELECROW_TN_M3; }
938+
Wire.end();
939+
pinMode(SOC_GPIO_PIN_M3_TEMP_EN, INPUT);
940+
}
941+
942+
if (nRF52_board == NRF52_ELECROW_TN_M1) { /* "ELECROWBOOT" */
943+
pinMode(SOC_GPIO_PIN_IO_M6_PWR, INPUT_PULLUP);
944+
delay(5);
945+
946+
#if !defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_ZEPHYR)
947+
Wire.setPins(SOC_GPIO_PIN_M6_SDA, SOC_GPIO_PIN_M6_SCL);
948+
#endif /* ARDUINO_ARCH_MBED */
949+
Wire.begin();
950+
Wire.beginTransmission(PCF8563_SLAVE_ADDRESS);
951+
if (Wire.endTransmission() == 0) { nRF52_board = NRF52_ELECROW_TN_M6; }
952+
Wire.end();
953+
pinMode(SOC_GPIO_PIN_IO_M6_PWR, INPUT);
954+
}
955+
928956
#if !defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_ZEPHYR)
929957
switch (nRF52_board)
930958
{
@@ -1662,6 +1690,10 @@ static void nRF52_setup()
16621690
}
16631691
break;
16641692

1693+
case NRF52_ELECROW_TN_M3:
1694+
/* TBD */
1695+
break;
1696+
16651697
default:
16661698
break;
16671699
}
@@ -2249,7 +2281,7 @@ static void nRF52_loop()
22492281
IMU_Time_Marker = millis();
22502282
}
22512283

2252-
#if !defined(EXCLUDE_BHI260)
2284+
#if 0 /* TODO */ // !defined(EXCLUDE_BHI260)
22532285
if (hw_info.imu == IMU_BHI260AP &&
22542286
(millis() - IMU_Time_Marker) > (IMU_UPDATE_INTERVAL / 10)) {
22552287
// Update sensor fifo

software/firmware/source/SoftRF/src/platform/nRF52.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ struct rst_info {
135135
#define BME280_ADDRESS (0x77)
136136
#define BHI260AP_ADDRESS_L (0x28)
137137
#define BHI260AP_ADDRESS_H (0x29)
138-
#define AHT10_ADDRESS (0x38)
138+
#define AHT20_ADDRESS (0x38)
139+
#define SC7A20H_ADDRESS_L (0x18)
140+
#define SC7A20H_ADDRESS_H (0x19)
139141

140142
#if defined(ARDUINO_ARCH_MBED) || defined(ARDUINO_ARCH_ZEPHYR)
141143
#define PCF8563_SLAVE_ADDRESS (0x51)
@@ -342,7 +344,7 @@ struct rst_info {
342344
#endif /* ARDUINO_ARCH_MBED */
343345

344346
//#define EXCLUDE_BHI260
345-
//#define USE_BHI260_RAM_FW
347+
#define USE_BHI260_RAM_FW
346348

347349
/* T-Ultima */
348350
#define EXCLUDE_PMU

software/firmware/source/SoftRF/src/ui/IMU_EPD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ static const char G_load_text[] = "G-load";
3030

3131
void EPD_imu_setup()
3232
{
33-
if (hw_info.imu != IMU_NONE) {
33+
if (hw_info.imu != IMU_NONE &&
34+
hw_info.imu != IMU_BHI260AP /* TODO */) {
3435
EPD_pages_mask |= (1 << VIEW_MODE_IMU);
3536
}
3637
}

0 commit comments

Comments
 (0)