diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index 3363c11..1098260 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -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, }; diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 2b62a0f..9c7be3f 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -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 @@ -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 diff --git a/Core/Src/stm32f4xx_it.c b/Core/Src/stm32f4xx_it.c index f3baa99..25a348d 100644 --- a/Core/Src/stm32f4xx_it.c +++ b/Core/Src/stm32f4xx_it.c @@ -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 */ } } diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index fe86adc..20415db 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit fe86adccf26edb23b0d80366a99426d177ed824d +Subproject commit 20415dbef0a34e5ffce356a2f68d9d8ad8108e86