hw_flash.h 16 KB

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