From 61ddbcf2cde06cc92c4735b78a890a01d19eef43 Mon Sep 17 00:00:00 2001 From: yelvlab Date: Thu, 3 Apr 2025 00:59:48 +0800 Subject: [PATCH] RS485 hardware function OK! --- src/main.c | 1 + src/rs485.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 6cf02e9..b860e95 100644 --- a/src/main.c +++ b/src/main.c @@ -48,6 +48,7 @@ int main(void) { while (1) { delay_ms(99); fwdgt_counter_reload(); + printf("Hello World!\n"); } } diff --git a/src/rs485.c b/src/rs485.c index 24da43b..9021a89 100644 --- a/src/rs485.c +++ b/src/rs485.c @@ -20,7 +20,7 @@ void rs485_config(void) { /* configure 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); - gpio_bit_write(RS485_GPIO_PORT, RS485_EN_PIN, SET); + // gpio_bit_write(RS485_GPIO_PORT, RS485_EN_PIN, SET); /* USART configure */ usart_deinit(RS485_PHY); @@ -28,8 +28,8 @@ void rs485_config(void) { // usart_parity_config(RS485_PHY, USART_PM_NONE); // usart_word_length_set(RS485_PHY, USART_WL_8BIT); // usart_stop_bit_set(RS485_PHY, USART_STB_1BIT); - // usart_receive_config(RS485_PHY, USART_RECEIVE_ENABLE); - // usart_transmit_config(RS485_PHY, USART_TRANSMIT_ENABLE); + 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, 0x01); @@ -37,8 +37,8 @@ void rs485_config(void) { // usart_depolarity_config(USART0, USART_DEP_HIGH); // usart_depolarity_config(USART0, USART_DEP_LOW); - // usart_enable(RS485_PHY); usart_rs485_driver_enable(RS485_PHY); + usart_enable(RS485_PHY); nvic_irq_enable(USART0_IRQn, 0); usart_interrupt_enable(RS485_PHY, USART_INT_RBNE);