#include "uarts.h" #define UART6_RX_BUFFER_SIZE 256 uint8_t UART6_RxBuffer[UART6_RX_BUFFER_SIZE]; UART_BUF uart1; //串口结构体实体 uint8_t RxBuffer; //接收数据中间变量 #pragma import(__use_no_semihosting_swi) #pragma import(__use_no_semihosting) void _sys_exit(int x) { x = x; } struct __FILE { int handle; /* Whatever you require here. If the only file you are using is */ /* standard output using printf() for debugging, no file handling */ /* is required. */ }; /* FILE is typedef’ d in stdio.h. */ FILE __stdout; int fputc(int ch, FILE *f) { HAL_UART_Transmit(&MODBUS_HUART, (uint8_t *)&ch, 1, 0xffff); return ch; } void uart_send(UART_HandleTypeDef *huart,uint8_t *Tx_Buf,uint16_t Size) { HAL_UART_Transmit_DMA(huart,Tx_Buf,Size); } void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if(huart->Instance == USART1) { modbus_rx_cb(); } if(huart->Instance == USART2) { } if(huart->Instance == USART3) { } if(huart->Instance == USART6) { } }