| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- // gfabootlmast.h :
- //
- #if !defined(AGD_GFABOOTLMAST_H__9BEF8C2B_D667_41C2_A0F0_6F1CC86DCF36__INCLUDED_)
- #define AGD_GFABOOTLMAST_H__9BEF8C2B_D667_41C2_A0F0_6F1CC86DCF36__INCLUDED_
- #include <stdio.h>
- #include <string.h>
- #include <stdint.h>
- #include <stdbool.h>
- #include <sys/time.h>
- #include <gfamininetmst.h>
- #ifdef __cplusplus
- extern "C" {
- #endif // __cplusplus
- /////////////////////////////////////////////////////////////////////////////
- // gfabootlmast.h - Declarations:
- typedef void *HGFABLM;
- /////////////////////////////////////////////////////////////////////////////
- #ifdef _DEBUG
- typedef void (*PFN_BU_CMD_DOWNLOAD_STATUS)(const char *pszFile, int nLine, uint8_t nNodeAddr, uint32_t nFlashStartAddr, uint32_t nCbData, int nCtx, int nErrorCode);
- typedef void (*PFN_BU_CMD_SEND_DATA_STATUS)(const char *pszFile, int nLine, uint8_t nNodeAddr, uint32_t nCbBlock, uint32_t nCbData, int nCtx, int nErrorCode);
- #else // _DEBUG
- typedef void (*PFN_BU_CMD_DOWNLOAD_STATUS)(uint8_t nNodeAddr, uint32_t nFlashStartAddr, uint32_t nCbData, int nCtx, int nErrorCode);
- typedef void (*PFN_BU_CMD_SEND_DATA_STATUS)(uint8_t nNodeAddr, uint32_t nCbBlock, uint32_t nCbData, int nCtx, int nErrorCode);
- #endif // _DEBUG
- /////////////////////////////////////////////////////////////////////////////
- typedef struct _GFA_BLM_CFG_PARAMS
- {
- GFA_MININET_MST_CFG_PARAMS mmcp;
- PFN_BU_CMD_DOWNLOAD_STATUS pfnBuCmdDownloadStatus;
- PFN_BU_CMD_SEND_DATA_STATUS pfnBuCmdSendDataStatus;
- }GFA_BLM_CFG_PARAMS, *LPGFA_BLM_CFG_PARAMS;
- typedef const GFA_BLM_CFG_PARAMS *LPCGFA_BLM_CFG_PARAMS;
- /////////////////////////////////////////////////////////////////////////////
- typedef enum _GFA_BLM_EXEC_CONTEXT
- {
- GfaBlmCtx_Err = -1,
- GfaBlmCtx_Boot,
- GfaBlmCtx_App
- }GFA_BLM_EXEC_CONTEXT, *LPGFA_BLM_EXEC_CONTEXT;
- /////////////////////////////////////////////////////////////////////////////
- #define GFA_APP_MAX_IMG_MATERIAL_NUM_LENGTH 16 // including the zero terminator
- #define GFA_APP_MAX_IMG_NAME_BUILD_LENGTH 24 // including the zero terminator
- /////////////////////////////////////////////////////////////////////////////
- typedef struct _GFA_IMG_INFO
- {
- uint32_t nImgLength;
- uint32_t nImgCRC32;
- char szImgMaterialNum[GFA_APP_MAX_IMG_MATERIAL_NUM_LENGTH];
- char szImgNameBuild[GFA_APP_MAX_IMG_NAME_BUILD_LENGTH];
- }GFA_IMG_INFO, *LPGFA_IMG_INFO;
- typedef const GFA_IMG_INFO *LPCGFA_IMG_INFO;
- typedef struct _GFA_BL_APP_IMG_INFO
- {
- GFA_IMG_INFO bl;
- GFA_IMG_INFO app;
- }GFA_BL_APP_IMG_INFO, *LPGFA_BL_APP_IMG_INFO;
- typedef const GFA_BL_APP_IMG_INFO *LPCGFA_BL_APP_IMG_INFO;
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- HGFABLM GfaBlmOpen(LPCGFA_BLM_CFG_PARAMS pblmcfg);
- void GfaBlmClose(HGFABLM hBlm);
- /////////////////////////////////////////////////////////////////////////////
- int GfaBlmResetSlaveIndex(HGFABLM hBlm, uint8_t nNodeAddr);
- GFA_BLM_EXEC_CONTEXT GfaBlmGetExecutionContext(HGFABLM hBlm, uint8_t nNodeAddr);
- /////////////////////////////////////////////////////////////////////////////
- // GfA commands
- int GfaBlmBootloaderExecute(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t *pnImgCRC32, uint32_t nTimeoutMS);
- int GfaBlmBootloaderSetBaudrate(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nBaudrate);
- int GfaBlmBootloaderDump(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nAddress, uint32_t nCntDwords, void *pBuffer, size_t nCbBuffer);
- int GfaBlmGetImgInfo(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nDumpAddr, bool bCtxIsApp, LPGFA_IMG_INFO pii);
- int GfaBlmGetInfoBD(HGFABLM hBlm, uint8_t nNodeAddr, LPGFA_BL_APP_IMG_INFO paii);
- int GfaBlmGetInfoBI(HGFABLM hBlm, uint8_t nNodeAddr, LPGFA_BL_APP_IMG_INFO paii);
- int GfaBlmReadMaterialAndSerialID(HGFABLM hBlm, uint8_t nNodeAddr, char *pszMaterial, size_t nCbMaterial, char *pszSerial, size_t nCbSerial);
- int GfaBlmWriteMaterialAndSerialID(HGFABLM hBlm, uint8_t nNodeAddr, const char *pszMaterial, const char *pszSerial);
- /////////////////////////////////////////////////////////////////////////////
- // TI commands
- int GfaBlmBUCmdReset(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nTimeoutMS);
- int GfaBlmBUCmdPing(HGFABLM hBlm, uint8_t nNodeAddr);
- int GfaBlmBUCmdGetStatus(HGFABLM hBlm, uint8_t nNodeAddr, uint8_t *pbStatus);
- ssize_t GfaBlmBUCmdPollData(HGFABLM hBlm, uint8_t nNodeAddr, void *pData, size_t nCbData, uint32_t nTimeoutMS);
- int GfaBlmBUCmdDownload(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nFlashStartAddr, uint32_t nCbData, uint32_t nTimeoutMS);
- int GfaBlmBUCmdSendDataBlock(HGFABLM hBlm, uint8_t nNodeAddr, const void *pDataBlock, size_t nCbDataBlock);
- int GfaBlmBUCmdSendData(HGFABLM hBlm, uint8_t nNodeAddr, const void *pData, size_t nCbData, size_t nCbBlock);
- int GfaBlmBUCmdSendDataFile(HGFABLM hBlm, uint8_t nNodeAddr, const char *pszFilename, uint32_t nFlashStartAddr, size_t nCbBlock, uint32_t nTimeoutMS);
- /////////////////////////////////////////////////////////////////////////////
- int GfaBlmSetVerbosity(HGFABLM hBlm, int nVerbosity);
- HGFAMINEMST GfaBlmGetMininetMasterHandle(HGFABLM hBlm);
- uint8_t GfaBlmDataCheckSum(const void *pData, size_t nCbData);
- size_t GfaBlmBuildCmdDataPacket(const char *pszCmd, uint8_t tiCmd, const void *pCmdData, size_t nCbCmdData, void *pPacket, size_t nCbPacket, bool bAddLenAndCheck);
- const char* GfaBlmStrError(int nErrorCode);
- /////////////////////////////////////////////////////////////////////////////
- #ifdef __cplusplus
- }
- #endif // __cplusplus
- #endif // !defined(AGD_GFABOOTLMAST_H__9BEF8C2B_D667_41C2_A0F0_6F1CC86DCF36__INCLUDED_)
|