]> hackdaworld.org Git - my-code/arm.git/blob - betty/flash.h
enhanced linker script and startup
[my-code/arm.git] / betty / flash.h
1 /*
2  * flash.h - header file for the low level flash handling
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 #ifndef FLASH_H
9 #define FLASH_H
10
11 #include "lpc2xxx.h"
12 #include "types.h"
13
14 /*
15  * defines
16  */
17
18 #define BANK0                           '0'
19 #define BANK2                           '2'
20 #define FLASH_BANK0                     0x80000000
21 #define FLASH_BANK2                     0x82000000
22 #define FLASH_SIZE                      0x00100000
23
24 /* cmd addresses (shifted to left!) */
25 #define FLASH_B0F555    (*((volatile unsigned short *)(FLASH_BANK0|0xaaa)))
26 #define FLASH_B0F2AA    (*((volatile unsigned short *)(FLASH_BANK0|0x554)))
27 #define FLASH_B0F       (*((volatile unsigned short *)(FLASH_BANK0)))
28 #define FLASH_B2F555    (*((volatile unsigned short *)(FLASH_BANK2|0xaaa)))
29 #define FLASH_B2F2AA    (*((volatile unsigned short *)(FLASH_BANK2|0x554)))
30 #define FLASH_B2F       (*((volatile unsigned short *)(FLASH_BANK2)))
31
32 /*
33  * function prototypes
34  */
35
36 void flash_init(void);
37 void flash_reset(u8 bank);
38 void flash_sector_erase(u8 flash,u8 sector);
39 int flash_sec_erase(u32 addr);
40 void flash_chip_erase(u8 bank);
41 void flash_unlock_bypass(u8 bank);
42 void flash_unlock_bypass_reset(u8 bank);
43 int flash_write_word(u32 addr,u16 data);
44 int flash_write_buf(u32 addr,u16 *buf,int len);
45 void flash_read_buf(u32 addr,u16 *buf,int len);
46
47 #endif