Skip to content

Commit

Permalink
Feature/LSM6DSO (#112)
Browse files Browse the repository at this point in the history
* Add LSM6DSO for HW 0.9.x

* Add LSMDSO for HW 0.10 and 0.11

* Add new LSM6DSO variants to CI
  • Loading branch information
Apehaenger authored Jan 19, 2025
1 parent 42f5810 commit 09a28f0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ jobs:
cp Firmware/LowLevel/.pio/build/0_11_X_WT901/firmware.elf ./artifacts/0_11_X_WT901
cp Firmware/LowLevel/.pio/build/0_11_X_WT901/firmware.uf2 ./artifacts/0_11_X_WT901
mkdir ./artifacts/0_11_X_LSM6DSO
cp Firmware/LowLevel/.pio/build/0_11_X_LSM6DSO/firmware.elf ./artifacts/0_11_X_LSM6DSO
cp Firmware/LowLevel/.pio/build/0_11_X_LSM6DSO/firmware.uf2 ./artifacts/0_11_X_LSM6DSO
mkdir ./artifacts/0_10_X_MPU9250
cp Firmware/LowLevel/.pio/build/0_10_X_MPU9250/firmware.elf ./artifacts/0_10_X_MPU9250
cp Firmware/LowLevel/.pio/build/0_10_X_MPU9250/firmware.uf2 ./artifacts/0_10_X_MPU9250
Expand All @@ -104,6 +108,10 @@ jobs:
cp Firmware/LowLevel/.pio/build/0_10_X_WT901/firmware.elf ./artifacts/0_10_X_WT901
cp Firmware/LowLevel/.pio/build/0_10_X_WT901/firmware.uf2 ./artifacts/0_10_X_WT901
mkdir ./artifacts/0_10_X_LSM6DSO
cp Firmware/LowLevel/.pio/build/0_10_X_LSM6DSO/firmware.elf ./artifacts/0_10_X_LSM6DSO
cp Firmware/LowLevel/.pio/build/0_10_X_LSM6DSO/firmware.uf2 ./artifacts/0_10_X_LSM6DSO
mkdir ./artifacts/0_9_X_MPU9250
cp Firmware/LowLevel/.pio/build/0_9_X_MPU9250/firmware.elf ./artifacts/0_9_X_MPU9250
cp Firmware/LowLevel/.pio/build/0_9_X_MPU9250/firmware.uf2 ./artifacts/0_9_X_MPU9250
Expand All @@ -115,7 +123,11 @@ jobs:
mkdir ./artifacts/0_9_X_WT901_INSTEAD_OF_SOUND
cp Firmware/LowLevel/.pio/build/0_9_X_WT901_INSTEAD_OF_SOUND/firmware.elf ./artifacts/0_9_X_WT901_INSTEAD_OF_SOUND
cp Firmware/LowLevel/.pio/build/0_9_X_WT901_INSTEAD_OF_SOUND/firmware.uf2 ./artifacts/0_9_X_WT901_INSTEAD_OF_SOUND
mkdir ./artifacts/0_9_X_LSM6DSO
cp Firmware/LowLevel/.pio/build/0_9_X_LSM6DSO/firmware.elf ./artifacts/0_9_X_LSM6DSO
cp Firmware/LowLevel/.pio/build/0_9_X_LSM6DSO/firmware.uf2 ./artifacts/0_9_X_LSM6DSO
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
26 changes: 26 additions & 0 deletions Firmware/LowLevel/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ lib_deps = ${env.lib_deps}
JY901_I2C
build_flags = ${env.build_flags} -DWT901_I2C -DHW_0_11_X -DENABLE_SOUND_MODULE

[env:0_11_X_LSM6DSO]
build_src_filter = ${env.build_src_filter} +<imu/LSM6DSO/>
lib_ignore = JY901_SERIAL,JY901_I2C
lib_deps = ${env.lib_deps}
${sound.lib_deps}
stm32duino/STM32duino LSM6DSO@^2.0.3
jpiat/PioSPI@^0.0.1
build_flags = ${env.build_flags} -DHW_0_11_X -DENABLE_SOUND_MODULE


[env:0_10_X_MPU9250]
lib_ignore = JY901_SERIAL,JY901_I2C
Expand All @@ -98,6 +107,15 @@ lib_deps = ${env.lib_deps}
JY901_I2C
build_flags = ${env.build_flags} -DWT901_I2C -DHW_0_10_X -DENABLE_SOUND_MODULE

[env:0_10_X_LSM6DSO]
build_src_filter = ${env.build_src_filter} +<imu/LSM6DSO/>
lib_ignore = JY901_SERIAL,JY901_I2C
lib_deps = ${env.lib_deps}
${sound.lib_deps}
stm32duino/STM32duino LSM6DSO@^2.0.3
jpiat/PioSPI@^0.0.1
build_flags = ${env.build_flags} -DHW_0_10_X -DENABLE_SOUND_MODULE


[env:0_9_X_MPU9250]
lib_ignore = JY901_SERIAL,JY901_I2C
Expand All @@ -121,3 +139,11 @@ lib_deps = ${env.lib_deps}
${sound.lib_deps}
JY901_SERIAL
build_flags = ${env.build_flags} -DWT901 -DHW_0_9_X -DENABLE_SOUND_MODULE

[env:0_9_X_LSM6DSO]
lib_ignore = JY901_SERIAL,JY901_I2C
build_src_filter = ${env.build_src_filter} +<imu/LSM6DSO/>
lib_deps = ${env.lib_deps}
${sound.lib_deps}
stm32duino/STM32duino LSM6DSO@^2.0.3
build_flags = ${env.build_flags} -DHW_0_9_X -DENABLE_SOUND_MODULE
6 changes: 3 additions & 3 deletions Firmware/LowLevel/src/imu/LSM6DSO/imu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "pins.h"
#include <LSM6DSOSensor.h>

#ifdef HW_0_12_X
// Needs software UART because pins were messed up in 0.12
#if defined(HW_0_10_X) || defined(HW_0_11_X) || defined(HW_0_12_X)
// Needs software SPI because pins were messed up in 0.10-0.12
#include <PioSPI.h>
PioSPI spiBus(PIN_IMU_MOSI, PIN_IMU_MISO, PIN_IMU_SCK, PIN_IMU_CS, SPI_MODE3, 1000000);
#else
Expand All @@ -16,7 +16,7 @@ int32_t accelerometer[3];
int32_t gyroscope[3];

bool init_imu() {
#ifdef HW_0_12_X
#if defined(HW_0_10_X) || defined(HW_0_11_X) || defined(HW_0_12_X)
spiBus.begin();
#else
spiBus.setCS(PIN_IMU_CS);
Expand Down
11 changes: 8 additions & 3 deletions Firmware/LowLevel/src/pins.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#ifdef HW_0_9_X
#define PIN_IMU_CS 17
#define PIN_ANALOG_BATTERY_VOLTAGE 27
#define PIN_ANALOG_CHARGE_VOLTAGE 26
#define PIN_ANALOG_CHARGE_CURRENT 28
Expand Down Expand Up @@ -32,15 +31,21 @@
#define PIN_SOUND_RX 9
#endif

#ifdef WT901_INSTEAD_OF_SOUND
// IMU Variants
#ifdef WT901_INSTEAD_OF_SOUND // WT901 via HardwareSerial
#ifdef ENABLE_SOUND_MODULE
#error you can not enable sound and have wt901 on sound port at the same time.
#endif
#define PIN_WT901_TX 8
#define PIN_WT901_RX 9
#elif WT901 //This is to use WT901 on MPU9250 Slot via Serial.
#elif WT901 // WT901 on MPU9250 Slot via SerialPIO.
#define PIN_WT901_TX 17
#define PIN_WT901_RX 16
#else
#define PIN_IMU_CS 17 // MPU9250
#define PIN_IMU_RX 16 // LSM6DSx
#define PIN_IMU_TX 19 // LSM6DSx
#define PIN_IMU_SCK 18 // LSM6DSx
#endif

#elif HW_0_10_X || HW_0_11_X || HW_0_12_X
Expand Down

0 comments on commit 09a28f0

Please sign in to comment.