00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef AVRLIB_SPIFLASH_H
00020 #define AVRLIB_SPIFLASH_H
00021
00022 #include "global.h"
00023
00024
00025
00026
00027
00028
00029
00030 #define SPIFLASH_CMD_WREN 0x06 // write enable
00031 #define SPIFLASH_CMD_WRDI 0x04 // write disable
00032 #define SPIFLASH_CMD_RDID 0x9F // read ID register
00033 #define SPIFLASH_CMD_RDSR 0x05 // read status register
00034 #define SPIFLASH_CMD_WRSR 0x01 // write status register
00035 #define SPIFLASH_CMD_READ 0x03 // read
00036 #define SPIFLASH_CMD_FASTREAD 0x0B // high-speed read
00037 #define SPIFLASH_CMD_PAGEPROG 0x02 // page program
00038 #define SPIFLASH_CMD_SECTERASE 0xD8 // sector erase
00039 #define SPIFLASH_CMD_CHIPERASE 0xC7 // chip erase
00040
00041
00042 #define SPIFLASH_STATUS_BUSY 0x01 // busy, write in progress
00043 #define SPIFLASH_STATUS_WEN 0x02 // write enable
00044 #define SPIFLASH_STATUS_BP0 0x04 // block protect 0
00045 #define SPIFLASH_STATUS_BP1 0x08 // block protect 1
00046 #define SPIFLASH_STATUS_BP2 0x10 // block protect 2
00047 #define SPIFLASH_STATUS_WPEN 0x80 // write protect enabled
00048
00049
00050 #define SPIFLASH_PAGESIZE 256 // 256 bytes/page
00051
00052
00053
00054
00055 void spiflashInit(void);
00056
00057
00058
00059 unsigned short spiflashGetID(void);
00060
00061
00062 void spiflashChipErase(void);
00063
00064
00065
00066
00067 void spiflashRead(unsigned long addr, unsigned long nbytes, unsigned char *data);
00068
00069
00070
00071
00072
00073
00074 void spiflashWrite(unsigned long addr, unsigned long nbytes, unsigned char *data);
00075
00076 #endif