fix(rs485):修改内置RS485_DE引脚的配置过程,从GPIO切换到AF,可以由RS485 PHY自动控制方向。

This commit is contained in:
2026-07-28 20:51:42 +08:00
parent ffb8ba0329
commit b683c877b9
+2 -2
View File
@@ -20,9 +20,9 @@ void uart_init(void) {
#if RS485_MODE == CFG_ENABLE #if RS485_MODE == CFG_ENABLE
/* 配置 RS485 DE 引脚 */ /* 配置 RS485 DE 引脚 */
rcu_periph_clock_enable(RS485_DE_RCU); rcu_periph_clock_enable(RS485_DE_RCU);
gpio_mode_set(RS485_DE_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, RS485_DE_PIN); gpio_af_set(RS485_DE_PORT, GPIO_AF_1, RS485_DE_PIN);
gpio_mode_set(RS485_DE_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, RS485_DE_PIN);
gpio_output_options_set(RS485_DE_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_DE_PIN); gpio_output_options_set(RS485_DE_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_DE_PIN);
gpio_bit_reset(RS485_DE_PORT, RS485_DE_PIN); // 初始状态为接收模式
#endif #endif
/* 配置波特率、数据位、停止位等 */ /* 配置波特率、数据位、停止位等 */