129 lines
3.7 KiB
C
129 lines
3.7 KiB
C
|
|
/**
|
|||
|
|
******************************************************************************
|
|||
|
|
* @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>© COPYRIGHT 2016 TMC</center></h2>
|
|||
|
|
******************************************************************************
|
|||
|
|
**/
|
|||
|
|
|
|||
|
|
#ifndef __CMDHANDLE_H__
|
|||
|
|
#define __CMDHANDLE_H__
|
|||
|
|
#include "global.h"
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>볤<EFBFBD><EBB3A4>
|
|||
|
|
#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) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧģʽ5sδʶ<CEB4><CAB6><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
|||
|
|
|
|||
|
|
#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 //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
|
#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
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD>ʽ
|
|||
|
|
#define SETTINGCODE_MODE_0 0x00 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨһ<C9A8><D2BB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>Ч
|
|||
|
|
#define SETTINGCODE_MODE_1 0x01 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>Ч
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef enum
|
|||
|
|
{
|
|||
|
|
SN_EXIT = 0x06U,
|
|||
|
|
} SN_StatusTypeDef;
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
uint8_t HandleMsg[MAX_SETCODELEN]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8_t MsgLen;
|
|||
|
|
uint8_t (*pFunc)(BarData *pCode); //<2F><><EFBFBD><EFBFBD>Ӧ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
|||
|
|
} ScanCodeHandle;
|
|||
|
|
|
|||
|
|
uint8_t OUTPicture(BarData *pCode);
|
|||
|
|
|
|||
|
|
uint8_t WriteBLFirstPage(void);
|
|||
|
|
|
|||
|
|
uint8_t UpdateApp(BarData *pCode);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>汾<EFBFBD><E6B1BE>Ϣ
|
|||
|
|
uint8_t OutVersion(BarData *pCode);
|
|||
|
|
|
|||
|
|
//<2F>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
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__*/
|