Skip to content

Commit 9da4c9d

Browse files
committed
fix
1 parent c7b2da8 commit 9da4c9d

7 files changed

Lines changed: 357 additions & 144 deletions

File tree

Core/Inc/u_can.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
#define IMU_ACCEL_CAN_ID 0xFC
77
#define IMU_GYRO_CAN_ID 0xFB
88
#define MAGNOMETER_CAN_ID 0XFD
9+
#define ORIENTATION_CAN_ID 0XFD
910

1011
// u_TODO - finish this file

Core/Inc/u_sensors.h

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,70 @@
22

33
#include <stdint.h>
44

5+
#define MOTION_FX_STATE_SIZE (size_t)(2432)
6+
7+
/*
8+
* Bias correction thresholds from MotionFX example implementations.
9+
* Lower GBIAS_* = more correction, higher = more stability.
10+
* Adjust if drift or instability occurs.
11+
*/
12+
#define GBIAS_ACC_TH_SC (2.0f * 0.000765f)
13+
#define GBIAS_GYRO_TH_SC (2.0f * 0.002f)
14+
#define GBIAS_MAG_TH_SC 0.0f
15+
16+
/*
17+
* DECIMATION controls how often sensor data is processed.
18+
* 1U = use every sample, higher = skip samples
19+
* Increase to ignore more samples if CPU usage is too high.
20+
*/
21+
#define DECIMATION 1U
22+
523
/**
624
* @brief initializes the lsm6dsv imu
725
* @return whether there were errors initializing the lsm6dsv imu
826
*/
927
uint16_t init_imu();
1028

11-
/**
12-
* @brief reads and sends data from the lsm6dsv
13-
* @return whether there were errors in reading/sending the data
14-
*/
15-
uint8_t read_imu();
16-
1729
/**
1830
* @brief initializes Magnetometer for reading
1931
* @return returns tx status for errors
2032
*/
2133
uint16_t init_magnetometer();
2234

2335
/**
24-
* @brief reads and returns the information from magnetometer
25-
* @return returns any tx errors in reading from the magnetometer
36+
* @brief reads data from the lsm6dsv and lis2mdl, and performs motionfx rotation calculations
37+
* @return whether there were errors in reading the data
38+
*/
39+
uint16_t read_imu_and_magnometer();
40+
41+
/**
42+
* @brief sends data from the lsm6dsv, lis2mdl, and motionfx rotation data over CAN
43+
*/
44+
void send_imu_and_magnometer_data();
45+
46+
/**
47+
* @brief initializes the motion fx library
48+
*/
49+
void motion_fx_init();
50+
51+
/**
52+
* @brief zeros the motion fx rotation data
2653
*/
27-
uint16_t read_magnetometer();
54+
void calibrate();
2855

2956
/**
3057
* @brief initializes the sht30 for reading temp and humidity
3158
* @return whether there were errors initializing the sht30
3259
*/
33-
uint8_t init_sht30();
60+
uint16_t init_sht30();
61+
62+
/**
63+
* @brief reads temp and humidity data from the sht30
64+
* @return whether there were errors in reading the data
65+
*/
66+
uint16_t read_sht30();
3467

3568
/**
36-
* @brief reads and sends temp and humidity data from the sht30
37-
* @return whether there were errors in reading/sending the data
69+
* @brief sends temp and humidity data from the sht30 over CAN
3870
*/
39-
uint8_t read_sht30();
71+
void send_sht30_data();

Core/Inc/u_utils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
/**
4+
* Converts a float to a 16 bit integer.
5+
*
6+
* @param value The float value to be converted
7+
*
8+
* @return The converted 16 bit integer
9+
*/
10+
int16_t float_to_int16(float value);

Core/Src/app_threadx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ UINT App_ThreadX_Init(VOID *memory_ptr)
7272
CATCH_ERROR(init_imu(), U_SUCCESS);
7373
CATCH_ERROR(init_magnetometer(), U_SUCCESS);
7474
CATCH_ERROR(init_sht30(), U_SUCCESS);
75+
CATCH_ERROR(motion_fx_init(), U_SUCCESS);
7576
CATCH_ERROR(threads_init(byte_pool), U_SUCCESS);
7677

7778
/* USER CODE END App_ThreadX_MEM_POOL */

0 commit comments

Comments
 (0)