yc11xx_qspi.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * Copyright 2016, yichip Semiconductor(shenzhen office)
  3. * All Rights Reserved.
  4. *
  5. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Yichip Semiconductor;
  6. * the contents of this file may not be disclosed to third parties, copied
  7. * or duplicated in any form, in whole or in part, without the prior
  8. * written permission of Yichip Semiconductor.
  9. */
  10. /**
  11. *@file qspi.h
  12. *@brief Queued SPI support for application.
  13. */
  14. #ifndef _QSPI_H_
  15. #define _QSPI_H_
  16. #include "yc11xx.h"
  17. #include "ycdef.h"
  18. #include "yc_drv_common.h"
  19. #define FlashCMD_ReadRegister1 0x05
  20. #define FlashCMD_ReadRegister2 0x35
  21. #define FlashCMD_WriteRegister 0x01
  22. #define FlashCMD_PageProgram 0x02
  23. #define FlashCMD_READ_DATA 0x03
  24. #define FlashCMD_WriteEnable 0x06
  25. #define FlashCMD_WriteDisable 0x04
  26. #define FlashCMD_ReadDual 0x3b
  27. #define FlashCMD_RDID 0x9f
  28. #define FlashCMD_REMS 0x90
  29. #define FlashCMD_UID 0x4b
  30. #define FlashCMD_PageErase 0x81
  31. #define FlashCMD_SectorErase 0x20
  32. #define FlashCMD_32kErase 0x52
  33. #define FlashCMD_64kErase 0xd8
  34. #define FlashCMD_ChipErase 0x60
  35. #define FlashCMD_DeepPowerDown 0xb9
  36. #define FLASHCMD_RELEASE_POWERDOWN 0xAB
  37. void __attribute__((noinline)) SetLockQSPI(void);
  38. void __attribute__((noinline)) SetReleaseQSPI(void);
  39. /*
  40. * @brief:sector erase 4kB
  41. * @param:flash addr
  42. * @return: ERROR ,SUCCESS
  43. */
  44. uint8_t qspi_flash_sectorerase(uint32_t flash_addr);
  45. /*
  46. * @brief:block erase 32K
  47. * @param:flash addr
  48. * @return: ERROR ,SUCCESS
  49. */
  50. uint8_t qspi_flash_blockerase32k(uint32_t flash_addr);
  51. /*
  52. * @brief:block erase 64K
  53. * @param:flash addr
  54. * @return: ERROR ,SUCCESS
  55. */
  56. uint8_t qspi_flash_blockerase64k(uint32_t flash_addr);
  57. /*
  58. * @brief:chip erase
  59. * @param:None
  60. * @return: ERROR ,SUCCESS
  61. */
  62. uint8_t qspi_flash_chiperase(void);
  63. /*
  64. * @brief: flash write
  65. * @param: flash_addr
  66. * @param: len
  67. * @param: txbuf
  68. * @return: ERROR ,SUCCESS
  69. */
  70. uint8_t qspi_flash_write(uint32_t flash_addr,uint32_t len,uint8_t *tbuf);
  71. /*
  72. * @brief: flash read
  73. * @param: flash_addr
  74. * @param: len
  75. * @param: rxbuf
  76. * @return: ERROR ,SUCCESS
  77. */
  78. uint8_t qspi_flash_read(uint32_t flash_addr,uint32_t rlen,uint8_t *rbuf);
  79. /*
  80. * @brief:read flash id
  81. * @return: flash id
  82. */
  83. uint32_t qspi_flash_ManufactureID(void);
  84. uint8_t QSPI_ReadFlashData(uint32_t flash_addr,uint32_t rlen,uint8_t *rbuf);
  85. uint8_t QSPI_WriteFlashData(uint32_t flash_addr,uint32_t len,uint8_t *tbuf);
  86. uint8_t QSPI_SectorEraseFlash(uint32_t flash_addr);
  87. uint8_t QSPI_PageEraseFlash(uint32_t flash_addr);
  88. uint8_t QSPI_BlockEraseFlash32k(uint32_t flash_addr);
  89. uint8_t QSPI_BlockEraseFlash64k(uint32_t flash_addr);
  90. #endif