obsidian-notes/代码/STM32串口打印重定义.md
CSSC-WORK\murmur 3e6078442b init version
2024-04-15 11:19:57 +08:00

773 B

title updated created tags
STM32串口打印重定义 2022-01-11 01:27:18Z 2022-01-11 01:20:11Z
mcu
printf
代码块

STM32串口打印重定义

#ifdef __GNUC__
  /* With GCC/RAISONANCE, 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 USART */
 HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,0xFFFF);
  return ch;
}

#mcu #printf #代码块