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