| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- /*
- * @Description:
- * @Version: 2.0
- * @Author: Seven
- * @Date: 2022-08-22 09:55:26
- * @LastEditors: Seven
- * @LastEditTime: 2023-04-28 15:39:14
- */
- #ifndef __BSP_H
- #define __BSP_H
- #include "includes.h"
- #include "tools.h"
- //app版本号
- #define SOFTWARE_VERSION_APP 0X02013130
- #define EEPROM_VER 0X01
- #define EEPROM_FIRST_INIT_FLAG 0x55AA
- extern const char PowerOn_Info[][64];
- extern FunctionalState irq_state;
- //任务执行次数
- typedef struct _task_count_t
- {
- uint32_t uart_count_cur;
- uint32_t uart_count_prev;
- uint32_t prog_count_cur;
- uint32_t prog_count_prev;
- uint32_t ota_count_cur;
- uint32_t ota_count_prev;
- uint32_t lora_count_cur;
- uint32_t lora_count_prev;
- uint32_t encoder_count_cur;
- uint32_t encoder_count_prev;
- }__attribute__((packed)) task_count_t;
- extern task_count_t task_count;
- void watchdog_feed(void);
- //共用体(float与u32)
- union data_u
- {
- float dataf;
- uint32_t datai;
- };
- extern union data_u Voltage,Temperature;
- #define REAL_TIME_TIMEOUT (10*1000) //实时参数读取(电压、温度)
- //工作模式
- typedef enum DEV_WORK_STATE
- {
- DEV_WORK_STATE_NORMAL, //正常工作模式
- DEV_WORK_STATE_UPDATING, //升级模式
- DEV_WORK_STATE_PT, //产测模式
- DEV_WORK_STATE_UNINIT, //出厂信息未初始化模式
- DEV_WORK_STATE_XSP_UPDATING, //显示屏升级模式
- // DEV_WORK_STATE_UPDATE_RETRANSMIT, //
- // DEV_WORK_STATE_ONLOOKER, //旁观者模式
- // DEV_WORK_STATE_OTA_BEGIN, //开始升级模式
- // DEV_WORK_STATE_OTA_CONTINUOUS, //升级中连续收包模式
- // DEV_WORK_STATE_OTA_RETRANSMIT, //升级中重传模式
- // DEV_WORK_STATE_OTA_UPGRADE_RCV_END, //升级中升级包接收完成模式
- // DEV_WORK_STATE_UPDATE_MASTER, //主设备升级模式
- // DEV_WORK_STATE_UPLOAD_SLAVE, //从设备主动上报升级状态模式
-
- DEV_WORK_STATE_MAX
- }DEV_WORK_STATE_T;
- //设备可配置信息,需存eeprom
- typedef struct _device_info
- {
- uint8_t alrd; //是否配置的标记
- uint32_t device_sn; //设备sn
- uint16_t device_type; //设备类型
- uint16_t manufactures; //产品制造商
- uint16_t batch_number; //批次号
- uint32_t production_data; //出厂日期
- uint8_t pcb_ver; //PCB版本
- }__attribute__((packed)) device_info_t;
- extern device_info_t device_info;
- //设备固定信息,不需在app中写eeprom
- typedef struct _device_fixed_info
- {
- uint32_t Soft_ver_app; //app版本号
- uint32_t Soft_ver_boot; //bootloader版本号
- uint8_t MCU_UUID[12]; //MCU的UUID
- uint16_t MCU_Type_ID; //MCU的芯片类型
- uint32_t Reset_total_cnt; //复位总次数
- uint8_t Last_reset_flag; //上次复位类型
- uint8_t Encrypt; //明密文状态
- uint8_t Work_State; //当前工作状态
- uint32_t Voltage; //电压
- uint32_t Temperature; //温度
- uint8_t lora_para_group; //lora参数选择
- uint8_t master_updata_start; //主设备开始升级标志
- uint8_t slave_uploade_start; //从设备主动上报标志
- uint8_t reset_flag; //采集器复位标记
- uint8_t xsp_update_start; //显示屏开始升级标记
- }device_fixed_info_t;
- extern device_fixed_info_t device_fixed_info;
- #define RS485_RX() {GPIO_ResetBits(GPIOA, GPIO_Pin_1);}
- #define RS485_TX() {GPIO_SetBits(GPIOA, GPIO_Pin_1);}
- void GPIO_COMM_Init(u32 clk, GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIOMode_TypeDef mode, GPIOSpeed_TypeDef speed);
- void BSP_Init(void);
- void key_task_handle(uint8_t num);
- uint8_t device_type_cmp(uint32_t device_fixed, uint16_t device_rcv);
- int device_type_and_id_cmp_NoBroadcast(uint16_t device_type, uint32_t device_sn);
- void device_real_time_para_read(void);
- void device_irq_set(FunctionalState state);
- void run_irq_set(void);
- void device_module_reset(void);
- #endif
|