by Sergey Lyubka @Cesanta, Jul 2025
int _write(int fd, unsigned char *buf, int len) { // Add before main()
if (fd == 1 || fd == 2) { // stdout or stderr ?
HAL_UART_Transmit(&huart1, buf, len, 999); // Print to the UART
}
return len;
}
while (1) { // Change main() loop to this:
printf("tick: %lu\n", HAL_GetTick());
HAL_Delay(500);
}