Flash2803x_API_Library.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //###########################################################################
  2. //
  3. // FILE: Flash2803x_API_Library.h
  4. //
  5. // TITLE: F2803x Flash Algo's main include file
  6. //
  7. // DESCRIPTION:
  8. //
  9. // This file should be included in any project that uses any of the
  10. // the F2803x flash APIs.
  11. //
  12. //###########################################################################
  13. // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V130 $
  14. // $Release Date: May 8, 2015 $
  15. // $Copyright: Copyright (C) 2009-2015 Texas Instruments Incorporated -
  16. // http://www.ti.com/ ALL RIGHTS RESERVED $
  17. //###########################################################################
  18. #ifndef Flash2803X_API_LIBRARY_H
  19. #define Flash2803X_API_LIBRARY_H
  20. #include "Flash2803x_API_Config.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /*---- device support includes ------------------------------------------------*/
  25. #include "DSP28x_Project.h"
  26. /*---------------------------------------------------------------------------
  27. API Status Messages
  28. The following status values are returned from the API to the calling
  29. program. These can be used to determine if the API function passed
  30. or failed.
  31. ---------------------------------------------------------------------------*/
  32. // Operation passed, no errors were flagged
  33. #define STATUS_SUCCESS 0
  34. // The CSM is preventing the function from performing its operation
  35. #define STATUS_FAIL_CSM_LOCKED 10
  36. // Device REVID does not match that required by the API
  37. #define STATUS_FAIL_REVID_INVALID 11
  38. // Invalid address passed to the API
  39. #define STATUS_FAIL_ADDR_INVALID 12
  40. // Incorrect PARTID
  41. // For example the F2806 API was used on a F2808 device.
  42. #define STATUS_FAIL_INCORRECT_PARTID 13
  43. // API/Silicon missmatch. An old version of the
  44. // API is being used on silicon it is not valid for
  45. // Please update to the latest API.
  46. #define STATUS_FAIL_API_SILICON_MISMATCH 14
  47. // ---- Erase Specific errors ----
  48. #define STATUS_FAIL_NO_SECTOR_SPECIFIED 20
  49. #define STATUS_FAIL_PRECONDITION 21
  50. #define STATUS_FAIL_ERASE 22
  51. #define STATUS_FAIL_COMPACT 23
  52. #define STATUS_FAIL_PRECOMPACT 24
  53. // ---- Program Specific errors ----
  54. #define STATUS_FAIL_PROGRAM 30
  55. #define STATUS_FAIL_ZERO_BIT_ERROR 31
  56. // ---- Verify Specific errors ----
  57. #define STATUS_FAIL_VERIFY 40
  58. // Busy is set by each API function before it determines
  59. // a pass or fail condition for that operation.
  60. // The calling function will will not receive this
  61. // status condition back from the API
  62. #define STATUS_BUSY 999
  63. #define STATUS_ERROR 0xFF
  64. /*---------------------------------------------------------------------------
  65. Flash sector mask definitions
  66. The following macros can be used to form a mask specifying which sectors
  67. will be erased by the erase API function.
  68. Bit0 = Sector A
  69. Bit1 = Sector B
  70. Bit2 = Sector C
  71. Bit3 = Sector D
  72. Bit4 = Sector E
  73. Bit5 = Sector F
  74. Bit6 = Sector G
  75. Bit7 = Sector H
  76. ---------------------------------------------------------------------------*/
  77. #define SECTORA (Uint16)0x0001
  78. #define SECTORB (Uint16)0x0002
  79. #define SECTORC (Uint16)0x0004
  80. #define SECTORD (Uint16)0x0008
  81. #define SECTORE (Uint16)0x0010
  82. #define SECTORF (Uint16)0x0020
  83. #define SECTORG (Uint16)0x0040
  84. #define SECTORH (Uint16)0x0080
  85. #if !defined(FLASH_F2802x)
  86. #define FLASH_F2802x 0
  87. #endif
  88. #if FLASH_F2802x || DEBUG_PICCOLO_B
  89. #define SECTOR_F2802x (SECTORA|SECTORB|SECTORC|SECTORD)
  90. #endif // -- end FLASH_F2802x
  91. #if FLASH_F2803x && !(DEBUG_PICCOLO_B)
  92. // All sectors on an F2803x - Sectors A - H
  93. #define SECTOR_F2803x (SECTORA|SECTORB|SECTORC|SECTORD|SECTORE|SECTORF|SECTORG|SECTORH)
  94. #endif // --end FLASH_F2803x || !(DEBUG_PICCOLO_B)
  95. /*---------------------------------------------------------------------------
  96. API Status Structure
  97. This structure is used to pass debug data back to the calling routine.
  98. Note that the Erase API function has 3 parts: precondition, erase and
  99. and compaction. Erase and compaction failures will not populate
  100. the expected and actual data fields.
  101. ---------------------------------------------------------------------------*/
  102. typedef struct {
  103. Uint32 FirstFailAddr;
  104. Uint16 ExpectedData;
  105. Uint16 ActualData;
  106. }FLASH_ST;
  107. /*---------------------------------------------------------------------------
  108. Interface Function prototypes
  109. For each 28x Flash API library, the function names are of the form:
  110. Flash<DeviceNum>_<Operation>()
  111. Where <DeviceNum> is the device: ie 2808, 2806, 2801
  112. <Operation> is the operation such as Erase, Program...
  113. For portability for users who may move between the F2808, F2806 and
  114. F2801, the following macro definitions are supplied.
  115. Using these macro definitions, the user can use instead make a generic
  116. call: Flash_<Operation> and the macro will map the call to the proper
  117. device function
  118. Note except for the toggle test function, all of the function prototypes
  119. are compatible with F281x devices as well.
  120. ---------------------------------------------------------------------------*/
  121. #if FLASH_F2803x
  122. #define Flash_Erase(a,b) Flash2803x_Erase(a,b)
  123. #define Flash_Program(a,b,c,d) Flash2803x_Program(a,b,c,d)
  124. #define Flash_Verify(a,b,c,d) Flash2803x_Verify(a,b,c,d)
  125. #define Flash_ToggleTest(a,b) Flash2803x_ToggleTest(a,b)
  126. #define Flash_DepRecover() Flash2803x_DepRecover()
  127. #define Flash_APIVersionHex() Flash2803x_APIVersionHex()
  128. #define Flash_APIVersion() Flash2803x_APIVersion()
  129. #endif
  130. extern Uint16 Flash_Erase(Uint16 SectorMask, FLASH_ST *FEraseStat);
  131. extern Uint16 Flash_Program(Uint16 *FlashAddr, Uint16 *BufAddr, Uint32 Length, FLASH_ST *FProgStatus);
  132. extern Uint16 Flash_Verify(Uint16 *StartAddr, Uint16 *BufAddr, Uint32 Length, FLASH_ST *FVerifyStat);
  133. extern void Flash_ToggleTest(volatile Uint32 *ToggleReg, Uint32 Mask);
  134. extern Uint16 Flash_DepRecover();
  135. extern float32 Flash_APIVersion();
  136. extern Uint16 Flash_APIVersionHex();
  137. /*---------------------------------------------------------------------------
  138. Frequency Scale factor:
  139. The calling program must provide this global parameter used
  140. for frequency scaling the algo's.
  141. ----------------------------------------------------------------------------*/
  142. extern Uint32 Flash_CPUScaleFactor;
  143. /*---------------------------------------------------------------------------
  144. Callback Function Pointer:
  145. A callback function can be specified. This function will be called
  146. at safe times during erase, program and verify. This function can
  147. then be used to service an external watchdog or send a communications
  148. packet.
  149. Note:
  150. THE FLASH AND OTP ARE NOT AVAILABLE DURING THIS FUNCTION CALL.
  151. THE FLASH/OTP CANNOT BE READ NOR CAN CODE EXECUTE FROM IT DURING THIS CALL
  152. DO NOT CALL ANY OF THE THE FLASH API FUNCTIONS DURING THIS CALL
  153. ----------------------------------------------------------------------------*/
  154. extern void (*Flash_CallbackPtr) (void);
  155. /*---------------------------------------------------------------------------
  156. API load/run symbols:
  157. These symbols are defined by the linker during the link. Refer to the
  158. Flash28_API section in the example .cmd file:
  159. Flash28_API:
  160. {
  161. Flash28035_API_Library.lib(.econst)
  162. Flash28035_API_Library.lib(.text)
  163. } LOAD = FLASH,
  164. RUN = SARAM,
  165. LOAD_START(_Flash28_API_LoadStart),
  166. LOAD_END(_Flash28_API_LoadEnd),
  167. RUN_START(_Flash28_API_RunStart),
  168. PAGE = 0
  169. These are used to copy the flash API from flash to SARAM
  170. ----------------------------------------------------------------------------*/
  171. extern Uint16 Flash28_API_LoadStart;
  172. extern Uint16 Flash28_API_LoadEnd;
  173. extern Uint16 Flash28_API_RunStart;
  174. #ifdef __cplusplus
  175. }
  176. #endif /* extern "C" */
  177. #endif // -- end FLASH2803x_API_LIBRARY_H
  178. // --------- END OF FILE ----------------------------------