Hal_Fls.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Hal_Fls.h
  3. *
  4. * Created on:
  5. * Author: Zhengchao
  6. */
  7. #ifndef HAL_FLS_H_
  8. #define HAL_FLS_H_
  9. #include "hal_adapter.h"
  10. #include "AppFunclib.h"
  11. #include "AppGlobalVar.h"
  12. #include "Hal_Wdg.h"
  13. #define EN_SUPPORT_APP_B
  14. typedef uint32 tLogicalAddr;
  15. typedef struct
  16. {
  17. tLogicalAddr xBlockStartLogicalAddr; /* block start logical addr */
  18. tLogicalAddr xBlockEndLogicalAddr; /* block end logical addr */
  19. } BlockInfo_t;
  20. #define LOGICAL_START_ADDR 0U
  21. #define NUMBER_OF_INTERNAL_SECTOR 128U
  22. #define INTERNAL_SECTOR_SIZE 0x1000U
  23. #define APP_B_START_ADDR 0U
  24. #define APP_B_END_ADDR NUMBER_OF_INTERNAL_SECTOR*INTERNAL_SECTOR_SIZE
  25. #define APP_FLAST_START_PHY_ADDR (0x80000u)
  26. #define APP_VECTOR_TABLE_OFFSET (0x200u) /* Vector table offset from gs_astBlockNumA/B */
  27. #define RESET_HANDLER_OFFSET (4u) /* From top vector table to reset handle */
  28. #define RESET_HANDLER_ADDR_LEN (4u) /* Pointer length or reset handler length */
  29. /* Flash finger print length */
  30. #define FL_FINGER_PRINT_LENGTH (14u)
  31. /* Program data buffer max length */
  32. #define MAX_FLASH_DATA_LEN (512u)
  33. #if (defined EN_SUPPORT_APP_B)
  34. typedef enum
  35. {
  36. CONTROLLER_SELF = 1,
  37. CONTROLLER_BLE,
  38. CONTROLLER_B,
  39. CONTROLLER_C,
  40. CONTROLLER_D,
  41. CONTROLLER_E,
  42. CONTROLLER_F,
  43. }ControllerType;
  44. typedef struct
  45. {
  46. /* Flash programming successful? If programming successful, the value set TRUE, else set FALSE */
  47. uint8 isFlashProgramSuccessfull;
  48. /* Is erase flash successful? If erased flash successful, set the TRUE, else set the FALSE. */
  49. uint8 isFlashErasedSuccessfull;
  50. /* Is Flash struct data valid? If written set the value is TRUE, else set the valid FALSE */
  51. uint8 isFlashStructValid;
  52. /* Indicate APP Counter. Before download. */
  53. uint8 appCnt;
  54. /* Is the App self update? If selfUpdate set the value is TRUE, else set the value FALSE*/
  55. ControllerType controllerName;
  56. /* Flag if finger print buffer */
  57. uint8 aFingerPrint[FL_FINGER_PRINT_LENGTH];
  58. /* Reset handler length */
  59. uint32 appStartAddrLen;
  60. /* APP Start address - reset handler */
  61. uint32 appStartAddr;
  62. /* APP Length - reset handler */
  63. uint32 appLength;
  64. /* Count CRC */
  65. uint32 crc;
  66. }tAppFlashStatus;
  67. typedef struct
  68. {
  69. /* Current process start address */
  70. uint32 appVectoTableStartAddr;
  71. /* Current process length */
  72. uint32 appLength;
  73. /* Received CRC value */
  74. uint32 receivedCRC;
  75. } tAppDownloadType;
  76. #endif
  77. MemIf_JobResultType Hal_FlsWrite(Fls_AddressType u32TargetAddress, uint8 * pSourceAddressPtr, Fls_LengthType u32Length, uint32 timeOutMs);
  78. MemIf_JobResultType Hal_FlsRead(Fls_AddressType u32TargetAddress, uint8 * pSourceAddressPtr, Fls_LengthType u32Length, uint32 timeOutMs);
  79. MemIf_JobResultType Hal_FlsErase(Fls_AddressType u32TargetAddress, uint32 eraseInternalSectorNum, uint32 timeOutMs);
  80. void Hal_FlsGetAppVectorTableStartAddr(uint32 *appVectorTableStartAddr);
  81. void Hal_SetAppInfo(uint32 appLength, uint32 appReceviedCRC,ControllerType controllerName);
  82. uint8 Hal_FlsCheckIsTransferSucceed(void);
  83. void Hal_OTAFlashAppInfoInit(void);
  84. extern void CRC_HAL_CreatSoftwareCrc(const uint8_t *i_pucDataBuf, const uint32_t i_ulDataLen, uint32_t *m_pCurCrc);
  85. //extern void CreatSoftwareCrc16(const uint8 *i_pDataBuf, const uint32 i_dataLen, uint32 *m_pCurCrc);
  86. #endif /* HAL_FLS_H_ */