近期使用STM32驱动MAX3485进行485通信,发现STM32F103C8并不自带硬件485首发功能,需要软件上控制IO高低来驱动MAX3485进行485接收、485发送。
根据MAX3485手册可得,进行485发送时给相应引脚高电平。其余时间为低电平进行485接收。因此需要找到串口DMA发送完成的回调函数,在发送完成后将引脚拉低。
在stm32f1xx_hal_uart.c中
/** @defgroup UART_Exported_Functions_Group2 IO operation functions
* @brief UART Transmit and Receive functions
*
@verbatim
==============================================================================
##### IO operation functions #####
====================