34 #define CMD_RDSR1 (unsigned char) 0x05
35 #define CMD_RDSR2 (unsigned char) 0x35
36 #define CMD_RDSR3 (unsigned char) 0x33
37 #define CMD_WREN (unsigned char) 0x06
38 #define CMD_EWSR (unsigned char) 0x50 //write enable volatile
39 #define CMD_WRDI (unsigned char) 0x04
40 #define CMD_SETBURST (unsigned char) 0x77
41 #define PAGE_PROGRAM (unsigned char) 0x02
43 #define CMD_READ_DATA (unsigned char) 0x03
44 #define CMD_READ_HS (unsigned char) 0x0B
46 #define ERASE_SECTOR (unsigned char) 0x20
47 #define ERASE_BLOCK32 (unsigned char) 0x52
48 #define ERASE_BLOCK64 (unsigned char) 0xD8
49 #define ERASE_CHIP (unsigned char) 0x60
51 #define CMD_DEEPSLP (unsigned char) 0xB9
52 #define CMD_RESDPD (unsigned char) 0xAB //release from sleep
53 #define CMD_RDID (unsigned char) 0x90
54 #define JEDEC (unsigned char) 0x9F
55 #define CMD_RDSFDP (unsigned char) 0x5A
56 #define CMD_RDSECREG (unsigned char) 0x48
57 #define CMD_ERSECREG (unsigned char) 0x44 //erase security reg
58 #define CMD_EHLD (unsigned char) 0xAA
60 #define S64MANID (unsigned char) 0x01
61 #define S64DEVID (unsigned char) 0x16
63 #define CMD_RSID (unsigned char) 0x88
64 #define CMD_PSID (unsigned char) 0xA5
65 #define CMD_LSID (unsigned char) 0x85
68 #define CMD_WRSR (unsigned char) 0x01 //write status register
69 #define STAT_REG1 (unsigned char) 0x05 //status register number one
70 #define STAT_REG2 (unsigned char) 0x35 //status register number two
71 #define STAT_REG3 (unsigned char) 0x33 //status register mumber three
78 #define SECTOR_SIZE 4096 //0x000-0xfff
79 #define SECTOR_COUNT 128
80 #define PAGE_NUM 2048 //16 pages per sector
81 #define PAGE_INCR 0x100 //256 bytes
86 #define CE_OUTPUT() bcm2835_gpio_fsel(RPI_V2_GPIO_P1_26,BCM2835_GPIO_FSEL_OUTP); //Set CE0 as output
87 #define CE_DESELECT() bcm2835_gpio_write(RPI_V2_GPIO_P1_26, HIGH);
88 #define CE_SELECT() bcm2835_gpio_write(RPI_V2_GPIO_P1_26, LOW);
unsigned char buffer[256]
void S25FL_ChipErase(void)
Erase all chip contents. Erase is slow on flash chips.
void S25FL_Setup(void)
Setup SPI and IOs connected to Serial FLASH.
void S25FL_WakeUp(void)
Wakes the flash memory chip from deep sleep mode.
void S25FL_SectorErase(unsigned long address)
This function erases a 4Kb sector (it erase a page actually)
void S25FL_SetBlockProtection(unsigned char prot)
Sets the block protection of the chip.
void S25FL_WriteArray(unsigned long address, unsigned char *pData, unsigned int arrayLength)
Write data array at the specified address , this procedure does page programming. The destination add...
unsigned int S25FL_ReadID()
This function reads the Manufacturer ID code This procedure Reads the manufacturer's ID and device ID...
void S25FL_ReadPage(unsigned long page, unsigned char buffer[])
void S25FL_WriteByte(unsigned char data, unsigned long address)
Write a byte to the address specified (24 bit address)
unsigned char S25FL_IsWriteBusy()
This function reads status register and checks BUSY bit for a write in progress operation.It waits until the device is no longer busy.
unsigned char S25FL_ReadByte(unsigned long address)
Read a byte from the specified 24 bit address.
void S25FL_SReg_Write(unsigned char statReg)
This procedure writes a byte to the Status Register.
unsigned char S25FL_SReg_Read(unsigned char statReg)
Read specific Status Register depending on value of statReg.
void S25FL_BlockErase(unsigned long address)
This function erases a 64Kb block.
unsigned long S25FL_Jedec_ID_Read()
This procedure Reads the manufacturer's ID (BFh), memory type (25h) and device ID (4Bh)...
void S25FL_ReadArray(unsigned long address, unsigned char *pData, unsigned int arrayLength)
Read an array of data from the given address.
void S25FL_DeepSleep(void)
Puts the flash chip into deep sleep mode.