|
|
@@ -22,7 +22,13 @@
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
|
/* USER CODE BEGIN Includes */
|
|
|
#include "nbus_app.h"
|
|
|
+#if MODULE == MODULE_FSR
|
|
|
#include "app_adc.h"
|
|
|
+#endif
|
|
|
+#if MODULE == MODULE_DUMMY
|
|
|
+#include "app_dummy.h"
|
|
|
+#endif
|
|
|
+#include "app_interface.h"
|
|
|
/* USER CODE END Includes */
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
@@ -68,7 +74,7 @@ static void MX_ADC_Init(void);
|
|
|
|
|
|
/* Private user code ---------------------------------------------------------*/
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
-void uart_send(uint8_t *data, int n)
|
|
|
+inline void uart_send(uint8_t *data, int n)
|
|
|
{
|
|
|
#if USE_USART_DMA_TX == 1
|
|
|
HAL_UART_Transmit_DMA(&huart2, data, n);
|
|
|
@@ -77,26 +83,45 @@ void uart_send(uint8_t *data, int n)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-void led_on(){
|
|
|
+
|
|
|
+inline void led_on(){
|
|
|
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_SET);
|
|
|
}
|
|
|
|
|
|
-void led_off(){
|
|
|
+inline void led_off(){
|
|
|
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
|
|
|
}
|
|
|
|
|
|
-void led_toggle(){
|
|
|
+inline void led_toggle(){
|
|
|
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
|
|
|
}
|
|
|
|
|
|
-void uart_receive_it(uint8_t *data, int n)
|
|
|
+inline void uart_receive_it(uint8_t *data, int n)
|
|
|
{
|
|
|
HAL_UART_Receive_IT(&huart2, data, n);
|
|
|
}
|
|
|
|
|
|
-void uart_abort_receive(){
|
|
|
+inline void uart_abort_receive(){
|
|
|
HAL_UART_AbortReceive_IT(&huart2);
|
|
|
}
|
|
|
+
|
|
|
+inline void timer_uart_start(int n){
|
|
|
+ htim22.Instance->CNT = 1;
|
|
|
+ htim22.Instance->ARR = 40*n + 400; // (10*n + 100)us
|
|
|
+ HAL_TIM_Base_Start_IT(&htim22);
|
|
|
+}
|
|
|
+
|
|
|
+inline void timer_uart_stop(){
|
|
|
+ HAL_TIM_Base_Stop_IT(&htim22);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void nbus_app_UART_RX(UART_HandleTypeDef *huart){
|
|
|
+ nbus_cb_UART_RX();
|
|
|
+}
|
|
|
+
|
|
|
+static inline void nbus_app_TIM_periodElapsed(TIM_HandleTypeDef *htim){
|
|
|
+ nbus_cb_TIM_periodElapsed();
|
|
|
+}
|
|
|
/* USER CODE END 0 */
|
|
|
|
|
|
/**
|
|
|
@@ -152,34 +177,32 @@ int main(void)
|
|
|
led_on,
|
|
|
led_off,
|
|
|
led_toggle,
|
|
|
+ timer_uart_start,
|
|
|
+ timer_uart_stop
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- Peripheral_typeDef periph;
|
|
|
- //periph.huart = &huart2;
|
|
|
- periph.uart_timer = &htim22;
|
|
|
- periph.measure_timer = &htim21; // TODO ?
|
|
|
- //periph.adc = NULL;
|
|
|
- //periph.led = &Led;
|
|
|
#if MODULE_MASTER == 1
|
|
|
periph.rtc = &hrtc;
|
|
|
#endif
|
|
|
|
|
|
|
|
|
- //nBusAppInterface_t *dummy = getDummyDriver();
|
|
|
+#if MODULE == MODULE_DUMMY
|
|
|
+ nbus_init(getDummyDriver(), &hw_platform);
|
|
|
+ nbus_init_app(NULL, NULL);
|
|
|
+#endif
|
|
|
|
|
|
#if MODULE == MODULE_FSR
|
|
|
- nbus_init(&periph, getMcuAdcDriver(), &hw_platform);
|
|
|
+ nbus_init(getMcuAdcDriver(), &hw_platform);
|
|
|
+ nbus_init_app(&hadc, NULL);
|
|
|
#endif
|
|
|
|
|
|
#if MODULE == MODULE_IMU
|
|
|
- nbus_init(&periph, getImuDriver());
|
|
|
+ nbus_init(getImuDriver(), &hw_platform);
|
|
|
+ nbus_init_app(&hspi, NULL);
|
|
|
#endif
|
|
|
|
|
|
- HAL_UART_RegisterCallback(&huart2, HAL_UART_RX_COMPLETE_CB_ID, nbus_cb_UART_RX);
|
|
|
-
|
|
|
- nbus_init_app(&hadc, NULL);
|
|
|
+ HAL_UART_RegisterCallback(&huart2, HAL_UART_RX_COMPLETE_CB_ID, nbus_app_UART_RX);
|
|
|
+ HAL_TIM_RegisterCallback(&htim22, HAL_TIM_PERIOD_ELAPSED_CB_ID, nbus_app_TIM_periodElapsed);
|
|
|
|
|
|
nBus_MemoryDriver memory_ec20 = {
|
|
|
DS28EC20_init,
|
|
|
@@ -189,8 +212,10 @@ int main(void)
|
|
|
DS28EC20_writeData2B,
|
|
|
DS28EC20_getId
|
|
|
};
|
|
|
+
|
|
|
memory_ec20.init(ONE_WIRE_GPIO_Port, ONE_WIRE_Pin);
|
|
|
nbus_init_memory_driver(&memory_ec20,16);
|
|
|
+
|
|
|
nbus_stack();
|
|
|
|
|
|
/* USER CODE END 2 */
|