dev_sflash.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-05-06 onelife Initial creation by using USART module
  9. */
  10. #ifndef __DEV_SFLASH_H__
  11. #define __DEV_SFLASH_H__
  12. /* Includes ------------------------------------------------------------------*/
  13. /* Exported types ------------------------------------------------------------*/
  14. enum sflash_inst_type_t
  15. {
  16. /* Instruction only */
  17. sflash_inst_wren = 0x00,
  18. sflash_inst_wrdi,
  19. sflash_inst_rdid_l,
  20. sflash_inst_rdid_s,
  21. sflash_inst_rdsr,
  22. sflash_inst_wrsr,
  23. sflash_inst_be,
  24. sflash_inst_dp,
  25. sflash_inst_rdp,
  26. /* Instruction and address */
  27. sflash_inst_wrlr,
  28. sflash_inst_rdlr,
  29. sflash_inst_read,
  30. sflash_inst_potp,
  31. sflash_inst_pp,
  32. sflash_inst_difp,
  33. sflash_inst_sse,
  34. sflash_inst_se,
  35. /* Instruction, address and dummy read */
  36. sflash_inst_read_f,
  37. sflash_inst_dofr,
  38. sflash_inst_rotp
  39. };
  40. /* Exported constants --------------------------------------------------------*/
  41. /* Exported macro ------------------------------------------------------------*/
  42. #define SFLASH_SPI_COMMAND_SKIP (1)
  43. #define SFLASH_SPI_READ_SKIP (2)
  44. #define SFLASH_INST_CODE_WREN (0x06)
  45. #define SFLASH_INST_CODE_WRDI (0x04)
  46. #define SFLASH_INST_CODE_RDID_L (0x9F)
  47. #define SFLASH_INST_CODE_RDID_S (0x9E)
  48. #define SFLASH_INST_CODE_RDSR (0x05)
  49. #define SFLASH_INST_CODE_WRSR (0x01)
  50. #define SFLASH_INST_CODE_WRLR (0xE5)
  51. #define SFLASH_INST_CODE_RDLR (0xE8)
  52. #define SFLASH_INST_CODE_READ (0x03)
  53. #define SFLASH_INST_CODE_READ_F (0x0B)
  54. #define SFLASH_INST_CODE_DOFR (0x3B)
  55. #define SFLASH_INST_CODE_ROTP (0x4B)
  56. #define SFLASH_INST_CODE_POTP (0x42)
  57. #define SFLASH_INST_CODE_PP (0x02)
  58. #define SFLASH_INST_CODE_DIFP (0xA2)
  59. #define SFLASH_INST_CODE_SSE (0x20)
  60. #define SFLASH_INST_CODE_SE (0xD8)
  61. #define SFLASH_INST_CODE_BE (0xC7)
  62. #define SFLASH_INST_CODE_DP (0xB9)
  63. #define SFLASH_INST_CODE_RDP (0xAB)
  64. #define SFLASH_REPLY_LEN_WREN (0)
  65. #define SFLASH_REPLY_LEN_WRDI (0)
  66. #define SFLASH_REPLY_LEN_RDID_L (20)
  67. #define SFLASH_REPLY_LEN_RDID_S (3)
  68. #define SFLASH_REPLY_LEN_RDSR (1)
  69. #define SFLASH_REPLY_LEN_WRSR (1)
  70. #define SFLASH_REPLY_LEN_WRLR (1)
  71. #define SFLASH_REPLY_LEN_RDLR (1)
  72. #define SFLASH_REPLY_LEN_READ (-1)
  73. #define SFLASH_REPLY_LEN_READ_F (-1)
  74. #define SFLASH_REPLY_LEN_DOFR (-1)
  75. #define SFLASH_REPLY_LEN_ROTP (65)
  76. #define SFLASH_REPLY_LEN_POTP (65)
  77. #define SFLASH_REPLY_LEN_PP (256)
  78. #define SFLASH_REPLY_LEN_DIFP (256)
  79. #define SFLASH_REPLY_LEN_SSE (0)
  80. #define SFLASH_REPLY_LEN_SE (0)
  81. #define SFLASH_REPLY_LEN_BE (0)
  82. #define SFLASH_REPLY_LEN_DP (0)
  83. #define SFLASH_REPLY_LEN_RDP (0)
  84. /* Exported functions ------------------------------------------------------- */
  85. rt_err_t efm_spiFlash_init(void);
  86. rt_err_t efm_spiFlash_deinit(void);
  87. rt_uint32_t efm_spiFlash_cmd(
  88. enum sflash_inst_type_t command,
  89. rt_uint32_t address,
  90. rt_uint8_t *buffer,
  91. rt_uint32_t size);
  92. #endif /* __DEV_SFLASH_H__ */