此文章方法可以一并解决重定向问题[[解决“_close is not implemented and will always fail”等编译警告]]。 重写_write函数即可重定向printf输出:
_close is not implemented and will always fail
#include <stdio.h> int _write(int file, char *ptr, int len) { HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, HAL_MAX_DELAY); return len; }