STM32
直播中

李军

7年用户 1234经验值
私信 关注
[问答]

求大神分享stm32 printf函数使用前须知事项

求大神分享STM32 printf函数使用前须知事项

回帖(1)

李晓婷

2021-12-2 14:31:48
写在你用printf之前

UART_HandleTypeDef UartHandle;


/* Private function prototypes -----------------------------------------------*/
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small printf
   set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/**
  * @brief  Retargets the C library printf function to the USART.
  * @param  None
  * @retval None
  */
PUTCHAR_PROTOTYPE
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the USART1 and Loop until the end of transmission */
  HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);


  return ch;
}
huart1是串口号
举报

更多回帖

发帖
×
20
完善资料,
赚取积分