fsl_semc.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. /*
  2. * Copyright 2017-2020 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef _FSL_SEMC_H_
  8. #define _FSL_SEMC_H_
  9. #include "fsl_common.h"
  10. /*!
  11. * @addtogroup semc
  12. * @{
  13. */
  14. /*******************************************************************************
  15. * Definitions
  16. ******************************************************************************/
  17. /*! @name Driver version */
  18. /*@{*/
  19. /*! @brief SEMC driver version 2.3.1. */
  20. #define FSL_SEMC_DRIVER_VERSION (MAKE_VERSION(2, 4, 0))
  21. /*@}*/
  22. /*! @brief SEMC status, _semc_status. */
  23. enum
  24. {
  25. kStatus_SEMC_InvalidDeviceType = MAKE_STATUS(kStatusGroup_SEMC, 0), /*!< Invalid device type. */
  26. kStatus_SEMC_IpCommandExecutionError = MAKE_STATUS(kStatusGroup_SEMC, 1), /*!< IP command execution error. */
  27. kStatus_SEMC_AxiCommandExecutionError = MAKE_STATUS(kStatusGroup_SEMC, 2), /*!< AXI command execution error. */
  28. kStatus_SEMC_InvalidMemorySize = MAKE_STATUS(kStatusGroup_SEMC, 3), /*!< Invalid memory sie. */
  29. kStatus_SEMC_InvalidIpcmdDataSize = MAKE_STATUS(kStatusGroup_SEMC, 4), /*!< Invalid IP command data size. */
  30. kStatus_SEMC_InvalidAddressPortWidth = MAKE_STATUS(kStatusGroup_SEMC, 5), /*!< Invalid address port width. */
  31. kStatus_SEMC_InvalidDataPortWidth = MAKE_STATUS(kStatusGroup_SEMC, 6), /*!< Invalid data port width. */
  32. kStatus_SEMC_InvalidSwPinmuxSelection = MAKE_STATUS(kStatusGroup_SEMC, 7), /*!< Invalid SW pinmux selection. */
  33. kStatus_SEMC_InvalidBurstLength = MAKE_STATUS(kStatusGroup_SEMC, 8), /*!< Invalid burst length */
  34. /*! Invalid column address bit width. */
  35. kStatus_SEMC_InvalidColumnAddressBitWidth = MAKE_STATUS(kStatusGroup_SEMC, 9),
  36. kStatus_SEMC_InvalidBaseAddress = MAKE_STATUS(kStatusGroup_SEMC, 10), /*!< Invalid base address. */
  37. kStatus_SEMC_InvalidTimerSetting = MAKE_STATUS(kStatusGroup_SEMC, 11), /*!< Invalid timer setting. */
  38. };
  39. /*! @brief SEMC memory device type. */
  40. typedef enum _semc_mem_type
  41. {
  42. kSEMC_MemType_SDRAM = 0, /*!< SDRAM */
  43. kSEMC_MemType_SRAM, /*!< SRAM */
  44. kSEMC_MemType_NOR, /*!< NOR */
  45. kSEMC_MemType_NAND, /*!< NAND */
  46. kSEMC_MemType_8080 /*!< 8080. */
  47. } semc_mem_type_t;
  48. /*! @brief SEMC WAIT/RDY polarity. */
  49. typedef enum _semc_waitready_polarity
  50. {
  51. kSEMC_LowActive = 0, /*!< Low active. */
  52. kSEMC_HighActive, /*!< High active. */
  53. } semc_waitready_polarity_t;
  54. /*! @brief SEMC SDRAM Chip selection . */
  55. typedef enum _semc_sdram_cs
  56. {
  57. kSEMC_SDRAM_CS0 = 0, /*!< SEMC SDRAM CS0. */
  58. kSEMC_SDRAM_CS1, /*!< SEMC SDRAM CS1. */
  59. kSEMC_SDRAM_CS2, /*!< SEMC SDRAM CS2. */
  60. kSEMC_SDRAM_CS3 /*!< SEMC SDRAM CS3. */
  61. } semc_sdram_cs_t;
  62. /*! @brief SEMC SRAM Chip selection . */
  63. typedef enum _semc_sram_cs
  64. {
  65. #if defined(FSL_FEATURE_SEMC_SUPPORT_SRAM_COUNT) && (FSL_FEATURE_SEMC_SUPPORT_SRAM_COUNT == 0x04U)
  66. kSEMC_SRAM_CS0 = 0, /*!< SEMC SRAM CS0. */
  67. kSEMC_SRAM_CS1, /*!< SEMC SRAM CS1. */
  68. kSEMC_SRAM_CS2, /*!< SEMC SRAM CS2. */
  69. kSEMC_SRAM_CS3 /*!< SEMC SRAM CS3. */
  70. #else
  71. kSEMC_SRAM_CS0 = 0, /*!< SEMC SRAM CS0. */
  72. #endif /* FSL_FEATURE_SEMC_SUPPORT_SRAM_COUNT */
  73. } semc_sram_cs_t;
  74. /*! @brief SEMC NAND device type. */
  75. typedef enum _semc_nand_access_type
  76. {
  77. kSEMC_NAND_ACCESS_BY_AXI = 0, /*!< Access to NAND flash by AXI bus. */
  78. kSEMC_NAND_ACCESS_BY_IPCMD, /*!< Access to NAND flash by IP bus. */
  79. } semc_nand_access_type_t;
  80. /*! @brief SEMC interrupts . */
  81. typedef enum _semc_interrupt_enable
  82. {
  83. kSEMC_IPCmdDoneInterrupt = SEMC_INTEN_IPCMDDONEEN_MASK, /*!< Ip command done interrupt. */
  84. kSEMC_IPCmdErrInterrupt = SEMC_INTEN_IPCMDERREN_MASK, /*!< Ip command error interrupt. */
  85. kSEMC_AXICmdErrInterrupt = SEMC_INTEN_AXICMDERREN_MASK, /*!< AXI command error interrupt. */
  86. kSEMC_AXIBusErrInterrupt = SEMC_INTEN_AXIBUSERREN_MASK /*!< AXI bus error interrupt. */
  87. } semc_interrupt_enable_t;
  88. /*! @brief SEMC IP command data size in bytes. */
  89. typedef enum _semc_ipcmd_datasize
  90. {
  91. kSEMC_IPcmdDataSize_1bytes = 1, /*!< The IP command data size 1 byte. */
  92. kSEMC_IPcmdDataSize_2bytes, /*!< The IP command data size 2 byte. */
  93. kSEMC_IPcmdDataSize_3bytes, /*!< The IP command data size 3 byte. */
  94. kSEMC_IPcmdDataSize_4bytes /*!< The IP command data size 4 byte. */
  95. } semc_ipcmd_datasize_t;
  96. /*! @brief SEMC auto-refresh timing. */
  97. typedef enum _semc_refresh_time
  98. {
  99. kSEMC_RefreshThreeClocks = 0x0U, /*!< The refresh timing with three bus clocks. */
  100. kSEMC_RefreshSixClocks, /*!< The refresh timing with six bus clocks. */
  101. kSEMC_RefreshNineClocks /*!< The refresh timing with nine bus clocks. */
  102. } semc_refresh_time_t;
  103. /*! @brief CAS latency */
  104. typedef enum _semc_caslatency
  105. {
  106. kSEMC_LatencyOne = 1, /*!< Latency 1. */
  107. kSEMC_LatencyTwo, /*!< Latency 2. */
  108. kSEMC_LatencyThree, /*!< Latency 3. */
  109. } semc_caslatency_t;
  110. /*! @brief SEMC sdram column address bit number. */
  111. typedef enum _semc_sdram_column_bit_num
  112. {
  113. kSEMC_SdramColunm_12bit = 0x0U, /*!< 12 bit. */
  114. kSEMC_SdramColunm_11bit, /*!< 11 bit. */
  115. kSEMC_SdramColunm_10bit, /*!< 10 bit. */
  116. kSEMC_SdramColunm_9bit, /*!< 9 bit. */
  117. #if defined(FSL_FEATURE_SEMC_SDRAM_SUPPORT_COLUMN_ADDRESS_8BIT) && (FSL_FEATURE_SEMC_SDRAM_SUPPORT_COLUMN_ADDRESS_8BIT)
  118. kSEMC_SdramColunm_8bit, /*!< 8 bit. */
  119. #endif /* FSL_FEATURE_SEMC_SDRAM_SUPPORT_COLUMN_ADDRESS_8BIT */
  120. } semc_sdram_column_bit_num_t;
  121. /*! @brief SEMC sdram burst length. */
  122. typedef enum _semc_sdram_burst_len
  123. {
  124. /*! According to ERR050577, Auto-refresh command may possibly fail to be triggered during
  125. long time back-to-back write (or read) when SDRAM controller's burst length is greater than 1. */
  126. #if defined(FSL_FEATURE_SEMC_ERRATA_050577) && (FSL_FEATURE_SEMC_ERRATA_050577 == 0x01U)
  127. kSEMC_Sdram_BurstLen1 = 0, /*!< Burst length 1*/
  128. #else
  129. kSEMC_Sdram_BurstLen1 = 0, /*!< Burst length 1*/
  130. kSEMC_Sdram_BurstLen2, /*!< Burst length 2*/
  131. kSEMC_Sdram_BurstLen4, /*!< Burst length 4*/
  132. kSEMC_Sdram_BurstLen8 /*!< Burst length 8*/
  133. #endif /* FSL_FEATURE_SEMC_ERRATA_050577 */
  134. } sem_sdram_burst_len_t;
  135. /*! @brief SEMC nand column address bit number. */
  136. typedef enum _semc_nand_column_bit_num
  137. {
  138. kSEMC_NandColum_16bit = 0x0U, /*!< 16 bit. */
  139. kSEMC_NandColum_15bit, /*!< 15 bit. */
  140. kSEMC_NandColum_14bit, /*!< 14 bit. */
  141. kSEMC_NandColum_13bit, /*!< 13 bit. */
  142. kSEMC_NandColum_12bit, /*!< 12 bit. */
  143. kSEMC_NandColum_11bit, /*!< 11 bit. */
  144. kSEMC_NandColum_10bit, /*!< 10 bit. */
  145. kSEMC_NandColum_9bit, /*!< 9 bit. */
  146. } semc_nand_column_bit_num_t;
  147. /*! @brief SEMC nand burst length. */
  148. typedef enum _semc_nand_burst_len
  149. {
  150. kSEMC_Nand_BurstLen1 = 0, /*!< Burst length 1*/
  151. kSEMC_Nand_BurstLen2, /*!< Burst length 2*/
  152. kSEMC_Nand_BurstLen4, /*!< Burst length 4*/
  153. kSEMC_Nand_BurstLen8, /*!< Burst length 8*/
  154. kSEMC_Nand_BurstLen16, /*!< Burst length 16*/
  155. kSEMC_Nand_BurstLen32, /*!< Burst length 32*/
  156. kSEMC_Nand_BurstLen64 /*!< Burst length 64*/
  157. } sem_nand_burst_len_t;
  158. /*! @brief SEMC nor/sram column address bit number. */
  159. typedef enum _semc_norsram_column_bit_num
  160. {
  161. kSEMC_NorColum_12bit = 0x0U, /*!< 12 bit. */
  162. kSEMC_NorColum_11bit, /*!< 11 bit. */
  163. kSEMC_NorColum_10bit, /*!< 10 bit. */
  164. kSEMC_NorColum_9bit, /*!< 9 bit. */
  165. kSEMC_NorColum_8bit, /*!< 8 bit. */
  166. kSEMC_NorColum_7bit, /*!< 7 bit. */
  167. kSEMC_NorColum_6bit, /*!< 6 bit. */
  168. kSEMC_NorColum_5bit, /*!< 5 bit. */
  169. kSEMC_NorColum_4bit, /*!< 4 bit. */
  170. kSEMC_NorColum_3bit, /*!< 3 bit. */
  171. kSEMC_NorColum_2bit /*!< 2 bit. */
  172. } semc_norsram_column_bit_num_t;
  173. /*! @brief SEMC nor/sram burst length. */
  174. typedef enum _semc_norsram_burst_len
  175. {
  176. kSEMC_Nor_BurstLen1 = 0, /*!< Burst length 1*/
  177. kSEMC_Nor_BurstLen2, /*!< Burst length 2*/
  178. kSEMC_Nor_BurstLen4, /*!< Burst length 4*/
  179. kSEMC_Nor_BurstLen8, /*!< Burst length 8*/
  180. kSEMC_Nor_BurstLen16, /*!< Burst length 16*/
  181. kSEMC_Nor_BurstLen32, /*!< Burst length 32*/
  182. kSEMC_Nor_BurstLen64 /*!< Burst length 64*/
  183. } sem_norsram_burst_len_t;
  184. /*! @brief SEMC dbi column address bit number. */
  185. typedef enum _semc_dbi_column_bit_num
  186. {
  187. kSEMC_Dbi_Colum_12bit = 0x0U, /*!< 12 bit. */
  188. kSEMC_Dbi_Colum_11bit, /*!< 11 bit. */
  189. kSEMC_Dbi_Colum_10bit, /*!< 10 bit. */
  190. kSEMC_Dbi_Colum_9bit, /*!< 9 bit. */
  191. kSEMC_Dbi_Colum_8bit, /*!< 8 bit. */
  192. kSEMC_Dbi_Colum_7bit, /*!< 7 bit. */
  193. kSEMC_Dbi_Colum_6bit, /*!< 6 bit. */
  194. kSEMC_Dbi_Colum_5bit, /*!< 5 bit. */
  195. kSEMC_Dbi_Colum_4bit, /*!< 4 bit. */
  196. kSEMC_Dbi_Colum_3bit, /*!< 3 bit. */
  197. kSEMC_Dbi_Colum_2bit /*!< 2 bit. */
  198. } semc_dbi_column_bit_num_t;
  199. /*! @brief SEMC dbi burst length. */
  200. typedef enum _semc_dbi_burst_len
  201. {
  202. kSEMC_Dbi_BurstLen1 = 0, /*!< Burst length 1*/
  203. kSEMC_Dbi_BurstLen2, /*!< Burst length 2*/
  204. kSEMC_Dbi_Dbi_BurstLen4, /*!< Burst length 4*/
  205. kSEMC_Dbi_BurstLen8, /*!< Burst length 8*/
  206. kSEMC_Dbi_BurstLen16, /*!< Burst length 16*/
  207. kSEMC_Dbi_BurstLen32, /*!< Burst length 32*/
  208. kSEMC_Dbi_BurstLen64 /*!< Burst length 64*/
  209. } sem_dbi_burst_len_t;
  210. /*! @brief SEMC IOMUXC. */
  211. typedef enum _semc_iomux_pin
  212. {
  213. kSEMC_MUXA8 = SEMC_IOCR_MUX_A8_SHIFT, /*!< MUX A8 pin. */
  214. kSEMC_MUXCSX0 = SEMC_IOCR_MUX_CSX0_SHIFT, /*!< MUX CSX0 pin */
  215. kSEMC_MUXCSX1 = SEMC_IOCR_MUX_CSX1_SHIFT, /*!< MUX CSX1 Pin.*/
  216. kSEMC_MUXCSX2 = SEMC_IOCR_MUX_CSX2_SHIFT, /*!< MUX CSX2 Pin. */
  217. kSEMC_MUXCSX3 = SEMC_IOCR_MUX_CSX3_SHIFT, /*!< MUX CSX3 Pin. */
  218. kSEMC_MUXRDY = SEMC_IOCR_MUX_RDY_SHIFT /*!< MUX RDY pin. */
  219. } semc_iomux_pin;
  220. /*! @brief SEMC NOR/PSRAM Address bit 27 A27. */
  221. typedef enum _semc_iomux_nora27_pin
  222. {
  223. kSEMC_MORA27_NONE = 0, /*!< No NOR/SRAM A27 pin. */
  224. kSEMC_NORA27_MUXCSX3 = SEMC_IOCR_MUX_CSX3_SHIFT, /*!< MUX CSX3 Pin. */
  225. kSEMC_NORA27_MUXRDY = SEMC_IOCR_MUX_RDY_SHIFT /*!< MUX RDY pin. */
  226. } semc_iomux_nora27_pin;
  227. /*! @brief SEMC port size. */
  228. typedef enum _semc_port_size
  229. {
  230. kSEMC_PortSize8Bit = 0, /*!< 8-Bit port size. */
  231. kSEMC_PortSize16Bit, /*!< 16-Bit port size. */
  232. #if defined(FSL_FEATURE_SEMC_SUPPORT_SDRAM_PS_BITWIDTH) && (FSL_FEATURE_SEMC_SUPPORT_SDRAM_PS_BITWIDTH == 0x02U)
  233. kSEMC_PortSize32Bit /*!< 32-Bit port size. */
  234. #endif /* FSL_FEATURE_SEMC_SUPPORT_SDRAM_PS_BITWIDTH */
  235. } smec_port_size_t;
  236. /*! @brief SEMC address mode. */
  237. typedef enum _semc_addr_mode
  238. {
  239. kSEMC_AddrDataMux = 0, /*!< SEMC address/data mux mode. */
  240. kSEMC_AdvAddrdataMux, /*!< Advanced address/data mux mode. */
  241. kSEMC_AddrDataNonMux /*!< Address/data non-mux mode. */
  242. } semc_addr_mode_t;
  243. /*! @brief SEMC DQS read strobe mode. */
  244. typedef enum _semc_dqs_mode
  245. {
  246. kSEMC_Loopbackinternal = 0, /*!< Dummy read strobe loopbacked internally. */
  247. kSEMC_Loopbackdqspad, /*!< Dummy read strobe loopbacked from DQS pad. */
  248. } semc_dqs_mode_t;
  249. /*! @brief SEMC ADV signal active polarity. */
  250. typedef enum _semc_adv_polarity
  251. {
  252. kSEMC_AdvActiveLow = 0, /*!< Adv active low. */
  253. kSEMC_AdvActiveHigh, /*!< Adv active high. */
  254. } semc_adv_polarity_t;
  255. /*! @brief SEMC sync mode. */
  256. typedef enum _semc_sync_mode
  257. {
  258. kSEMC_AsyncMode = 0, /*!< Async mode. */
  259. kSEMC_SyncMode, /*!< Sync mode. */
  260. } semc_sync_mode_t;
  261. /*! @brief SEMC ADV signal level control. */
  262. typedef enum _semc_adv_level_control
  263. {
  264. kSEMC_AdvHigh = 0, /*!< Adv is high during address hold state. */
  265. kSEMC_AdvLow, /*!< Adv is low during address hold state. */
  266. } semc_adv_level_control_t;
  267. /*! @brief SEMC RDY signal active polarity. */
  268. typedef enum _semc_rdy_polarity
  269. {
  270. kSEMC_RdyActiveLow = 0, /*!< Adv active low. */
  271. kSEMC_RdyActivehigh, /*!< Adv active low. */
  272. } semc_rdy_polarity_t;
  273. /*! @brief SEMC IP command for NAND: address mode. */
  274. typedef enum _semc_ipcmd_nand_addrmode
  275. {
  276. kSEMC_NANDAM_ColumnRow = 0x0U, /*!< Address mode: column and row address(5Byte-CA0/CA1/RA0/RA1/RA2). */
  277. kSEMC_NANDAM_ColumnCA0, /*!< Address mode: column address only(1 Byte-CA0). */
  278. kSEMC_NANDAM_ColumnCA0CA1, /*!< Address mode: column address only(2 Byte-CA0/CA1). */
  279. kSEMC_NANDAM_RawRA0, /*!< Address mode: row address only(1 Byte-RA0). */
  280. kSEMC_NANDAM_RawRA0RA1, /*!< Address mode: row address only(2 Byte-RA0/RA1). */
  281. kSEMC_NANDAM_RawRA0RA1RA2 /*!< Address mode: row address only(3 Byte-RA0). */
  282. } semc_ipcmd_nand_addrmode_t;
  283. /*! @brief SEMC IP command for NAND: command mode. */
  284. typedef enum _semc_ipcmd_nand_cmdmode
  285. {
  286. kSEMC_NANDCM_Command = 0x2U, /*!< command. */
  287. kSEMC_NANDCM_CommandHold, /*!< Command hold. */
  288. kSEMC_NANDCM_CommandAddress, /*!< Command address. */
  289. kSEMC_NANDCM_CommandAddressHold, /*!< Command address hold. */
  290. kSEMC_NANDCM_CommandAddressRead, /*!< Command address read. */
  291. kSEMC_NANDCM_CommandAddressWrite, /*!< Command address write. */
  292. kSEMC_NANDCM_CommandRead, /*!< Command read. */
  293. kSEMC_NANDCM_CommandWrite, /*!< Command write. */
  294. kSEMC_NANDCM_Read, /*!< Read. */
  295. kSEMC_NANDCM_Write /*!< Write. */
  296. } semc_ipcmd_nand_cmdmode_t;
  297. /*! @brief SEMC NAND address option. */
  298. typedef enum _semc_nand_address_option
  299. {
  300. kSEMC_NandAddrOption_5byte_CA2RA3 = 0U, /*!< CA0+CA1+RA0+RA1+RA2 */
  301. kSEMC_NandAddrOption_4byte_CA2RA2 = 2U, /*!< CA0+CA1+RA0+RA1 */
  302. kSEMC_NandAddrOption_3byte_CA2RA1 = 4U, /*!< CA0+CA1+RA0 */
  303. kSEMC_NandAddrOption_4byte_CA1RA3 = 1U, /*!< CA0+RA0+RA1+RA2 */
  304. kSEMC_NandAddrOption_3byte_CA1RA2 = 3U, /*!< CA0+RA0+RA1 */
  305. kSEMC_NandAddrOption_2byte_CA1RA1 = 7U, /*!< CA0+RA0 */
  306. } semc_nand_address_option_t;
  307. /*! @brief SEMC IP command for NOR. */
  308. typedef enum _semc_ipcmd_nor_dbi
  309. {
  310. kSEMC_NORDBICM_Read = 0x2U, /*!< NOR read. */
  311. kSEMC_NORDBICM_Write /*!< NOR write. */
  312. } semc_ipcmd_nor_dbi_t;
  313. /*! @brief SEMC IP command for SRAM. */
  314. typedef enum _semc_ipcmd_sram
  315. {
  316. kSEMC_SRAMCM_ArrayRead = 0x2U, /*!< SRAM memory array read. */
  317. kSEMC_SRAMCM_ArrayWrite, /*!< SRAM memory array write. */
  318. kSEMC_SRAMCM_RegRead, /*!< SRAM memory register read. */
  319. kSEMC_SRAMCM_RegWrite /*!< SRAM memory register write. */
  320. } semc_ipcmd_sram_t;
  321. /*! @brief SEMC IP command for SDARM. */
  322. typedef enum _semc_ipcmd_sdram
  323. {
  324. kSEMC_SDRAMCM_Read = 0x8U, /*!< SDRAM memory read. */
  325. kSEMC_SDRAMCM_Write, /*!< SDRAM memory write. */
  326. kSEMC_SDRAMCM_Modeset, /*!< SDRAM MODE SET. */
  327. kSEMC_SDRAMCM_Active, /*!< SDRAM active. */
  328. kSEMC_SDRAMCM_AutoRefresh, /*!< SDRAM auto-refresh. */
  329. kSEMC_SDRAMCM_SelfRefresh, /*!< SDRAM self-refresh. */
  330. kSEMC_SDRAMCM_Precharge, /*!< SDRAM precharge. */
  331. kSEMC_SDRAMCM_Prechargeall /*!< SDRAM precharge all. */
  332. } semc_ipcmd_sdram_t;
  333. /*! @brief SEMC SDRAM configuration structure.
  334. *
  335. * 1. The memory size in the configuration is in the unit of KB. So memsize_kbytes
  336. * should be set as 2^2, 2^3, 2^4 .etc which is base 2KB exponential function.
  337. * Take refer to BR0~BR3 register in RM for details.
  338. * 2. The prescalePeriod_N16Cycle is in unit of 16 clock cycle. It is a exception for prescaleTimer_n16cycle = 0,
  339. * it means the prescaler timer period is 256 * 16 clock cycles. For precalerIf precalerTimer_n16cycle not equal to 0,
  340. * The prescaler timer period is prescalePeriod_N16Cycle * 16 clock cycles.
  341. * idleTimeout_NprescalePeriod, refreshUrgThreshold_NprescalePeriod, refreshPeriod_NprescalePeriod are
  342. * similar to prescalePeriod_N16Cycle.
  343. *
  344. */
  345. typedef struct _semc_sdram_config
  346. {
  347. semc_iomux_pin csxPinMux; /*!< CS pin mux. The kSEMC_MUXA8 is not valid in sdram pin mux setting. */
  348. uint32_t address; /*!< The base address. */
  349. uint32_t memsize_kbytes; /*!< The memory size in unit of kbytes. */
  350. smec_port_size_t portSize; /*!< Port size. */
  351. sem_sdram_burst_len_t burstLen; /*!< Burst length. */
  352. semc_sdram_column_bit_num_t columnAddrBitNum; /*!< Column address bit number. */
  353. semc_caslatency_t casLatency; /*!< CAS latency. */
  354. uint8_t tPrecharge2Act_Ns; /*!< Precharge to active wait time in unit of nanosecond. */
  355. uint8_t tAct2ReadWrite_Ns; /*!< Act to read/write wait time in unit of nanosecond. */
  356. uint8_t tRefreshRecovery_Ns; /*!< Refresh recovery time in unit of nanosecond. */
  357. uint8_t tWriteRecovery_Ns; /*!< write recovery time in unit of nanosecond. */
  358. uint8_t tCkeOff_Ns; /*!< CKE off minimum time in unit of nanosecond. */
  359. uint8_t tAct2Prechage_Ns; /*!< Active to precharge in unit of nanosecond. */
  360. uint8_t tSelfRefRecovery_Ns; /*!< Self refresh recovery time in unit of nanosecond. */
  361. uint8_t tRefresh2Refresh_Ns; /*!< Refresh to refresh wait time in unit of nanosecond. */
  362. uint8_t tAct2Act_Ns; /*!< Active to active wait time in unit of nanosecond. */
  363. uint32_t tPrescalePeriod_Ns; /*!< Prescaler timer period should not be larger than 256 * 16 * clock cycle. */
  364. uint32_t tIdleTimeout_Ns; /*!< Idle timeout in unit of prescale time period. */
  365. uint32_t refreshPeriod_nsPerRow; /*!< Refresh timer period like 64ms * 1000000/8192 . */
  366. uint32_t refreshUrgThreshold; /*!< Refresh urgent threshold. */
  367. uint8_t refreshBurstLen; /*!< Refresh burst length. */
  368. #if defined(FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL) && (FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL)
  369. uint8_t delayChain; /*!< Delay chain, which adds delays on DQS clock to compensate timings while DQS is faster than
  370. read data. */
  371. #endif /* FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL */
  372. } semc_sdram_config_t;
  373. /*! @brief SEMC NAND device timing configuration structure. */
  374. typedef struct _semc_nand_timing_config
  375. {
  376. uint8_t tCeSetup_Ns; /*!< CE setup time: tCS. */
  377. uint8_t tCeHold_Ns; /*!< CE hold time: tCH. */
  378. uint8_t tCeInterval_Ns; /*!< CE interval time:tCEITV. */
  379. uint8_t tWeLow_Ns; /*!< WE low time: tWP. */
  380. uint8_t tWeHigh_Ns; /*!< WE high time: tWH. */
  381. uint8_t tReLow_Ns; /*!< RE low time: tRP. */
  382. uint8_t tReHigh_Ns; /*!< RE high time: tREH. */
  383. uint8_t tTurnAround_Ns; /*!< Turnaround time for async mode: tTA. */
  384. uint8_t tWehigh2Relow_Ns; /*!< WE# high to RE# wait time: tWHR. */
  385. uint8_t tRehigh2Welow_Ns; /*!< RE# high to WE# low wait time: tRHW. */
  386. uint8_t tAle2WriteStart_Ns; /*!< ALE to write start wait time: tADL. */
  387. uint8_t tReady2Relow_Ns; /*!< Ready to RE# low min wait time: tRR. */
  388. uint8_t tWehigh2Busy_Ns; /*!< WE# high to busy wait time: tWB. */
  389. } semc_nand_timing_config_t;
  390. /*! @brief SEMC NAND configuration structure. */
  391. typedef struct _semc_nand_config
  392. {
  393. semc_iomux_pin cePinMux; /*!< The CE pin mux setting. The kSEMC_MUXRDY is not valid for CE pin setting. */
  394. uint32_t axiAddress; /*!< The base address for AXI nand. */
  395. uint32_t axiMemsize_kbytes; /*!< The memory size in unit of kbytes for AXI nand. */
  396. uint32_t ipgAddress; /*!< The base address for IPG nand . */
  397. uint32_t ipgMemsize_kbytes; /*!< The memory size in unit of kbytes for IPG nand. */
  398. semc_rdy_polarity_t rdyactivePolarity; /*!< Wait ready polarity. */
  399. bool edoModeEnabled; /*!< EDO mode enabled. */
  400. semc_nand_column_bit_num_t columnAddrBitNum; /*!< Column address bit number. */
  401. semc_nand_address_option_t arrayAddrOption; /*!< Address option. */
  402. sem_nand_burst_len_t burstLen; /*!< Burst length. */
  403. smec_port_size_t portSize; /*!< Port size. */
  404. semc_nand_timing_config_t *timingConfig; /*!< SEMC nand timing configuration. */
  405. } semc_nand_config_t;
  406. /*! @brief SEMC NOR configuration structure. */
  407. typedef struct _semc_nor_config
  408. {
  409. semc_iomux_pin cePinMux; /*!< The CE# pin mux setting. */
  410. semc_iomux_nora27_pin addr27; /*!< The Addr bit 27 pin mux setting. */
  411. uint32_t address; /*!< The base address. */
  412. uint32_t memsize_kbytes; /*!< The memory size in unit of kbytes. */
  413. uint8_t addrPortWidth; /*!< The address port width. */
  414. semc_rdy_polarity_t rdyactivePolarity; /*!< Wait ready polarity. */
  415. semc_adv_polarity_t advActivePolarity; /*!< ADV# polarity. */
  416. semc_norsram_column_bit_num_t columnAddrBitNum; /*!< Column address bit number. */
  417. semc_addr_mode_t addrMode; /*!< Address mode. */
  418. sem_norsram_burst_len_t burstLen; /*!< Burst length. */
  419. smec_port_size_t portSize; /*!< Port size. */
  420. uint8_t tCeSetup_Ns; /*!< The CE setup time. */
  421. uint8_t tCeHold_Ns; /*!< The CE hold time. */
  422. uint8_t tCeInterval_Ns; /*!< CE interval minimum time. */
  423. uint8_t tAddrSetup_Ns; /*!< The address setup time. */
  424. uint8_t tAddrHold_Ns; /*!< The address hold time. */
  425. uint8_t tWeLow_Ns; /*!< WE low time for async mode. */
  426. uint8_t tWeHigh_Ns; /*!< WE high time for async mode. */
  427. uint8_t tReLow_Ns; /*!< RE low time for async mode. */
  428. uint8_t tReHigh_Ns; /*!< RE high time for async mode. */
  429. uint8_t tTurnAround_Ns; /*!< Turnaround time for async mode. */
  430. uint8_t tAddr2WriteHold_Ns; /*!< Address to write data hold time for async mode. */
  431. #if defined(FSL_FEATURE_SEMC_HAS_NOR_WDS_TIME) && (FSL_FEATURE_SEMC_HAS_NOR_WDS_TIME)
  432. uint8_t tWriteSetup_Ns; /*!< Write data setup time for sync mode.*/
  433. #endif
  434. #if defined(FSL_FEATURE_SEMC_HAS_NOR_WDH_TIME) && (FSL_FEATURE_SEMC_HAS_NOR_WDH_TIME)
  435. uint8_t tWriteHold_Ns; /*!< Write hold time for sync mode. */
  436. #endif
  437. #if defined(FSL_FEATURE_SEMC_HAS_NOR_LC_TIME) && (FSL_FEATURE_SEMC_HAS_NOR_LC_TIME)
  438. uint8_t latencyCount; /*!< Latency count for sync mode. */
  439. #endif
  440. #if defined(FSL_FEATURE_SEMC_HAS_NOR_RD_TIME) && (FSL_FEATURE_SEMC_HAS_NOR_RD_TIME)
  441. uint8_t readCycle; /*!< Read cycle time for sync mode. */
  442. #endif
  443. #if defined(FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL) && (FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL)
  444. uint8_t delayChain; /*!< Delay chain, which adds delays on DQS clock to compensate timings while DQS is faster than
  445. read data. */
  446. #endif /* FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL */
  447. } semc_nor_config_t;
  448. /*! @brief SEMC SRAM configuration structure. */
  449. typedef struct _semc_sram_config
  450. {
  451. semc_iomux_pin cePinMux; /*!< The CE# pin mux setting. */
  452. semc_iomux_nora27_pin addr27; /*!< The Addr bit 27 pin mux setting. */
  453. uint32_t address; /*!< The base address. */
  454. uint32_t memsize_kbytes; /*!< The memory size in unit of kbytes. */
  455. uint8_t addrPortWidth; /*!< The address port width. */
  456. semc_adv_polarity_t advActivePolarity; /*!< ADV# polarity 1: active high, 0: active low. */
  457. semc_addr_mode_t addrMode; /*!< Address mode. */
  458. sem_norsram_burst_len_t burstLen; /*!< Burst length. */
  459. smec_port_size_t portSize; /*!< Port size. */
  460. #if defined(SEMC_SRAMCR4_SYNCEN_MASK) && (SEMC_SRAMCR4_SYNCEN_MASK)
  461. semc_sync_mode_t syncMode; /*!< Sync mode. */
  462. #endif /* SEMC_SRAMCR4_SYNCEN_MASK */
  463. #if defined(SEMC_SRAMCR0_WAITEN_MASK) && (SEMC_SRAMCR0_WAITEN_MASK)
  464. bool waitEnable; /*!< Wait enable. */
  465. #endif /* SEMC_SRAMCR0_WAITEN_MASK */
  466. #if defined(SEMC_SRAMCR0_WAITSP_MASK) && (SEMC_SRAMCR0_WAITSP_MASK)
  467. uint8_t waitSample; /*!< Wait sample. */
  468. #endif /* SEMC_SRAMCR0_WAITSP_MASK */
  469. #if defined(SEMC_SRAMCR4_ADVH_MASK) && (SEMC_SRAMCR4_ADVH_MASK)
  470. semc_adv_level_control_t advLevelCtrl; /*!< ADV# level control during address hold state, 1: low, 0: high. */
  471. #endif /* SEMC_SRAMCR4_ADVH_MASK */
  472. uint8_t tCeSetup_Ns; /*!< The CE setup time. */
  473. uint8_t tCeHold_Ns; /*!< The CE hold time. */
  474. uint8_t tCeInterval_Ns; /*!< CE interval minimum time. */
  475. #if defined(FSL_FEATURE_SEMC_HAS_SRAM_RDH_TIME) && (FSL_FEATURE_SEMC_HAS_SRAM_RDH_TIME)
  476. uint8_t readHoldTime_Ns; /*!< read hold time. */
  477. #endif /* FSL_FEATURE_SEMC_HAS_SRAM_RDH_TIME */
  478. uint8_t tAddrSetup_Ns; /*!< The address setup time. */
  479. uint8_t tAddrHold_Ns; /*!< The address hold time. */
  480. uint8_t tWeLow_Ns; /*!< WE low time for async mode. */
  481. uint8_t tWeHigh_Ns; /*!< WE high time for async mode. */
  482. uint8_t tReLow_Ns; /*!< RE low time for async mode. */
  483. uint8_t tReHigh_Ns; /*!< RE high time for async mode. */
  484. uint8_t tTurnAround_Ns; /*!< Turnaround time for async mode. */
  485. uint8_t tAddr2WriteHold_Ns; /*!< Address to write data hold time for async mode. */
  486. #if defined(FSL_FEATURE_SEMC_HAS_SRAM_WDS_TIME) && (FSL_FEATURE_SEMC_HAS_SRAM_WDS_TIME)
  487. uint8_t tWriteSetup_Ns; /*!<Write data setup time for sync mode. */
  488. #endif
  489. #if defined(FSL_FEATURE_SEMC_HAS_SRAM_WDH_TIME) && (FSL_FEATURE_SEMC_HAS_SRAM_WDH_TIME)
  490. uint8_t tWriteHold_Ns; /*!<Write hold time for sync mode. */
  491. #endif
  492. #if defined(FSL_FEATURE_SEMC_HAS_SRAM_LC_TIME) && (FSL_FEATURE_SEMC_HAS_SRAM_LC_TIME)
  493. uint8_t latencyCount; /*!<Latency count for sync mode. */
  494. #endif
  495. #if defined(FSL_FEATURE_SEMC_HAS_SRAM_RD_TIME) && (FSL_FEATURE_SEMC_HAS_SRAM_RD_TIME)
  496. uint8_t readCycle; /*!<Read cycle time for sync mode. */
  497. #endif
  498. #if defined(FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL) && (FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL)
  499. uint8_t delayChain; /*!< Delay chain, which adds delays on DQS clock to compensate timings while DQS is faster than
  500. read data. */
  501. #endif /* FSL_FEATURE_SEMC_HAS_DELAY_CHAIN_CONTROL */
  502. } semc_sram_config_t;
  503. /*! @brief SEMC DBI configuration structure. */
  504. typedef struct _semc_dbi_config
  505. {
  506. semc_iomux_pin csxPinMux; /*!< The CE# pin mux. */
  507. uint32_t address; /*!< The base address. */
  508. uint32_t memsize_kbytes; /*!< The memory size in unit of 4kbytes. */
  509. semc_dbi_column_bit_num_t columnAddrBitNum; /*!< Column address bit number. */
  510. sem_dbi_burst_len_t burstLen; /*!< Burst length. */
  511. smec_port_size_t portSize; /*!< Port size. */
  512. uint8_t tCsxSetup_Ns; /*!< The CSX setup time. */
  513. uint8_t tCsxHold_Ns; /*!< The CSX hold time. */
  514. uint8_t tWexLow_Ns; /*!< WEX low time. */
  515. uint8_t tWexHigh_Ns; /*!< WEX high time. */
  516. uint8_t tRdxLow_Ns; /*!< RDX low time. */
  517. uint8_t tRdxHigh_Ns; /*!< RDX high time. */
  518. uint8_t tCsxInterval_Ns; /*!< Write data setup time.*/
  519. } semc_dbi_config_t;
  520. /*! @brief SEMC AXI queue a weight setting structure. */
  521. typedef struct _semc_queuea_weight_struct
  522. {
  523. uint32_t qos : 4; /*!< weight of qos for queue 0 . */
  524. uint32_t aging : 4; /*!< weight of aging for queue 0.*/
  525. uint32_t slaveHitSwith : 8; /*!< weight of read/write switch for queue 0.*/
  526. uint32_t slaveHitNoswitch : 8; /*!< weight of read/write no switch for queue 0 .*/
  527. } semc_queuea_weight_struct_t;
  528. /*! @brief SEMC AXI queue a weight setting union. */
  529. typedef union _semc_queuea_weight
  530. {
  531. semc_queuea_weight_struct_t queueaConfig; /*!< Structure configuration for queueA. */
  532. uint32_t queueaValue; /*!< Configuration value for queueA which could directly write to the reg. */
  533. } semc_queuea_weight_t;
  534. /*! @brief SEMC AXI queue b weight setting structure. */
  535. typedef struct _semc_queueb_weight_struct
  536. {
  537. uint32_t qos : 4; /*!< weight of qos for queue 1. */
  538. uint32_t aging : 4; /*!< weight of aging for queue 1.*/
  539. uint32_t slaveHitSwith : 8; /*!< weight of read/write switch for queue 1.*/
  540. uint32_t weightPagehit : 8; /*!< weight of page hit for queue 1 only .*/
  541. uint32_t bankRotation : 8; /*!< weight of bank rotation for queue 1 only .*/
  542. } semc_queueb_weight_struct_t;
  543. /*! @brief SEMC AXI queue b weight setting union. */
  544. typedef union _semc_queueb_weight
  545. {
  546. semc_queueb_weight_struct_t queuebConfig; /*!< Structure configuration for queueB. */
  547. uint32_t queuebValue; /*!< Configuration value for queueB which could directly write to the reg. */
  548. } semc_queueb_weight_t;
  549. /*! @brief SEMC AXI queue weight setting. */
  550. typedef struct _semc_axi_queueweight
  551. {
  552. bool queueaEnable; /*!< Enable queue a. */
  553. semc_queuea_weight_t queueaWeight; /*!< Weight settings for queue a. */
  554. bool queuebEnable; /*!< Enable queue b. */
  555. semc_queueb_weight_t queuebWeight; /*!< Weight settings for queue b. */
  556. } semc_axi_queueweight_t;
  557. /*!
  558. * @brief SEMC configuration structure.
  559. *
  560. * busTimeoutCycles: when busTimeoutCycles is zero, the bus timeout cycle is
  561. * 255*1024. otherwise the bus timeout cycles is busTimeoutCycles*1024.
  562. * cmdTimeoutCycles: is used for command execution timeout cycles. it's
  563. * similar to the busTimeoutCycles.
  564. */
  565. typedef struct _semc_config_t
  566. {
  567. semc_dqs_mode_t dqsMode; /*!< Dummy read strobe mode: use enum in "semc_dqs_mode_t". */
  568. uint8_t cmdTimeoutCycles; /*!< Command execution timeout cycles. */
  569. uint8_t busTimeoutCycles; /*!< Bus timeout cycles. */
  570. semc_axi_queueweight_t queueWeight; /*!< AXI queue weight. */
  571. } semc_config_t;
  572. /*******************************************************************************
  573. * API
  574. ******************************************************************************/
  575. #if defined(__cplusplus)
  576. extern "C" {
  577. #endif
  578. /*!
  579. * @name SEMC Initialization and De-initialization
  580. * @{
  581. */
  582. /*!
  583. * @brief Gets the SEMC default basic configuration structure.
  584. *
  585. * The purpose of this API is to get the default SEMC
  586. * configure structure for SEMC_Init(). User may use the initialized
  587. * structure unchanged in SEMC_Init(), or modify some fields of the
  588. * structure before calling SEMC_Init().
  589. * Example:
  590. @code
  591. semc_config_t config;
  592. SEMC_GetDefaultConfig(&config);
  593. @endcode
  594. * @param config The SEMC configuration structure pointer.
  595. */
  596. void SEMC_GetDefaultConfig(semc_config_t *config);
  597. /*!
  598. * @brief Initializes SEMC.
  599. * This function ungates the SEMC clock and initializes SEMC.
  600. * This function must be called before calling any other SEMC driver functions.
  601. *
  602. * @param base SEMC peripheral base address.
  603. * @param configure The SEMC configuration structure pointer.
  604. */
  605. void SEMC_Init(SEMC_Type *base, semc_config_t *configure);
  606. /*!
  607. * @brief Deinitializes the SEMC module and gates the clock.
  608. *
  609. * This function gates the SEMC clock. As a result, the SEMC module doesn't work after
  610. * calling this function, for some IDE, calling this API may cause the next downloading
  611. * operation failed. so, please call this API cautiously. Additional, users can
  612. * using "#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL (1)" to disable the clock control
  613. * operation in drivers.
  614. *
  615. * @param base SEMC peripheral base address.
  616. */
  617. void SEMC_Deinit(SEMC_Type *base);
  618. /* @} */
  619. /*!
  620. * @name SEMC Configuration Operation For Each Memory Type
  621. * @{
  622. */
  623. /*!
  624. * @brief Configures SDRAM controller in SEMC.
  625. *
  626. * @param base SEMC peripheral base address.
  627. * @param cs The chip selection.
  628. * @param config The sdram configuration.
  629. * @param clkSrc_Hz The SEMC clock frequency.
  630. */
  631. status_t SEMC_ConfigureSDRAM(SEMC_Type *base, semc_sdram_cs_t cs, semc_sdram_config_t *config, uint32_t clkSrc_Hz);
  632. /*!
  633. * @brief Configures NAND controller in SEMC.
  634. *
  635. * @param base SEMC peripheral base address.
  636. * @param config The nand configuration.
  637. * @param clkSrc_Hz The SEMC clock frequency.
  638. */
  639. status_t SEMC_ConfigureNAND(SEMC_Type *base, semc_nand_config_t *config, uint32_t clkSrc_Hz);
  640. /*!
  641. * @brief Configures NOR controller in SEMC.
  642. *
  643. * @param base SEMC peripheral base address.
  644. * @param config The nor configuration.
  645. * @param clkSrc_Hz The SEMC clock frequency.
  646. */
  647. status_t SEMC_ConfigureNOR(SEMC_Type *base, semc_nor_config_t *config, uint32_t clkSrc_Hz);
  648. /*!
  649. * @brief Configures SRAM controller in SEMC.
  650. *
  651. * @param base SEMC peripheral base address.
  652. * @param cs The chip selection.
  653. * @param config The sram configuration.
  654. * @param clkSrc_Hz The SEMC clock frequency.
  655. */
  656. status_t SEMC_ConfigureSRAMWithChipSelection(SEMC_Type *base,
  657. semc_sram_cs_t cs,
  658. semc_sram_config_t *config,
  659. uint32_t clkSrc_Hz);
  660. /*!
  661. * @brief Configures SRAM controller in SEMC.
  662. * @deprecated Do not use this function. It has been superceded by @ref SEMC_ConfigureSRAMWithChipSelection.
  663. * @param base SEMC peripheral base address.
  664. * @param config The sram configuration.
  665. * @param clkSrc_Hz The SEMC clock frequency.
  666. */
  667. status_t SEMC_ConfigureSRAM(SEMC_Type *base, semc_sram_config_t *config, uint32_t clkSrc_Hz);
  668. /*!
  669. * @brief Configures DBI controller in SEMC.
  670. *
  671. * @param base SEMC peripheral base address.
  672. * @param config The dbi configuration.
  673. * @param clkSrc_Hz The SEMC clock frequency.
  674. */
  675. status_t SEMC_ConfigureDBI(SEMC_Type *base, semc_dbi_config_t *config, uint32_t clkSrc_Hz);
  676. /* @} */
  677. /*!
  678. * @name SEMC Interrupt Operation
  679. * @{
  680. */
  681. /*!
  682. * @brief Enables the SEMC interrupt.
  683. *
  684. * This function enables the SEMC interrupts according to the provided mask. The mask
  685. * is a logical OR of enumeration members. See @ref semc_interrupt_enable_t.
  686. * For example, to enable the IP command done and error interrupt, do the following.
  687. * @code
  688. * SEMC_EnableInterrupts(ENET, kSEMC_IPCmdDoneInterrupt | kSEMC_IPCmdErrInterrupt);
  689. * @endcode
  690. *
  691. * @param base SEMC peripheral base address.
  692. * @param mask SEMC interrupts to enable. This is a logical OR of the
  693. * enumeration :: semc_interrupt_enable_t.
  694. */
  695. static inline void SEMC_EnableInterrupts(SEMC_Type *base, uint32_t mask)
  696. {
  697. base->INTEN |= mask;
  698. }
  699. /*!
  700. * @brief Disables the SEMC interrupt.
  701. *
  702. * This function disables the SEMC interrupts according to the provided mask. The mask
  703. * is a logical OR of enumeration members. See @ref semc_interrupt_enable_t.
  704. * For example, to disable the IP command done and error interrupt, do the following.
  705. * @code
  706. * SEMC_DisableInterrupts(ENET, kSEMC_IPCmdDoneInterrupt | kSEMC_IPCmdErrInterrupt);
  707. * @endcode
  708. *
  709. * @param base SEMC peripheral base address.
  710. * @param mask SEMC interrupts to disable. This is a logical OR of the
  711. * enumeration :: semc_interrupt_enable_t.
  712. */
  713. static inline void SEMC_DisableInterrupts(SEMC_Type *base, uint32_t mask)
  714. {
  715. base->INTEN &= ~mask;
  716. }
  717. /*!
  718. * @brief Gets the SEMC status.
  719. *
  720. * This function gets the SEMC interrupts event status.
  721. * User can use the a logical OR of enumeration member as a mask.
  722. * See @ref semc_interrupt_enable_t.
  723. *
  724. * @param base SEMC peripheral base address.
  725. * @return status flag, use status flag in semc_interrupt_enable_t to get the related status.
  726. */
  727. static inline bool SEMC_GetStatusFlag(SEMC_Type *base)
  728. {
  729. return (base->INTR != 0x00U) ? true : false;
  730. }
  731. /*!
  732. * @brief Clears the SEMC status flag state.
  733. *
  734. * The following status register flags can be cleared SEMC interrupt status.
  735. *
  736. * @param base SEMC base pointer
  737. * @param mask The status flag mask, a logical OR of enumeration member @ref semc_interrupt_enable_t.
  738. */
  739. static inline void SEMC_ClearStatusFlags(SEMC_Type *base, uint32_t mask)
  740. {
  741. base->INTR |= mask;
  742. }
  743. /* @} */
  744. /*!
  745. * @name SEMC Memory Access Operation
  746. * @{
  747. */
  748. /*!
  749. * @brief Check if SEMC is in idle.
  750. *
  751. * @param base SEMC peripheral base address.
  752. * @return True SEMC is in idle, false is not in idle.
  753. */
  754. static inline bool SEMC_IsInIdle(SEMC_Type *base)
  755. {
  756. return ((base->STS0 & SEMC_STS0_IDLE_MASK) != 0x00U) ? true : false;
  757. }
  758. /*!
  759. * @brief SEMC IP command access.
  760. *
  761. * @param base SEMC peripheral base address.
  762. * @param type SEMC memory type. refer to "semc_mem_type_t"
  763. * @param address SEMC device address.
  764. * @param command SEMC IP command.
  765. * For NAND device, we should use the SEMC_BuildNandIPCommand to get the right nand command.
  766. * For NOR/DBI device, take refer to "semc_ipcmd_nor_dbi_t".
  767. * For SRAM device, take refer to "semc_ipcmd_sram_t".
  768. * For SDRAM device, take refer to "semc_ipcmd_sdram_t".
  769. * @param write Data for write access.
  770. * @param read Data pointer for read data out.
  771. */
  772. status_t SEMC_SendIPCommand(
  773. SEMC_Type *base, semc_mem_type_t type, uint32_t address, uint32_t command, uint32_t write, uint32_t *read);
  774. /*!
  775. * @brief Build SEMC IP command for NAND.
  776. *
  777. * This function build SEMC NAND IP command. The command is build of user command code,
  778. * SEMC address mode and SEMC command mode.
  779. *
  780. * @param userCommand NAND device normal command.
  781. * @param addrMode NAND address mode. Refer to "semc_ipcmd_nand_addrmode_t".
  782. * @param cmdMode NAND command mode. Refer to "semc_ipcmd_nand_cmdmode_t".
  783. */
  784. static inline uint16_t SEMC_BuildNandIPCommand(uint8_t userCommand,
  785. semc_ipcmd_nand_addrmode_t addrMode,
  786. semc_ipcmd_nand_cmdmode_t cmdMode)
  787. {
  788. return ((uint16_t)userCommand << 8U) | ((uint16_t)addrMode << 4U) | ((uint16_t)cmdMode & 0x000FU);
  789. }
  790. /*!
  791. * @brief Check if the NAND device is ready.
  792. *
  793. * @param base SEMC peripheral base address.
  794. * @return True NAND is ready, false NAND is not ready.
  795. */
  796. static inline bool SEMC_IsNandReady(SEMC_Type *base)
  797. {
  798. return ((base->STS0 & SEMC_STS0_NARDY_MASK) != 0x00U) ? true : false;
  799. }
  800. /*!
  801. * @brief SEMC NAND device memory write through IP command.
  802. *
  803. * @param base SEMC peripheral base address.
  804. * @param address SEMC NAND device address.
  805. * @param data Data for write access.
  806. * @param size_bytes Data length.
  807. */
  808. status_t SEMC_IPCommandNandWrite(SEMC_Type *base, uint32_t address, uint8_t *data, uint32_t size_bytes);
  809. /*!
  810. * @brief SEMC NAND device memory read through IP command.
  811. *
  812. * @param base SEMC peripheral base address.
  813. * @param address SEMC NAND device address.
  814. * @param data Data pointer for data read out.
  815. * @param size_bytes Data length.
  816. */
  817. status_t SEMC_IPCommandNandRead(SEMC_Type *base, uint32_t address, uint8_t *data, uint32_t size_bytes);
  818. /*!
  819. * @brief SEMC NOR device memory write through IP command.
  820. *
  821. * @param base SEMC peripheral base address.
  822. * @param address SEMC NOR device address.
  823. * @param data Data for write access.
  824. * @param size_bytes Data length.
  825. */
  826. status_t SEMC_IPCommandNorWrite(SEMC_Type *base, uint32_t address, uint8_t *data, uint32_t size_bytes);
  827. /*!
  828. * @brief SEMC NOR device memory read through IP command.
  829. *
  830. * @param base SEMC peripheral base address.
  831. * @param address SEMC NOR device address.
  832. * @param data Data pointer for data read out.
  833. * @param size_bytes Data length.
  834. */
  835. status_t SEMC_IPCommandNorRead(SEMC_Type *base, uint32_t address, uint8_t *data, uint32_t size_bytes);
  836. /* @} */
  837. #if defined(__cplusplus)
  838. }
  839. #endif
  840. /*! @}*/
  841. #endif /* _FSL_SEMC_H_*/