add usart(rs485)

This commit is contained in:
2024-12-30 22:59:49 +08:00
parent dbbeea4dc7
commit 88fc97d037
12 changed files with 97 additions and 69 deletions

View File

@@ -21,13 +21,15 @@
/******************************************************************************/
#define RS485_RCU RCU_USART0
#define RS485_GPIO_RCU RCU_GPIOA
#define RS485_GPIO_PORT GPIOA
#define RS485_TX_PIN GPIO_PIN_2
#define RS485_RX_PIN GPIO_PIN_3
#define RS485_PHY USART0
#define RS485_BAUDRATE 115200U
#define USART_RCU RCU_USART0
#define USART_GPIO_RCU RCU_GPIOA
#define USART_GPIO_PORT GPIOA
#define USART_GPIO_AF GPIO_AF_1
#define USART_TX_PIN GPIO_PIN_2
#define USART_RX_PIN GPIO_PIN_3
#define USART_PHY USART0
#define USART_PHY_BAUDRATE 115200U
#define RS485_EN_PORT GPIOA
#define RS485_EN_PIN GPIO_PIN_1
/******************************************************************************/

View File

@@ -36,6 +36,9 @@ OF SUCH DAMAGE.
#define GD32E23X_IT_H
#include "gd32e23x.h"
#include "main.h"
#include "systick.h"
#include "board_config.h"
/* function declarations */
/* this function handles NMI exception */
@@ -49,4 +52,6 @@ void PendSV_Handler(void);
/* this function handles SysTick exception */
void SysTick_Handler(void);
void TIMER16_IRQHandler(void);
#endif /* GD32E23X_IT_H */

14
inc/led.h Normal file
View File

@@ -0,0 +1,14 @@
//
// Created by yelv1 on 24-12-30.
//
#ifndef LED_H
#define LED_H
#include "gd32e23x_it.h"
#include "gd32e23x.h"
#include "board_config.h"
void led_blink_config(void);
#endif //LED_H

View File

@@ -35,4 +35,12 @@ OF SUCH DAMAGE.
#ifndef MAIN_H
#define MAIN_H
#include <stdio.h>
#include "gd32e23x.h"
#include "systick.h"
#include "gd32e23x_libopt.h"
#include "led.h"
#include "usart.h"
#include "board_config.h"
#endif /* MAIN_H */

View File

@@ -1,11 +0,0 @@
//
// Created by yelv1 on 24-9-22.
//
#ifndef PERIPHERAL_H
#define PERIPHERAL_H
void usart_config(void);
#endif //PERIPHERAL_H

15
inc/usart.h Normal file
View File

@@ -0,0 +1,15 @@
//
// Created by yelv1 on 24-12-30.
//
#ifndef USART_H
#define USART_H
#include "gd32e23x.h"
#include "board_config.h"
void usart_config(void);
void rs485_config(void);
#endif //USART_H