ADC,串口,printf重定义

#include <stdio.h>

#ifdef __GNUC__
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif

PUTCHAR_PROTOTYPE
{
     
  HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,0xFFFF);//huart1¸ù¾ÝÐèÒª¸ü¸Ä
  return ch;
}
	uint32_t AD_Val;
	float Real_Val;
  while (1)
  {
     
		HAL_ADC_Start(&hadc1);//¿ªÆôÂÖѯ
		HAL_ADC_PollForConversion(&hadc1,30);//µÈ´ýת»»Íê³É
		if(HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc1),HAL_ADC_STATE_REG_EOC)){
     
			AD_Val=HAL_ADC_GetValue(&hadc1);
			Real_Val=AD_Val*3.3/4096;
			printf("%lfv\r\n",Real_Val);
		
		}
		

你可能感兴趣的:(单片机)