Part Number:CC2538Other Parts Discussed in Thread: Z-STACK
在研究CC2538 hal_ota.c文件中,看到计算Crc32有这么一段代码
typedef long (* volatile HAPI_CRC32_T)(unsigned char *, unsigned long);
#define HAPI_CRC32_FUNC_PTR 0x00000048
#define P_HAPI_CRC32 ((HAPI_CRC32_T *)HAPI_CRC32_FUNC_PTR)
#define CalcCrc32(a,b) (*P_HAPI_CRC32)(a,b)
请问这段代码如何实现镜像的CRC校验呢?这个0x00000048具体指向的是什么,实在是搞不懂,还请各位指导指导,谢谢。
Kevin Qiu1:
HAPI代表“Hard API”,0x00000048指向存储在ROM中的Crc32函数:
#ifndef __ROM_H__ #define __ROM_H__//***************************************************************************** // // If building with a C++ compiler, make all of the definitions in this header // have a C binding. // //***************************************************************************** #ifdef __cplusplus extern "C" { #endif#include "hw_types.h"// // Start address of the ROM hard API access table (located after the ROM FW rev field) // #define ROM_API_TABLE_ADDR 0x00000048// // ROM utility function interface types // typedef uint32_t(* volatile FPTR_CRC32_T)(uint8_t* /*pData*/, uint32_t /*byteCount*/); typedef uint32_t(* volatile FPTR_GETFLSIZE_T)(void); typedef uint32_t(* volatile FPTR_GETCHIPID_T)(void); typedef int32_t(* volatile FPTR_PAGEERASE_T)(uint32_t /*FlashAddr*/, uint32_t /*Size*/); typedef int32_t(* volatile FPTR_PROGFLASH_T)(uint32_t* /*pRamData*/, uint32_t /*FlashAdr*/, uint32_t /*ByteCount*/); typedef void(* volatile FPTR_RESETDEV_T)(void); typedef void*(* volatile FPTR_MEMSET_T)(void* /*s*/, int32_t /*c*/, uint32_t /*n*/); typedef void*(* volatile FPTR_MEMCPY_T)(void* /*s1*/, const void* /*s2*/, uint32_t /*n*/); typedef int32_t(* volatile FPTR_MEMCMP_T)(const void* /*s1*/, const void* /*s2*/, uint32_t /*n*/); typedef void*(* volatile FPTR_MEMMOVE_T)(void* /*s1*/, const void* /*s2*/, uint32_t /*n*/);// // ROM Hard-API access table type // typedef struct{FPTR_CRC32_TCrc32;FPTR_GETFLSIZE_TGetFlashSize;FPTR_GETCHIPID_TGetChipId;FPTR_PAGEERASE_TPageErase;FPTR_PROGFLASH_TProgramFlash;FPTR_RESETDEV_TResetDevice;FPTR_MEMSET_Tmemset;FPTR_MEMCPY_Tmemcpy;FPTR_MEMCMP_Tmemcmp;FPTR_MEMMOVE_Tmemmove;} ROM_API_T;// // Pointer to the ROM API table // #define P_ROM_API((ROM_API_T*) ROM_API_TABLE_ADDR)#define ROM_Crc32(a,b)P_ROM_API->Crc32(a,b) #define ROM_GetFlashSize()P_ROM_API->GetFlashSize() #define ROM_GetChipId()P_ROM_API->GetChipId() #define ROM_PageErase(a,b)P_ROM_API->PageErase(a,b) #define ROM_ProgramFlash(a,b,c) P_ROM_API->ProgramFlash(a,b,c) #define ROM_ResetDevice()P_ROM_API->ResetDevice() #define ROM_Memset(a,b,c)P_ROM_API->memset(a,b,c) #define ROM_Memcpy(a,b,c)P_ROM_API->memcpy(a,b,c) #define ROM_Memcmp(a,b,c)P_ROM_API->memcmp(a,b,c) #define ROM_Memmove(a,b,c)P_ROM_API->memmove(a,b,c)//***************************************************************************** // // Mark the end of the C bindings section for C++ compilers. // //***************************************************************************** #ifdef __cplusplus } #endif#endif // __ROM_H__
,
user5932793:
非常感谢Kevin Qiu1,请问这部分程序是否不开放呢?
,
Kevin Qiu1:
上面代码在C:\ti\Z-Stack 3.0.1\Components\driverlib\cc2538\source\rom.h中
ROM中的其他代码无法查看,也不开放
,
user5932793:
好的,非常感谢
,
Kevin Qiu1:
不客气