|
|
@@ -130,13 +130,30 @@ inline void app_delay(uint8_t ms){
|
|
|
HAL_Delay(ms);
|
|
|
}
|
|
|
|
|
|
-static inline void nbus_app_UART_RX(UART_HandleTypeDef *huart){
|
|
|
+static inline void nbus_app_UART_RX(UART_HandleTypeDef *huart) {
|
|
|
nbus_cb_UART_RX();
|
|
|
}
|
|
|
|
|
|
-static inline void nbus_app_TIM_periodElapsed(TIM_HandleTypeDef *htim){
|
|
|
+static inline void nbus_app_TIM_periodElapsed(TIM_HandleTypeDef *htim) {
|
|
|
nbus_cb_TIM_periodElapsed();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+volatile uint8_t icm_data_ready = 0;
|
|
|
+
|
|
|
+void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
|
|
|
+ icm_data_ready = 1;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+static inline uint8_t loop_callback() {
|
|
|
+ if(icm_data_ready == 1){
|
|
|
+ icm_data_ready = 0;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
/* USER CODE END 0 */
|
|
|
|
|
|
/**
|
|
|
@@ -187,7 +204,7 @@ int main(void)
|
|
|
MX_RTC_Init();
|
|
|
#endif
|
|
|
|
|
|
- nBusPlatformInterface_t hw_platform ={
|
|
|
+ nBusPlatformInterface_t hw_platform = {
|
|
|
uart_receive_it,
|
|
|
uart_send,
|
|
|
uart_abort_receive,
|
|
|
@@ -196,7 +213,8 @@ int main(void)
|
|
|
led_toggle,
|
|
|
timer_uart_start,
|
|
|
timer_uart_stop,
|
|
|
- app_delay
|
|
|
+ app_delay,
|
|
|
+ loop_callback,
|
|
|
};
|
|
|
|
|
|
#if MODULE_MASTER == 1
|
|
|
@@ -225,9 +243,12 @@ int main(void)
|
|
|
config.gyro.sample_rate = GYRO_samplerate_281_3Hz;
|
|
|
config.accel.low_pass_filter = ACCEL_lpf_246Hz;
|
|
|
config.accel.sample_rate = ACCEL_samplerate_281_3Hz;
|
|
|
+ config.int_source = interrupt_RAW_DATA_0_RDY_EN;
|
|
|
+ config.mag.mode = mag_mode_power_down;
|
|
|
|
|
|
nbus_init(getImuDriver(), &hw_platform);
|
|
|
nbus_init_app(&hspi1, &config);
|
|
|
+ // nbus_set_app_callback(loop_callback);
|
|
|
#endif
|
|
|
|
|
|
HAL_UART_RegisterCallback(&huart2, HAL_UART_RX_COMPLETE_CB_ID, nbus_app_UART_RX);
|
|
|
@@ -445,7 +466,7 @@ static void MX_SPI1_Init(void)
|
|
|
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
|
|
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
|
|
hspi1.Init.NSS = SPI_NSS_SOFT;
|
|
|
- hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
|
|
|
+ hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
|
|
|
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
|
|
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
|
|
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
|
|
@@ -636,12 +657,6 @@ static void MX_GPIO_Init(void)
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
|
HAL_GPIO_Init(SPI_SS_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
- /*Configure GPIO pin : SPI_INT_Pin */
|
|
|
- GPIO_InitStruct.Pin = SPI_INT_Pin;
|
|
|
- GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
|
- GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
- HAL_GPIO_Init(SPI_INT_GPIO_Port, &GPIO_InitStruct);
|
|
|
-
|
|
|
/*Configure GPIO pin : LD3_Pin */
|
|
|
GPIO_InitStruct.Pin = LD3_Pin;
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
@@ -656,6 +671,12 @@ static void MX_GPIO_Init(void)
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
|
|
HAL_GPIO_Init(ONE_WIRE_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
+ /*Configure GPIO pin : SPI_INT_Pin */
|
|
|
+ GPIO_InitStruct.Pin = SPI_INT_Pin;
|
|
|
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
|
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
|
+ HAL_GPIO_Init(SPI_INT_GPIO_Port, &GPIO_InitStruct);
|
|
|
+
|
|
|
/*Configure GPIO pins : PB6 PB7 */
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|