本文主要是介绍STM32 RTOS 各任务模块逐一测试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
LED BLINK
void StartLEDTask(void const * argument)
{/* USER CODE BEGIN StartLEDTask *//* Infinite loop */for(;;){HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);osDelay(5000);}/* USER CODE END StartLEDTask */
}
ADC采集串口发送
void StartSampleTask(void const * argument)
{/* USER CODE BEGIN StartSampleTask *//* Infinite loop */for(;;){/*##-1- Start the conversion process #######################################*/HAL_ADC_Start(&hadc1);/*##-2- Wait for the end of conversion #####################################*//* Before starting a new conversion, you need to check the current state ofthe peripheral; if it’s busy you need to wait for the end of currentconversion before starting a new one.For simplicity reasons, this example is just waiting till the end of theconversion, but application may perform other tasks while conversionoperation is ongoing. */HAL_ADC_PollForConversion(&hadc1, 50);/* Check if the continous conversion of regular channel is finished */if(HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc1), HAL_ADC_STATE_REG_EOC)){/*##-3- Get the converted value of regular channel ######################*/AD_Value = HAL_ADC_GetValue(&hadc1); // 0-4096 0-3.3vprintf("Temperature : %d\r\n",(AD_Value)); //*3300/4096}HAL_ADC_Stop(&hadc1);osDelay(8000);}/* USER CODE END StartSampleTask */
}
IO口控制
声卡采集
物联网发送
这篇关于STM32 RTOS 各任务模块逐一测试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!