?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik /*! \file spiflash.h \brief SPI Flash Memory Driver (M25Pxx/AT25Fxxx/etc). */
2 //*****************************************************************************
3 //
4 // File Name : 'spiflash.h'
5 // Title : SPI Flash Memory Driver (M25Pxx/AT25Fxxx/etc)
6 // Author : Pascal Stang - Copyright (C) 2006
7 // Created : 2006-04-15
8 // Revised : 2006-07-02
9 // Version : 0.1
10 // Target MCU : AVR processors
11 // Editor Tabs : 4
12 //
13 // NOTE: This code is currently below version 1.0, and therefore is considered
14 // to be lacking in some functionality or documentation, or may not be fully
15 // tested. Nonetheless, you can expect most functions to work.
16 //
17 //*****************************************************************************
18  
19 #ifndef AVRLIB_SPIFLASH_H
20 #define AVRLIB_SPIFLASH_H
21  
22 #include "global.h"
23  
24 // Compatible with:
25 // - ST M25Pxx devices
26 // - Atmel AT25Fxxx devices
27 // - many more
28  
29 // device commands
30 #define SPIFLASH_CMD_WREN 0x06 // write enable
31 #define SPIFLASH_CMD_WRDI 0x04 // write disable
32 #define SPIFLASH_CMD_RDID 0x9F // read ID register
33 #define SPIFLASH_CMD_RDSR 0x05 // read status register
34 #define SPIFLASH_CMD_WRSR 0x01 // write status register
35 #define SPIFLASH_CMD_READ 0x03 // read
36 #define SPIFLASH_CMD_FASTREAD 0x0B // high-speed read
37 #define SPIFLASH_CMD_PAGEPROG 0x02 // page program
38 #define SPIFLASH_CMD_SECTERASE 0xD8 // sector erase
39 #define SPIFLASH_CMD_CHIPERASE 0xC7 // chip erase
40  
41 // status register bits
42 #define SPIFLASH_STATUS_BUSY 0x01 // busy, write in progress
43 #define SPIFLASH_STATUS_WEN 0x02 // write enable
44 #define SPIFLASH_STATUS_BP0 0x04 // block protect 0
45 #define SPIFLASH_STATUS_BP1 0x08 // block protect 1
46 #define SPIFLASH_STATUS_BP2 0x10 // block protect 2
47 #define SPIFLASH_STATUS_WPEN 0x80 // write protect enabled
48  
49 // device constants
50 #define SPIFLASH_PAGESIZE 256 // 256 bytes/page
51  
52 // functions
53  
54 // Initializes spiflash for operation
55 void spiflashInit(void);
56  
57 // Get spiflash ID
58 // NOTE: supported only on some flash memories
59 unsigned short spiflashGetID(void);
60  
61 // Erase entire flash chip
62 void spiflashChipErase(void);
63  
64 // Read flash memory
65 // - addr may be any value
66 // - nbytes may be any value
67 void spiflashRead(unsigned long addr, unsigned long nbytes, unsigned char *data);
68  
69 // Write flash memory (automatic handling of page writes)
70 // - memory must be previously erased
71 // - addr MUST start at a page break
72 // OR
73 // - nbytes must be small enough such that page boundary is not crossed
74 void spiflashWrite(unsigned long addr, unsigned long nbytes, unsigned char *data);
75  
76 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3