ql_boot_spi4_nor_flash.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /** @file
  2. ql_boot_spi_nor_flash.h
  3. @brief
  4. This file is used to define boot spi4 nor flash api for different Quectel Project.
  5. */
  6. /*================================================================
  7. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  8. Quectel Wireless Solution Proprietary and Confidential.
  9. =================================================================*/
  10. /*=================================================================
  11. EDIT HISTORY FOR MODULE
  12. This section contains comments describing changes made to the module.
  13. Notice that changes are listed in reverse chronological order.
  14. WHEN WHO WHAT, WHERE, WHY
  15. ------------ ------- -------------------------------------------------------------------------------
  16. =================================================================*/
  17. #ifndef QL_BOOT_SPI4_NOR_FLASH_H
  18. #define QL_BOOT_SPI4_NOR_FLASH_H
  19. #include "quec_boot_spi.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*========================================================================
  24. * Variable Definition
  25. *========================================================================*/
  26. /**************************** error code about ql boot spi nor flash ***************************/
  27. typedef ql_boot_spi_flash_config_s ql_boot_spi_nor_config_s ;
  28. /*========================================================================
  29. * function Definition
  30. *========================================================================*/
  31. /*****************************************************************
  32. * Function: ql_boot_spi_nor_init
  33. *
  34. * Description:
  35. * 初始化NOR FLASH
  36. *
  37. * Parameters:
  38. * port [in] SPI总线选择
  39. * spiclk [in] SPI时钟选择
  40. *
  41. * Return:ql_boot_errcode_spi_e
  42. *
  43. *****************************************************************/
  44. ql_boot_errcode_spi_e ql_boot_spi_nor_init(ql_boot_spi_port_e port, ql_boot_spi_clk_e spiclk);
  45. /*****************************************************************
  46. * Function: ql_boot_spi_nor_init_ext
  47. *
  48. * Description:
  49. * 扩展初始化NOR FLASH,与ql_boot_spi_nor_init有更多的设置选项
  50. *
  51. * Parameters:
  52. * nor_config [in] SPI配置参数
  53. *
  54. * Return:ql_boot_errcode_spi_e
  55. *
  56. *****************************************************************/
  57. ql_boot_errcode_spi_e ql_boot_spi_nor_init_ext(ql_boot_spi_nor_config_s nor_config);
  58. /*****************************************************************
  59. * Function: ql_boot_spi_nor_write_8bit_status
  60. *
  61. * Description:
  62. * 写8bit的状态寄存器
  63. *
  64. * Parameters:
  65. * port [in] SPI总线选择
  66. * status [in] 设置状态寄存器的值
  67. *
  68. * Return:ql_boot_errcode_spi_e
  69. *
  70. *****************************************************************/
  71. ql_boot_errcode_spi_e ql_boot_spi_nor_write_8bit_status(ql_boot_spi_port_e port, unsigned char status);
  72. /*****************************************************************
  73. * Function: ql_boot_spi_nor_write_16bit_status
  74. *
  75. * Description:
  76. * 写16bit的状态寄存器
  77. *
  78. * Parameters:
  79. * port [in] SPI总线选择
  80. * status [in] 设置状态寄存器的值
  81. *
  82. * Return:ql_boot_errcode_spi_e
  83. *
  84. *****************************************************************/
  85. ql_boot_errcode_spi_e ql_boot_spi_nor_write_16bit_status(ql_boot_spi_port_e port, unsigned short status);
  86. /*****************************************************************
  87. * Function: ql_boot_spi_nor_read_status_low
  88. *
  89. * Description:
  90. * 读状态寄存器的低8bit
  91. *
  92. * Parameters:
  93. * port [in] SPI总线选择
  94. * status [out] 读取状态寄存器的值
  95. *
  96. * Return:ql_boot_errcode_spi_e
  97. *
  98. *****************************************************************/
  99. ql_boot_errcode_spi_e ql_boot_spi_nor_read_status_low(ql_boot_spi_port_e port, unsigned char *status);
  100. /*****************************************************************
  101. * Function: ql_boot_spi_nor_read_status_high
  102. *
  103. * Description:
  104. * 读状态寄存器的高8bit
  105. *
  106. * Parameters:
  107. * port [in] SPI总线选择
  108. * status [out] 读取状态寄存器的值
  109. *
  110. * Return:ql_boot_errcode_spi_e
  111. *
  112. *****************************************************************/
  113. ql_boot_errcode_spi_e ql_boot_spi_nor_read_status_high(ql_boot_spi_port_e port, unsigned char *status);
  114. /*****************************************************************
  115. * Function: ql_boot_spi_nor_read
  116. *
  117. * Description:
  118. * 从NOR FLASH芯片读数据
  119. *
  120. * Parameters:
  121. * port [in] SPI总线选择
  122. * data [out] 读取数据的缓存
  123. * addr [in] 读取数据地址
  124. * len [in] 读取数据长度
  125. *
  126. * Return:ql_boot_errcode_spi_e
  127. *
  128. *****************************************************************/
  129. ql_boot_errcode_spi_e ql_boot_spi_nor_read(ql_boot_spi_port_e port, unsigned char* data, unsigned int addr, unsigned short len);
  130. /*****************************************************************
  131. * Function: ql_boot_spi_nor_write
  132. *
  133. * Description:
  134. * 写数据到NOR FLASH芯片
  135. *
  136. * Parameters:
  137. * port [in] SPI总线选择
  138. * data [in] 写入数据的缓存
  139. * addr [in] 写入数据地址
  140. * len [in] 写入数据长度
  141. *
  142. * Return:ql_boot_errcode_spi_e
  143. *
  144. *****************************************************************/
  145. ql_boot_errcode_spi_e ql_boot_spi_nor_write(ql_boot_spi_port_e port, unsigned char *data, unsigned int addr, unsigned short len);
  146. /*****************************************************************
  147. * Function: ql_boot_spi_nor_erase_chip
  148. *
  149. * Description:
  150. * 擦除整个NOR FLASH芯片的数据
  151. *
  152. * Parameters:
  153. * port [in] SPI总线选择
  154. *
  155. * Return:ql_boot_errcode_spi_e
  156. *
  157. *****************************************************************/
  158. ql_boot_errcode_spi_e ql_boot_spi_nor_erase_chip(ql_boot_spi_port_e port);
  159. /*****************************************************************
  160. * Function: ql_boot_spi_nor_erase_sector
  161. *
  162. * Description:
  163. * 擦除NOR FLASH数据,4K大小
  164. *
  165. * Parameters:
  166. * port [in] SPI总线选择
  167. * addr [in] 擦除数据地址
  168. *
  169. * Return:ql_boot_errcode_spi_e
  170. *
  171. *****************************************************************/
  172. ql_boot_errcode_spi_e ql_boot_spi_nor_erase_sector(ql_boot_spi_port_e port, unsigned int addr);
  173. /*****************************************************************
  174. * Function: ql_boot_spi_nor_erase_64k_block
  175. *
  176. * Description:
  177. * 擦除NOR FLASH数据,64K大小
  178. *
  179. * Parameters:
  180. * port [in] SPI总线选择
  181. * addr [in] 擦除数据地址
  182. *
  183. * Return:ql_boot_errcode_spi_e
  184. *
  185. *****************************************************************/
  186. ql_boot_errcode_spi_e ql_boot_spi_nor_erase_64k_block(ql_boot_spi_port_e port, unsigned int addr);
  187. #ifdef __cplusplus
  188. } /*"C" */
  189. #endif
  190. #endif /* QL_API_SPI_NOR_FLASH_H */