From 0516210c95dba317ee670cfa66e3c26dfb809564 Mon Sep 17 00:00:00 2001 From: iorebuild Date: Thu, 28 May 2026 21:55:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=AD=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bsp/Inc/Bsp.h | 38 +-- Bsp/Inc/LetterShell.h | 8 - Bsp/Inc/{VoiletTypeDef.h => VoiletPort.h} | 37 ++- Bsp/Src/Bsp.c | 297 ++++++++++++---------- Bsp/Src/Interrupt.c | 39 ++- Bsp/Src/LetterShell.c | 102 -------- Bsp/Src/SeggerCall.c | 2 +- Bsp/Src/SysCall.c | 7 +- 8 files changed, 219 insertions(+), 311 deletions(-) delete mode 100644 Bsp/Inc/LetterShell.h rename Bsp/Inc/{VoiletTypeDef.h => VoiletPort.h} (94%) delete mode 100644 Bsp/Src/LetterShell.c diff --git a/Bsp/Inc/Bsp.h b/Bsp/Inc/Bsp.h index 6f7aac2..13d7714 100644 --- a/Bsp/Inc/Bsp.h +++ b/Bsp/Inc/Bsp.h @@ -1,37 +1,13 @@ #ifndef __BSP_H__ #define __BSP_H__ -#include "VoiletTypeDef.h" - -/* Extra Library Enable */ -#define USE_SHELL //系统使用Shell - -#ifdef USE_SHELL -#include "LetterShell.h" -#endif - -#define ARRAY_LEN(arr) (sizeof(arr) / sizeof((arr)[0])) - -/* BOOL类型定义 */ -typedef enum { - false = 0, - true = 1, -} bool_t; - -//GPIO -//数组信号输入/出开关 -#define DI_ON 1 -#define DI_OFF 0 -#define DO_ON 1 -#define DO_OFF 0 -//LED灯开关 -#define LED_ON 0 -#define LED_OFF 1 - -/* Voilet */ -void VoiletBspInit(void); +/* Voilet Bsp */ +#include "VoiletPort.h" +/* Board */ +#include "Board.h" /* BSP */ +void BspInit(void); void LedOn(uint8_t Chnl); void LedOff(uint8_t Chnl); void LedSet(uint8_t Chnl,uint8_t Value); @@ -39,8 +15,8 @@ void LedToggle(uint8_t Chnl); //Interrupt void IrqInit(void); -void IrqRegister(unsigned int Irq, void(*Func)(void *Param)); -void IrqConfig(uint32_t Irq, uint8_t NvicPrePriority, uint8_t NvicSubPriority); +void IrqRegister(unsigned char Irqn,void(*Func)(void *Param)); +void IrqEnable(uint32_t Irq, uint8_t NvicPrePriority, uint8_t NvicSubPriority); void IrqDisable(uint32_t Irq); //System Delay diff --git a/Bsp/Inc/LetterShell.h b/Bsp/Inc/LetterShell.h deleted file mode 100644 index 3319cc9..0000000 --- a/Bsp/Inc/LetterShell.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __LETTER_SHELL_H__ -#define __LETTER_SHELL_H__ - -#include "Bsp.h" - -void LetterShellInit(const COM_MAP_T *ComX, uint32_t Baud); - -#endif diff --git a/Bsp/Inc/VoiletTypeDef.h b/Bsp/Inc/VoiletPort.h similarity index 94% rename from Bsp/Inc/VoiletTypeDef.h rename to Bsp/Inc/VoiletPort.h index a694c6e..9651097 100644 --- a/Bsp/Inc/VoiletTypeDef.h +++ b/Bsp/Inc/VoiletPort.h @@ -2,24 +2,37 @@ // Created by anonymous on 2026/5/24. // -#ifndef VOILETTYPEDEF_H -#define VOILETTYPEDEF_H +#ifndef _VOILET_PORT_H +#define _VOILET_PORT_H #include "stm32f10x.h" #define INTERRUPT_ENABLE __set_PRIMASK(0); //开启中断 #define INTERRUPT_DISABLE __set_PRIMASK(1); //关闭中断 +#define ARRAY_LEN(arr) (sizeof(arr) / sizeof((arr)[0])) + +/* BOOL类型定义 */ +typedef enum { + false = 0, + true = 1, +} bool_t; + +/* Interrupt Irq */ typedef struct { + unsigned char Irqn; + void *Periph; void (*IrqCallback)(void *Param); }IRQ_MAP_T; -#define IRQ_NUM 0xFF //中断数量 +#define IRQ_NUM 67 //系统共有多少个中断 #define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2 //中断组 +/* GPIO */ typedef struct { GPIO_TypeDef *GpioPort; unsigned short GpioPin; + unsigned char Irqn; } GPIO_PERIPH_T; typedef struct { @@ -28,6 +41,12 @@ typedef struct { GPIO_PERIPH_T Periph; } GPIO_MAP_T; +typedef struct { + GPIO_MAP_T GpioX; + GPIOMode_TypeDef Mode; + GPIOSpeed_TypeDef Speed; +}GPIO_CONFIG; + // ==================== GPIOA 组 ==================== #ifdef GPIOA #define GPIO0 {RCC_APB2PeriphClockCmd, RCC_APB2Periph_GPIOA, {GPIOA, GPIO_Pin_0}} @@ -162,9 +181,10 @@ typedef struct { #define GPIO111 {RCC_APB2PeriphClockCmd, RCC_APB2Periph_GPIOG, {GPIOG, GPIO_Pin_15}} #endif +/* COM */ typedef struct { USART_TypeDef *UartId; - unsigned int Irqn; + unsigned char Irqn; } COM_PERIPH_T; typedef struct { @@ -173,6 +193,13 @@ typedef struct { COM_PERIPH_T Periph; } COM_MAP_T; +typedef struct { + COM_MAP_T *ComX; + GPIO_MAP_T TxPort; + GPIO_MAP_T RxPort; + GPIOSpeed_TypeDef Speed; +}COM_CONFIG; + #ifdef USART1 #define COM0 (&(COM_MAP_T){RCC_APB2PeriphClockCmd, RCC_APB2Periph_USART1, {USART1,USART1_IRQn}}) #endif @@ -187,4 +214,4 @@ typedef struct { #endif #define COM4 (&(COM_MAP_T){RCC_APB1PeriphClockCmd, RCC_APB1Periph_UART5,{UART5,UART5_IRQn}}) -#endif //VOILETTYPEDEF_H +#endif //_VOILET_PORT_H diff --git a/Bsp/Src/Bsp.c b/Bsp/Src/Bsp.c index fb758a1..c4dd95c 100644 --- a/Bsp/Src/Bsp.c +++ b/Bsp/Src/Bsp.c @@ -1,151 +1,168 @@ #include "Bsp.h" -// -// #ifdef USE_DIGITAL_OUTPUT -// GPIO_ST DigiTalOutPut[DO_NUM] = -// { -// GPIOB,GPIO_Pin_8,RESET, -// }; -// #endif -// -// #ifdef USE_DIGITAL_INPUT -// GPIO_ST DigiTalInPut[DI_NUM] = -// { -// GPIOF,GPIO_Pin_8,SET, -// GPIOE,GPIO_Pin_4,SET, -// GPIOE,GPIO_Pin_3,SET, -// }; -// #endif -// -// //LED灯数组 -// #ifdef USE_LED -// GPIO_ST DigiTalLed[LED_NUM] = -// { -// GPIOB,GPIO_Pin_5,SET, -// GPIOE,GPIO_Pin_5,SET, -// }; -// #endif -// -// /** -// * @brief BSP的配置和初始化 -// * @param void -// * @retval void -// * @note void -// * @example void -// */ -// void BspInit(void) -// { -// //关闭所有系统中断 -// INTERRUPT_DISABLE -// -// //System Delay -// SystemDelayConfig(); -// -// //Interrupt -// SystemInterruptInit(); -// -// //Gpio -// SystemGpioInit(); -// -// { -// //DO -// #ifdef USE_DIGITAL_OUTPUT -// for (uint8_t i = 0; i < DO_NUM; i++) { -// GpioConfig(DigiTalOutPut[i].GpioPort,DigiTalOutPut[i].GpioPin,GPIO_Mode_Out_PP,GPIO_Speed_50MHz); -// GpioSetSts(DigiTalOutPut[i].GpioPort,DigiTalOutPut[i].GpioPin,DigiTalOutPut[i].DefaultStatus); -// } -// #endif -// //DI -// #ifdef USE_DIGITAL_INPUT -// for (uint8_t i = 0; i < DI_NUM; i++) { -// GpioConfig(DigiTalInPut[i].GpioPort,DigiTalInPut[i].GpioPin,GPIO_Mode_IPU,GPIO_Speed_50MHz); -// } -// #endif -// //LED -// #ifdef USE_LED -// for (uint8_t i = 0; i < LED_NUM; i++) { -// GpioConfig(DigiTalLed[i].GpioPort,DigiTalLed[i].GpioPin,GPIO_Mode_Out_PP,GPIO_Speed_50MHz); -// GpioSetSts(DigiTalLed[i].GpioPort,DigiTalLed[i].GpioPin,DigiTalLed[i].DefaultStatus); -// } -// #endif -// } -// -// //Usart -// SystemUsartInit(); -// -// { -// //串口的TX引脚需要复用推挽模式,RX引脚需要浮空输入模式 -// #ifdef USE_USART1 -// GpioConfig(COM0_TX_PORT,COM0_TX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// GpioConfig(COM0_RX_PORT,COM0_RX_PIN,GPIO_Mode_IPU,GPIO_Speed_50MHz); -// #endif -// #ifdef USE_USART2 -// GpioConfig(COM1_TX_PORT,COM1_TX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// GpioConfig(COM1_RX_PORT,COM1_RX_PIN,GPIO_Mode_IPU,GPIO_Speed_50MHz); -// #endif -// #ifdef USE_USART3 -// GpioConfig(COM2_TX_PORT,COM2_TX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// GpioConfig(COM2_RX_PORT,COM2_RX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// #endif -// #ifdef USE_USART4 -// GpioConfig(COM3_TX_PORT,COM3_TX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// GpioConfig(COM3_RX_PORT,COM3_RX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// #endif -// #ifdef USE_USART5 -// GpioConfig(COM4_TX_PORT,COM4_TX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// GpioConfig(COM4_RX_PORT,COM4_RX_PIN,GPIO_Mode_AF_PP,GPIO_Speed_50MHz); -// #endif -// } -// -// #ifdef EXTRA_BSP -// BspExtraInit(); -// #endif -// } -// -// void SystemStart(void) -// { -// //开启系统中断 -// INTERRUPT_ENABLE -// -// #ifdef USE_RTOS -// #ifdef USE_FREERTOS -// #endif -// #ifdef USE_UCOS -// #endif -// #ifdef USE_THREADX -// #endif -// #endif -// } -// -// /** -// * @brief 扩展库初始化 -// * @param void -// * @retval void -// * @note 理论上扩展库要在BSP的最后加载 -// * @example void -// */ -// void BspExtraInit(void) -// { -// //LetterShell初始化 -// #ifdef USE_SHELL -// LetterShellInit(TTY_COM,TTY_BAUD); -// #endif -// } -// -// //用户层接口 -// void BspSystemReboot(void) -// { -// INTERRUPT_DISABLE -// NVIC_SystemReset(); // 执行软件复位 -// } +#ifdef TTY_COM +#include "LetterShell.h" +#endif + +// LED灯数组 +#if (LED_NUM != 0) +const GPIO_CONFIG LED_PERIPH[] = { + {.GpioX = GPIO21, .Mode = GPIO_Mode_Out_PP, .Speed = GPIO_Speed_10MHz}, + {.GpioX = GPIO69, .Mode = GPIO_Mode_Out_PP, .Speed = GPIO_Speed_10MHz}, +}; +#endif +//数字输入数组 +#if (DI_NUM != 0) +const GPIO_CONFIG DI_PERIPH[] = { + {}, +}; +#endif +//数字输出数组 +#if (DO_NUM != 0) +const GPIO_CONFIG DO_PERIPH[] = { + {}, +}; +#endif +//串口配置表 +const COM_CONFIG COM_PERIPH[] = { + {COM0,.TxPort = GPIO9, .RxPort =GPIO10, .Speed = GPIO_Speed_50MHz}, + {COM1,.TxPort = GPIO2, .RxPort = GPIO3, .Speed = GPIO_Speed_50MHz}, +}; + +void BspExtraInit(void); + +/** + * @brief Voilet BSP的初始化函数 + * @note void + * @param void + * @retval void + */ +void BspInit(void) { + unsigned char i = 0; + + INTERRUPT_DISABLE + + //初始化中断系统 + IrqInit(); + + //初始化延时库 + DelayConfig(); + + //LED灯配置 +#if (LED_NUM != 0) + for (i = 0;i < ARRAY_LEN(LED_PERIPH);i++) { + //配置GPIO口 + GpioConfig(&LED_PERIPH[i].GpioX, LED_PERIPH[i].Mode, LED_PERIPH[i].Speed); + } +#endif + + //DI采集配置 +#if (DI_NUM != 0) + // for (i = 0;i < DI_NUM;i++) { + // //打开外设时钟 + // GpioClockEnable(&LED_PERIPH[i].GpioX); + // //配置GPIO口 + // GpioConfig(&LED_PERIPH[i].GpioX, LED_PERIPH[i].Mode, LED_PERIPH[i].Speed); + // } +#endif + + //DO输出配置 +#if (DO_NUM != 0) + // for (i = 0;i < DO_NUM;i++) { + // //打开外设时钟 + // GpioClockEnable(&LED_PERIPH[i].GpioX); + // //配置GPIO口 + // GpioConfig(&LED_PERIPH[i].GpioX, LED_PERIPH[i].Mode, LED_PERIPH[i].Speed); + // } +#endif + + //串口配置 + for (i = 0;i < ARRAY_LEN(COM_PERIPH);i++) { + 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 + + BspExtraInit(); +} + +/** + * @brief 扩展库初始化 + * @note 理论上扩展库要在BSP的最后加载 + * @param void + * @retval void + */ +void BspExtraInit(void) +{ + //LetterShell初始化 +#ifdef TTY_COM + LetterShellInit(TTY_COM,TTY_BAUD); +#endif +} + +/** + * @brief 打开LED灯 + * @note void + * @param Chnl 通道 + * @retval void + */ +void LedOn(uint8_t Chnl) +{ + if (Chnl >= LED_NUM) + return; + GpioSet(&LED_PERIPH[Chnl].GpioX, RESET); +} +/** + * @brief 关闭LED灯 + * @note void + * @param Chnl 通道 + * @retval void + */ +void LedOff(uint8_t Chnl) +{ + if (Chnl >= LED_NUM) + return; + GpioSet(&LED_PERIPH[Chnl].GpioX, SET); +} + +void LedSet(uint8_t Chnl,uint8_t Value) +{ + if (Chnl >= LED_NUM) + return; + if (Value == LED_ON) { + GpioSet(&LED_PERIPH[Chnl].GpioX, RESET); + } + else { + GpioSet(&LED_PERIPH[Chnl].GpioX, SET); + } +} + +/** + * @brief 切换LED灯状态 + * @note void + * @param Chnl 通道 Status 状态 + * @retval void + */ +void LedToggle(uint8_t Chnl) +{ + if (Chnl >= LED_NUM) + return; + if (GpioGet(&LED_PERIPH[Chnl].GpioX) == LED_ON) + { + GpioSet(&LED_PERIPH[Chnl].GpioX,LED_OFF); + } + else + { + GpioSet(&LED_PERIPH[Chnl].GpioX,LED_ON); + } +} /** * @brief 重写Printf函数 * @note void * @param void * @retval void */ -// || -// #include #if defined(__CC_ARM) || defined(__CLANG_ARM) int fputc(int ch, FILE *f) { diff --git a/Bsp/Src/Interrupt.c b/Bsp/Src/Interrupt.c index 768cd35..2bfb1e9 100644 --- a/Bsp/Src/Interrupt.c +++ b/Bsp/Src/Interrupt.c @@ -1,8 +1,8 @@ +#include + #include "Bsp.h" -#define IRQ_NULL ((void *)0) - -IRQ_MAP_T IRQ_PERIPH[IRQ_NUM] = {0x00}; +IRQ_MAP_T IRQ_PERIPH[IRQ_NUM]; /** * @brief 中断回调函数初始化为空 @@ -15,19 +15,18 @@ void IrqInit(void) //设定系统中断组 NVIC_PriorityGroupConfig(NVIC_GROUP_LEVEL); for (uint8_t i = 0; i < IRQ_NUM; i++) { - IRQ_PERIPH[i].IrqCallback = IRQ_NULL; + IRQ_PERIPH[i].IrqCallback = NULL; } } - /** * @brief 中断回调函数注册 * @note 将外部传入的函数地址关联到INTERRUPT_ST表中 * @param Vector:中断号 void(*Func)(uint32_t):回调函数 * @retval void */ -void IrqRegister(unsigned int Irq, void(*Func)(void *Param)) -{ - IRQ_PERIPH[Irq].IrqCallback = Func; +void IrqRegister(unsigned char Irqn,void(*Func)(void *Param)) { + IRQ_PERIPH[Irqn].Irqn = Irqn; + IRQ_PERIPH[Irqn].IrqCallback = Func; } /** @@ -36,7 +35,7 @@ void IrqRegister(unsigned int Irq, void(*Func)(void *Param)) * @param Vector:中断号 NvicPrePriority:主优先级 NvicSubPriority:抢占优先级 * @retval void */ -void IrqConfig(uint32_t Irq, uint8_t NvicPrePriority, uint8_t NvicSubPriority) +void IrqEnable(uint32_t Irq, uint8_t NvicPrePriority, uint8_t NvicSubPriority) { NVIC_InitTypeDef NVIC_InitStructure; @@ -59,17 +58,17 @@ void IrqDisable(uint32_t Irq) NVIC_InitStructure.NVIC_IRQChannel = Irq; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE; NVIC_Init(&NVIC_InitStructure); } void USART1_IRQHandler(void) { - if (USART_GetFlagStatus(COM0->Periph.UartId, USART_FLAG_ORE) == SET) - { - USART_ClearFlag(COM0->Periph.UartId, USART_FLAG_ORE); - } - if (IRQ_PERIPH[COM0->Periph.Irqn].IrqCallback != IRQ_NULL) { + if (IRQ_PERIPH[COM0->Periph.Irqn].IrqCallback != NULL) { + if (USART_GetFlagStatus(COM0->Periph.UartId, USART_FLAG_ORE) == SET) + { + USART_ClearFlag(COM0->Periph.UartId, USART_FLAG_ORE); + } IRQ_PERIPH[COM0->Periph.Irqn].IrqCallback(COM0); } } @@ -80,7 +79,7 @@ void USART2_IRQHandler(void) { USART_ClearFlag(COM1->Periph.UartId, USART_FLAG_ORE); } - if (IRQ_PERIPH[COM1->Periph.Irqn].IrqCallback != IRQ_NULL) { + if (IRQ_PERIPH[COM1->Periph.Irqn].IrqCallback != NULL) { IRQ_PERIPH[COM1->Periph.Irqn].IrqCallback(COM1); } } @@ -91,8 +90,8 @@ void USART3_IRQHandler(void) { USART_ClearFlag(COM2->Periph.UartId, USART_FLAG_ORE); } - if (IRQ_PERIPH[COM2->Periph.Irqn].IrqCallback != IRQ_NULL) { - IRQ_PERIPH[COM2->Periph.Irqn].IrqCallback(COM1); + if (IRQ_PERIPH[COM2->Periph.Irqn].IrqCallback != NULL) { + IRQ_PERIPH[COM2->Periph.Irqn].IrqCallback(COM2); } } @@ -103,7 +102,7 @@ void USART4_IRQHandler(void) { USART_ClearFlag(COM3->Periph.UartId, USART_FLAG_ORE); } - if (IRQ_PERIPH[COM3->Periph.Irqn].IrqCallback != IRQ_NULL) { + if (IRQ_PERIPH[COM3->Periph.Irqn].IrqCallback != NULL) { IRQ_PERIPH[COM3->Periph.Irqn].IrqCallback(COM3); } } @@ -114,7 +113,7 @@ void USART5_IRQHandler(void) { USART_ClearFlag(COM4->Periph.UartId, USART_FLAG_ORE); } - if (IRQ_PERIPH[COM4->Periph.Irqn].IrqCallback != IRQ_NULL) { + if (IRQ_PERIPH[COM4->Periph.Irqn].IrqCallback != NULL) { IRQ_PERIPH[COM4->Periph.Irqn].IrqCallback(COM4); } } diff --git a/Bsp/Src/LetterShell.c b/Bsp/Src/LetterShell.c deleted file mode 100644 index 0d6d388..0000000 --- a/Bsp/Src/LetterShell.c +++ /dev/null @@ -1,102 +0,0 @@ -#include "LetterShell.h" -#include "shell.h" -/* 板级BSP头文件 */ -#include "Bsp.h" -#include "Voilet.h" - -#define WR_BUFFER_SIZE 512 - -/* 1. 创建shell对象,开辟shell缓冲区 */ -Shell Host; //Shell实例化 -char HostBuffer[WR_BUFFER_SIZE]; //读写缓冲区 -const COM_MAP_T *HostCom = TTY_COM; -/** - * @brief Shell写函数 - * @param ComId 串口号,ch 数据 - * @retval void - * @note void - * @example void - */ -signed short ShellWrite(char* ch, unsigned short Len) -{ - ComSendStr(HostCom, (uint8_t* )ch,Len); - return Len; -} -/** - * @brief Shell读函数 - 中断回调实现 - * @param Vector 中断向量号 - * @retval void - * @note void - * @example void - */ -void LetterShellIrqFunc(void *Param) -{ - uint8_t ch = 0x00; - ch = ComReceiveChar(Param); - shellHandler(&Host, ch); -} - - -/** - * @brief 初始化Shell - * @param ComId 串口号,baud 波特率 - * @retval void - * @note void - * @example void - */ -void LetterShellInit(const COM_MAP_T *ComX, uint32_t Baud) -{ - //初始化串口 - ComStdConfig(ComX, Baud); - //设置串口回调函数 - IrqRegister(ComX->Periph.Irqn, LetterShellIrqFunc); - //设置中断等级 - IrqConfig(ComX->Periph.Irqn,1,1); - //注册写函数 - Host.write = ShellWrite; - //初始化LetterShell - shellInit(&Host, HostBuffer, WR_BUFFER_SIZE); -} - -// /** -// * @brief 打印版本号 -// * @param void -// * @retval void -// * @note void -// * @example void -// */ -// void version(void) -// { -// printf("%s,%s\r\n",HARDWARE_VERSION,SOFTWARE_VERSION); -// } -// -// /** -// * @brief 重启单片机 -// * @param void -// * @retval void -// * @note void -// * @example void -// */ -// void reboot(void) -// { -// SystemReboot(); -// } -// -// /** -// * @brief 串口测试程序 -// * @param void -// * @retval void -// * @note void -// * @example void -// */ -// -// void comTest(uint8_t ComId) -// { -// } -// -// //打印版本号 -// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), version, version, version); -// //软重启单片机 -// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), reboot, reboot, reboot); -// //串口测试 -// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), comTest, comTest, comTest); diff --git a/Bsp/Src/SeggerCall.c b/Bsp/Src/SeggerCall.c index 672db49..166a0c6 100644 --- a/Bsp/Src/SeggerCall.c +++ b/Bsp/Src/SeggerCall.c @@ -16,7 +16,7 @@ Purpose : Implementation of low-level functions for I/O with the * ********************************************************************** */ -#ifdef defined (__SEGGER__) +#if defined (__SEGGER__) #include "__SEGGER_RTL_Int.h" #include "stdio.h" #include "Bsp.h" diff --git a/Bsp/Src/SysCall.c b/Bsp/Src/SysCall.c index a059005..198386b 100644 --- a/Bsp/Src/SysCall.c +++ b/Bsp/Src/SysCall.c @@ -20,7 +20,7 @@ * ****************************************************************************** */ -#ifdef defined (__GNUC__) +#if defined (__GNUC__) /* Includes */ #include "Bsp.h" @@ -69,7 +69,7 @@ __attribute__((weak)) int _write(int file, char *ptr, int len) */ PUTCHAR_PROTOTYPE { - UsartSendChar(TTY_COM, ch); //阻塞式无限等待 + ComSendChar(TTY_COM, ch); //阻塞式无限等待 return ch; } @@ -83,8 +83,7 @@ PUTCHAR_PROTOTYPE GETCHAR_PROTOTYPE { uint8_t ch = 0; - ch = UsartReceiveChar(TTY_COM); - + ch = ComReceiveChar(TTY_COM); return ch; }