hi
I'm using stm32 by keil5 compiler and This is my printf function
C:
#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)
#define GETCHAR_PROTOTYPE int __io_getchar(void)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#define GETCHAR_PROTOTYPE int fgetc(FILE *f)
#endif /* __GNUC__ */
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1,(uint8_t*)&ch,1,100);
return ch;
}
in this code my printf only sends data in uart1. is there any function to send data by printf and choosing uart.
for example my printf become like this :
If you read the C compiler documentation ( I am unsure here as I use Microchip) you provide the putch() and getch() to source the input / output to suit.. You could simple swap the default before sprint() is called...
In your example.. &huart1 is a handle so make anther to handle port 2
Do not use the handle in the sprint() statement printf and sprint are looking for a character array and not a destination output