Skip to content

Commit ff77e80

Browse files
author
clemens
committed
feat: Added 0.12 hardware support
1 parent 35d1eae commit ff77e80

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

Firmware/LowLevel/platformio.ini

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ lib_deps =
2424
SPI
2525
FastCRC
2626
bakercp/PacketSerial@^1.4.0
27-
mryslab/NeoPixelConnect@^1.1.0
2827
powerbroker2/FireTimer@^1.0.5
28+
https://github.com/ClemensElflein/NeoPixelConnect.git
2929

3030

3131
debug_tool = custom
@@ -43,6 +43,17 @@ debug_build_flags = -O0 -g -ggdb
4343
build_src_filter = +<*> -<.git/> -<.svn/> -<imu/*> -<soundsystem.cpp>
4444

4545

46+
47+
[env:0_12_X]
48+
lib_ignore = JY901_SERIAL,JY901_I2C
49+
lib_deps = ${env.lib_deps}
50+
stm32duino/STM32duino LSM6DSO@^2.0.3
51+
jpiat/PioSPI@^0.0.1
52+
powerbroker2/DFPlayerMini_Fast@^1.2.4
53+
build_src_filter = ${env.build_src_filter} +<imu/LSM6DSO/> +<soundsystem.cpp>
54+
build_flags = ${env.build_flags} -DHW_0_12_X -DENABLE_SOUND_MODULE
55+
56+
4657
[env:0_11_X_MPU9250]
4758
lib_ignore = JY901_SERIAL,JY901_I2C
4859
lib_deps = ${env.lib_deps}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "imu.h"
2+
#include "pins.h"
3+
#include <LSM6DSOSensor.h>
4+
#include <PioSPI.h>
5+
6+
PioSPI spiBus(PIN_IMU_MOSI, PIN_IMU_MISO, PIN_IMU_SCK, PIN_IMU_CS, SPI_MODE3, 1000000);
7+
LSM6DSOSensor IMU(&spiBus, PIN_IMU_CS, 1000000);
8+
int32_t accelerometer[3];
9+
int32_t gyroscope[3];
10+
11+
bool init_imu()
12+
{
13+
spiBus.begin();
14+
int status = IMU.begin();
15+
if (status != 0)
16+
return false;
17+
18+
if (IMU.Enable_G() != 0)
19+
return false;
20+
21+
if (IMU.Enable_X() != 0)
22+
return false;
23+
return true;
24+
}
25+
26+
bool imu_read(float *acceleration_mss, float *gyro_rads, float *mag_uT)
27+
{
28+
bool success = true;
29+
success &= IMU.Get_X_Axes(accelerometer) == 0;
30+
success &= IMU.Get_G_Axes(gyroscope) == 0;
31+
32+
acceleration_mss[0] = accelerometer[0];
33+
acceleration_mss[1] = accelerometer[1];
34+
acceleration_mss[2] = accelerometer[2];
35+
36+
gyro_rads[0] = gyroscope[0];
37+
gyro_rads[1] = gyroscope[1];
38+
gyro_rads[2] = -gyroscope[2];
39+
40+
mag_uT[0] = 0;
41+
mag_uT[1] = 0;
42+
mag_uT[2] = 0;
43+
44+
return success;
45+
}
46+
47+
void imu_loop()
48+
{
49+
}

Firmware/LowLevel/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SerialPIO uiSerial(PIN_UI_TX, PIN_UI_RX, 250);
7070
// Emergency will be engaged, if no heartbeat was received in this time frame.
7171
#define HEARTBEAT_MILLIS 500
7272

73-
NeoPixelConnect p(PIN_NEOPIXEL, 1, pio1, 0); // use state machine 1, sm 0 is used by hardwareserial class
73+
NeoPixelConnect p(PIN_NEOPIXEL, 1);
7474
uint8_t led_blink_counter = 0;
7575

7676
PacketSerial packetSerial; // COBS communication PICO <> Raspi

Firmware/LowLevel/src/pins.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@
4343
#define PIN_WT901_RX 16
4444
#endif
4545

46-
#elif HW_0_10_X || HW_0_11_X
46+
#elif HW_0_10_X || HW_0_11_X || HW_0_12_X
4747
#define WT901_WIRE Wire
4848

4949
#define PIN_WT901_SDA 8
5050
#define PIN_WT901_SCL 9
5151

5252
#define PIN_IMU_CS 9
53+
#define PIN_IMU_MOSI 7
54+
#define PIN_IMU_MISO 8
55+
#define PIN_IMU_SCK 6
56+
5357
#define PIN_ANALOG_BATTERY_VOLTAGE 27
5458
#define PIN_ANALOG_CHARGE_VOLTAGE 26
5559
#define PIN_ANALOG_CHARGE_CURRENT 28

0 commit comments

Comments
 (0)