221 lines
5.9 KiB
C
221 lines
5.9 KiB
C
#include "Bsp.h"
|
|
|
|
void AllPeriphClockDisable(void);
|
|
|
|
/**
|
|
* @brief 关闭所有外设时钟
|
|
* @note void
|
|
* @param void
|
|
* @retval void
|
|
*/
|
|
void AllPeriphClockDisable(void)
|
|
{
|
|
// ==================== GPIOA 组 ====================
|
|
#ifdef GPIOA
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, DISABLE);
|
|
#endif
|
|
#ifdef GPIOB
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, DISABLE);
|
|
// ==================== GPIOB 组 ====================
|
|
#endif
|
|
#ifdef GPIOC
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, DISABLE);
|
|
// ==================== GPIOC 组 ====================
|
|
#endif
|
|
#ifdef GPIOD
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, DISABLE);
|
|
// ==================== GPIOD 组 ====================
|
|
#endif
|
|
#ifdef GPIOE
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, DISABLE);
|
|
// ==================== GPIOE 组 ====================
|
|
#endif
|
|
#ifdef GPIOF
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, DISABLE);
|
|
// ==================== GPIOF 组 ====================
|
|
#endif
|
|
#ifdef GPIOG
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOG, DISABLE);
|
|
// ==================== GPIOG 组 ====================
|
|
#endif
|
|
|
|
#ifdef USART1
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, DISABLE);
|
|
#endif
|
|
|
|
#ifdef USART2
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, DISABLE);
|
|
#endif
|
|
|
|
#ifdef USART3
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, DISABLE);
|
|
#endif
|
|
|
|
#ifdef UART4
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, DISABLE);
|
|
#endif
|
|
|
|
#ifdef UART5
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, DISABLE);
|
|
#endif
|
|
}
|
|
//
|
|
// #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(); // 执行软件复位
|
|
// }
|
|
/**
|
|
* @brief 重写Printf函数
|
|
* @note void
|
|
* @param void
|
|
* @retval void
|
|
*/
|
|
// ||
|
|
// #include <SysCall.c>
|
|
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
|
int fputc(int ch, FILE *f)
|
|
{
|
|
UsartSendChar(TTY_COM, ch);
|
|
return ch;
|
|
}
|
|
int fgetc(FILE *f)
|
|
{
|
|
uint8_t ch;
|
|
ch = UsartReceiveChar(TTY_COM);
|
|
return ch;
|
|
}
|
|
#endif
|