Skip to content

Commit

Permalink
Merge branch 'feat/hw_0_12'
Browse files Browse the repository at this point in the history
  • Loading branch information
clemens committed Apr 11, 2023
2 parents bf7a313 + 12d5b4c commit f04a971
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion Firmware/LowLevel/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +43,17 @@ debug_build_flags = -O0 -g -ggdb
build_src_filter = +<*> -<.git/> -<.svn/> -<imu/*> -<soundsystem.cpp>



[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} +<imu/LSM6DSO/> +<soundsystem.cpp>
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}
Expand Down
49 changes: 49 additions & 0 deletions Firmware/LowLevel/src/imu/LSM6DSO/imu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "imu.h"
#include "pins.h"
#include <LSM6DSOSensor.h>
#include <PioSPI.h>

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()
{
}
2 changes: 1 addition & 1 deletion Firmware/LowLevel/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Firmware/LowLevel/src/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f04a971

Please sign in to comment.