串口和中断写完

This commit is contained in:
2026-05-25 23:53:30 +08:00
parent 589b67a3f9
commit bedceb1785
4 changed files with 15 additions and 20 deletions
+9 -12
View File
@@ -1,7 +1,6 @@
//
// Created by anonymous on 2026/5/24.
//
#include "Bsp.h"
#include "Voilet.h"
// LED灯数组
@@ -25,7 +24,8 @@ const GPIO_CONFIG DO_PERIPH[] = {
#endif
//串口配置表
const COM_CONFIG COM_PERIPH[] = {
{COM1,.TxPort = GPIO2, .TxMode = GPIO_Mode_AF_PP,.RxPort = GPIO3, .RxMode = GPIO_Mode_IPU,.Speed = GPIO_Speed_50MHz},
{COM0,.TxPort = GPIO9, .RxPort =GPIO10, .Speed = GPIO_Speed_50MHz},
{COM1,.TxPort = GPIO2, .RxPort = GPIO3, .Speed = GPIO_Speed_50MHz},
};
void BspExtraInit(void);
@@ -41,17 +41,15 @@ void VoiletBspInit(void) {
INTERRUPT_DISABLE
//初始化中断系统
IrqInit();
//初始化延时库
DelayConfig();
//关闭所有外设时钟
AllPeriphClockDisable();
//LED灯配置
#if (LED_NUM != 0)
for (i = 0;i < LED_NUM;i++) {
//打开外设时钟
GpioClockEnable(&LED_PERIPH[i].GpioX);
for (i = 0;i < ARRAY_LEN(LED_PERIPH);i++) {
//配置GPIO口
GpioConfig(&LED_PERIPH[i].GpioX, LED_PERIPH[i].Mode, LED_PERIPH[i].Speed);
}
@@ -79,9 +77,8 @@ void VoiletBspInit(void) {
//串口配置
for (i = 0;i < ARRAY_LEN(COM_PERIPH);i++) {
UartClockEnable(&COM_PERIPH[i].ComX);
GpioConfig(&COM_PERIPH[i].TxPort, COM_PERIPH[i].TxMode, COM_PERIPH[i].Speed);
GpioConfig(&COM_PERIPH[i].TxPort, COM_PERIPH[i].RxMode, COM_PERIPH[i].Speed);
GpioConfig(&COM_PERIPH[i].TxPort, GPIO_Mode_AF_PP, COM_PERIPH[i].Speed);
GpioConfig(&COM_PERIPH[i].RxPort, GPIO_Mode_IPU, COM_PERIPH[i].Speed);
}
INTERRUPT_ENABLE
@@ -99,7 +96,7 @@ void BspExtraInit(void)
{
//LetterShell初始化
#ifdef USE_SHELL
// LetterShellInit(TTY_COM,TTY_BAUD);
LetterShellInit(TTY_COM,TTY_BAUD);
#endif
}