| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- /*
- * @Description:
- * @Version: 2.0
- * @Author: Seven
- * @Date: 2022-03-22 10:09:08
- * @LastEditors: Seven
- * @LastEditTime: 2023-03-30 14:12:09
- */
- #ifndef __TOOLS_H__
- #define __TOOLS_H__
- #include "gd32f10x.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 1 //Lora发送数据
- #define LORA_TASK_DATA_DEBUG 1 //
- #define LORA_BUSINESS_DEBUG 0 //业务数据返回
- #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;
- uint16_t CRC16_get(uint8_t *_buff,uint32_t _len);
- uint16_t _crc_get(uint8_t *data, uint8_t size);
- void msg_data_code(uint8_t *buff, uint16_t *len, uint8_t head, uint8_t tail);
- void msg_data_decode(uint8_t *buff, uint16_t *len, uint8_t head, uint8_t tail);
- int HasByte_head(uint8_t *s, char ch , uint16_t len);
- int HasByte_tail(uint8_t *s, char ch , uint16_t len);
- unsigned char HexToChar(unsigned char bChar);
- int asciitohex(char *data, uint8_t *out_data, int len);
- int decimal_bcd_code(int decimal);
- uint16_t set_flag_not(uint16_t data);
- uint8_t flag_not_cmp(uint16_t data);
- 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);
- 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
|