gfabootlmast.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // gfabootlmast.h :
  2. //
  3. #if !defined(AGD_GFABOOTLMAST_H__9BEF8C2B_D667_41C2_A0F0_6F1CC86DCF36__INCLUDED_)
  4. #define AGD_GFABOOTLMAST_H__9BEF8C2B_D667_41C2_A0F0_6F1CC86DCF36__INCLUDED_
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include <sys/time.h>
  10. #include <gfamininetmst.h>
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif // __cplusplus
  14. /////////////////////////////////////////////////////////////////////////////
  15. // gfabootlmast.h - Declarations:
  16. typedef void *HGFABLM;
  17. /////////////////////////////////////////////////////////////////////////////
  18. #ifdef _DEBUG
  19. 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);
  20. 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);
  21. #else // _DEBUG
  22. typedef void (*PFN_BU_CMD_DOWNLOAD_STATUS)(uint8_t nNodeAddr, uint32_t nFlashStartAddr, uint32_t nCbData, int nCtx, int nErrorCode);
  23. typedef void (*PFN_BU_CMD_SEND_DATA_STATUS)(uint8_t nNodeAddr, uint32_t nCbBlock, uint32_t nCbData, int nCtx, int nErrorCode);
  24. #endif // _DEBUG
  25. /////////////////////////////////////////////////////////////////////////////
  26. typedef struct _GFA_BLM_CFG_PARAMS
  27. {
  28. GFA_MININET_MST_CFG_PARAMS mmcp;
  29. PFN_BU_CMD_DOWNLOAD_STATUS pfnBuCmdDownloadStatus;
  30. PFN_BU_CMD_SEND_DATA_STATUS pfnBuCmdSendDataStatus;
  31. }GFA_BLM_CFG_PARAMS, *LPGFA_BLM_CFG_PARAMS;
  32. typedef const GFA_BLM_CFG_PARAMS *LPCGFA_BLM_CFG_PARAMS;
  33. /////////////////////////////////////////////////////////////////////////////
  34. typedef enum _GFA_BLM_EXEC_CONTEXT
  35. {
  36. GfaBlmCtx_Err = -1,
  37. GfaBlmCtx_Boot,
  38. GfaBlmCtx_App
  39. }GFA_BLM_EXEC_CONTEXT, *LPGFA_BLM_EXEC_CONTEXT;
  40. /////////////////////////////////////////////////////////////////////////////
  41. #define GFA_APP_MAX_IMG_MATERIAL_NUM_LENGTH 16 // including the zero terminator
  42. #define GFA_APP_MAX_IMG_NAME_BUILD_LENGTH 24 // including the zero terminator
  43. /////////////////////////////////////////////////////////////////////////////
  44. typedef struct _GFA_IMG_INFO
  45. {
  46. uint32_t nImgLength;
  47. uint32_t nImgCRC32;
  48. char szImgMaterialNum[GFA_APP_MAX_IMG_MATERIAL_NUM_LENGTH];
  49. char szImgNameBuild[GFA_APP_MAX_IMG_NAME_BUILD_LENGTH];
  50. }GFA_IMG_INFO, *LPGFA_IMG_INFO;
  51. typedef const GFA_IMG_INFO *LPCGFA_IMG_INFO;
  52. typedef struct _GFA_BL_APP_IMG_INFO
  53. {
  54. GFA_IMG_INFO bl;
  55. GFA_IMG_INFO app;
  56. }GFA_BL_APP_IMG_INFO, *LPGFA_BL_APP_IMG_INFO;
  57. typedef const GFA_BL_APP_IMG_INFO *LPCGFA_BL_APP_IMG_INFO;
  58. /////////////////////////////////////////////////////////////////////////////
  59. /////////////////////////////////////////////////////////////////////////////
  60. /////////////////////////////////////////////////////////////////////////////
  61. HGFABLM GfaBlmOpen(LPCGFA_BLM_CFG_PARAMS pblmcfg);
  62. void GfaBlmClose(HGFABLM hBlm);
  63. /////////////////////////////////////////////////////////////////////////////
  64. int GfaBlmResetSlaveIndex(HGFABLM hBlm, uint8_t nNodeAddr);
  65. GFA_BLM_EXEC_CONTEXT GfaBlmGetExecutionContext(HGFABLM hBlm, uint8_t nNodeAddr);
  66. /////////////////////////////////////////////////////////////////////////////
  67. // GfA commands
  68. int GfaBlmBootloaderExecute(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t *pnImgCRC32, uint32_t nTimeoutMS);
  69. int GfaBlmBootloaderSetBaudrate(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nBaudrate);
  70. int GfaBlmBootloaderDump(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nAddress, uint32_t nCntDwords, void *pBuffer, size_t nCbBuffer);
  71. int GfaBlmGetImgInfo(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nDumpAddr, bool bCtxIsApp, LPGFA_IMG_INFO pii);
  72. int GfaBlmGetInfoBD(HGFABLM hBlm, uint8_t nNodeAddr, LPGFA_BL_APP_IMG_INFO paii);
  73. int GfaBlmGetInfoBI(HGFABLM hBlm, uint8_t nNodeAddr, LPGFA_BL_APP_IMG_INFO paii);
  74. int GfaBlmReadMaterialAndSerialID(HGFABLM hBlm, uint8_t nNodeAddr, char *pszMaterial, size_t nCbMaterial, char *pszSerial, size_t nCbSerial);
  75. int GfaBlmWriteMaterialAndSerialID(HGFABLM hBlm, uint8_t nNodeAddr, const char *pszMaterial, const char *pszSerial);
  76. /////////////////////////////////////////////////////////////////////////////
  77. // TI commands
  78. int GfaBlmBUCmdReset(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nTimeoutMS);
  79. int GfaBlmBUCmdPing(HGFABLM hBlm, uint8_t nNodeAddr);
  80. int GfaBlmBUCmdGetStatus(HGFABLM hBlm, uint8_t nNodeAddr, uint8_t *pbStatus);
  81. ssize_t GfaBlmBUCmdPollData(HGFABLM hBlm, uint8_t nNodeAddr, void *pData, size_t nCbData, uint32_t nTimeoutMS);
  82. int GfaBlmBUCmdDownload(HGFABLM hBlm, uint8_t nNodeAddr, uint32_t nFlashStartAddr, uint32_t nCbData, uint32_t nTimeoutMS);
  83. int GfaBlmBUCmdSendDataBlock(HGFABLM hBlm, uint8_t nNodeAddr, const void *pDataBlock, size_t nCbDataBlock);
  84. int GfaBlmBUCmdSendData(HGFABLM hBlm, uint8_t nNodeAddr, const void *pData, size_t nCbData, size_t nCbBlock);
  85. int GfaBlmBUCmdSendDataFile(HGFABLM hBlm, uint8_t nNodeAddr, const char *pszFilename, uint32_t nFlashStartAddr, size_t nCbBlock, uint32_t nTimeoutMS);
  86. /////////////////////////////////////////////////////////////////////////////
  87. int GfaBlmSetVerbosity(HGFABLM hBlm, int nVerbosity);
  88. HGFAMINEMST GfaBlmGetMininetMasterHandle(HGFABLM hBlm);
  89. uint8_t GfaBlmDataCheckSum(const void *pData, size_t nCbData);
  90. size_t GfaBlmBuildCmdDataPacket(const char *pszCmd, uint8_t tiCmd, const void *pCmdData, size_t nCbCmdData, void *pPacket, size_t nCbPacket, bool bAddLenAndCheck);
  91. const char* GfaBlmStrError(int nErrorCode);
  92. /////////////////////////////////////////////////////////////////////////////
  93. #ifdef __cplusplus
  94. }
  95. #endif // __cplusplus
  96. #endif // !defined(AGD_GFABOOTLMAST_H__9BEF8C2B_D667_41C2_A0F0_6F1CC86DCF36__INCLUDED_)