generated from hulk/gd32e23x_template_cmake_vscode
添加新版型
This commit is contained in:
12
Src/uart.c
12
Src/uart.c
@@ -12,13 +12,13 @@ void rs485_init(void) {
|
||||
rcu_periph_clock_enable(RS485_RCU);
|
||||
|
||||
/* 配置 PA2 为 USART0_TX,PA3 为 USART0_RX */
|
||||
gpio_af_set(RS485_GPIO_PORT, GPIO_AF_1, RS485_TX_PIN | RS485_RX_PIN | RS485_EN_PIN);
|
||||
gpio_af_set(RS485_GPIO_PORT, GPIO_AF_1, RS485_TX_PIN | RS485_RX_PIN );
|
||||
|
||||
gpio_mode_set(RS485_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, RS485_TX_PIN | RS485_RX_PIN);
|
||||
gpio_output_options_set(RS485_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_TX_PIN | RS485_RX_PIN);
|
||||
|
||||
gpio_mode_set(RS485_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, RS485_EN_PIN);
|
||||
gpio_output_options_set(RS485_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_EN_PIN);
|
||||
// gpio_mode_set(RS485_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, RS485_EN_PIN);
|
||||
// gpio_output_options_set(RS485_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_EN_PIN);
|
||||
|
||||
/* 配置波特率、数据位、停止位等 */
|
||||
usart_deinit(RS485_PHY);
|
||||
@@ -29,10 +29,10 @@ void rs485_init(void) {
|
||||
usart_receive_config(RS485_PHY, USART_RECEIVE_ENABLE);
|
||||
usart_transmit_config(RS485_PHY, USART_TRANSMIT_ENABLE);
|
||||
|
||||
usart_driver_assertime_config(RS485_PHY, 0x01);
|
||||
usart_driver_deassertime_config(RS485_PHY, 0x10);
|
||||
// usart_driver_assertime_config(RS485_PHY, 0x01);
|
||||
// usart_driver_deassertime_config(RS485_PHY, 0x10);
|
||||
|
||||
usart_rs485_driver_enable(RS485_PHY);
|
||||
// usart_rs485_driver_enable(RS485_PHY);
|
||||
|
||||
usart_interrupt_enable(RS485_PHY, USART_INT_RBNE);
|
||||
// usart_interrupt_enable(RS485_PHY, USART_INT_IDLE);
|
||||
|
||||
Reference in New Issue
Block a user