dev_sflash.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /******************************************************************//**
  2. * @file dev_sflash.h
  3. * @brief SPI Flash driver of RT-Thread RTOS for using EFM32 USART module
  4. * This driver is tested by using the M25PX16 device on the EFM32 development kit.
  5. * COPYRIGHT (C) 2011, RT-Thread Development Team
  6. * @author onelife
  7. * @version 0.4 beta
  8. **********************************************************************
  9. * @section License
  10. * The license and distribution terms for this file may be found in the file LICENSE in this
  11. * distribution or at http://www.rt-thread.org/license/LICENSE
  12. **********************************************************************
  13. * @section Change Logs
  14. * Date Author Notes
  15. * 2010-05-06 onelife Initial creation for using EFM32 USART module
  16. *********************************************************************/
  17. #ifndef __DEV_SFLASH_H__
  18. #define __DEV_SFLASH_H__
  19. /* Includes -------------------------------------------------------------------*/
  20. /* Exported types -------------------------------------------------------------*/
  21. enum sflash_inst_type_t
  22. {
  23. /* Instruction only */
  24. sflash_inst_wren = 0x00,
  25. sflash_inst_wrdi,
  26. sflash_inst_rdid_l,
  27. sflash_inst_rdid_s,
  28. sflash_inst_rdsr,
  29. sflash_inst_wrsr,
  30. sflash_inst_be,
  31. sflash_inst_dp,
  32. sflash_inst_rdp,
  33. /* Instruction and address */
  34. sflash_inst_wrlr,
  35. sflash_inst_rdlr,
  36. sflash_inst_read,
  37. sflash_inst_potp,
  38. sflash_inst_pp,
  39. sflash_inst_difp,
  40. sflash_inst_sse,
  41. sflash_inst_se,
  42. /* Instruction, address and dummy read */
  43. sflash_inst_read_f,
  44. sflash_inst_dofr,
  45. sflash_inst_rotp
  46. };
  47. /* Exported constants ---------------------------------------------------------*/
  48. /* Exported macro -------------------------------------------------------------*/
  49. #define SFLASH_INST_CODE_WREN (0x06)
  50. #define SFLASH_INST_CODE_WRDI (0x04)
  51. #define SFLASH_INST_CODE_RDID_L (0x9F)
  52. #define SFLASH_INST_CODE_RDID_S (0x9E)
  53. #define SFLASH_INST_CODE_RDSR (0x05)
  54. #define SFLASH_INST_CODE_WRSR (0x01)
  55. #define SFLASH_INST_CODE_WRLR (0xE5)
  56. #define SFLASH_INST_CODE_RDLR (0xE8)
  57. #define SFLASH_INST_CODE_READ (0x03)
  58. #define SFLASH_INST_CODE_READ_F (0x0B)
  59. #define SFLASH_INST_CODE_DOFR (0x3B)
  60. #define SFLASH_INST_CODE_ROTP (0x4B)
  61. #define SFLASH_INST_CODE_POTP (0x42)
  62. #define SFLASH_INST_CODE_PP (0x02)
  63. #define SFLASH_INST_CODE_DIFP (0xA2)
  64. #define SFLASH_INST_CODE_SSE (0x20)
  65. #define SFLASH_INST_CODE_SE (0xD8)
  66. #define SFLASH_INST_CODE_BE (0xC7)
  67. #define SFLASH_INST_CODE_DP (0xB9)
  68. #define SFLASH_INST_CODE_RDP (0xAB)
  69. #define SFLASH_REPLY_LEN_WREN (0)
  70. #define SFLASH_REPLY_LEN_WRDI (0)
  71. #define SFLASH_REPLY_LEN_RDID_L (20)
  72. #define SFLASH_REPLY_LEN_RDID_S (3)
  73. #define SFLASH_REPLY_LEN_RDSR (1)
  74. #define SFLASH_REPLY_LEN_WRSR (1)
  75. #define SFLASH_REPLY_LEN_WRLR (1)
  76. #define SFLASH_REPLY_LEN_RDLR (1)
  77. #define SFLASH_REPLY_LEN_READ (-1)
  78. #define SFLASH_REPLY_LEN_READ_F (-1)
  79. #define SFLASH_REPLY_LEN_DOFR (-1)
  80. #define SFLASH_REPLY_LEN_ROTP (65)
  81. #define SFLASH_REPLY_LEN_POTP (65)
  82. #define SFLASH_REPLY_LEN_PP (256)
  83. #define SFLASH_REPLY_LEN_DIFP (256)
  84. #define SFLASH_REPLY_LEN_SSE (0)
  85. #define SFLASH_REPLY_LEN_SE (0)
  86. #define SFLASH_REPLY_LEN_BE (0)
  87. #define SFLASH_REPLY_LEN_DP (0)
  88. #define SFLASH_REPLY_LEN_RDP (0)
  89. /* Exported functions --------------------------------------------------------- */
  90. rt_err_t efm_spiFash_init(void);
  91. rt_err_t efm_spiFash_deinit(void);
  92. rt_uint32_t efm_spiFash_cmd(
  93. enum sflash_inst_type_t command,
  94. rt_uint32_t address,
  95. rt_uint8_t *buffer,
  96. rt_uint32_t size);
  97. #endif /* __DEV_SFLASH_H__ */