spiflash.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. #ifndef __SPIFLASH_H__
  29. #define __SPIFLASH_H__
  30. #include "types.h"
  31. /*gd25q16 cmd define*/
  32. #define FLASH_WREN 0x06
  33. #define FLASH_WRDIS 0x04
  34. #define FLASH_CE 0x60
  35. //#define FLASH_CE 0xC7
  36. #define FLASH_DP 0xB9
  37. #define FLASH_RDI 0xAB
  38. #define FLASH_SE 0x20
  39. #define FLASH_BE_32KB 0x52
  40. #define FLASH_BE_64KB 0xD8
  41. #define FLASH_WRSR 0x01
  42. #define FLASH_RDID 0x9F
  43. #define FLASH_RDSR_LOW 0x05
  44. #define FLASH_RDSR_HIGH 0x35
  45. #define FLASH_PP 0x02
  46. #define FLASH_READ 0x03
  47. #define FLASH_PES 0x75
  48. #define FLASH_PER 0x7A
  49. //#define FLASH_BE_128KB 0xD2
  50. //#define FLASH_CRS 0xFF
  51. //#define FLASH_DUAL_FAST_READ 0x3B
  52. //#define FLASH_DUAD_FAST_READ 0x6B
  53. //#define FLASH_DUAL_IO_FAST_READ 0xBB
  54. //#define FLASH_DUAD_IO_FAST_READ 0xEB
  55. //#define FALSH_QUAD_IO_WORD_FAST_READ 0xE7
  56. //#define FLASH_HPM 0xA3
  57. //#define FLASH_FAST_READ 0x0B
  58. //#define FLASH_REMS 0x90
  59. typedef enum{
  60. FLASH_ERROR = 0,
  61. FLASH_IDLE = 1,
  62. FLASH_ERASING = 2,
  63. FALSH_DATA_WRITING = 3,
  64. FLASH_STATUS_WRITEING = 4,
  65. FLASH_READING = 5
  66. }FLASH_STATUS_e;
  67. /*gd25q16 api for hardware debug*/
  68. uint32_t spiflash_read_identification(void);
  69. uint16_t spiflash_read_status_register(uint8_t bitsSel);
  70. bool spiflash_bus_busy(void);
  71. void spiflash_program_erase_suspend(void);
  72. void spiflash_program_erase_resume(void);
  73. void spiflash_deep_powerdown(void);
  74. void spiflash_release_from_powerdown(void);
  75. void spiflash_write_enable(void);
  76. void spiflash_write_disable(void);
  77. void spiflash_chip_erase(void);
  78. void spiflash_sector_erase(uint32_t addr);
  79. void spiflash_block_erase_32KB(uint32_t addr);
  80. void spiflash_block_erase_64KB(uint32_t addr);
  81. void spiflash_write_status_register(uint8_t data);
  82. void spiflash_write(uint32_t addr,uint8_t* tx_buf,uint16_t tx_len);
  83. void spiflash_read(uint32_t addr,uint8_t* rx_buf,uint16_t rx_len);
  84. /*gd25q16 api for user develop*/
  85. int GD25_init(void);
  86. int GD25_read(uint32_t addr,uint8_t *data,uint8_t len);
  87. int GD25_erase(uint32_t addr,uint32_t len);
  88. int GD25_write(uint32_t addr,const uint8_t *data,uint8_t len);
  89. #endif