ql_embed_nor_flash.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. =================================================================*/
  18. /*=================================================================
  19. READ ME
  20. API能够直接读写位于内置NorFlash中用户新增的自定义flash分区,
  21. 并判断读写地址的合法性,请确保读写区域在分区文件中已经被预留并定义,否则将返回失败
  22. 定义预留的flash分区时,分区的地址和大小必须为4K对齐。
  23. 用户需在 components\ql-config\build\EXX00GXX_XX\8850XX_cat1_open\target.config
  24. 文件中添加 CONFIG_QUEC_PROJECT_FEATURE_EMBED_NOR_FLASH=y 启用此功能
  25. 其中EXX00GXX_XX指代用户需要的实际型号
  26. =================================================================*/
  27. #ifndef QL_EMBED_NOR_RESERVED_FLASH_H
  28. #define QL_EMBED_NOR_RESERVED_FLASH_H
  29. #include "ql_api_common.h"
  30. #include <stdlib.h>
  31. #include "drv_names.h"
  32. #include "ql_spi6_nor_flash.h"
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. typedef ql_spi6_nor_flash_e ql_embed_nor_flash_e;
  37. /*****************************************************************
  38. * Function: ql_embed_nor_flash_write
  39. * Description: embed nor flash write data
  40. * This will just use flash PROGRAM command to write. Caller should ensure
  41. * the write sector or block is erased before. Otherwise, the data on
  42. * flash may be different from the input data.
  43. * Parameters:
  44. * write_addr [in] write address
  45. * data [in] write data
  46. * size [in] the size of write data
  47. *
  48. * Return:
  49. * success:QL_EMBED_NOR_FLASH_SUCCESS
  50. * failed: OTHER
  51. *****************************************************************/
  52. #define ql_embed_nor_flash_write(write_addr,data,size) ql_spi6_nor_flash_write(DRV_NAME_SPI_FLASH, write_addr, data, size);
  53. /*****************************************************************
  54. * Function: ql_embed_nor_flash_read
  55. * Description: embed nor flash read data
  56. * Parameters:
  57. * read_addr [in] read address
  58. * data [in] read data
  59. * size [in] the size of read data
  60. *
  61. * Return:
  62. * success:QL_EMBED_NOR_FLASH_SUCCESS
  63. * failed: OTHER
  64. *****************************************************************/
  65. #define ql_embed_nor_flash_read(read_addr,data,size) ql_spi6_nor_flash_read(DRV_NAME_SPI_FLASH, read_addr, data, size);
  66. /*****************************************************************
  67. * Function: ql_embed_nor_flash_erase
  68. *
  69. * Description: erase embed nor flash,
  70. * Both erase_addr and size must be sector (4KB) aligned.
  71. * Parameters:
  72. * erase_addr [in] erase address
  73. * size [in] the size of erase
  74. *
  75. * Return:
  76. * success:QL_EMBED_NOR_FLASH_SUCCESS
  77. * failed: OTHER
  78. *****************************************************************/
  79. #define ql_embed_nor_flash_erase(erase_addr,size) ql_spi6_nor_flash_erase(DRV_NAME_SPI_FLASH, erase_addr, size);
  80. #ifdef __cplusplus
  81. } /*"C" */
  82. #endif
  83. #endif