重写BSP
This commit is contained in:
@@ -1,131 +1,26 @@
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
|
||||
/* MCU INCLUDE */
|
||||
#include <stm32f10x.h>
|
||||
|
||||
#define VERSION "v1.0.0"
|
||||
|
||||
/* **********NVIC中断向量控制器组别********** */
|
||||
#define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2
|
||||
/* **********END********** */
|
||||
|
||||
/* 使用OS,ThreadX */
|
||||
#define USE_THREADX
|
||||
|
||||
/* **********SystemClock相关********** */
|
||||
// GPIO
|
||||
#define GPIO_ENABLE
|
||||
#define USE_GPIOA
|
||||
#define USE_GPIOB
|
||||
#define USE_GPIOC
|
||||
#define USE_GPIOD
|
||||
#define USE_GPIOE
|
||||
#define USE_GPIOF
|
||||
#define USE_GPIOG
|
||||
// USART
|
||||
#define USART_ENABLE
|
||||
#define USE_USART1
|
||||
#undef USE_USART2
|
||||
#undef USE_USART3
|
||||
#undef USE_USART4
|
||||
#undef USE_USART5
|
||||
#undef USE_USART6
|
||||
/* **********END********** */
|
||||
|
||||
/* **********GPIO DO DI相关********** */
|
||||
// 数字输出
|
||||
#undef USE_DIGITAL_OUTPUT
|
||||
#ifdef USE_DIGITAL_OUTPUT
|
||||
#define DO_NUM 2
|
||||
#define DO1 0
|
||||
#define DO2 1
|
||||
#endif
|
||||
|
||||
// 数字输入
|
||||
#undef USE_DIGITAL_INPUT
|
||||
#ifdef USE_DIGITAL_INPUT
|
||||
#define DI_NUM 2
|
||||
#define DI1 0
|
||||
#define DI2 1
|
||||
#endif
|
||||
|
||||
// LED灯
|
||||
#define USE_LED
|
||||
#ifdef USE_LED
|
||||
#define LED_NUM 3
|
||||
#define LED0 0
|
||||
#define LED1 1
|
||||
#define LED2 2
|
||||
#endif
|
||||
/* **********END********** */
|
||||
|
||||
/* **********串口相关********** */
|
||||
#ifdef USE_USART1
|
||||
#define COM0 USART1_BASE
|
||||
#define COM0_IRQN USART1_IRQn
|
||||
#define COM0_TX_PORT GPIOA
|
||||
#define COM0_RX_PORT GPIOA
|
||||
#define COM0_TX_PIN GPIO_Pin_9
|
||||
#define COM0_RX_PIN GPIO_Pin_10
|
||||
#endif
|
||||
#ifdef USE_USART2
|
||||
#define COM1 USART2_BASE
|
||||
#define COM1_IRQN USART2_IRQn
|
||||
#define COM1_TX_PORT GPIOA
|
||||
#define COM1_RX_PORT GPIOA
|
||||
#define COM1_TX_PIN GPIO_Pin_2
|
||||
#define COM1_RX_PIN GPIO_Pin_3
|
||||
#endif
|
||||
#ifdef USE_USART3
|
||||
#define COM2 USART3_BASE
|
||||
#define COM2_IRQN USART3_IRQn
|
||||
#define COM2_TX_PORT GPIOB
|
||||
#define COM2_RX_PORT GPIOB
|
||||
#define COM2_TX_PIN GPIO_Pin_10
|
||||
#define COM2_RX_PIN GPIO_Pin_11
|
||||
#endif
|
||||
#ifdef USE_USART4
|
||||
#define COM3 UART4_BASE
|
||||
#define COM3_IRQN UART4_IRQn
|
||||
#define COM3_TX_PORT GPIOC
|
||||
#define COM3_RX_PORT GPIOC
|
||||
#define COM3_TX_PIN GPIO_Pin_10
|
||||
#define COM3_RX_PIN GPIO_Pin_11
|
||||
#endif
|
||||
#ifdef USE_USART5
|
||||
#define COM4 UART5_BASE
|
||||
#define COM4_IRQN UART5_IRQn
|
||||
#define COM4_TX_PORT GPIOB
|
||||
#define COM4_RX_PORT GPIOD
|
||||
#define COM4_TX_PIN GPIO_Pin_12
|
||||
#define COM4_RX_PIN GPIO_Pin_2
|
||||
#endif
|
||||
/* LetterShell */
|
||||
#define USE_SHELL
|
||||
#ifdef USE_SHELL
|
||||
#define TTY_COM COM0
|
||||
#define TTY_COM_IRQN COM0_IRQN
|
||||
#endif
|
||||
/* **********END********** */
|
||||
|
||||
#define USE_ANALOG_INPUT
|
||||
#define USE_ANALOG_OUTPUT
|
||||
/* PERIPH INCLUDE */
|
||||
#include "Gpio.h"
|
||||
#include "Usart.h"
|
||||
#include "Interrupt.h"
|
||||
#include "Flash.h"
|
||||
|
||||
|
||||
/* 自定义Flash布局相关 */
|
||||
#define BOOT_SIZE_16 /* 16Kb的Bootloader大小 不带网络*/
|
||||
//#define BOOT_SIZE_32 /* 32Kb的Bootloader大小 带网络*/
|
||||
/* VERSION INFO */
|
||||
#define HARDWARE_VERSION "v1.0.0"
|
||||
#define SOFTWARE_VERSION "v1.0.0"
|
||||
|
||||
#define FLASH_BASE_ADDR 0x08000000 //Flash基地址
|
||||
#define BOOT_ADDR 0x08000000 //引导程序地址
|
||||
//BOOT程序大小
|
||||
#ifdef BOOT_SIZE_16
|
||||
#define BOOT_ROM 0x4000
|
||||
/* RTOS */
|
||||
#define USE_RTOS
|
||||
#ifdef USE_RTOS
|
||||
#undef USE_FREERTOS
|
||||
#undef USE_UCOS
|
||||
#define USE_THREADX
|
||||
#endif
|
||||
#ifdef BOOT_SIZE_32
|
||||
#define BOOT_ROM 0x8000
|
||||
#endif
|
||||
#define USER_PARAM_ADDR (FLASH_BASE_ADDR + BOOT_ROM) //用户参数分区
|
||||
#define APPLICATION_ADDR 0x08010000 //从128K的位置开始是应用程序
|
||||
/* **********END********** */
|
||||
|
||||
#endif
|
||||
|
||||
20
App/Board/Flash.h
Normal file
20
App/Board/Flash.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __FLASH_H__
|
||||
#define __FLASH_H__
|
||||
|
||||
///* 自定义Flash布局相关 */
|
||||
//#define BOOT_SIZE_16 /* 16Kb的Bootloader大小 不带网络*/
|
||||
////#define BOOT_SIZE_32 /* 32Kb的Bootloader大小 带网络*/
|
||||
|
||||
//#define FLASH_BASE_ADDR 0x08000000 //Flash基地址
|
||||
//#define BOOT_ADDR 0x08000000 //引导程序地址
|
||||
////BOOT程序大小
|
||||
//#ifdef BOOT_SIZE_16
|
||||
// #define BOOT_ROM 0x4000
|
||||
//#endif
|
||||
//#ifdef BOOT_SIZE_32
|
||||
// #define BOOT_ROM 0x8000
|
||||
//#endif
|
||||
//#define USER_PARAM_ADDR (FLASH_BASE_ADDR + BOOT_ROM) //用户参数分区
|
||||
//#define APPLICATION_ADDR 0x08010000 //从128K的位置开始是应用程序
|
||||
|
||||
#endif
|
||||
62
App/Board/Gpio.h
Normal file
62
App/Board/Gpio.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef __GPIO_H__
|
||||
#define __GPIO_H__
|
||||
|
||||
/* MCU_GPIO_INFO */
|
||||
#define GPIO_PORT_NUM 7 //共7组GPIO
|
||||
#define GPIO_PIN_NUM 16 //每组16个Pin
|
||||
|
||||
//数组信号输出开关
|
||||
#define DO_ON 0
|
||||
#define DO_OFF 1
|
||||
|
||||
//LED灯开关
|
||||
#define LED_ON 0
|
||||
#define LED_OFF 1
|
||||
|
||||
//GPIO结构体
|
||||
typedef struct
|
||||
{
|
||||
GPIO_TypeDef* GpioPort;
|
||||
unsigned short GpioPin;
|
||||
uint8_t DefaultStatus;
|
||||
}GPIO_ST, *GPIO_ST_PTR;
|
||||
|
||||
/* **********SystemClock相关********** */
|
||||
// GPIO
|
||||
#define GPIO_ENABLE
|
||||
#ifdef GPIO_ENABLE
|
||||
#define USE_GPIOA
|
||||
#define USE_GPIOB
|
||||
#define USE_GPIOC
|
||||
#define USE_GPIOD
|
||||
#define USE_GPIOE
|
||||
#define USE_GPIOF
|
||||
#define USE_GPIOG
|
||||
#endif
|
||||
|
||||
/* **********GPIO DO DI相关********** */
|
||||
// 数字输出
|
||||
#undef USE_DIGITAL_OUTPUT
|
||||
#ifdef USE_DIGITAL_OUTPUT
|
||||
#define DO_NUM 2
|
||||
#define DO1 0
|
||||
#define DO2 1
|
||||
#endif
|
||||
|
||||
// 数字输入
|
||||
#undef USE_DIGITAL_INPUT
|
||||
#ifdef USE_DIGITAL_INPUT
|
||||
#define DI_NUM 2
|
||||
#define DI1 0
|
||||
#define DI2 1
|
||||
#endif
|
||||
|
||||
// LED灯
|
||||
#define USE_LED
|
||||
#ifdef USE_LED
|
||||
#define LED_NUM 2
|
||||
#define LED0 0
|
||||
#define LED1 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
69
App/Board/Interrupt.h
Normal file
69
App/Board/Interrupt.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef __INTERRUPT_H__
|
||||
#define __INTERRUPT_H__
|
||||
|
||||
/* **********NVIC中断向量控制器组别********** */
|
||||
#define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2
|
||||
/* **********END********** */
|
||||
|
||||
/* Control System Interrupt Sw */
|
||||
#define DISABLE_INTERRUPT __set_PRIMASK(1);
|
||||
#define ENABLE_INTERRUPT __set_PRIMASK(0);
|
||||
|
||||
#define INTERRUPT_NUM 300 //System Interrupt Num
|
||||
|
||||
#ifdef INTERRUPT_NUM
|
||||
/* INTERRUPT_DESC_ST STRUCT */
|
||||
typedef struct
|
||||
{
|
||||
void(*CallBack)(unsigned int); //回调函数
|
||||
unsigned int IntId; //触发中断的外设id
|
||||
} INTERRUPT_DESC_ST;
|
||||
|
||||
/* INTERRUPT_ST STRUCT */
|
||||
typedef struct
|
||||
{
|
||||
INTERRUPT_DESC_ST Adc_1_2;
|
||||
INTERRUPT_DESC_ST Usb_Hp_Can1_Tx;
|
||||
INTERRUPT_DESC_ST Usb_Hp_Can1_Rx0;
|
||||
INTERRUPT_DESC_ST Can1_Rx1;
|
||||
INTERRUPT_DESC_ST Can1_Sce;
|
||||
INTERRUPT_DESC_ST Exti_9_5;
|
||||
INTERRUPT_DESC_ST Tim_1_Brk;
|
||||
INTERRUPT_DESC_ST Tim_1_Up;
|
||||
INTERRUPT_DESC_ST Tim_1_Trg_Com;
|
||||
INTERRUPT_DESC_ST Tim_1_Cc;
|
||||
INTERRUPT_DESC_ST Tim_2;
|
||||
INTERRUPT_DESC_ST Tim_3;
|
||||
INTERRUPT_DESC_ST Tim_4;
|
||||
INTERRUPT_DESC_ST I2c_1_Ev;
|
||||
INTERRUPT_DESC_ST I2c_1_ER;
|
||||
INTERRUPT_DESC_ST I2c_2_Ev;
|
||||
INTERRUPT_DESC_ST I2c_2_ER;
|
||||
INTERRUPT_DESC_ST Spi_1;
|
||||
INTERRUPT_DESC_ST Spi_2;
|
||||
INTERRUPT_DESC_ST Usart1;
|
||||
INTERRUPT_DESC_ST Usart2;
|
||||
INTERRUPT_DESC_ST Usart3;
|
||||
INTERRUPT_DESC_ST Exti_15_10;
|
||||
INTERRUPT_DESC_ST Rtc_Alarm;
|
||||
INTERRUPT_DESC_ST Usb_WackUp;
|
||||
INTERRUPT_DESC_ST Tim_8_Brk;
|
||||
INTERRUPT_DESC_ST Tim_8_Up;
|
||||
INTERRUPT_DESC_ST Tim_8_Trg_Com;
|
||||
INTERRUPT_DESC_ST Tim_8_Cc;
|
||||
INTERRUPT_DESC_ST Adc_3;
|
||||
INTERRUPT_DESC_ST Fsmc;
|
||||
INTERRUPT_DESC_ST Sdio;
|
||||
INTERRUPT_DESC_ST Tim_5;
|
||||
INTERRUPT_DESC_ST Spi_3;
|
||||
INTERRUPT_DESC_ST Uart4;
|
||||
INTERRUPT_DESC_ST Uart5;
|
||||
INTERRUPT_DESC_ST Tim_6;
|
||||
INTERRUPT_DESC_ST Tim_7;
|
||||
INTERRUPT_DESC_ST Dma_2_Chnl_1;
|
||||
INTERRUPT_DESC_ST Dma_2_Chnl_2;
|
||||
INTERRUPT_DESC_ST Dma_2_Chnl_3;
|
||||
INTERRUPT_DESC_ST Dma_2_Chnl_4;
|
||||
} INTERRUPT_ST, *INTERRUPT_ST_PTR;
|
||||
#endif
|
||||
#endif
|
||||
112
App/Board/Usart.h
Normal file
112
App/Board/Usart.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef __USART_H__
|
||||
#define __USART_H__
|
||||
|
||||
//数据位
|
||||
#define USART_DATA_BIT_8 USART_WordLength_8b //数据位8
|
||||
#define USART_DATA_BIT_9 USART_WordLength_9b //数据位9
|
||||
|
||||
//停止位
|
||||
#define USART_STOP_BIT_1 USART_StopBits_1 //停止位1
|
||||
#define USART_STOP_BIT_0_5 USART_StopBits_0_5 //停止位0.5
|
||||
#define USART_STOP_BIT_2 USART_StopBits_2 //停止位2
|
||||
#define USART_STOP_BIT_1_5 USART_StopBits_1_5 //停止位1.5
|
||||
|
||||
//校验位
|
||||
#define USART_PARITY_NO USART_Parity_No //无校验
|
||||
#define USART_PRAITY_EVEN USART_Parity_Even //偶校验
|
||||
#define USART_PRAITY_ODD USART_Parity_Odd //奇校验
|
||||
|
||||
//USART
|
||||
#define USART_ENABLE
|
||||
#ifdef USART_ENABLE
|
||||
#define USE_USART1
|
||||
#undef USE_USART2
|
||||
#undef USE_USART3
|
||||
#undef USE_USART4
|
||||
#undef USE_USART5
|
||||
#undef USE_USART6
|
||||
#endif
|
||||
|
||||
/* **********串口相关********** */
|
||||
#ifdef USE_USART1
|
||||
#define COM0 USART1_BASE
|
||||
#define COM0_IRQN USART1_IRQn
|
||||
#define COM0_TX_PORT GPIOA
|
||||
#define COM0_RX_PORT GPIOA
|
||||
#define COM0_TX_PIN GPIO_Pin_9
|
||||
#define COM0_RX_PIN GPIO_Pin_10
|
||||
#endif
|
||||
#ifdef USE_USART2
|
||||
#define COM1 USART2_BASE
|
||||
#define COM1_IRQN USART2_IRQn
|
||||
#define COM1_TX_PORT GPIOA
|
||||
#define COM1_RX_PORT GPIOA
|
||||
#define COM1_TX_PIN GPIO_Pin_2
|
||||
#define COM1_RX_PIN GPIO_Pin_3
|
||||
#endif
|
||||
#ifdef USE_USART3
|
||||
#define COM2 USART3_BASE
|
||||
#define COM2_IRQN USART3_IRQn
|
||||
#define COM2_TX_PORT GPIOB
|
||||
#define COM2_RX_PORT GPIOB
|
||||
#define COM2_TX_PIN GPIO_Pin_10
|
||||
#define COM2_RX_PIN GPIO_Pin_11
|
||||
#endif
|
||||
#ifdef USE_USART4
|
||||
#define COM3 UART4_BASE
|
||||
#define COM3_IRQN UART4_IRQn
|
||||
#define COM3_TX_PORT GPIOC
|
||||
#define COM3_RX_PORT GPIOC
|
||||
#define COM3_TX_PIN GPIO_Pin_10
|
||||
#define COM3_RX_PIN GPIO_Pin_11
|
||||
#endif
|
||||
#ifdef USE_USART5
|
||||
#define COM4 UART5_BASE
|
||||
#define COM4_IRQN UART5_IRQn
|
||||
#define COM4_TX_PORT GPIOB
|
||||
#define COM4_RX_PORT GPIOD
|
||||
#define COM4_TX_PIN GPIO_Pin_12
|
||||
#define COM4_RX_PIN GPIO_Pin_2
|
||||
#endif
|
||||
|
||||
/* LetterShell */
|
||||
#define USE_SHELL
|
||||
#ifdef USE_SHELL
|
||||
#define TTY_COM COM0
|
||||
#define TTY_COM_IRQN COM0_IRQN
|
||||
#endif
|
||||
|
||||
/* 此BSP规定最多4路RS485 */
|
||||
#undef USE_RS4851
|
||||
#ifdef USE_RS4851
|
||||
#define RS4851_TRANS_PORT GPIOx
|
||||
#define RS4851_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4851_TRANS_TX RESET
|
||||
#define RS4851_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#undef USE_RS4852
|
||||
#ifdef USE_RS4852
|
||||
#define RS4852_TRANS_PORT GPIOx
|
||||
#define RS4852_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4852_TRANS_TX RESET
|
||||
#define RS4852_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#undef USE_RS4853
|
||||
#ifdef USE_RS4853
|
||||
#define RS4853_TRANS_PORT GPIOx
|
||||
#define RS4853_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4853_TRANS_TX RESET
|
||||
#define RS4853_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#undef USE_RS4854
|
||||
#ifdef USE_RS4854
|
||||
#define RS4854_TRANS_PORT GPIOx
|
||||
#define RS4854_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4854_TRANS_TX RESET
|
||||
#define RS4854_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user