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 of
the peripheral; if it’s busy you need to wait for the end of current
conversion before starting a new one.
For simplicity reasons, this example is just waiting till the end of the
conversion, but application may perform other tasks while conversion
operation 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.3v
printf("Temperature : %d\r\n",(AD_Value)); //*3300/4096
}
HAL_ADC_Stop(&hadc1);
osDelay(8000);
}
/* USER CODE END StartSampleTask */
}
IO口控制 声卡采集 物联网发送
|