ql_api_spi_nor_flash.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /** @file
  2. ql_api_spi_nor_flash.h
  3. @brief
  4. This file is used to define bt 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_API_SPI_NOR_FLASH_H
  18. #define QL_API_SPI_NOR_FLASH_H
  19. #include "ql_api_common.h"
  20. #include "ql_api_spi.h"
  21. #include "ql_api_spi_flash.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /*========================================================================
  26. * Variable Definition
  27. *========================================================================*/
  28. /**************************** error code about ql spi nor flash ***************************/
  29. typedef ql_errcode_spi_flash_e ql_errcode_spi_nor_e ;
  30. typedef ql_spi_flash_config_s ql_spi_nor_config_s ;
  31. /*========================================================================
  32. * function Definition
  33. *========================================================================*/
  34. /*****************************************************************
  35. * Function: ql_spi_nor_init
  36. *
  37. * Description:
  38. * 初始化NOR FLASH
  39. *
  40. * Parameters:
  41. * port [in] SPI总线选择
  42. * spiclk [in] SPI时钟选择
  43. *
  44. * Return:ql_errcode_spi_nor_e
  45. *
  46. *****************************************************************/
  47. ql_errcode_spi_nor_e ql_spi_nor_init(ql_spi_port_e port, ql_spi_clk_e spiclk);
  48. /*****************************************************************
  49. * Function: ql_spi_nor_init_ext
  50. *
  51. * Description:
  52. * 扩展初始化NOR FLASH,与ql_spi_nor_init有更多的设置选项
  53. *
  54. * Parameters:
  55. * nor_config [in] SPI配置参数
  56. *
  57. * Return:ql_errcode_spi_nor_e
  58. *
  59. *****************************************************************/
  60. ql_errcode_spi_nor_e ql_spi_nor_init_ext(ql_spi_nor_config_s nor_config);
  61. /*****************************************************************
  62. * Function: ql_spi_nor_write_8bit_status
  63. *
  64. * Description:
  65. * 写8bit的状态寄存器
  66. *
  67. * Parameters:
  68. * port [in] SPI总线选择
  69. * status [in] 设置状态寄存器的值
  70. *
  71. * Return:ql_errcode_spi_nor_e
  72. *
  73. *****************************************************************/
  74. ql_errcode_spi_nor_e ql_spi_nor_write_8bit_status(ql_spi_port_e port, unsigned char status);
  75. /*****************************************************************
  76. * Function: ql_spi_nor_write_16bit_status
  77. *
  78. * Description:
  79. * 写16bit的状态寄存器
  80. *
  81. * Parameters:
  82. * port [in] SPI总线选择
  83. * status [in] 设置状态寄存器的值
  84. *
  85. * Return:ql_errcode_spi_nor_e
  86. *
  87. *****************************************************************/
  88. ql_errcode_spi_nor_e ql_spi_nor_write_16bit_status(ql_spi_port_e port, unsigned short status);
  89. /*****************************************************************
  90. * Function: ql_spi_nor_read_status_low
  91. *
  92. * Description:
  93. * 读状态寄存器的低8bit
  94. *
  95. * Parameters:
  96. * port [in] SPI总线选择
  97. * status [out] 读取状态寄存器的值
  98. *
  99. * Return:ql_errcode_spi_nor_e
  100. *
  101. *****************************************************************/
  102. ql_errcode_spi_nor_e ql_spi_nor_read_status_low(ql_spi_port_e port, unsigned char *status);
  103. /*****************************************************************
  104. * Function: ql_spi_nor_read_status_high
  105. *
  106. * Description:
  107. * 读状态寄存器的高8bit
  108. *
  109. * Parameters:
  110. * port [in] SPI总线选择
  111. * status [out] 读取状态寄存器的值
  112. *
  113. * Return:ql_errcode_spi_nor_e
  114. *
  115. *****************************************************************/
  116. ql_errcode_spi_nor_e ql_spi_nor_read_status_high(ql_spi_port_e port, unsigned char *status);
  117. /*****************************************************************
  118. * Function: ql_spi_nor_read
  119. *
  120. * Description:
  121. * 从NOR FLASH芯片读数据
  122. *
  123. * Parameters:
  124. * port [in] SPI总线选择
  125. * data [out] 读取数据的缓存
  126. * addr [in] 读取数据地址
  127. * len [in] 读取数据长度
  128. *
  129. * Return:ql_errcode_spi_nor_e
  130. *
  131. *****************************************************************/
  132. ql_errcode_spi_nor_e ql_spi_nor_read(ql_spi_port_e port, unsigned char* data, unsigned int addr, unsigned short len);
  133. /*****************************************************************
  134. * Function: ql_spi_nor_write
  135. *
  136. * Description:
  137. * 写数据到NOR FLASH芯片
  138. *
  139. * Parameters:
  140. * port [in] SPI总线选择
  141. * data [in] 写入数据的缓存
  142. * addr [in] 写入数据地址
  143. * len [in] 写入数据长度
  144. *
  145. * Return:ql_errcode_spi_nor_e
  146. *
  147. *****************************************************************/
  148. ql_errcode_spi_nor_e ql_spi_nor_write(ql_spi_port_e port, unsigned char *data, unsigned int addr, unsigned short len);
  149. /*****************************************************************
  150. * Function: ql_spi_nor_erase_chip
  151. *
  152. * Description:
  153. * 擦除整个NOR FLASH芯片的数据
  154. *
  155. * Parameters:
  156. * port [in] SPI总线选择
  157. *
  158. * Return:ql_errcode_spi_nor_e
  159. *
  160. *****************************************************************/
  161. ql_errcode_spi_nor_e ql_spi_nor_erase_chip(ql_spi_port_e port);
  162. /*****************************************************************
  163. * Function: ql_spi_nor_erase_sector
  164. *
  165. * Description:
  166. * 擦除NOR FLASH数据,4K大小
  167. *
  168. * Parameters:
  169. * port [in] SPI总线选择
  170. * addr [in] 擦除数据地址
  171. *
  172. * Return:ql_errcode_spi_nor_e
  173. *
  174. *****************************************************************/
  175. ql_errcode_spi_nor_e ql_spi_nor_erase_sector(ql_spi_port_e port, unsigned int addr);
  176. /*****************************************************************
  177. * Function: ql_spi_nor_erase_64k_block
  178. *
  179. * Description:
  180. * 擦除NOR FLASH数据,64K大小
  181. *
  182. * Parameters:
  183. * port [in] SPI总线选择
  184. * addr [in] 擦除数据地址
  185. *
  186. * Return:ql_errcode_spi_nor_e
  187. *
  188. *****************************************************************/
  189. ql_errcode_spi_nor_e ql_spi_nor_erase_64k_block(ql_spi_port_e port, unsigned int addr);
  190. #ifdef __cplusplus
  191. } /*"C" */
  192. #endif
  193. #endif /* QL_API_SPI_NOR_FLASH_H */