/* * @Description: * @Version: 2.0 * @Author: Seven * @Date: 2022-03-22 10:09:08 * @LastEditors: Seven * @LastEditTime: 2022-12-03 16:11:03 */ #ifndef __TOOLS_H__ #define __TOOLS_H__ #include "stm32f10x.h" extern volatile uint32_t TickCounter; //printf打印 #define INIT_DEBUG 1 //初始化打印 #define MSG_DISPLAY_DOWN_TYPE1 1 //显示屏命令打印sn和消息类型 #define MSG_DISPLAY_DOWN_TYPE2 0 //显示屏和报税口打印设备类型和加密状态 #define MSG_DISPLAY_DOWN_TYPE3 1 //显示屏命令打印串口号、报税口号、枪号 #define MSG_DISPLAY_DOWN_TYPE4 1 // #define MSG_DISPLAY_DOWN_TYPE5 1 // #define MSG_HEARTBEAT_DOWN_TYPE1 1 //心跳包命令打印sn和消息类型 #define MSG_HEARTBEAT_DOWN_TYPE2 1 // #define MSG_HEARTBEAT_DOWN_TYPE3 1 // #define MSG_HEARTBEAT_DOWN_TYPE4 1 // #define MSG_HEARTBEAT_DOWN_TYPE5 1 // #define MSG_TAX_DOWN_TYPE1 1 //报税口命令打印sn和消息类型 #define MSG_TAX_DOWN_TYPE2 1 // #define MSG_TAX_DOWN_TYPE3 1 //报税口打印串口号、报税口号、枪号 #define MSG_TAX_DOWN_TYPE4 1 // #define MSG_TAX_DOWN_TYPE5 1 // #define MSG_HART_DOWN_TYPE1 1 //固件信息打印sn和消息类型 #define MSG_HART_DOWN_TYPE2 1 //固件信息打印运行时长 #define MSG_HART_DOWN_TYPE3 1 // #define MSG_HART_DOWN_TYPE4 1 // #define MSG_HART_DOWN_TYPE5 1 // #define MSG_REBOOT_DOWN_TYPE1 1 //重启指令打印sn和消息类型 #define MSG_REBOOT_DOWN_TYPE2 1 // #define MSG_REBOOT_DOWN_TYPE3 1 // #define MSG_REBOOT_DOWN_TYPE4 1 // #define MSG_REBOOT_DOWN_TYPE5 1 // #define MSG_TIMESYNC_DOWN_TYPE1 1 //时间同步指令打印sn和消息类型 #define MSG_TIMESYNC_DOWN_TYPE2 1 // #define MSG_TIMESYNC_DOWN_TYPE3 1 // #define MSG_TIMESYNC_DOWN_TYPE4 1 // #define MSG_TIMESYNC_DOWN_TYPE5 1 // #define MSG_LORA_DOWN_TYPE1 1 //lora配置信道指令打印sn和消息类型 #define MSG_LORA_DOWN_TYPE2 1 //打印Lora配置的信道索引号 #define MSG_LORA_DOWN_TYPE3 1 // #define MSG_LORA_DOWN_TYPE4 1 // #define MSG_LORA_DOWN_TYPE5 1 // #define MSG_ENCODER_DOWN_TYPE1 1 //编码器指令打印sn和消息类型 #define MSG_ENCODER_DOWN_TYPE2 1 //编码器指令打印报税口号和枪号和指令 #define MSG_ENCODER_DOWN_TYPE3 1 //编码器指令打印读取的组号和新纪录标识 #define MSG_ENCODER_DOWN_TYPE4 1 //编码器打印指令的设备类型 #define MSG_ENCODER_DOWN_TYPE5 1 // #define MSG_REBOOT_TYPE_DOWN_TYPE1 1 //根据设备类型复位 #define UART_RCV_DEBUG 1 //串口接收打印 #define UART_SEND_DEBUG 1 // #define LORA_RCV_DEBUG 0 //lora接收打印snr和rssi #define LORA_SEND_DEBUG 1 // #define LORA_TASK_DEBUG 1 // #define ENCODER_INIT_DEBUG 1 //编码器初始化打印 #define ENCODER_GUN_DEBUG 1 //编码器抬枪信号中断打印 #define ENCODER_NEW_DEBUG 1 //编码器产生新数据打印 #define ENCODER_EEPROM_DEBUG 0 //编码器写eeprom打印 /////////////////////////////////// //十六进制打印(data_dump) #define MSG_DISPLAY_DATA_TYPE1 1 //显示屏发送数据 #define MSG_DISPLAY_DATA_TYPE2 0 //显示屏命令正常返回数据 #define MSG_DISPLAY_DATA_TYPE3 1 //显示屏命令执行错误返回数据 #define MSG_DISPLAY_DATA_TYPE4 1 // #define MSG_DISPLAY_DATA_TYPE5 1 // #define MSG_HEARTBEAT_DATA_TYPE1 0 //心跳包返回数据 #define MSG_HEARTBEAT_DATA_TYPE2 1 // #define MSG_HEARTBEAT_DATA_TYPE3 1 // #define MSG_HEARTBEAT_DATA_TYPE4 1 // #define MSG_HEARTBEAT_DATA_TYPE5 1 // #define MSG_TAX_DATA_TYPE1 1 //报税口发送数据 #define MSG_TAX_DATA_TYPE2 0 //报税口正常返回数据 #define MSG_TAX_DATA_TYPE3 1 //报税口执行错误返回数据 #define MSG_TAX_DATA_TYPE4 1 // #define MSG_TAX_DATA_TYPE5 1 // #define MSG_HART_DATA_TYPE1 0 //固件信息返回数据 #define MSG_HART_DATA_TYPE2 1 // #define MSG_HART_DATA_TYPE3 1 // #define MSG_HART_DATA_TYPE4 1 // #define MSG_HART_DATA_TYPE5 1 // #define MSG_REBOOT_DATA_TYPE1 1 // #define MSG_REBOOT_DATA_TYPE2 1 // #define MSG_REBOOT_DATA_TYPE3 1 // #define MSG_REBOOT_DATA_TYPE4 1 // #define MSG_REBOOT_DATA_TYPE5 1 // #define MSG_TIMESYNC_DATA_TYPE1 1 // #define MSG_TIMESYNC_DATA_TYPE2 1 // #define MSG_TIMESYNC_DATA_TYPE3 1 // #define MSG_TIMESYNC_DATA_TYPE4 1 // #define MSG_TIMESYNC_DATA_TYPE5 1 // #define MSG_LORA_DATA_TYPE1 1 // #define MSG_LORA_DATA_TYPE2 1 // #define MSG_LORA_DATA_TYPE3 1 // #define MSG_LORA_DATA_TYPE4 1 // #define MSG_LORA_DATA_TYPE5 1 // #define MSG_ENCODER_DATA_TYPE1 1 //编码器返回数据 #define MSG_ENCODER_DATA_TYPE2 1 //编码器返回执行错误数据 #define MSG_ENCODER_DATA_TYPE3 1 // #define MSG_ENCODER_DATA_TYPE4 1 // #define MSG_ENCODER_DATA_TYPE5 1 // #define MSG_ERR_DATA_TYPE1 1 //业务查询执行错误数据返回 #define UART_RCV_DATA_DEBUG 1 //串口接收数据 #define UART_SEND_DATA_DEBUG 1 // #define LORA_RCV_DATA_DEBUG 0 //Lora接收数据 #define LORA_SEND_DATA_DEBUG 0 //Lora发送数据 #define LORA_TASK_DATA_DEBUG 1 // #define LORA_BUSINESS_DEBUG 1 //业务数据返回 #define ENCODER_INIT_DATA_DEBUG 0 //编码器初始化数据 #define ENCODER_NEW_DATA_DEBUG 1 // #define ENCODER_EEPROM_DATA_DEBUG 0 //编码器写eeprom数据 #ifndef INIT_DEBUG #define INIT_DEBUG 0 #endif typedef struct timeout_ { uint8_t flag; uint32_t count; uint32_t timeout; }__attribute__((packed)) timeout_t; void GetCodeVerify(uint32_t _start,uint32_t _len,uint32_t * _verify); void GetCodeVerify_t(uint32_t _start,uint32_t _len,uint32_t * _verify); uint16_t CRC16_get(uint8_t *_buff,uint32_t _len); uint16_t CRC16_get_flash(uint32_t addr, uint32_t len); int _ytsf_data_code(uint8_t *buff, uint8_t *len); int _ytsf_data_decode(uint8_t *buff, uint8_t *len); long HextoDec(char *s); unsigned char HexToChar(unsigned char bChar); int asciitohex(char *data, uint8_t *out_data, int len); int decimal_bcd_code(int decimal); void timeout_setValue(timeout_t *tt,uint32_t val,uint8_t flg); void timeout_start(timeout_t *tt,uint8_t flg); void timeout_stop(timeout_t *tt); uint8_t timeout_isOut(timeout_t *tt); void timeout_setValue_us(timeout_t *tt,uint32_t val,uint8_t flg); void timeout_start_us(timeout_t *tt,uint8_t flg); void timeout_stop_us(timeout_t *tt); uint8_t timeout_isOut_us(timeout_t *tt); uint8_t uart_baud_judge(uint32_t baud); uint8_t buf_is_zero(uint8_t *buf, uint16_t size); uint8_t buff_compare(uint8_t *buf1, uint8_t *buf2, uint16_t len); uint8_t get_xor(uint8_t *buf, uint16_t len); uint8_t _crc_get_gw(uint8_t *data, uint8_t size); uint32_t strtohex(char *data, uint8_t len); void printf_debug(uint8_t cmd1, const char *fmt, ...); void data_dump_debug(uint8_t cmd1, const char *name, uint8_t *data, uint16_t len); #endif