rt-thread/bsp/essemi/es8p508x/libraries/Library/Include/lib_crc.h

94 lines
2.4 KiB
C
Raw Normal View History

2019-11-07 10:00:14 +08:00
/***************************************************************
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd.
*<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Liut
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: V1.00
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 2017/07/14
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*<EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ES8P508xоƬ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>κη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
***************************************************************/
#ifndef __LIBCRC_H
#define __LIBCRC_H
#include "ES8P508x.h"
#include "type.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CRC_EmptayCheck_addr 0x10000010
#define CRC_FlashVerify_addr 0x10000014
#define CRC_UserCal_addr 0x10000018
#define CRC_CheckReset_addr 0x1000001C
typedef uint32_t (*CRC_EM)(void* address, uint32_t data_len);
typedef uint32_t (*CRC_FL)(void* address, uint32_t data_len, uint32_t type);
typedef uint32_t (*CRC_US)(void* address, uint32_t data_len, uint32_t type);
typedef uint32_t (*CRC_CH)(void);
typedef enum
{
CRC_XOROUT_NORMAL = 0x0, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
CRC_XOROUT_ANTI = (1U<<14), //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
} CRC_XOROUT;
typedef enum
{
CRC_REFOUT_NORMAL = 0x0, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CRC_REFOUT_REVERSE = (1U<<13), //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
} CRC_REFOUT;
typedef enum
{
CRC_REFIN_NORMAL = 0x0, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CRC_REFIN_REVERSE = (1U<<12), //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5B9>
} CRC_REFIN;
typedef enum
{
CRC_MOD_CRC32 = 0x0, //CRCλ<43><CEBB>Ϊ<EFBFBD>ֽ<EFBFBD>
CRC_MOD_CRC16 = (2U<<8), //CRCλ<43><CEBB>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
CRC_MOD_CRC16_CCITT = (3U<<8), //CRCλ<43><CEBB>Ϊ<EFBFBD><CEAA>
} CRC_MOD_TYPE;
typedef enum
{
CRC_INIT_DATA_ALL_0 = 0x0, //CRC<52><43>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫΪ0
CRC_INIT_DATA_ALL_1 = (1U<<3), //CRC<52><43>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫΪ1
} CRC_INIT_DATA;
typedef enum
{
CRC_HS_TYPE_DISABLE = 0x0, //CRC<52><43><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ֹ
CRC_HS_TYPE_ENABLE = (1U<<2), //CRC<52><43><EFBFBD><EFBFBD>ģʽʹ<CABD>ܣ<EFBFBD><DCA3><EFBFBD>CRCʱ<43><CAB1>С<EFBFBD><D0A1>24Mʱ<4D><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
} CRC_HS_TYPE;
/*CRC_CON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>*/
typedef struct
{
CRC_XOROUT xorout;
CRC_REFOUT refout;
CRC_REFIN refin;
CRC_MOD_TYPE mode;
CRC_INIT_DATA init_data_type;
CRC_HS_TYPE hs_type;
} CRC_CONValueStruType;
uint32_t CRC_getTypeValue(CRC_CONValueStruType con_value);
uint32_t CRC_EmptayCheck(void* address, uint32_t data_len);
uint32_t CRC_FlashVerify(void* address, uint32_t data_len, uint32_t type);
uint32_t CRC_UserCal(void* address, uint32_t data_len, uint32_t type);
uint32_t CRC_CheckReset(void);
#ifdef __cplusplus
}
#endif
#endif
/*************************END OF FILE**********************/