detect MCU flash size and config usart

This commit is contained in:
2025-08-20 21:02:52 +08:00
parent b6485c5c39
commit c93704383a
8 changed files with 164 additions and 16 deletions

View File

@@ -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_TXPA3 为 USART0_RX */
gpio_af_set(RS485_GPIO_PORT, GPIO_AF_1, RS485_TX_PIN | RS485_RX_PIN | RS485_EN_PIN);
/* 配置 PA2 为 USART_TXPA3 为 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);