Skip to content

Commit

Permalink
changing msb for imu driver
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Oct 20, 2024
1 parent 72b7917 commit bd28331
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions Core/Src/msb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ extern device_loc_t device_loc;

osMutexId_t i2c_mutex;

// reads imu reg
static inline int read_reg(uint8_t *data,
uint8_t reg,
uint8_t length) {

return HAL_I2C_Mem_Read(&hi2c3, LSM6DSO_I2C_ADDRESS, reg,
I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY);
}

// read imu write
static inline int write_reg(uint8_t *data,
uint8_t reg,
uint8_t length) {

return HAL_I2C_Mem_Write(&hi2c3, LSM6DSO_I2C_ADDRESS, reg,
I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY);
}

#ifdef SENSOR_TEMP
sht30_t temp_sensor;
#endif
Expand Down Expand Up @@ -41,9 +59,10 @@ int8_t msb_init()
#endif

#ifdef SENSOR_IMU

/* Initialize the IMU */
imu = (lsm6dso_t){ .i2c_handle = &hi2c3 };
assert(!lsm6dso_init(&imu, &hi2c3)); /* This is always connected */
lsm6dso_t imu;
assert(!lsm6dso_init(&imu, read_reg, write_reg)); /* This is always connected */
#endif

#ifdef SENSOR_TOF
Expand Down
2 changes: 1 addition & 1 deletion Drivers/Embedded-Base

0 comments on commit bd28331

Please sign in to comment.