From 9c8efa9294b105f50fd82e761e7fe448befabe8a Mon Sep 17 00:00:00 2001 From: MQjehovah <1421706030@qq.com> Date: Tue, 5 Dec 2023 20:45:48 +0800 Subject: [PATCH] fix --- src/App/main.c | 38 ++++++++++++++++++++------------------ src/Bsp/timer.c | 1 + 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/App/main.c b/src/App/main.c index 3c8aff6..220d40a 100644 --- a/src/App/main.c +++ b/src/App/main.c @@ -18,6 +18,24 @@ foc_handle_t foc_handle; const char *data = "hello world\n"; /* Function ------------------------------------------------------------------*/ +//#ifdef __GNUC__ +#pragma import(__use_no_semihosting) + +void _sys_exit(int x) +{ + x = x; +} + +int _write(int fd, char *ptr, int len) +{ + HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, 0xFFFF); + // fflush(stdout); + return len; +} + +//#endif + + /** * @brief The application entry point. * @retval int @@ -59,7 +77,8 @@ int main(void) while (1) { // 测试PWM输出 - printf("direction is %d\n", hall_handle.direction); + HAL_UART_Transmit(&huart1, "a", 1, 0xFFFF); + printf("direction is %d\r\n", hall_handle.direction); led_ctrl(1); HAL_Delay(500); led_ctrl(0); @@ -67,23 +86,6 @@ int main(void) } } -#ifdef __GNUC__ -// #pragma import(__use_no_semihosting) - -// void _sys_exit(int x) -// { -// x = x; -// } - -int _write(int fd, char *ptr, int len) -{ - HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, 0xFFFF); - fflush(stdout); - return len; -} - -#endif - // /// 重定向c库函数printf到串口DEBUG_USART,重定向后可使用printf函数 // int fputc(int ch, FILE *f) // { diff --git a/src/Bsp/timer.c b/src/Bsp/timer.c index 8f7637f..0ccfa04 100644 --- a/src/Bsp/timer.c +++ b/src/Bsp/timer.c @@ -358,3 +358,4 @@ void TIM3_IRQHandler(void) calc_hall_angle(&hall_handle, new_state); } } +