hc32_ll_qspi.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_qspi.h
  4. * @brief This file contains all the functions prototypes of the QSPI driver
  5. * library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_QSPI_H__
  22. #define __HC32_LL_QSPI_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx.h"
  33. #include "hc32f4xx_conf.h"
  34. /**
  35. * @addtogroup LL_Driver
  36. * @{
  37. */
  38. /**
  39. * @addtogroup LL_QSPI
  40. * @{
  41. */
  42. #if (LL_QSPI_ENABLE == DDL_ON)
  43. /*******************************************************************************
  44. * Global type definitions ('typedef')
  45. ******************************************************************************/
  46. /**
  47. * @defgroup QSPI_Global_Types QSPI Global Types
  48. * @{
  49. */
  50. /**
  51. * @brief QSPI initialization structure definition
  52. */
  53. typedef struct {
  54. uint32_t u32ClockDiv; /*!< Specifies the clock division.
  55. This parameter can be a value of @ref QSPI_Clock_Division */
  56. uint32_t u32SpiMode; /*!< Specifies the SPI mode.
  57. This parameter can be a value of @ref QSPI_SPI_Mode */
  58. uint32_t u32PrefetchMode; /*!< Specifies the prefetch mode.
  59. This parameter can be a value of @ref QSPI_Prefetch_Mode */
  60. uint32_t u32ReadMode; /*!< Specifies the read mode.
  61. This parameter can be a value of @ref QSPI_Read_Mode */
  62. uint32_t u32DummyCycle; /*!< Specifies the number of dummy cycles.
  63. This parameter can be a value of @ref QSPI_Dummy_Cycle */
  64. uint32_t u32AddrWidth; /*!< Specifies the address width.
  65. This parameter can be a value of @ref QSPI_Addr_Width */
  66. uint32_t u32SetupTime; /*!< Specifies the advance time of QSSN setup.
  67. This parameter can be a value of @ref QSPI_QSSN_Setup_Time */
  68. uint32_t u32ReleaseTime; /*!< Specifies the delay time of QSSN release.
  69. This parameter can be a value of @ref QSPI_QSSN_Release_Time */
  70. uint32_t u32IntervalTime; /*!< Specifies the minimum interval time of QSSN.
  71. This parameter can be a value of @ref QSPI_QSSN_Interval_Time */
  72. } stc_qspi_init_t;
  73. /**
  74. * @brief QSPI Custom read mode structure definition
  75. */
  76. typedef struct {
  77. uint32_t u32InstrProtocol; /*!< Specifies the instruction stage protocol.
  78. This parameter can be a value of @ref QSPI_Instruction_Protocol */
  79. uint32_t u32AddrProtocol; /*!< Specifies the address stage protocol.
  80. This parameter can be a value of @ref QSPI_Addr_Protocol */
  81. uint32_t u32DataProtocol; /*!< Specifies the data stage protocol.
  82. This parameter can be a value of @ref QSPI_Data_Protocol */
  83. uint8_t u8InstrCode; /*!< Specifies the instruction code in custom read mode.
  84. This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFF */
  85. } stc_qspi_custom_mode_t;
  86. /**
  87. * @}
  88. */
  89. /*******************************************************************************
  90. * Global pre-processor symbols/macros ('#define')
  91. ******************************************************************************/
  92. /**
  93. * @defgroup QSPI_Global_Macros QSPI Global Macros
  94. * @{
  95. */
  96. /* QSPI memory mapping base and end address */
  97. #define QSPI_ROM_BASE (0x98000000UL)
  98. #define QSPI_ROM_END (0x9BFFFFFFUL)
  99. /**
  100. * @defgroup QSPI_Clock_Division QSPI Clock Division
  101. * @{
  102. */
  103. #define QSPI_CLK_DIV2 (0x01UL << QSPI_CR_DIV_POS) /*!< Clock division by 2 */
  104. #define QSPI_CLK_DIV3 (0x02UL << QSPI_CR_DIV_POS) /*!< Clock division by 3 */
  105. #define QSPI_CLK_DIV4 (0x03UL << QSPI_CR_DIV_POS) /*!< Clock division by 4 */
  106. #define QSPI_CLK_DIV5 (0x04UL << QSPI_CR_DIV_POS) /*!< Clock division by 5 */
  107. #define QSPI_CLK_DIV6 (0x05UL << QSPI_CR_DIV_POS) /*!< Clock division by 6 */
  108. #define QSPI_CLK_DIV7 (0x06UL << QSPI_CR_DIV_POS) /*!< Clock division by 7 */
  109. #define QSPI_CLK_DIV8 (0x07UL << QSPI_CR_DIV_POS) /*!< Clock division by 8 */
  110. #define QSPI_CLK_DIV9 (0x08UL << QSPI_CR_DIV_POS) /*!< Clock division by 9 */
  111. #define QSPI_CLK_DIV10 (0x09UL << QSPI_CR_DIV_POS) /*!< Clock division by 10 */
  112. #define QSPI_CLK_DIV11 (0x0AUL << QSPI_CR_DIV_POS) /*!< Clock division by 11 */
  113. #define QSPI_CLK_DIV12 (0x0BUL << QSPI_CR_DIV_POS) /*!< Clock division by 12 */
  114. #define QSPI_CLK_DIV13 (0x0CUL << QSPI_CR_DIV_POS) /*!< Clock division by 13 */
  115. #define QSPI_CLK_DIV14 (0x0DUL << QSPI_CR_DIV_POS) /*!< Clock division by 14 */
  116. #define QSPI_CLK_DIV15 (0x0EUL << QSPI_CR_DIV_POS) /*!< Clock division by 15 */
  117. #define QSPI_CLK_DIV16 (0x0FUL << QSPI_CR_DIV_POS) /*!< Clock division by 16 */
  118. #define QSPI_CLK_DIV17 (0x10UL << QSPI_CR_DIV_POS) /*!< Clock division by 17 */
  119. #define QSPI_CLK_DIV18 (0x11UL << QSPI_CR_DIV_POS) /*!< Clock division by 18 */
  120. #define QSPI_CLK_DIV19 (0x12UL << QSPI_CR_DIV_POS) /*!< Clock division by 19 */
  121. #define QSPI_CLK_DIV20 (0x13UL << QSPI_CR_DIV_POS) /*!< Clock division by 20 */
  122. #define QSPI_CLK_DIV21 (0x14UL << QSPI_CR_DIV_POS) /*!< Clock division by 21 */
  123. #define QSPI_CLK_DIV22 (0x15UL << QSPI_CR_DIV_POS) /*!< Clock division by 22 */
  124. #define QSPI_CLK_DIV23 (0x16UL << QSPI_CR_DIV_POS) /*!< Clock division by 23 */
  125. #define QSPI_CLK_DIV24 (0x17UL << QSPI_CR_DIV_POS) /*!< Clock division by 24 */
  126. #define QSPI_CLK_DIV25 (0x18UL << QSPI_CR_DIV_POS) /*!< Clock division by 25 */
  127. #define QSPI_CLK_DIV26 (0x19UL << QSPI_CR_DIV_POS) /*!< Clock division by 26 */
  128. #define QSPI_CLK_DIV27 (0x1AUL << QSPI_CR_DIV_POS) /*!< Clock division by 27 */
  129. #define QSPI_CLK_DIV28 (0x1BUL << QSPI_CR_DIV_POS) /*!< Clock division by 28 */
  130. #define QSPI_CLK_DIV29 (0x1CUL << QSPI_CR_DIV_POS) /*!< Clock division by 29 */
  131. #define QSPI_CLK_DIV30 (0x1DUL << QSPI_CR_DIV_POS) /*!< Clock division by 30 */
  132. #define QSPI_CLK_DIV31 (0x1EUL << QSPI_CR_DIV_POS) /*!< Clock division by 31 */
  133. #define QSPI_CLK_DIV32 (0x1FUL << QSPI_CR_DIV_POS) /*!< Clock division by 32 */
  134. #define QSPI_CLK_DIV33 (0x20UL << QSPI_CR_DIV_POS) /*!< Clock division by 33 */
  135. #define QSPI_CLK_DIV34 (0x21UL << QSPI_CR_DIV_POS) /*!< Clock division by 34 */
  136. #define QSPI_CLK_DIV35 (0x22UL << QSPI_CR_DIV_POS) /*!< Clock division by 35 */
  137. #define QSPI_CLK_DIV36 (0x23UL << QSPI_CR_DIV_POS) /*!< Clock division by 36 */
  138. #define QSPI_CLK_DIV37 (0x24UL << QSPI_CR_DIV_POS) /*!< Clock division by 37 */
  139. #define QSPI_CLK_DIV38 (0x25UL << QSPI_CR_DIV_POS) /*!< Clock division by 38 */
  140. #define QSPI_CLK_DIV39 (0x26UL << QSPI_CR_DIV_POS) /*!< Clock division by 39 */
  141. #define QSPI_CLK_DIV40 (0x27UL << QSPI_CR_DIV_POS) /*!< Clock division by 40 */
  142. #define QSPI_CLK_DIV41 (0x28UL << QSPI_CR_DIV_POS) /*!< Clock division by 41 */
  143. #define QSPI_CLK_DIV42 (0x29UL << QSPI_CR_DIV_POS) /*!< Clock division by 42 */
  144. #define QSPI_CLK_DIV43 (0x2AUL << QSPI_CR_DIV_POS) /*!< Clock division by 43 */
  145. #define QSPI_CLK_DIV44 (0x2BUL << QSPI_CR_DIV_POS) /*!< Clock division by 44 */
  146. #define QSPI_CLK_DIV45 (0x2CUL << QSPI_CR_DIV_POS) /*!< Clock division by 45 */
  147. #define QSPI_CLK_DIV46 (0x2DUL << QSPI_CR_DIV_POS) /*!< Clock division by 46 */
  148. #define QSPI_CLK_DIV47 (0x2EUL << QSPI_CR_DIV_POS) /*!< Clock division by 47 */
  149. #define QSPI_CLK_DIV48 (0x2FUL << QSPI_CR_DIV_POS) /*!< Clock division by 48 */
  150. #define QSPI_CLK_DIV49 (0x30UL << QSPI_CR_DIV_POS) /*!< Clock division by 49 */
  151. #define QSPI_CLK_DIV50 (0x31UL << QSPI_CR_DIV_POS) /*!< Clock division by 50 */
  152. #define QSPI_CLK_DIV51 (0x32UL << QSPI_CR_DIV_POS) /*!< Clock division by 51 */
  153. #define QSPI_CLK_DIV52 (0x33UL << QSPI_CR_DIV_POS) /*!< Clock division by 52 */
  154. #define QSPI_CLK_DIV53 (0x34UL << QSPI_CR_DIV_POS) /*!< Clock division by 53 */
  155. #define QSPI_CLK_DIV54 (0x35UL << QSPI_CR_DIV_POS) /*!< Clock division by 54 */
  156. #define QSPI_CLK_DIV55 (0x36UL << QSPI_CR_DIV_POS) /*!< Clock division by 55 */
  157. #define QSPI_CLK_DIV56 (0x37UL << QSPI_CR_DIV_POS) /*!< Clock division by 56 */
  158. #define QSPI_CLK_DIV57 (0x38UL << QSPI_CR_DIV_POS) /*!< Clock division by 57 */
  159. #define QSPI_CLK_DIV58 (0x39UL << QSPI_CR_DIV_POS) /*!< Clock division by 58 */
  160. #define QSPI_CLK_DIV59 (0x3AUL << QSPI_CR_DIV_POS) /*!< Clock division by 59 */
  161. #define QSPI_CLK_DIV60 (0x3BUL << QSPI_CR_DIV_POS) /*!< Clock division by 60 */
  162. #define QSPI_CLK_DIV61 (0x3CUL << QSPI_CR_DIV_POS) /*!< Clock division by 61 */
  163. #define QSPI_CLK_DIV62 (0x3DUL << QSPI_CR_DIV_POS) /*!< Clock division by 62 */
  164. #define QSPI_CLK_DIV63 (0x3EUL << QSPI_CR_DIV_POS) /*!< Clock division by 63 */
  165. #define QSPI_CLK_DIV64 (0x3FUL << QSPI_CR_DIV_POS) /*!< Clock division by 64 */
  166. /**
  167. * @}
  168. */
  169. /**
  170. * @defgroup QSPI_SPI_Mode QSPI SPI Mode
  171. * @{
  172. */
  173. #define QSPI_SPI_MD0 (0UL) /*!< Selects SPI mode 0 */
  174. #define QSPI_SPI_MD3 (QSPI_CR_SPIMD3) /*!< Selects SPI mode 3 */
  175. /**
  176. * @}
  177. */
  178. /**
  179. * @defgroup QSPI_Prefetch_Mode QSPI Prefetch Mode
  180. * @{
  181. */
  182. #define QSPI_PREFETCH_MD_INVD (0UL) /*!< Disable prefetch */
  183. #define QSPI_PREFETCH_MD_EDGE_STOP (QSPI_CR_PFE) /*!< Stop prefetch at the edge of byte */
  184. #define QSPI_PREFETCH_MD_IMMED_STOP (QSPI_CR_PFE | QSPI_CR_PFSAE) /*!< Stop prefetch at current position immediately */
  185. /**
  186. * @}
  187. */
  188. /**
  189. * @defgroup QSPI_Read_Mode QSPI Read Mode
  190. * @{
  191. */
  192. #define QSPI_RD_MD_STD_RD (0UL) /*!< Standard read mode (no dummy cycles) */
  193. #define QSPI_RD_MD_FAST_RD (0x01UL << QSPI_CR_MDSEL_POS) /*!< Fast read mode (dummy cycles between address and data) */
  194. #define QSPI_RD_MD_DUAL_OUTPUT_FAST_RD (0x02UL << QSPI_CR_MDSEL_POS) /*!< Fast read dual output mode (data on 2 lines) */
  195. #define QSPI_RD_MD_DUAL_IO_FAST_RD (0x03UL << QSPI_CR_MDSEL_POS) /*!< Fast read dual I/O mode (address and data on 2 lines) */
  196. #define QSPI_RD_MD_QUAD_OUTPUT_FAST_RD (0x04UL << QSPI_CR_MDSEL_POS) /*!< Fast read quad output mode (data on 4 lines) */
  197. #define QSPI_RD_MD_QUAD_IO_FAST_RD (0x05UL << QSPI_CR_MDSEL_POS) /*!< Fast read quad I/O mode (address and data on 4 lines) */
  198. #define QSPI_RD_MD_CUSTOM_STANDARD_RD (0x06UL << QSPI_CR_MDSEL_POS) /*!< Custom standard read mode */
  199. #define QSPI_RD_MD_CUSTOM_FAST_RD (0x07UL << QSPI_CR_MDSEL_POS) /*!< Custom fast read mode */
  200. /**
  201. * @}
  202. */
  203. /**
  204. * @defgroup QSPI_Dummy_Cycle QSPI Dummy Cycle
  205. * @{
  206. */
  207. #define QSPI_DUMMY_CYCLE3 (0UL) /*!< Dummy cycle is 3 */
  208. #define QSPI_DUMMY_CYCLE4 (0x01UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 4 */
  209. #define QSPI_DUMMY_CYCLE5 (0x02UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 5 */
  210. #define QSPI_DUMMY_CYCLE6 (0x03UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 6 */
  211. #define QSPI_DUMMY_CYCLE7 (0x04UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 7 */
  212. #define QSPI_DUMMY_CYCLE8 (0x05UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 8 */
  213. #define QSPI_DUMMY_CYCLE9 (0x06UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 9 */
  214. #define QSPI_DUMMY_CYCLE10 (0x07UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 10 */
  215. #define QSPI_DUMMY_CYCLE11 (0x08UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 11 */
  216. #define QSPI_DUMMY_CYCLE12 (0x09UL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 12 */
  217. #define QSPI_DUMMY_CYCLE13 (0x0AUL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 13 */
  218. #define QSPI_DUMMY_CYCLE14 (0x0BUL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 14 */
  219. #define QSPI_DUMMY_CYCLE15 (0x0CUL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 15 */
  220. #define QSPI_DUMMY_CYCLE16 (0x0DUL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 16 */
  221. #define QSPI_DUMMY_CYCLE17 (0x0EUL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 15 */
  222. #define QSPI_DUMMY_CYCLE18 (0x0FUL << QSPI_FCR_DMCYCN_POS) /*!< Dummy cycle is 16 */
  223. /**
  224. * @}
  225. */
  226. /**
  227. * @defgroup QSPI_Addr_Width QSPI Address Width
  228. * @{
  229. */
  230. #define QSPI_ADDR_WIDTH_8BIT (0x0U) /*!< QSPI address width is 8 bits */
  231. #define QSPI_ADDR_WIDTH_16BIT (QSPI_FCR_AWSL_0) /*!< QSPI address width is 16 bits */
  232. #define QSPI_ADDR_WIDTH_24BIT (QSPI_FCR_AWSL_1) /*!< QSPI address width is 24 bits */
  233. #define QSPI_ADDR_WIDTH_32BIT_INSTR_24BIT (QSPI_FCR_AWSL) /*!< QSPI address width is 32 bits and don't use 4-byte address read instruction code */
  234. #define QSPI_ADDR_WIDTH_32BIT_INSTR_32BIT (QSPI_FCR_AWSL | QSPI_FCR_FOUR_BIC) /*!< QSPI address width is 32 bits and use 4-byte address read instruction code */
  235. /**
  236. * @}
  237. */
  238. /**
  239. * @defgroup QSPI_QSSN_Setup_Time QSPI QSSN Setup Time
  240. * @{
  241. */
  242. #define QSPI_QSSN_SETUP_ADVANCE_QSCK0P5 (0UL) /*!< Output QSSN signal 0.5 QSCK before the first rising edge of QSCK */
  243. #define QSPI_QSSN_SETUP_ADVANCE_QSCK1P5 (QSPI_FCR_SSNLD) /*!< Output QSSN signal 1.5 QSCK before the first rising edge of QSCK */
  244. /**
  245. * @}
  246. */
  247. /**
  248. * @defgroup QSPI_QSSN_Release_Time QSPI QSSN Release Time
  249. * @{
  250. */
  251. #define QSPI_QSSN_RELEASE_DELAY_QSCK0P5 (0UL) /*!< Release QSSN signal 0.5 QSCK after the last rising edge of QSCK */
  252. #define QSPI_QSSN_RELEASE_DELAY_QSCK1P5 (QSPI_FCR_SSNHD) /*!< Release QSSN signal 1.5 QSCK after the last rising edge of QSCK */
  253. #define QSPI_QSSN_RELEASE_DELAY_QSCK32 (QSPI_CSCR_SSNW_0 << 8U) /*!< Release QSSN signal 32 QSCK after the last rising edge of QSCK */
  254. #define QSPI_QSSN_RELEASE_DELAY_QSCK128 (QSPI_CSCR_SSNW_1 << 8U) /*!< Release QSSN signal 128 QSCK after the last rising edge of QSCK */
  255. #define QSPI_QSSN_RELEASE_DELAY_INFINITE (QSPI_CSCR_SSNW << 8U) /*!< Never release QSSN signal after the last rising edge of QSCK */
  256. /**
  257. * @}
  258. */
  259. /**
  260. * @defgroup QSPI_QSSN_Interval_Time QSPI QSSN Interval Time
  261. * @{
  262. */
  263. #define QSPI_QSSN_INTERVAL_QSCK1 (0UL) /*!< Minimum interval time is 1 QSCK */
  264. #define QSPI_QSSN_INTERVAL_QSCK2 (0x01UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 2 QSCK */
  265. #define QSPI_QSSN_INTERVAL_QSCK3 (0x02UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 3 QSCK */
  266. #define QSPI_QSSN_INTERVAL_QSCK4 (0x03UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 4 QSCK */
  267. #define QSPI_QSSN_INTERVAL_QSCK5 (0x04UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 5 QSCK */
  268. #define QSPI_QSSN_INTERVAL_QSCK6 (0x05UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 6 QSCK */
  269. #define QSPI_QSSN_INTERVAL_QSCK7 (0x06UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 7 QSCK */
  270. #define QSPI_QSSN_INTERVAL_QSCK8 (0x07UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 8 QSCK */
  271. #define QSPI_QSSN_INTERVAL_QSCK9 (0x08UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 9 QSCK */
  272. #define QSPI_QSSN_INTERVAL_QSCK10 (0x09UL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 10 QSCK */
  273. #define QSPI_QSSN_INTERVAL_QSCK11 (0x0AUL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 11 QSCK */
  274. #define QSPI_QSSN_INTERVAL_QSCK12 (0x0BUL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 12 QSCK */
  275. #define QSPI_QSSN_INTERVAL_QSCK13 (0x0CUL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 13 QSCK */
  276. #define QSPI_QSSN_INTERVAL_QSCK14 (0x0DUL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 14 QSCK */
  277. #define QSPI_QSSN_INTERVAL_QSCK15 (0x0EUL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 15 QSCK */
  278. #define QSPI_QSSN_INTERVAL_QSCK16 (0x0FUL << QSPI_CSCR_SSHW_POS) /*!< Minimum interval time is 16 QSCK */
  279. /**
  280. * @}
  281. */
  282. /**
  283. * @defgroup QSPI_Instruction_Protocol QSPI Instruction Protocol
  284. * @{
  285. */
  286. #define QSPI_INSTR_PROTOCOL_1LINE (0x0U) /*!< Instruction on 1 line */
  287. #define QSPI_INSTR_PROTOCOL_2LINE (QSPI_CR_IPRSL_0) /*!< Instruction on 2 lines */
  288. #define QSPI_INSTR_PROTOCOL_4LINE (QSPI_CR_IPRSL_1) /*!< Instruction on 4 lines */
  289. /**
  290. * @}
  291. */
  292. /**
  293. * @defgroup QSPI_Addr_Protocol QSPI Address Protocol
  294. * @{
  295. */
  296. #define QSPI_ADDR_PROTOCOL_1LINE (0x0U) /*!< Address on 1 line */
  297. #define QSPI_ADDR_PROTOCOL_2LINE (QSPI_CR_APRSL_0) /*!< Address on 2 lines */
  298. #define QSPI_ADDR_PROTOCOL_4LINE (QSPI_CR_APRSL_1) /*!< Address on 4 lines */
  299. /**
  300. * @}
  301. */
  302. /**
  303. * @defgroup QSPI_Data_Protocol QSPI Data Protocol
  304. * @{
  305. */
  306. #define QSPI_DATA_PROTOCOL_1LINE (0x0U) /*!< Data on 1 line */
  307. #define QSPI_DATA_PROTOCOL_2LINE (QSPI_CR_DPRSL_0) /*!< Data on 2 lines */
  308. #define QSPI_DATA_PROTOCOL_4LINE (QSPI_CR_DPRSL_1) /*!< Data on 4 lines */
  309. /**
  310. * @}
  311. */
  312. /**
  313. * @defgroup QSPI_WP_Pin_Level QSPI WP Pin Level
  314. * @{
  315. */
  316. #define QSPI_WP_PIN_LOW (0x0U) /*!< WP(QSIO2) pin output low */
  317. #define QSPI_WP_PIN_HIGH (QSPI_FCR_WPOL) /*!< WP(QSIO2) pin output high */
  318. /**
  319. * @}
  320. */
  321. /**
  322. * @defgroup QSPI_Direct_Comm_Protocol QSPI Direct Communication Protocol
  323. * @{
  324. */
  325. #define QSPI_DIRECT_COMM_PROTOCOL_1LINE (0x0U) /*!< Direct communication protocol on 1 line */
  326. #define QSPI_DIRECT_COMM_PROTOCOL_2LINE (QSPI_DCOM_DCOMPRSL_0) /*!< Direct communication protocol on 2 lines */
  327. #define QSPI_DIRECT_COMM_PROTOCOL_4LINE (QSPI_DCOM_DCOMPRSL_1) /*!< Direct communication protocol on 4 lines */
  328. /**
  329. * @}
  330. */
  331. /**
  332. * @defgroup QSPI_Status_Flag QSPI Status Flag
  333. * @{
  334. */
  335. #define QSPI_FLAG_DIRECT_COMM_BUSY (QSPI_SR_BUSY) /*!< Serial transfer being processed */
  336. #define QSPI_FLAG_XIP_MD (QSPI_SR_XIPF) /*!< XIP mode */
  337. #define QSPI_FLAG_ROM_ACCESS_ERR (QSPI_SR_RAER) /*!< ROM access detection status in direct communication mode */
  338. #define QSPI_FLAG_PREFETCH_BUF_FULL (QSPI_SR_PFFUL) /*!< Prefetch buffer is full */
  339. #define QSPI_FLAG_PREFETCH_STOP (QSPI_SR_PFAN) /*!< Prefetch function operating */
  340. #define QSPI_FLAG_ALL (QSPI_FLAG_DIRECT_COMM_BUSY | QSPI_FLAG_XIP_MD | \
  341. QSPI_FLAG_ROM_ACCESS_ERR | QSPI_FLAG_PREFETCH_BUF_FULL | \
  342. QSPI_FLAG_PREFETCH_STOP)
  343. #define QSPI_FLAG_CLR_ALL (QSPI_FLAG_ROM_ACCESS_ERR)
  344. /**
  345. * @}
  346. */
  347. /**
  348. * @}
  349. */
  350. /*******************************************************************************
  351. * Global variable definitions ('extern')
  352. ******************************************************************************/
  353. /*******************************************************************************
  354. Global function prototypes (definition in C source)
  355. ******************************************************************************/
  356. /**
  357. * @addtogroup QSPI_Global_Functions
  358. * @{
  359. */
  360. /**
  361. * @brief Read data in direct communication mode.
  362. * @param None
  363. * @retval uint8_t Byte data.
  364. */
  365. __STATIC_INLINE uint8_t QSPI_ReadDirectCommValue(void)
  366. {
  367. return (uint8_t)CM_QSPI->DCOM;
  368. }
  369. /* Initialization and configuration functions */
  370. void QSPI_DeInit(void);
  371. int32_t QSPI_Init(const stc_qspi_init_t *pstcQspiInit);
  372. int32_t QSPI_StructInit(stc_qspi_init_t *pstcQspiInit);
  373. void QSPI_SetWpPinLevel(uint32_t u32Level);
  374. void QSPI_SetPrefetchMode(uint32_t u32Mode);
  375. void QSPI_SelectMemoryBlock(uint8_t u8Block);
  376. void QSPI_SetReadMode(uint32_t u32Mode);
  377. int32_t QSPI_CustomReadConfig(const stc_qspi_custom_mode_t *pstcCustomMode);
  378. void QSPI_XipModeCmd(uint8_t u8ModeCode, en_functional_state_t enNewState);
  379. /* Transfer and receive data functions */
  380. void QSPI_EnterDirectCommMode(void);
  381. void QSPI_ExitDirectCommMode(void);
  382. void QSPI_WriteDirectCommValue(uint32_t u32Protocol, uint8_t u8Value);
  383. uint8_t QSPI_ReadDirectCommValue(void);
  384. /* Interrupt and flag management functions */
  385. uint8_t QSPI_GetPrefetchBufSize(void);
  386. en_flag_status_t QSPI_GetStatus(uint32_t u32Flag);
  387. void QSPI_ClearStatus(uint32_t u32Flag);
  388. /**
  389. * @}
  390. */
  391. #endif /* LL_QSPI_ENABLE */
  392. /**
  393. * @}
  394. */
  395. /**
  396. * @}
  397. */
  398. #ifdef __cplusplus
  399. }
  400. #endif
  401. #endif /* __HC32_LL_QSPI_H__ */
  402. /*******************************************************************************
  403. * EOF (not truncated)
  404. ******************************************************************************/