29#define NILE_FLASH_ID_W25Q16JV_IQ 0xEF4015
30#define NILE_FLASH_ID_W25Q16JV_IM 0xEF7015
32#define NILE_FLASH_SR1_BUSY (1 << 0)
33#define NILE_FLASH_SR1_WEL (1 << 1)
34#define NILE_FLASH_SR1_BP0 (1 << 2)
35#define NILE_FLASH_SR1_BP1 (1 << 3)
36#define NILE_FLASH_SR1_BP2 (1 << 4)
37#define NILE_FLASH_SR1_TB (1 << 5)
38#define NILE_FLASH_SR1_SEC (1 << 6)
39#define NILE_FLASH_SR1_CMP (1 << 7)
41#define NILE_FLASH_SR2_SRL (1 << 0)
42#define NILE_FLASH_SR2_LB1 (1 << 3)
43#define NILE_FLASH_SR2_LB2 (1 << 4)
44#define NILE_FLASH_SR2_LB3 (1 << 5)
45#define NILE_FLASH_SR2_CMP (1 << 6)
46#define NILE_FLASH_SR2_SUS (1 << 7)
48#define NILE_FLASH_SR3_WPS (1 << 2)
49#define NILE_FLASH_SR3_DRV_100 (0)
50#define NILE_FLASH_SR3_DRV_75 (1 << 5)
51#define NILE_FLASH_SR3_DRV_50 (2 << 5)
52#define NILE_FLASH_SR3_DRV_25 (3 << 5)
53#define NILE_FLASH_SR3_DRV_MASK (3 << 5)
55#define NILE_FLASH_CMD_WRSR1 0x01
56#define NILE_FLASH_CMD_WRITE 0x02
57#define NILE_FLASH_CMD_READ 0x03
58#define NILE_FLASH_CMD_WRDI 0x04
59#define NILE_FLASH_CMD_RDSR1 0x05
60#define NILE_FLASH_CMD_WREN 0x06
61#define NILE_FLASH_CMD_WRSR3 0x11
62#define NILE_FLASH_CMD_RDSR3 0x15
63#define NILE_FLASH_CMD_ERASE_4K 0x20
64#define NILE_FLASH_CMD_WRSR2 0x31
65#define NILE_FLASH_CMD_RDSR2 0x35
66#define NILE_FLASH_CMD_BLOCK_LOCK 0x36
67#define NILE_FLASH_CMD_BLOCK_UNLOCK 0x39
68#define NILE_FLASH_CMD_BLOCK_RDLOCK 0x3D
69#define NILE_FLASH_CMD_SEC_WRITE 0x42
70#define NILE_FLASH_CMD_SEC_ERASE 0x44
71#define NILE_FLASH_CMD_SEC_READ 0x48
72#define NILE_FLASH_CMD_RDUUID 0x4B
73#define NILE_FLASH_CMD_ERASE_32K 0x52
74#define NILE_FLASH_CMD_RDSFPD 0x5A
75#define NILE_FLASH_CMD_RESET_EN 0x66
76#define NILE_FLASH_CMD_SUSPEND 0x75
77#define NILE_FLASH_CMD_RESUME 0x7A
78#define NILE_FLASH_CMD_LOCK 0x7E
79#define NILE_FLASH_CMD_MFR_ID 0x90
80#define NILE_FLASH_CMD_UNLOCK 0x98
81#define NILE_FLASH_CMD_RESET 0x99
82#define NILE_FLASH_CMD_RDID 0x9F
83#define NILE_FLASH_CMD_WAKE_ID 0xAB
84#define NILE_FLASH_CMD_SLEEP 0xB9
85#define NILE_FLASH_CMD_ERASE_ALL 0xC7
86#define NILE_FLASH_CMD_ERASE_64K 0xD8
96 bool __nile_flash_cmd(uint8_t cmd);
104 bool __nile_flash_cmd(uint8_t cmd);
112 bool __nile_flash_cmd(uint8_t cmd);
120 bool __nile_flash_cmd(uint8_t cmd);
128 bool __nile_flash_cmd(uint8_t cmd);
169 bool __nile_flash_erase_address(uint32_t address);
170 return __nile_flash_erase_address((((uint32_t) type) << 24) | address);
174 uint8_t __nile_flash_read_sr(uint8_t value);
179 uint8_t __nile_flash_read_sr(uint8_t value);
184 uint8_t __nile_flash_read_sr(uint8_t value);
189 bool __nile_flash_write_sr(uint16_t value);
194 bool __nile_flash_write_sr(uint16_t value);
199 bool __nile_flash_write_sr(uint16_t value);
static bool nile_flash_write_disable(void)
Disable SPI flash writing.
#define NILE_FLASH_CMD_WRSR2
Write Status Register 2.
static bool nile_flash_write_enable(void)
Enable SPI flash writing.
static uint8_t nile_flash_read_sr3(void)
static uint8_t nile_flash_read_sr1(void)
static bool nile_flash_sleep(void)
Put SPI flash to sleep.
bool nile_flash_wait_ready(void)
Wait until SPI flash is ready.
#define NILE_FLASH_CMD_WREN
Write Enable.
static bool nile_flash_write_sr2(uint8_t value)
#define NILE_FLASH_CMD_WAKE_ID
Release Power-down / Device ID.
bool nile_flash_write_page(const void __far *buffer, uint32_t address, uint16_t size)
Write page to SPI flash.
#define NILE_FLASH_CMD_UNLOCK
Global unlock.
#define NILE_FLASH_CMD_WRSR1
Write Status Register 1.
#define NILE_FLASH_CMD_SLEEP
Power-down.
#define NILE_FLASH_CMD_WRDI
Write Disable.
static bool nile_flash_erase_part(uint8_t type, uint32_t address)
Erase area from SPI flash.
static uint8_t nile_flash_read_sr2(void)
uint32_t nile_flash_read_id(void)
Read JEDEC ID from SPI flash.
static bool nile_flash_write_sr3(uint8_t value)
#define NILE_FLASH_CMD_RDSR2
Read Status Register 2.
static bool nile_flash_write_sr1(uint8_t value)
#define NILE_FLASH_CMD_RDSR1
Read Status Register 1.
static bool nile_flash_wake(void)
Wake up SPI flash.
static bool nile_flash_write_unlock_global(void)
Unlock global SPI flash writing.
#define NILE_FLASH_CMD_WRSR3
Write Status Register 3.
bool nile_flash_read(void __far *buffer, uint32_t address, uint16_t size)
Read data from SPI flash.
bool nile_flash_read_uuid(uint8_t *buffer)
Read device UUID (8 bytes) from SPI flash.
#define NILE_FLASH_CMD_RDSR3
Read Status Register 3.