初始版本
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
#ifndef _BSP_H
|
||||
#define _BSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "gpio.h"
|
||||
|
||||
/*设备类型*/
|
||||
#define FORCE_6D 0x0001 //0x0001 六维应力
|
||||
#define OSMOTIC_PRESSURE 0x0002 //0x0002 渗透压
|
||||
#define ELASTIC_WAVEGUIDE 0x0003 //0x0003 弹性波导
|
||||
#define DIELECTRIC_MASS 0x0004 //0x0004 介电质普
|
||||
#define _0x0005 0x0005 //0x0005 保留
|
||||
#define CONT_DEFOR_3D 0x0006 //0x0006 三维连续变形
|
||||
#define COMM_UNIT 0x0007 //0x0007 通讯单元
|
||||
#define FORCE_3D 0x0008 //0x0008 三维应力
|
||||
#define LASER_TRACING 0x0009 //0x0009 激光示踪
|
||||
#define _0x000A 0x000A //0x000A 保留
|
||||
#define _0x000B 0x000B //0x000B 保留
|
||||
#define _0x000C 0x000C //0x000C 保留
|
||||
#define MULTI_PARAMETER_FUSION 0x000D //0x000D 多参数融合
|
||||
#define CRACK_DETECTION 0x000E //0x000E 裂缝仪
|
||||
#define _0x000F 0x000F //0x000F 保留
|
||||
#define ATTITUDE_MONITOR 0x0010 //0x0010 姿态检测
|
||||
#define LASER_DISPLACE 0x0011 //0x0011 激光位移
|
||||
#define REBAR_STRESS 0x0012 //0x0012 钢筋应力
|
||||
#define ANCHOR_ROD_STRESS 0x0013 //0x0013 锚杆轴力
|
||||
#define SURFACE_STRESS 0x0014 //0x0014 表面应力
|
||||
#define PRESSURE 0x0015 //0x0015 压力
|
||||
#define MICROWAVE_DISPLACE 0x0016 //0x0016 微波测距
|
||||
/*通讯方式*/
|
||||
typedef enum {
|
||||
LORA = 0x01, //0x01 LORA通讯
|
||||
RS485 = 0x02, //0x02 RS485通讯
|
||||
RS232 = 0x03, //0x03 RS232通讯
|
||||
CAN = 0x04, //0x04 CAN通讯
|
||||
_4G = 0x05, //0x05 _4G通讯
|
||||
BLE = 0x06, //0x06 BLE通讯
|
||||
WIFI = 0x07, //0x07 WIFI通讯
|
||||
}COMM_WAY_M;
|
||||
/*设备标志*/
|
||||
typedef enum {
|
||||
MASTER = 0x000000, //0x000000 主设备
|
||||
SUBSET = 0x800000, //0x800000 子设备
|
||||
}DEVICE_SIGN_M;
|
||||
|
||||
/*设备类型选择*/
|
||||
#define DEVICE_TYPE LASER_TRACING
|
||||
/*通讯方式选择*/
|
||||
#define COMM_WAY LORA
|
||||
/*设备标志选择*/
|
||||
#define DEVICE_SIGN MASTER
|
||||
/*设备地址编号设置*/
|
||||
#define ADD_NUMBER (0x000000 + DEVICE_SIGN) //数字部分对应唯一地址编号
|
||||
|
||||
#if(DEVICE_TYPE == LASER_TRACING)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf4
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin10
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin1
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
#if(DEVICE_TYPE == FORCE_6D)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf3
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin0
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin1
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
#if(DEVICE_TYPE == OSMOTIC_PRESSURE)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf3
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin0
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin1
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
#if(DEVICE_TYPE == CONT_DEFOR_3D)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf3
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin0
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin1
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
#if(DEVICE_TYPE == COMM_UNIT)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf4
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin10
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin2
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
#if(DEVICE_TYPE == FORCE_3D)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf3
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin0
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin1
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
#if(DEVICE_TYPE == CRACK_DETECTION)
|
||||
#define LP_UART_CH 0
|
||||
#define LPUART (M0P_LPUART0)
|
||||
#define LPUART_IRQN (LPUART0_IRQn)
|
||||
#define LPUART_PERIPHERAL_CLK (SysctrlPeripheralLpUart0)
|
||||
|
||||
#define LPUART_TX_AF GpioAf4
|
||||
#define LPUART_TX_PORT GpioPortB
|
||||
#define LPUART_TX_PIN GpioPin10
|
||||
|
||||
#define LPUART_RX_AF GpioAf3
|
||||
#define LPUART_RX_PORT GpioPortB
|
||||
#define LPUART_RX_PIN GpioPin11
|
||||
|
||||
#define RS485_CTRL_PORT GpioPortB
|
||||
#define RS485_CTRL_PIN GpioPin2
|
||||
|
||||
#define RS485_CTRL_RX() Gpio_ClrIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_CTRL_TX() Gpio_SetIO(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#endif
|
||||
|
||||
|
||||
#define FLASH_SECTOR_SIZE 0x200ul
|
||||
#define FLASH_BASE ((uint32_t)0x00000000)
|
||||
#define FLASH_SIZE (230u * FLASH_SECTOR_SIZE)
|
||||
|
||||
|
||||
#define SRAM_BASE ((uint32_t)0x20000000)
|
||||
#define RAM_SIZE 0x4000ul
|
||||
|
||||
|
||||
#define BOOT_SIZE (20 * FLASH_SECTOR_SIZE)
|
||||
#define APP_ADDRESS (0x2A00)//(FLASH_BASE + BOOT_SIZE)
|
||||
|
||||
#define BOOT_PARA_ADDRESS (0x0001FC00)
|
||||
#define BOOT_PARA_SIZE (FLASH_SECTOR_SIZE)
|
||||
|
||||
#define DEBUG 1
|
||||
#define USE_LOWPOWER 0
|
||||
#define USE_WDT 1
|
||||
|
||||
//#define WAKEUP_TIME_ARR (65536 - (30 * 150)) //65536 - time * 38400Hz / 256分频
|
||||
|
||||
#define SYSCLK_RCH 0
|
||||
#define SYSCLK_XTH 1
|
||||
#define SYSCLK_PLL 2
|
||||
|
||||
#define SYSCLK SYSCLK_RCH
|
||||
|
||||
typedef struct {
|
||||
uint32_t AppFlag;
|
||||
uint32_t UpdateFlag;
|
||||
uint32_t PackageCnt;
|
||||
uint32_t AppSize;
|
||||
uint32_t Crc32Check;
|
||||
}BootPara_t, *BootPara;
|
||||
|
||||
typedef void (*ReadPara)(BootPara_t rPara);
|
||||
typedef void (*SavPara)(BootPara_t wPara);
|
||||
typedef void (*UartSend)(uint8_t *sData, int sLen);
|
||||
typedef void (*DataRevCallBack)(uint8_t *rData, uint8_t rLen);
|
||||
|
||||
void BspInit(void);
|
||||
void DBGUartSendByte(uint8_t sData);
|
||||
void DBGUartSend(uint8_t *sData, int sLen);
|
||||
|
||||
void ReadBootPara(BootPara rData);
|
||||
void WriteBootPara(BootPara wData);
|
||||
void EraseFlash(void);
|
||||
|
||||
uint32_t GetSysTick(void);
|
||||
void delay_ms(uint32_t ms);
|
||||
void Delay(uint8_t time);
|
||||
void FeedDog(void);
|
||||
void SystemReset(void);
|
||||
#endif
|
||||
Reference in New Issue
Block a user