ql_spi6_nor_flash.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /** @file
  2. ql_embed_nor_flash.h
  3. @brief
  4. This file is used to define embed_nor flash interface 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. 07/06/2021 Mahat Init version
  17. 20/05/2022 Sum update
  18. =================================================================*/
  19. /*=================================================================
  20. READ ME
  21. API能够直接读写位于内置NorFlash或者外置NorFlash中用户新增的自定义flash分区,
  22. 并判断读写地址的合法性,请确保读写区域在分区文件中已经被预留并定义,否则将返回失败
  23. 定义预留的flash分区时,分区的地址和大小必须为4K对齐。
  24. 用户需在 components\ql-config\build\EXX00GXX_XX\8850XX_cat1_open\target.config
  25. 文件中添加 CONFIG_QUEC_PROJECT_FEATURE_EMBED_NOR_FLASH=y 或者
  26. CONFIG_QUEC_PROJECT_FEATURE_EXT_NOR_SFFS_MOUNT=n启用此功能
  27. 其中EXX00GXX_XX指代用户需要的实际型号
  28. =================================================================*/
  29. #ifndef QL_SPI6_NOR_FLASH_H
  30. #define QL_SPI6_NOR_FLASH_H
  31. #include "ql_api_common.h"
  32. #include <stdlib.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #define QL_EMBED_NOR_FLASH_ERRCODE_BASE (QL_COMPONENT_STORAGE_EMBED_NOR_FLASH<<16)
  37. typedef enum
  38. {
  39. QL_SPI6_NOR_FLASH_SUCCESS = QL_SUCCESS,
  40. QL_SPI6_NOR_FLASH_WRITE_ERR = 1|QL_EMBED_NOR_FLASH_ERRCODE_BASE,
  41. QL_SPI6_NOR_FLASH_READ_ERR,
  42. QL_SPI6_NOR_FLASH_ERASE_ERR,
  43. QL_SPI6_NOR_FLASH_OPERATE_ERR,
  44. QL_SPI6_NOR_FLASH_ADDRESS_ERR,
  45. QL_SPI6_NOR_FLASH_NAME_ERR,
  46. QL_EMBED_NOR_FLASH_SUCCESS = QL_SPI6_NOR_FLASH_SUCCESS,
  47. QL_EMBED_NOR_FLASH_WRITE_ERR = QL_SPI6_NOR_FLASH_WRITE_ERR,
  48. QL_EMBED_NOR_FLASH_READ_ERR = QL_SPI6_NOR_FLASH_READ_ERR,
  49. QL_EMBED_NOR_FLASH_ERASE_ERR = QL_SPI6_NOR_FLASH_ERASE_ERR,
  50. QL_EMBED_NOR_FLASH_OPERATE_ERR = QL_SPI6_NOR_FLASH_OPERATE_ERR,
  51. QL_EMBED_NOR_FLASH_ADDRESS_ERR = QL_SPI6_NOR_FLASH_ADDRESS_ERR,
  52. QL_EMBED_NOR_FLASH_NAME_ERR = QL_SPI6_NOR_FLASH_NAME_ERR,
  53. }ql_spi6_nor_flash_e;
  54. /*****************************************************************
  55. * Function: ql_spi6_nor_flash_write
  56. * Description: spi6 nor flash write data
  57. * This will just use flash PROGRAM command to write. Caller should ensure
  58. * the write sector or block is erased before. Otherwise, the data on
  59. * flash may be different from the input data.
  60. * Parameters:
  61. * write_addr [in] write address
  62. * data [in] write data
  63. * size [in] the size of write data
  64. *
  65. * Return:
  66. * success:QL_SPI6_NOR_FLASH_SUCCESS
  67. * failed: OTHER
  68. *****************************************************************/
  69. ql_spi6_nor_flash_e ql_spi6_nor_flash_write(uint32 name,uint32 write_addr,void *data,size_t size);
  70. /*****************************************************************
  71. * Function: ql_spi6_nor_flash_read
  72. * Description: spi6 nor flash read data
  73. * Parameters:
  74. * read_addr [in] read address
  75. * data [in] read data
  76. * size [in] the size of read data
  77. *
  78. * Return:
  79. * success:QL_SPI6_NOR_FLASH_SUCCESS
  80. * failed: OTHER
  81. *****************************************************************/
  82. ql_spi6_nor_flash_e ql_spi6_nor_flash_read(uint32 name,uint32 read_addr,void *data,size_t size);
  83. /*****************************************************************
  84. * Function: ql_spi6_nor_flash_erase
  85. *
  86. * Description: erase spi6 nor flash,
  87. * Both erase_addr and size must be sector (4KB) aligned.
  88. * Parameters:
  89. * erase_addr [in] erase address
  90. * size [in] the size of erase
  91. *
  92. * Return:
  93. * success:QL_SPI6_NOR_FLASH_SUCCESS
  94. * failed: OTHER
  95. *****************************************************************/
  96. ql_spi6_nor_flash_e ql_spi6_nor_flash_erase(uint32 name,uint32 erase_addr,size_t size);
  97. #ifdef __cplusplus
  98. } /*"C" */
  99. #endif
  100. #endif