纯静态网站页面优化,网站栏目建设评活动,官网微信,重庆seo论前置文章#xff1a;
Freertos手把手教STM32CubeMx设置STM32F4芯片DMA发送ADC数据#xff08;一#xff09;-CSDN博客Freertos手把手教STM32CubeMx设置STM32F4芯片DMA发送ADC数据#xff08;二#xff09;-CSDN博客
在以上章节完成了对框架的初步探索以及对CubeMx的配置…前置文章Freertos手把手教STM32CubeMx设置STM32F4芯片DMA发送ADC数据一-CSDN博客Freertos手把手教STM32CubeMx设置STM32F4芯片DMA发送ADC数据二-CSDN博客在以上章节完成了对框架的初步探索以及对CubeMx的配置在freertos的task中对buffer进行了一些测试完成了队列的发送接收测试下面继续上一章的内容继续完成本次目标本期目标理清本工程系统框架弄懂CubeMx配置相关原理及设置的背后含义对DMA以及ADC相关的重要API接口使用详解梳理代码设计流程3.发送消息对列或任务通知邮箱给线程A/* USER CODE BEGIN Includes */ #include stdlib.h #include queue.h /* USER CODE END Includes */第一步先包含头文件* \defgroup xQueueSend xQueueSend * \ingroup QueueManagement */ #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** * queue. h * pre BaseType_t xQueueOverwrite( QueueHandle_t xQueue, const void * pvItemToQueue找到对应函数xQueueSend( xQueue, pvItemToQueue, xTicksToWait )第一个形参依旧是句柄所以要先创建队列 再传参进来第二个形参P就是指针v是variables(变量)传入的是变量的地址第三个形参是等待时间xQueueCreate( uxQueueLength, uxItemSize )在点h文件里找到队列创建函数第一个形参是队列的长度第二个形参是队列里每一个元素的大小假如一个队列被分成了四份这个份数就是由第一个形参决定而分成了四份后的大小就是由第二个形参决定假设第二个形参是4那么总的队列长度就是4x4 16xQueue1 xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold. ITEM_SIZE // The size of each item in the queue ( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue. xQueueBuffer ); // The buffer that will hold the queue structure.创建队列使用样板xQueueReceiveBaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait )void StartDefaultTask(void *argument) { /* USER CODE BEGIN StartDefaultTask */ buffer1 (uint32_t *)malloc((sizeof(uint32_t)* BUFFER_SIZE)); buffer2 (uint32_t *)malloc((sizeof(uint32_t)* BUFFER_SIZE)); if(NULL buffer1) { printf(buffer1 malloc failed \r\n); } if(NULL buffer2) { printf(buffer2 malloc failed \r\n); return; } printf(buffer1 , buffer2 malloc success\r\n ); memset(buffer1, 0xff , (sizeof(uint32_t)* BUFFER_SIZE)); memset(buffer2, 0xff , (sizeof(uint32_t)* BUFFER_SIZE)); printf(Unit test ADC DMA\r\n ); HAL_StatusTypeDef ret1 HAL_OK; HAL_StatusTypeDef ret2 HAL_OK; ret1 HAL_ADC_Start_DMA(hadc1, buffer1, BUFFER_SIZE); ret2 HAL_ADC_Start_DMA(hadc1, buffer2, BUFFER_SIZE); if(HAL_OK ! ret1) { printf(HAL_ADC1 call failed ); } if(HAL_OK ! ret2) { printf(HAL_ADC2 call failed ); } //UnitTest Queue send and receive QueueHandle_t xQueue1 NULL; xQueue1 xQueueCreate(10 , 4 ); if(NULL xQueue1) { printf(Queue create failed \r\n); return ; } uint32_t queue_data_1 123; BaseType_t ret_queue pdPASS; ret_queue xQueueSend( xQueue1, queue_data_1, 0 ); printf(QueueSend ret_queue [%ld]\r\n , ret_queue); ret_queue pdPASS; uint32_t queue_data_2 0xff; ret_queue xQueueReceive( xQueue1, queue_data_2, 0 ); printf(xQueueSend ret_queue [%ld]\r\n , ret_queue); printf(xQueueReceive queue_data_2 [%d]\r\n , queue_data_2); /* Infinite loop */ for(;;) { printf(hello world \r\n); //printf(buffer1 data [%d] \r\n , buffer1[0]); //printf(buffer2 data [%d] \r\n , buffer2[0]); osDelay(1000); } /* USER CODE END StartDefaultTask */ }