This commit is contained in:
MQjehovah 2023-12-05 20:45:48 +08:00
parent 7195ddea0a
commit 9c8efa9294
2 changed files with 21 additions and 18 deletions

View File

@ -18,6 +18,24 @@ foc_handle_t foc_handle;
const char *data = "hello world\n"; const char *data = "hello world\n";
/* Function ------------------------------------------------------------------*/ /* 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. * @brief The application entry point.
* @retval int * @retval int
@ -59,7 +77,8 @@ int main(void)
while (1) while (1)
{ {
// 测试PWM输出 // 测试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); led_ctrl(1);
HAL_Delay(500); HAL_Delay(500);
led_ctrl(0); 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函数 // /// 重定向c库函数printf到串口DEBUG_USART重定向后可使用printf函数
// int fputc(int ch, FILE *f) // int fputc(int ch, FILE *f)
// { // {

View File

@ -358,3 +358,4 @@ void TIM3_IRQHandler(void)
calc_hall_angle(&hall_handle, new_state); calc_hall_angle(&hall_handle, new_state);
} }
} }