hw_flash.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. //*****************************************************************************
  2. //
  3. // hw_flash.h - Macros used when accessing the flash controller.
  4. //
  5. // Copyright (c) 2005-2010 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 6459 of the Stellaris Firmware Development Package.
  22. //
  23. //*****************************************************************************
  24. #ifndef __HW_FLASH_H__
  25. #define __HW_FLASH_H__
  26. //*****************************************************************************
  27. //
  28. // The following are defines for the FLASH register offsets.
  29. //
  30. //*****************************************************************************
  31. #define FLASH_FMA 0x400FD000 // Flash Memory Address
  32. #define FLASH_FMD 0x400FD004 // Flash Memory Data
  33. #define FLASH_FMC 0x400FD008 // Flash Memory Control
  34. #define FLASH_FCRIS 0x400FD00C // Flash Controller Raw Interrupt
  35. // Status
  36. #define FLASH_FCIM 0x400FD010 // Flash Controller Interrupt Mask
  37. #define FLASH_FCMISC 0x400FD014 // Flash Controller Masked
  38. // Interrupt Status and Clear
  39. #define FLASH_FMC2 0x400FD020 // Flash Memory Control 2
  40. #define FLASH_FWBVAL 0x400FD030 // Flash Write Buffer Valid
  41. #define FLASH_FCTL 0x400FD0F8 // Flash Control
  42. #define FLASH_FWBN 0x400FD100 // Flash Write Buffer n
  43. #define FLASH_RMCTL 0x400FE0F0 // ROM Control
  44. #define FLASH_RMVER 0x400FE0F4 // ROM Version Register
  45. #define FLASH_FMPRE 0x400FE130 // Flash Memory Protection Read
  46. // Enable
  47. #define FLASH_FMPPE 0x400FE134 // Flash Memory Protection Program
  48. // Enable
  49. #define FLASH_USECRL 0x400FE140 // USec Reload
  50. #define FLASH_USERDBG 0x400FE1D0 // User Debug
  51. #define FLASH_BOOTCFG 0x400FE1D0 // Boot Configuration
  52. #define FLASH_USERREG0 0x400FE1E0 // User Register 0
  53. #define FLASH_USERREG1 0x400FE1E4 // User Register 1
  54. #define FLASH_USERREG2 0x400FE1E8 // User Register 2
  55. #define FLASH_USERREG3 0x400FE1EC // User Register 3
  56. #define FLASH_FMPRE0 0x400FE200 // Flash Memory Protection Read
  57. // Enable 0
  58. #define FLASH_FMPRE1 0x400FE204 // Flash Memory Protection Read
  59. // Enable 1
  60. #define FLASH_FMPRE2 0x400FE208 // Flash Memory Protection Read
  61. // Enable 2
  62. #define FLASH_FMPRE3 0x400FE20C // Flash Memory Protection Read
  63. // Enable 3
  64. #define FLASH_FMPPE0 0x400FE400 // Flash Memory Protection Program
  65. // Enable 0
  66. #define FLASH_FMPPE1 0x400FE404 // Flash Memory Protection Program
  67. // Enable 1
  68. #define FLASH_FMPPE2 0x400FE408 // Flash Memory Protection Program
  69. // Enable 2
  70. #define FLASH_FMPPE3 0x400FE40C // Flash Memory Protection Program
  71. // Enable 3
  72. //*****************************************************************************
  73. //
  74. // The following are defines for the bit fields in the FLASH_FMA register.
  75. //
  76. //*****************************************************************************
  77. #define FLASH_FMA_OFFSET_M 0x0003FFFF // Address Offset
  78. #define FLASH_FMA_OFFSET_S 0
  79. //*****************************************************************************
  80. //
  81. // The following are defines for the bit fields in the FLASH_FMD register.
  82. //
  83. //*****************************************************************************
  84. #define FLASH_FMD_DATA_M 0xFFFFFFFF // Data Value
  85. #define FLASH_FMD_DATA_S 0
  86. //*****************************************************************************
  87. //
  88. // The following are defines for the bit fields in the FLASH_FMC register.
  89. //
  90. //*****************************************************************************
  91. #define FLASH_FMC_WRKEY 0xA4420000 // FLASH write key
  92. #define FLASH_FMC_COMT 0x00000008 // Commit Register Value
  93. #define FLASH_FMC_MERASE 0x00000004 // Mass Erase Flash Memory
  94. #define FLASH_FMC_ERASE 0x00000002 // Erase a Page of Flash Memory
  95. #define FLASH_FMC_WRITE 0x00000001 // Write a Word into Flash Memory
  96. //*****************************************************************************
  97. //
  98. // The following are defines for the bit fields in the FLASH_FCRIS register.
  99. //
  100. //*****************************************************************************
  101. #define FLASH_FCRIS_PRIS 0x00000002 // Programming Raw Interrupt Status
  102. #define FLASH_FCRIS_ARIS 0x00000001 // Access Raw Interrupt Status
  103. //*****************************************************************************
  104. //
  105. // The following are defines for the bit fields in the FLASH_FCIM register.
  106. //
  107. //*****************************************************************************
  108. #define FLASH_FCIM_PMASK 0x00000002 // Programming Interrupt Mask
  109. #define FLASH_FCIM_AMASK 0x00000001 // Access Interrupt Mask
  110. //*****************************************************************************
  111. //
  112. // The following are defines for the bit fields in the FLASH_FCMISC register.
  113. //
  114. //*****************************************************************************
  115. #define FLASH_FCMISC_PMISC 0x00000002 // Programming Masked Interrupt
  116. // Status and Clear
  117. #define FLASH_FCMISC_AMISC 0x00000001 // Access Masked Interrupt Status
  118. // and Clear
  119. //*****************************************************************************
  120. //
  121. // The following are defines for the bit fields in the FLASH_FMC2 register.
  122. //
  123. //*****************************************************************************
  124. #define FLASH_FMC2_WRKEY 0xA4420000 // FLASH write key
  125. #define FLASH_FMC2_WRBUF 0x00000001 // Buffered Flash Memory Write
  126. //*****************************************************************************
  127. //
  128. // The following are defines for the bit fields in the FLASH_FWBVAL register.
  129. //
  130. //*****************************************************************************
  131. #define FLASH_FWBVAL_FWB_M 0xFFFFFFFF // Flash Memory Write Buffer
  132. //*****************************************************************************
  133. //
  134. // The following are defines for the bit fields in the FLASH_FCTL register.
  135. //
  136. //*****************************************************************************
  137. #define FLASH_FCTL_USDACK 0x00000002 // User Shut Down Acknowledge
  138. #define FLASH_FCTL_USDREQ 0x00000001 // User Shut Down Request
  139. //*****************************************************************************
  140. //
  141. // The following are defines for the bit fields in the FLASH_FWBN register.
  142. //
  143. //*****************************************************************************
  144. #define FLASH_FWBN_DATA_M 0xFFFFFFFF // Data
  145. //*****************************************************************************
  146. //
  147. // The following are defines for the bit fields in the FLASH_RMCTL register.
  148. //
  149. //*****************************************************************************
  150. #define FLASH_RMCTL_BA 0x00000001 // Boot Alias
  151. //*****************************************************************************
  152. //
  153. // The following are defines for the bit fields in the FLASH_RMVER register.
  154. //
  155. //*****************************************************************************
  156. #define FLASH_RMVER_CONT_M 0xFF000000 // ROM Contents
  157. #define FLASH_RMVER_CONT_LM 0x00000000 // Stellaris Boot Loader &
  158. // DriverLib
  159. #define FLASH_RMVER_CONT_LM_AES 0x02000000 // Stellaris Boot Loader &
  160. // DriverLib with AES
  161. #define FLASH_RMVER_CONT_LM_AES_SAFERTOS \
  162. 0x03000000 // Stellaris Boot Loader &
  163. // DriverLib with AES and SAFERTOS
  164. #define FLASH_RMVER_CONT_LM_AES2 \
  165. 0x05000000 // Stellaris Boot Loader &
  166. // DriverLib with AES
  167. #define FLASH_RMVER_VER_M 0x0000FF00 // ROM Version
  168. #define FLASH_RMVER_REV_M 0x000000FF // ROM Revision
  169. #define FLASH_RMVER_VER_S 8
  170. #define FLASH_RMVER_REV_S 0
  171. //*****************************************************************************
  172. //
  173. // The following are defines for the bit fields in the FLASH_USECRL register.
  174. //
  175. //*****************************************************************************
  176. #define FLASH_USECRL_M 0x000000FF // Microsecond Reload Value
  177. #define FLASH_USECRL_S 0
  178. //*****************************************************************************
  179. //
  180. // The following are defines for the bit fields in the FLASH_USERDBG register.
  181. //
  182. //*****************************************************************************
  183. #define FLASH_USERDBG_NW 0x80000000 // User Debug Not Written
  184. #define FLASH_USERDBG_DATA_M 0x7FFFFFFC // User Data
  185. #define FLASH_USERDBG_DBG1 0x00000002 // Debug Control 1
  186. #define FLASH_USERDBG_DBG0 0x00000001 // Debug Control 0
  187. #define FLASH_USERDBG_DATA_S 2
  188. //*****************************************************************************
  189. //
  190. // The following are defines for the bit fields in the FLASH_BOOTCFG register.
  191. //
  192. //*****************************************************************************
  193. #define FLASH_BOOTCFG_NW 0x80000000 // Not Written
  194. #define FLASH_BOOTCFG_PORT_M 0x0000E000 // Boot GPIO Port
  195. #define FLASH_BOOTCFG_PORT_A 0x00000000 // Port A
  196. #define FLASH_BOOTCFG_PORT_B 0x00002000 // Port B
  197. #define FLASH_BOOTCFG_PORT_C 0x00004000 // Port C
  198. #define FLASH_BOOTCFG_PORT_D 0x00006000 // Port D
  199. #define FLASH_BOOTCFG_PORT_E 0x00008000 // Port E
  200. #define FLASH_BOOTCFG_PORT_F 0x0000A000 // Port F
  201. #define FLASH_BOOTCFG_PORT_G 0x0000C000 // Port G
  202. #define FLASH_BOOTCFG_PORT_H 0x0000E000 // Port H
  203. #define FLASH_BOOTCFG_PIN_M 0x00001C00 // Boot GPIO Pin
  204. #define FLASH_BOOTCFG_PIN_0 0x00000000 // Pin 0
  205. #define FLASH_BOOTCFG_PIN_1 0x00000400 // Pin 1
  206. #define FLASH_BOOTCFG_PIN_2 0x00000800 // Pin 2
  207. #define FLASH_BOOTCFG_PIN_3 0x00000C00 // Pin 3
  208. #define FLASH_BOOTCFG_PIN_4 0x00001000 // Pin 4
  209. #define FLASH_BOOTCFG_PIN_5 0x00001400 // Pin 5
  210. #define FLASH_BOOTCFG_PIN_6 0x00001800 // Pin 6
  211. #define FLASH_BOOTCFG_PIN_7 0x00001C00 // Pin 7
  212. #define FLASH_BOOTCFG_POL 0x00000200 // Boot GPIO Polarity
  213. #define FLASH_BOOTCFG_EN 0x00000100 // Boot GPIO Enable
  214. #define FLASH_BOOTCFG_DBG1 0x00000002 // Debug Control 1
  215. #define FLASH_BOOTCFG_DBG0 0x00000001 // Debug Control 0
  216. //*****************************************************************************
  217. //
  218. // The following are defines for the bit fields in the FLASH_USERREG0 register.
  219. //
  220. //*****************************************************************************
  221. #define FLASH_USERREG0_NW 0x80000000 // Not Written
  222. #define FLASH_USERREG0_DATA_M 0x7FFFFFFF // User Data
  223. #define FLASH_USERREG0_DATA_S 0
  224. //*****************************************************************************
  225. //
  226. // The following are defines for the bit fields in the FLASH_USERREG1 register.
  227. //
  228. //*****************************************************************************
  229. #define FLASH_USERREG1_NW 0x80000000 // Not Written
  230. #define FLASH_USERREG1_DATA_M 0x7FFFFFFF // User Data
  231. #define FLASH_USERREG1_DATA_S 0
  232. //*****************************************************************************
  233. //
  234. // The following are defines for the bit fields in the FLASH_USERREG2 register.
  235. //
  236. //*****************************************************************************
  237. #define FLASH_USERREG2_NW 0x80000000 // Not Written
  238. #define FLASH_USERREG2_DATA_M 0x7FFFFFFF // User Data
  239. #define FLASH_USERREG2_DATA_S 0
  240. //*****************************************************************************
  241. //
  242. // The following are defines for the bit fields in the FLASH_USERREG3 register.
  243. //
  244. //*****************************************************************************
  245. #define FLASH_USERREG3_NW 0x80000000 // Not Written
  246. #define FLASH_USERREG3_DATA_M 0x7FFFFFFF // User Data
  247. #define FLASH_USERREG3_DATA_S 0
  248. //*****************************************************************************
  249. //
  250. // The following are defines for the bit fields in the FLASH_FMPRE and
  251. // FLASH_FMPPE registers.
  252. //
  253. //*****************************************************************************
  254. #define FLASH_FMP_BLOCK_31 0x80000000 // Enable for block 31
  255. #define FLASH_FMP_BLOCK_30 0x40000000 // Enable for block 30
  256. #define FLASH_FMP_BLOCK_29 0x20000000 // Enable for block 29
  257. #define FLASH_FMP_BLOCK_28 0x10000000 // Enable for block 28
  258. #define FLASH_FMP_BLOCK_27 0x08000000 // Enable for block 27
  259. #define FLASH_FMP_BLOCK_26 0x04000000 // Enable for block 26
  260. #define FLASH_FMP_BLOCK_25 0x02000000 // Enable for block 25
  261. #define FLASH_FMP_BLOCK_24 0x01000000 // Enable for block 24
  262. #define FLASH_FMP_BLOCK_23 0x00800000 // Enable for block 23
  263. #define FLASH_FMP_BLOCK_22 0x00400000 // Enable for block 22
  264. #define FLASH_FMP_BLOCK_21 0x00200000 // Enable for block 21
  265. #define FLASH_FMP_BLOCK_20 0x00100000 // Enable for block 20
  266. #define FLASH_FMP_BLOCK_19 0x00080000 // Enable for block 19
  267. #define FLASH_FMP_BLOCK_18 0x00040000 // Enable for block 18
  268. #define FLASH_FMP_BLOCK_17 0x00020000 // Enable for block 17
  269. #define FLASH_FMP_BLOCK_16 0x00010000 // Enable for block 16
  270. #define FLASH_FMP_BLOCK_15 0x00008000 // Enable for block 15
  271. #define FLASH_FMP_BLOCK_14 0x00004000 // Enable for block 14
  272. #define FLASH_FMP_BLOCK_13 0x00002000 // Enable for block 13
  273. #define FLASH_FMP_BLOCK_12 0x00001000 // Enable for block 12
  274. #define FLASH_FMP_BLOCK_11 0x00000800 // Enable for block 11
  275. #define FLASH_FMP_BLOCK_10 0x00000400 // Enable for block 10
  276. #define FLASH_FMP_BLOCK_9 0x00000200 // Enable for block 9
  277. #define FLASH_FMP_BLOCK_8 0x00000100 // Enable for block 8
  278. #define FLASH_FMP_BLOCK_7 0x00000080 // Enable for block 7
  279. #define FLASH_FMP_BLOCK_6 0x00000040 // Enable for block 6
  280. #define FLASH_FMP_BLOCK_5 0x00000020 // Enable for block 5
  281. #define FLASH_FMP_BLOCK_4 0x00000010 // Enable for block 4
  282. #define FLASH_FMP_BLOCK_3 0x00000008 // Enable for block 3
  283. #define FLASH_FMP_BLOCK_2 0x00000004 // Enable for block 2
  284. #define FLASH_FMP_BLOCK_1 0x00000002 // Enable for block 1
  285. #define FLASH_FMP_BLOCK_0 0x00000001 // Enable for block 0
  286. //*****************************************************************************
  287. //
  288. // The following are defines for the erase size of the FLASH block that is
  289. // erased by an erase operation, and the protect size is the size of the FLASH
  290. // block that is protected by each protection register.
  291. //
  292. //*****************************************************************************
  293. #define FLASH_PROTECT_SIZE 0x00000800
  294. #define FLASH_ERASE_SIZE 0x00000400
  295. //*****************************************************************************
  296. //
  297. // The following definitions are deprecated.
  298. //
  299. //*****************************************************************************
  300. #ifndef DEPRECATED
  301. //*****************************************************************************
  302. //
  303. // The following are deprecated defines for the bit fields in the FLASH_FMC
  304. // register.
  305. //
  306. //*****************************************************************************
  307. #define FLASH_FMC_WRKEY_MASK 0xFFFF0000 // FLASH write key mask
  308. #define FLASH_FMC_WRKEY_M 0xFFFF0000 // Flash Memory Write Key
  309. #define FLASH_FMC_WRKEY_S 16
  310. //*****************************************************************************
  311. //
  312. // The following are deprecated defines for the bit fields in the FLASH_FCRIS
  313. // register.
  314. //
  315. //*****************************************************************************
  316. #define FLASH_FCRIS_PROGRAM 0x00000002 // Programming status
  317. #define FLASH_FCRIS_ACCESS 0x00000001 // Invalid access status
  318. //*****************************************************************************
  319. //
  320. // The following are deprecated defines for the bit fields in the FLASH_FCIM
  321. // register.
  322. //
  323. //*****************************************************************************
  324. #define FLASH_FCIM_PROGRAM 0x00000002 // Programming mask
  325. #define FLASH_FCIM_ACCESS 0x00000001 // Invalid access mask
  326. //*****************************************************************************
  327. //
  328. // The following are deprecated defines for the bit fields in the FLASH_FCMISC
  329. // register.
  330. //
  331. //*****************************************************************************
  332. #define FLASH_FCMISC_PROGRAM 0x00000002 // Programming status
  333. #define FLASH_FCMISC_ACCESS 0x00000001 // Invalid access status
  334. //*****************************************************************************
  335. //
  336. // The following are deprecated defines for the bit fields in the FLASH_USECRL
  337. // register.
  338. //
  339. //*****************************************************************************
  340. #define FLASH_USECRL_MASK 0x000000FF // Clock per uSec
  341. #define FLASH_USECRL_SHIFT 0
  342. #endif
  343. #endif // __HW_FLASH_H__