TMC32_QJB/App/cmdhandle.h
2026-04-30 16:23:12 +08:00

129 lines
3.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
******************************************************************************
* @file cmdhandle.h
* @author TMC Scan Team
* @version V1.0.0
* @date 09/07/2019
* @brief
******************************************************************************
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, TMC SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2016 TMC</center></h2>
******************************************************************************
**/
#ifndef __CMDHANDLE_H__
#define __CMDHANDLE_H__
#include "global.h"
//设置码长度
#define SETCODELEN 10
#define CODEMSGLEN 9
#define SYSMSGELEN 9
#define PARTCODELEN (SETCODELEN - 2)
#define MAX_SETCODELEN 20
#define SETCODELEN_MODULE 8
#define MAX_BATCH_SETCODE_LEN 256
#define HALF_BUF_SIZE (320 * 240)
#define MAXCODELEN 2070
#define CLK_BASE 12000
#define SENSOR_TIME_OUT (CLK_BASE * 5000) //如果感应模式5s未识读成功则退出
#define COMMUNICATION_CMD_LEN 10
#define ONE_BYTE_SUCCESS ((uint8_t) 0x00)
#define ONE_BYTE_FAIL ((uint8_t) 0x01)
#define SYSMODE_OPEN ((uint8_t) 0x01)
#define SYSMODE_CLOSE ((uint8_t) 0x00)
#define KEY_DELAY_MAX 50
#define KEY_POLL_SPEED_MAX 10
#define STABLE_TIME_MAX 5000 //稳像时长最大值
#define SENSORTIVITY_VALUE_MAX 8000
#define SAME_CODE_INTERVAL_MAX 8000
#define CMD_MODE_TIME_MAX 65535
#define CMD_MODE_TIME_MIN 500
#define DIFFERENT_CODE_INTERVAL_MAX 8000
/** @defgroup write SN protocal
* @{
*/
#define TUSNADDR 0x00000200
#define PRODUCT_FLAG_ADDR 0x00000400
#define PRODUCT_FLAG_LEN 5
#define PRODUCT_FLAG_VALUE "IDATA"
#define SN_PROTOCOL_WSN_OFFS 0x06 // 5A+FID+LEN(2)+DAT
#define SN_LEN_OFFS 0x00 // [Len][S][N][DATA]
#define SN_SFLAG_OFFS 0x01 // [Len][S][N][DATA]
#define SN_NFLAG_OFFS 0x02 // [Len][S][N][DATA]
#define SN_DATA_OFFS 0x03 // [Len][S][N][DATA]
#define SN_SNFLAG_LEN 0x02
#define CRLF_LEN 0x01
#define NO_SN_LEN 0x05
/**
* @}
*/
//memory definition
#define KEY_BASE_ADDR 0x00000800
#define CRYPTO_CMD_OFFS 4
//response status definition
#define P3ERROR 0x6C // P3 error,6C00
#define WRERROR 0x65 // Flash write error,6501
#define P1P2ERR 0x6A // P1 and/or P2 error,6A00
#define ALGOERR 0x6B // Alogrithm error,6507
#define RDERROR 0x6E
//标记使用哪种配置方式
#define SETTINGCODE_MODE_0 0x00 //表明先扫一个开始配置,再扫其他配置,最后再扫结束配置才生效
#define SETTINGCODE_MODE_1 0x01 //开启设置码的条件下,扫配置码直接生效
typedef enum
{
SN_EXIT = 0x06U,
} SN_StatusTypeDef;
typedef struct
{
uint8_t HandleMsg[MAX_SETCODELEN]; //码的内容
uint8_t MsgLen;
uint8_t (*pFunc)(BarData *pCode); //码对应的操作
} ScanCodeHandle;
uint8_t OUTPicture(BarData *pCode);
uint8_t WriteBLFirstPage(void);
uint8_t UpdateApp(BarData *pCode);
//读取版本信息
uint8_t OutVersion(BarData *pCode);
//恢复出厂设置
uint8_t RestoreFactorySetting(BarData *pCode);
void ScanCodeCmdHandle(BarData *pCode);
uint8_t SettingCodeBatch(BarData *pCode);
uint8_t SM2_Oper(BarData *pCode);
uint8_t RSA_Oper(BarData *pCode);
uint8_t WriteKey(BarData *pCode);
uint8_t SM3_Oper(BarData *pCode);
uint8_t SM4_Oper(BarData *pCode);
uint8_t DES_Oper(BarData *pCode);
#endif /*__CMDHANDLE_H__*/