first commit
This commit is contained in:
125
Bsp/Inc/Bsp.h
Normal file
125
Bsp/Inc/Bsp.h
Normal file
@@ -0,0 +1,125 @@
|
||||
#ifndef __BSP_H__
|
||||
#define __BSP_H__
|
||||
|
||||
/* BSP INCLUDE */
|
||||
#include "Board.h"
|
||||
/* STDC INCLUDE */
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
/* MCU INCLUDE */
|
||||
#include <stm32f10x.h>
|
||||
#include "stm32f10x_conf.h"
|
||||
|
||||
//SystemInit
|
||||
void BspConfigInit(void);
|
||||
|
||||
//GPIO
|
||||
#define IO_TYPE_DO 0
|
||||
#define IO_TYPE_DI 1
|
||||
#define IO_TYPE_AO 2
|
||||
#define IO_TYPE_AI 3
|
||||
#define IO_TYPE_LED 4
|
||||
typedef enum {
|
||||
false = 0,
|
||||
true = 1,
|
||||
} bool_t;
|
||||
typedef struct
|
||||
{
|
||||
GPIO_TypeDef* GpioX;
|
||||
uint16_t GpioPinX;
|
||||
}GPIO_LIST;
|
||||
void BspInitGpioClock(void);
|
||||
void GpioConfig(GPIO_TypeDef* GpioX, uint16_t GpioPinX, GPIOMode_TypeDef GpioMode, GPIOSpeed_TypeDef GpioSpeed);
|
||||
void SetGpioSts(GPIO_TypeDef* GpioX, uint16_t GpioPinX, bool_t state);
|
||||
bool_t GetGpioSts(GPIO_TypeDef *GpioX, uint16_t GpioPinX);
|
||||
|
||||
//Delay
|
||||
void DelayConfig(void);
|
||||
uint32_t GetDwtCnt(void);
|
||||
void DelayUs(uint32_t Us);
|
||||
void DelayMs(uint32_t Ms);
|
||||
|
||||
//Interrupt
|
||||
#define INTERRUPT_NUM 300
|
||||
typedef struct
|
||||
{
|
||||
void(*CallBack)(uint32_t); //回调函数
|
||||
int32_t IntId; //触发中断的外设id
|
||||
} INT_DESC;
|
||||
typedef struct
|
||||
{
|
||||
INT_DESC Adc_1_2;
|
||||
INT_DESC Usb_Hp_Can1_Tx;
|
||||
INT_DESC Usb_Hp_Can1_Rx0;
|
||||
INT_DESC Can1_Rx1;
|
||||
INT_DESC Can1_Sce;
|
||||
INT_DESC Exti_9_5;
|
||||
INT_DESC Tim_1_Brk;
|
||||
INT_DESC Tim_1_Up;
|
||||
INT_DESC Tim_1_Trg_Com;
|
||||
INT_DESC Tim_1_Cc;
|
||||
INT_DESC Tim_2;
|
||||
INT_DESC Tim_3;
|
||||
INT_DESC Tim_4;
|
||||
INT_DESC I2c_1_Ev;
|
||||
INT_DESC I2c_1_ER;
|
||||
INT_DESC I2c_2_Ev;
|
||||
INT_DESC I2c_2_ER;
|
||||
INT_DESC Spi_1;
|
||||
INT_DESC Spi_2;
|
||||
INT_DESC Usart1;
|
||||
INT_DESC Usart2;
|
||||
INT_DESC Usart3;
|
||||
INT_DESC Exti_15_10;
|
||||
INT_DESC Rtc_Alarm;
|
||||
INT_DESC Usb_WackUp;
|
||||
INT_DESC Tim_8_Brk;
|
||||
INT_DESC Tim_8_Up;
|
||||
INT_DESC Tim_8_Trg_Com;
|
||||
INT_DESC Tim_8_Cc;
|
||||
INT_DESC Adc_3;
|
||||
INT_DESC Fsmc;
|
||||
INT_DESC Sdio;
|
||||
INT_DESC Tim_5;
|
||||
INT_DESC Spi_3;
|
||||
INT_DESC Uart4;
|
||||
INT_DESC Uart5;
|
||||
INT_DESC Tim_6;
|
||||
INT_DESC Tim_7;
|
||||
INT_DESC Dma_2_Chnl_1;
|
||||
INT_DESC Dma_2_Chnl_2;
|
||||
INT_DESC Dma_2_Chnl_3;
|
||||
INT_DESC Dma_2_Chnl_4;
|
||||
} SYSTEM_INT_REG;
|
||||
void DisAllowInt(void);
|
||||
void AllowInt(void);
|
||||
void IntCbInit(void);
|
||||
void IntCbReg(uint32_t Vector, void(*Func)(uint32_t));
|
||||
void IntSetLevel(uint32_t Vector, uint8_t NvicPrePriority, uint8_t NvicSubPriority);
|
||||
|
||||
|
||||
//USART
|
||||
#define DataBit_8 USART_WordLength_8b
|
||||
#define DataBit_9 USART_WordLength_9b
|
||||
#define StopBit_1 USART_StopBits_1
|
||||
#define StopBit_0_5 USART_StopBits_0_5
|
||||
#define StopBit_2 USART_StopBits_2
|
||||
#define StopBit_1_5 USART_StopBits_1_5
|
||||
#define Parity_No USART_Parity_No
|
||||
#define Parity_Even USART_Parity_Even
|
||||
#define Parity_Odd USART_Parity_Odd
|
||||
void BspInitUsartClock(void);
|
||||
void UsartStdConfig(uint32_t ComId, uint32_t baud);
|
||||
void UsartAdvConfig(uint32_t ComId, uint32_t baud, uint8_t DataBits, uint8_t StopBits, uint8_t Parity);
|
||||
void UsartSendChar(uint32_t ComId,uint8_t Data);
|
||||
void UsartSendStr(uint32_t ComId,uint8_t* Data, uint64_t Len);
|
||||
uint8_t UsartReceiveChar(uint32_t ComId);
|
||||
|
||||
//用户层接口
|
||||
void IoCtlToggleDo(uint16_t IoChnl);
|
||||
uint32_t IoCtl(uint8_t IoType, uint16_t IoChnl,uint32_t state);
|
||||
void IoCtlLedToggle(uint16_t IoChnl);
|
||||
#endif
|
||||
0
Bsp/Inc/Interrupt.h
Normal file
0
Bsp/Inc/Interrupt.h
Normal file
Reference in New Issue
Block a user