2828/* USER CODE BEGIN Includes */
2929#include "i2c_drv.h"
3030#include "spi_drv.h"
31+ #include "uart_hal.h"
3132#include "tca6408a.h"
3233#include "vl53l5cx_api.h"
3334#include "test_tof.h"
3435#include "calibration.h"
3536#include "w25q64_ll.h"
37+ #include "uart_receive.h"
3638#include "libdw3000.h"
3739#include "dw3000.h"
3840#include "dwTypes.h"
@@ -53,7 +55,12 @@ SemaphoreHandle_t spiDeckRxComplete = NULL;
5355SemaphoreHandle_t spiDeckMutex = NULL ;
5456SemaphoreHandle_t uwbIrqSemaphore = NULL ;
5557uint8_t uwbdata_tx [260 ];
56-
58+ static uint8_t Pos [26 ];
59+ static uint8_t Pos_new [17 ];
60+ static float para [4 ];
61+ static float padX = 0.0 ;
62+ static float padY = 0.0 ;
63+ static float padZ = 0.0 ;
5764//拔尖基地展示
5865float datas_f [6 ];
5966
@@ -121,7 +128,7 @@ static void uwbTask(void *argument);
121128/* USER CODE END FunctionPrototypes */
122129
123130void StartDefaultTask (void * argument );
124-
131+ void compute ();
125132void MX_FREERTOS_Init (void ); /* (MISRA C 2004 rule 8.1) */
126133
127134/**
@@ -135,7 +142,7 @@ void MX_FREERTOS_Init(void) {
135142 rxComplete = xSemaphoreCreateBinary ();
136143 spiMutex = xSemaphoreCreateMutex ();
137144 UartRxReady = xSemaphoreCreateBinary ();
138-
145+ CreateUartRxQueue ();
139146 if (txComplete == NULL || rxComplete == NULL || spiMutex == NULL )
140147 {
141148 while (1 );
@@ -182,42 +189,76 @@ void MX_FREERTOS_Init(void) {
182189 * @param argument: Not used
183190 * @retval None
184191 */
192+ void para_get ()
193+ {
194+ padX = para [0 ];
195+ padY = para [1 ];
196+ padZ = para [2 ];
197+ }
198+
199+ void para_reget ()
200+ {
201+ para [0 ] = padX ;
202+ para [1 ] = padY ;
203+ para [2 ] = padZ ;
204+ }
185205
206+ void compute ()
207+ {
208+ switch (Pos [24 ])
209+ {
210+ case 0 :
211+ //add more control 1up 0down
212+ if (Pos [25 ])
213+ {
214+ padZ = 0.3f ;
215+ Pos_new [16 ] = 1 ;
216+ }
217+ else
218+ {
219+ Pos_new [16 ] = 0 ;
220+ }
221+ break ;
222+ case 1 :
223+ if (Pos [25 ])
224+ {
225+ Pos_new [16 ] = 2 ;
226+ }
227+ else
228+ {
229+ padZ = 0.3f ;
230+ Pos_new [16 ] = 3 ;
231+ }
232+ break ;
233+ }
234+ }
186235/* USER CODE END Header_StartDefaultTask */
187236void StartDefaultTask (void * argument )
188237{
189238 /* USER CODE BEGIN StartDefaultTask */
190239 /* Infinite loop */
191- // static uint8_t w25qID;
192- // BSP_W25Qx_Read_ID(&w25qID);
193-
194-
240+ uint8_t index = 0 ;
195241 while (1 )
196242 {
243+ if (xSemaphoreTake (UartRxReady , 0 ) == pdPASS )
244+ {
245+ while (index < 26 && xQueueReceive (UartRxQueue , & Pos [index ], 0 ) == pdPASS )
246+ {
247+ index ++ ;
248+ }
249+ if (index == 26 )
250+ {
251+ memcpy (para , (float * )Pos , 16 );
252+ para_get ();
253+ compute ();
254+ para_reget ();
255+ memcpy (Pos_new , (uint8_t * )para , 16 );
256+ UART_DMA_Transmit (Pos_new , 17 );
257+ index = 0 ;
258+ }
259+ }
197260 vTaskDelay (1 );
198261 }
199- // BSP_W25Qx_Init();
200- // uint8_t ID[2]={0};
201- // BSP_W25Qx_Read_ID(ID);
202- // //BSP_W25Qx_Erase_Chip();
203- // BSP_W25Qx_Erase_Block(0x123456);
204- // uint8_t tx_data[128] = {0xef};
205- // uint8_t rx_data[128] = {0x00};
206- // BSP_W25Qx_Write(tx_data, 0x123456, 128);
207- // BSP_W25Qx_Read(rx_data, 0x123456, 4);
208- // BSP_W25Qx_Erase_Block(0x123456);
209- // BSP_W25Qx_Read(rx_data, 0x123456, 4);
210- //
211- // uint8_t ID[4];
212- // I2C_expander_initialize();
213- // initialize_sensors_I2C(&vl53l5dev_f,1);
214- // vl53l5cx_start_ranging(&vl53l5dev_f);
215- // while(1){
216- // LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_9);
217- // LL_mDelay(100);
218- // get_sensor_data(&vl53l5dev_f, &vl53l5_res_f);
219- // }
220- // }
221262 /* USER CODE END StartDefaultTask */
222263}
223264
0 commit comments