sgdk
flash.h
Go to the documentation of this file.
00001 
00029 #ifndef __FLASH_H__
00030 #define __FLASH_H__
00031 
00032 // I usually include stdint.h, but SGDK defines some stdint types here:
00033 #include "types.h"
00034 
00035 // Maximum number of flash regions. CFI standard allows up to 4
00036 #define FLASH_REGION_MAX 4
00037 
00042 struct flash_region {
00043         uint32_t start_addr;    //< Sector start address
00044         uint16_t num_sectors;   //< Number of sectors
00045         uint16_t sector_len;    //< Sector length in 256 byte units
00046 };
00053 struct flash_chip {
00054         uint32_t len;                  //< Length of chip in bytes
00055         uint16_t num_regions;          //< Number of regions in chip
00056         struct flash_region region[FLASH_REGION_MAX]; //< Region data array
00057 };
00067 int16_t flash_init(void);
00068 
00072 void flash_deinit(void);
00073 
00079 const struct flash_chip *flash_metadata_get(void);
00080 
00095 uint32_t flash_sector_erase(uint32_t addr);
00096 
00115 uint16_t flash_program(uint32_t addr, const uint8_t *data, uint16_t len);
00116 
00130 int16_t flash_read(uint32_t addr, uint8_t *data, uint16_t len);
00131 
00148 int16_t flash_copy(uint32_t dst, uint32_t src, uint16_t len);
00149 
00162 int16_t flash_sector_limits(uint32_t addr, uint32_t *start, uint32_t *next);
00163 
00164 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines