wm_fls_gd25qxx.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @file wm_fls_gd25qxx.h
  3. *
  4. * @brief wm gd25qxx flash driver
  5. *
  6. * @author dave
  7. *
  8. * @copyright (c) 2015 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef TLS_EXSPIFLS_H
  11. #define TLS_EXSPIFLS_H
  12. #define SPI_SCLK (10000000) /** 10MHz. */
  13. #define FLASH_TOTAL_SIZE (1024*1024)
  14. #define PAGE_SIZE 256
  15. #define PROGRAM_SIZE 256
  16. #define PAGE_ADDR_OFFSET 8
  17. #define SECTOR_SIZE 4096
  18. /**
  19. * command code define.
  20. */
  21. #define EXSPIFLASH_WRITE_ENABLE (0x06) /** Global write enable */
  22. #define EXSPIFLASH_WRITE_DISABLE (0x04) /** Global write disable */
  23. #define EXSPIFLASH_READ_SR1 (0x05) /** Read flash status register s0~s7 */
  24. #define EXSPIFLASH_READ_SR2 (0x35) /** Read flash status register s8~s15 */
  25. #define EXSPIFLASH_WRITE_SR (0x01) /** Write flash status register s0~s15 */
  26. #define EXSPIFLASH_PAGE_PROGRAM (0x02) /** program one page */
  27. #define EXSPIFLASH_DATA_READ (0x03) /** read data from specified address */
  28. #define EXSPIFLASH_DATA_FAST_READ (0x0b) /** fast read data from specified address */
  29. #define EXSPIFLASH_SECTOR_ERASE (0x20) /** Sector erase */
  30. #define EXSPIFLASH_BLOCK32_ERASE (0x52) /** 32KB Block erase(128 pages) */
  31. #define EXSPIFLASH_BLOCK64_ERASE (0xd8) /** 64kb Block erase(256 pages) */
  32. #define EXSPIFLASH_CHIP_ERASE (0xc7) /** Chip erase */
  33. #define EXSPIFLASH_FLASH_DEVICEID (0x90) /** Read flash manufacturer/device ID */
  34. #define EXSPIFLASH_FLASH_ID (0x9f) /** Read flash ID */
  35. #define FLASH_STATUS_BUSY (1 << 0)
  36. #define FLASH_STATUS_WEL (1 << 1)
  37. /**
  38. * @brief This function is used to install gd25qxx driver.
  39. *
  40. * @param[in] None
  41. *
  42. * @retval TLS_FLS_STATUS_OK if write flash success
  43. * @retval TLS_FLS_STATUS_EPERM if flash struct point is null
  44. * @retval TLS_FLS_STATUS_ENODRV if flash driver is not installed
  45. * @retval TLS_FLS_STATUS_EINVAL if argument is invalid
  46. * @retval TLS_FLS_STATUS_EIO if io error
  47. * @retval TLS_FLS_STATUS_EEXIST if driver is already existed
  48. *
  49. * @note None
  50. */
  51. int tls_spifls_drv_install(void);
  52. #endif /* TLS_FLS_GD25QXX_H */