diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 3e3e7cd..863c98e 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/ASM330LHH/user_ams330lhh.c b/ASM330LHH/user_ams330lhh.c index 7451e6c..c204559 100644 --- a/ASM330LHH/user_ams330lhh.c +++ b/ASM330LHH/user_ams330lhh.c @@ -24,16 +24,6 @@ static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t { uint8_t temp = reg; temp |= 0x80; -// GPIO_TypeDef *GPIOx; -// uint16_t GPIO_Pin; -// if (handle == &hspi1) { -// GPIOx = SPI1_CS_PORT; -// GPIO_Pin = SPI1_CS_PIN; -// } -// HAL_GPIO_WritePin(GPIOx, GPIO_Pin, GPIO_PIN_RESET); -// HAL_SPI_Transmit(handle, &temp, 1, 1000); -// HAL_SPI_Receive(handle, bufp, len, 1000); -// HAL_GPIO_WritePin(GPIOx, GPIO_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); HAL_SPI_Transmit(handle, &temp, 1, 1000); @@ -94,12 +84,9 @@ void asm_sample() asm330.x_gyro = 0.001 * asm330lhh_from_fs2000dps_to_mdps(data_raw_angular_rate[0]); asm330.y_gyro = 0.001 * asm330lhh_from_fs2000dps_to_mdps(data_raw_angular_rate[1]); asm330.z_gyro = 0.001 * asm330lhh_from_fs2000dps_to_mdps(data_raw_angular_rate[2]); -// angular_rate_mdps[0] = asm330lhh_from_fs2000dps_to_mdps( -// data_raw_angular_rate[0]); -// angular_rate_mdps[1] = asm330lhh_from_fs2000dps_to_mdps( -// data_raw_angular_rate[1]); -// angular_rate_mdps[2] = asm330lhh_from_fs2000dps_to_mdps( -// data_raw_angular_rate[2]); +// angular_rate_mdps[0] = asm330lhh_from_fs2000dps_to_mdps(data_raw_angular_rate[0]); +// angular_rate_mdps[1] = asm330lhh_from_fs2000dps_to_mdps(data_raw_angular_rate[1]); +// angular_rate_mdps[2] = asm330lhh_from_fs2000dps_to_mdps(data_raw_angular_rate[2]); } asm330lhh_xl_flag_data_ready_get(&spi1_dev, ®); diff --git a/ASM330LHH/user_asm330lhh.h b/ASM330LHH/user_asm330lhh.h index cd912db..b9fe951 100644 --- a/ASM330LHH/user_asm330lhh.h +++ b/ASM330LHH/user_asm330lhh.h @@ -14,20 +14,21 @@ #define IMU_NOT_READY 1 #define IMU_LOCK 1 #define IMU_UNLOCK 0 -typedef struct{ - int16_t x_a; //加速度值原始数据 - int16_t y_a; - int16_t z_a; - int16_t x_g; //角速度值原始数据 - int16_t y_g; - int16_t z_g; - float x_acc; //转换为真实加速度 - float y_acc; - float z_acc; - float x_gyro; //转换为真实角速度 - float y_gyro; - float z_gyro; -}asm_value; +typedef struct +{ + int16_t x_a; //加速度值原始数据 + int16_t y_a; + int16_t z_a; + int16_t x_g; //角速度值原始数据 + int16_t y_g; + int16_t z_g; + float x_acc; //转换为真实加速度 + float y_acc; + float z_acc; + float x_gyro; //转换为真实角速度 + float y_gyro; + float z_gyro; +} asm_value; extern asm_value asm330; void user_dev_init(); diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 6e79bea..b006043 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -55,7 +55,7 @@ void MX_GPIO_Init(void) HAL_GPIO_WritePin(SPI2_CSN_GPIO_Port, SPI2_CSN_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, LED0_Pin|LED1_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, LED0_Pin|LED1_Pin, GPIO_PIN_SET); /*Configure GPIO pins : PAPin PAPin */ GPIO_InitStruct.Pin = PPS_INT_Pin|SPI2_INIT1_Pin; diff --git a/Core/Src/main.c b/Core/Src/main.c index c23aabb..46937cf 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -104,7 +104,7 @@ int main(void) /* USER CODE BEGIN 2 */ HAL_TIM_Base_Start(&htim3); user_dev_init(); - user_dev_init1(); +// user_dev_init1(); memcpy(IMU_mng_TDK.name, "TDK\0", 4); memcpy(IMU_mng_ST.name, "STM\0", 4); /* enable IMU */ diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c index 653c574..5841bd9 100644 --- a/Core/Src/stm32f1xx_it.c +++ b/Core/Src/stm32f1xx_it.c @@ -288,9 +288,9 @@ void USART1_IRQHandler(void) /* USER CODE END USART1_IRQn 0 */ HAL_UART_IRQHandler(&huart1); /* USER CODE BEGIN USART1_IRQn 1 */ - if(__HAL_UART_GET_FLAG(&huart1,UART_FLAG_TC) != RESET) + if (__HAL_UART_GET_FLAG(&huart1,UART_FLAG_TC) != RESET) { - __HAL_UART_CLEAR_FLAG(&huart1,UART_FLAG_TC); + __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_TC); U1_DMA_BUSY = 0; } /* USER CODE END USART1_IRQn 1 */ @@ -340,28 +340,29 @@ void USART2_IRQHandler(void) /* USER CODE BEGIN 1 */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - if (GPIO_Pin == SPI2_INIT1_Pin && 1 == IMU_mng_TDK.enable) - { - - TDK_IMU_INT = 1; - if (0 == IMU_mng_TDK.lock) - { - IMU_mng_TDK.ready = 1; - IMU_mng_TDK.gpstime = SYS_TIME.SYS_GPST_TIME; - IMU_mng_TDK.utctime = SYS_TIME.SYS_UTC_TIME; - IMU_mng_TDK.gpstime.sec = IMU_mng_TDK.utctime.sec = __HAL_TIM_GET_COUNTER(&htim3) / 10000.0; - } - else - { - HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); - printf("ERROR -> TDK IMU RD TIME OUT! \r\n"); - printf("Go to loop! please reboot MCU! \r\n"); -// while (1) -// ; - } - HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); - } - else if (GPIO_Pin == SPI1_INIT1_Pin && 1 == IMU_mng_ST.enable) +// if (GPIO_Pin == SPI2_INIT1_Pin && 1 == IMU_mng_TDK.enable) +// { +// +// TDK_IMU_INT = 1; +// if (0 == IMU_mng_TDK.lock) +// { +// IMU_mng_TDK.ready = 1; +// IMU_mng_TDK.gpstime = SYS_TIME.SYS_GPST_TIME; +// IMU_mng_TDK.utctime = SYS_TIME.SYS_UTC_TIME; +// IMU_mng_TDK.gpstime.sec = IMU_mng_TDK.utctime.sec = __HAL_TIM_GET_COUNTER(&htim3) / 10000.0; +// } +// else +// { +// HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); +// printf("ERROR -> TDK IMU RD TIME OUT! \r\n"); +// printf("Go to loop! please reboot MCU! \r\n"); +//// while (1) +//// ; +// } +// HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); +// } +// else + if (GPIO_Pin == SPI1_INIT1_Pin && 1 == IMU_mng_ST.enable) { ST_IMU_INT = 1;