Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated MSB for Platform Agnostic IMU driver #9

Merged
merged 5 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ uint16_t convert_can(uint16_t original_value, device_loc_t mode)
osThreadId_t temp_monitor_handle;
const osThreadAttr_t temp_monitor_attributes = {
.name = "TempMonitor",
.stack_size = 64 * 8,
.stack_size = 64 * 16,
.priority = (osPriority_t)osPriorityHigh1,
};

Expand Down
20 changes: 18 additions & 2 deletions Core/Src/msb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ extern device_loc_t device_loc;

osMutexId_t i2c_mutex;

// reads imu reg
static inline int imu_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 imu_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 @@ -42,8 +58,8 @@ int8_t msb_init()

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

#ifdef SENSOR_TOF
Expand Down
15 changes: 14 additions & 1 deletion Core/Src/stm32f4xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,24 @@ void NMI_Handler(void)
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */

/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
// this is an ISR where the MCU doesnt have an intact stack frame or peripherals, so its ok to f around
// no sleep exists in an ISR, for good reason
volatile uint32_t i = 0;
while (i < 120000) {
i += 1;
}
HAL_GPIO_WritePin(Debug_LED_1_GPIO_Port, Debug_LED_1_Pin, 0);
HAL_GPIO_WritePin(Debug_LED_2_GPIO_Port, Debug_LED_2_Pin, 0);
i = 0;
while (i < 120000) {
i += 1;
}
HAL_GPIO_WritePin(Debug_LED_1_GPIO_Port, Debug_LED_1_Pin, 1);
HAL_GPIO_WritePin(Debug_LED_2_GPIO_Port, Debug_LED_2_Pin, 1);
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
Expand Down
2 changes: 1 addition & 1 deletion Drivers/Embedded-Base