SWM320_norflash.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef __SWM320_NORFLASH_H__
  2. #define __SWM320_NORFLASH_H__
  3. typedef struct
  4. {
  5. uint8_t DataWidth; // 8、16
  6. uint8_t WELowPulseTime; // WE# pulse width,单位为系统时钟周期,最大值为7
  7. uint8_t OEPreValidTime; // Valid data output after OE# low,单位为系统时钟周期,最大值为15
  8. uint8_t OperFinishIEn; // 操作(写入、擦除)完成中断使能
  9. uint8_t OperTimeoutIEn;
  10. } NORFL_InitStructure;
  11. void NORFL_Init(NORFL_InitStructure *initStruct);
  12. uint32_t NORFL_ChipErase(void);
  13. uint32_t NORFL_SectorErase(uint32_t addr);
  14. uint32_t NORFL_Write(uint32_t addr, uint32_t data);
  15. uint32_t NORFL_Read(uint32_t addr);
  16. uint16_t NORFL_ReadID(uint32_t id_addr);
  17. /* 当前版本总线读只支持字读
  18. #define NORFL_Read8(addr) *((volatile uint8_t *)(NORFLM_BASE + addr))
  19. #define NORFL_Read16(addr) *((volatile uint16_t *)(NORFLM_BASE + addr)) */
  20. #define NORFL_Read32(addr) *((volatile uint32_t *)(NORFLM_BASE + addr))
  21. #define NORFL_CMD_READ 0
  22. #define NORFL_CMD_RESET 1
  23. #define NORFL_CMD_AUTO_SELECT 2
  24. #define NORFL_CMD_PROGRAM 3
  25. #define NORFL_CMD_CHIP_ERASE 4
  26. #define NORFL_CMD_SECTOR_ERASE 5
  27. #endif // __SWM320_NORFLASH_H__