diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1fe08c4e..538b8653 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,7 +47,15 @@ jobs: run: pio run -d Firmware/LowLevel - name: Copy Artifacts run: | + mkdir artifacts + mkdir ./artifacts/0_12_X_LSM6DSO + cp Firmware/LowLevel/.pio/build/0_12_X/firmware.elf ./artifacts/0_12_X_LSM6DSO + cp Firmware/LowLevel/.pio/build/0_12_X/firmware.uf2 ./artifacts/0_12_X_LSM6DSO + + mkdir ./artifacts/0_12_X + cp Firmware/LowLevel/.pio/build/0_12_X/firmware.elf ./artifacts/0_12_X + cp Firmware/LowLevel/.pio/build/0_12_X/firmware.uf2 ./artifacts/0_12_X mkdir ./artifacts/0_11_X_MPU9250 cp Firmware/LowLevel/.pio/build/0_11_X_MPU9250/firmware.elf ./artifacts/0_11_X_MPU9250 diff --git a/Firmware/LowLevel/platformio.ini b/Firmware/LowLevel/platformio.ini index f2f4beea..32c878d3 100644 --- a/Firmware/LowLevel/platformio.ini +++ b/Firmware/LowLevel/platformio.ini @@ -24,8 +24,8 @@ lib_deps = SPI FastCRC bakercp/PacketSerial@^1.4.0 - mryslab/NeoPixelConnect@^1.1.0 powerbroker2/FireTimer@^1.0.5 + https://github.com/ClemensElflein/NeoPixelConnect.git debug_tool = custom @@ -43,6 +43,17 @@ debug_build_flags = -O0 -g -ggdb build_src_filter = +<*> -<.git/> -<.svn/> - - + +[env:0_12_X] +lib_ignore = JY901_SERIAL,JY901_I2C +lib_deps = ${env.lib_deps} + stm32duino/STM32duino LSM6DSO@^2.0.3 + jpiat/PioSPI@^0.0.1 + powerbroker2/DFPlayerMini_Fast@^1.2.4 +build_src_filter = ${env.build_src_filter} + + +build_flags = ${env.build_flags} -DHW_0_12_X -DENABLE_SOUND_MODULE + + [env:0_11_X_MPU9250] lib_ignore = JY901_SERIAL,JY901_I2C lib_deps = ${env.lib_deps} diff --git a/Firmware/LowLevel/src/imu/LSM6DSO/imu.cpp b/Firmware/LowLevel/src/imu/LSM6DSO/imu.cpp new file mode 100644 index 00000000..c8eda843 --- /dev/null +++ b/Firmware/LowLevel/src/imu/LSM6DSO/imu.cpp @@ -0,0 +1,49 @@ +#include "imu.h" +#include "pins.h" +#include +#include + +PioSPI spiBus(PIN_IMU_MOSI, PIN_IMU_MISO, PIN_IMU_SCK, PIN_IMU_CS, SPI_MODE3, 1000000); +LSM6DSOSensor IMU(&spiBus, PIN_IMU_CS, 1000000); +int32_t accelerometer[3]; +int32_t gyroscope[3]; + +bool init_imu() +{ + spiBus.begin(); + int status = IMU.begin(); + if (status != 0) + return false; + + if (IMU.Enable_G() != 0) + return false; + + if (IMU.Enable_X() != 0) + return false; + return true; +} + +bool imu_read(float *acceleration_mss, float *gyro_rads, float *mag_uT) +{ + bool success = true; + success &= IMU.Get_X_Axes(accelerometer) == 0; + success &= IMU.Get_G_Axes(gyroscope) == 0; + + acceleration_mss[0] = accelerometer[0] * 9.81 / 1000.0; + acceleration_mss[1] = accelerometer[1] * 9.81 / 1000.0; + acceleration_mss[2] = accelerometer[2] * 9.81 / 1000.0; + + gyro_rads[0] = gyroscope[0] * (PI/180.0) / 1000.0; + gyro_rads[1] = gyroscope[1] * (PI/180.0) / 1000.0; + gyro_rads[2] = gyroscope[2] * (PI/180.0) / 1000.0; + + mag_uT[0] = 0; + mag_uT[1] = 0; + mag_uT[2] = 0; + + return success; +} + +void imu_loop() +{ +} diff --git a/Firmware/LowLevel/src/main.cpp b/Firmware/LowLevel/src/main.cpp index c9fece82..b16efee9 100644 --- a/Firmware/LowLevel/src/main.cpp +++ b/Firmware/LowLevel/src/main.cpp @@ -70,7 +70,7 @@ SerialPIO uiSerial(PIN_UI_TX, PIN_UI_RX, 250); // Emergency will be engaged, if no heartbeat was received in this time frame. #define HEARTBEAT_MILLIS 500 -NeoPixelConnect p(PIN_NEOPIXEL, 1, pio1, 0); // use state machine 1, sm 0 is used by hardwareserial class +NeoPixelConnect p(PIN_NEOPIXEL, 1); uint8_t led_blink_counter = 0; PacketSerial packetSerial; // COBS communication PICO <> Raspi diff --git a/Firmware/LowLevel/src/pins.h b/Firmware/LowLevel/src/pins.h index 38b0aff7..ede106b9 100644 --- a/Firmware/LowLevel/src/pins.h +++ b/Firmware/LowLevel/src/pins.h @@ -43,13 +43,17 @@ #define PIN_WT901_RX 16 #endif -#elif HW_0_10_X || HW_0_11_X +#elif HW_0_10_X || HW_0_11_X || HW_0_12_X #define WT901_WIRE Wire #define PIN_WT901_SDA 8 #define PIN_WT901_SCL 9 #define PIN_IMU_CS 9 +#define PIN_IMU_MOSI 7 +#define PIN_IMU_MISO 8 +#define PIN_IMU_SCK 6 + #define PIN_ANALOG_BATTERY_VOLTAGE 27 #define PIN_ANALOG_CHARGE_VOLTAGE 26 #define PIN_ANALOG_CHARGE_CURRENT 28