generated from hulk/gd32e23x_template_cmake_vscode
detect MCU flash size and config usart
This commit is contained in:
@@ -8,12 +8,12 @@
|
||||
void rs485_init(void) {
|
||||
|
||||
#ifndef RS485_MAX13487
|
||||
/* 使能 GPIOA 和 USART0 时钟 */
|
||||
/* 使能 GPIOA 和 USART 时钟 */
|
||||
rcu_periph_clock_enable(RS485_GPIO_RCU);
|
||||
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);
|
||||
/* 配置 PA2 为 USART_TX,PA3 为 USART_RX */
|
||||
gpio_af_set(RS485_GPIO_PORT, RS485_GPIO_AF, RS485_TX_PIN | RS485_RX_PIN | RS485_EN_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);
|
||||
@@ -37,7 +37,7 @@ void rs485_init(void) {
|
||||
|
||||
usart_enable(RS485_PHY);
|
||||
|
||||
nvic_irq_enable(USART0_IRQn, 0);
|
||||
nvic_irq_enable(RS485_IRQ, 0);
|
||||
usart_interrupt_enable(RS485_PHY, USART_INT_RBNE);
|
||||
// usart_interrupt_enable(RS485_PHY, USART_INT_IDLE);
|
||||
|
||||
|
Reference in New Issue
Block a user