libsavgba
A library to access various backup media in GBA cartridges
Enumerations | Functions
gba_flash.h File Reference

Go to the source code of this file.

Enumerations

enum  FlashSize { FLASH_SIZE_AUTO = 0 , FLASH_SIZE_64KB , FLASH_SIZE_128KB }
 Flash chip size. More...
 
enum  FlashManufacturer {
  FLASH_MFR_ATMEL = 0x1F , FLASH_MFR_PANASONIC = 0x32 , FLASH_MFR_SANYO = 0x62 , FLASH_MFR_SST = 0xBF ,
  FLASH_MFR_MACRONIX = 0xC2
}
 Flash chip manufacturer. More...
 
enum  FlashDevice {
  FLASH_DEV_MX29L010 = 0x09 , FLASH_DEV_LE26FV10N1TS = 0x13 , FLASH_DEV_MN63F805MNP = 0x1B , FLASH_DEV_MX29L512 = 0x1C ,
  FLASH_DEV_AT29LV512 = 0x3D , FLASH_DEV_LE39FW512 = 0xD4
}
 Flash chip device code. More...
 

Functions

int flash_init (u8 size)
 Init Flash chip. More...
 
int flash_reset ()
 Reset Flash chip. More...
 
int flash_read (u32 addr, u8 *data, size_t size)
 Read data from Flash (size: 64KB/128KB). More...
 
int flash_write (u32 addr, u8 *data, size_t size)
 Write data to Flash (size: 64KB/128KB). More...
 

Enumeration Type Documentation

◆ FlashDevice

Flash chip device code.

Enumerator
FLASH_DEV_MX29L010 
FLASH_DEV_LE26FV10N1TS 
FLASH_DEV_MN63F805MNP 
FLASH_DEV_MX29L512 
FLASH_DEV_AT29LV512 
FLASH_DEV_LE39FW512 

◆ FlashManufacturer

Flash chip manufacturer.

Enumerator
FLASH_MFR_ATMEL 
FLASH_MFR_PANASONIC 
FLASH_MFR_SANYO 
FLASH_MFR_SST 
FLASH_MFR_MACRONIX 

◆ FlashSize

enum FlashSize

Flash chip size.

Enumerator
FLASH_SIZE_AUTO 

Auto-detect.

FLASH_SIZE_64KB 

64KB(512Kb)

FLASH_SIZE_128KB 

128KB(1Mb)

Function Documentation

◆ flash_init()

int flash_init ( u8  size)

Init Flash chip.

Detect the type (and presence) of FLASH chips. It should be called once at first.

Parameters
sizeFlash chip size (FLASH_SIZE_AUTO / FLASH_SIZE_64KB / FLASH_SIZE_128KB). Use FLASH_SIZE_AUTO if you don't know.
Returns
0 for success, non-zero for error.

◆ flash_read()

int flash_read ( u32  addr,
u8 *  data,
size_t  size 
)

Read data from Flash (size: 64KB/128KB).

Parameters
addraddress in Flash (unit: byte).
databuffer to hold data.
sizedata size (unit: byte).
Returns
0 for success, non-zero for error.

◆ flash_reset()

int flash_reset ( )

Reset Flash chip.

Erases all memory in chip, erased memory is FFh-filled.

Returns
0 for success, non-zero for error.

◆ flash_write()

int flash_write ( u32  addr,
u8 *  data,
size_t  size 
)

Write data to Flash (size: 64KB/128KB).

Target sector will be erased.

Parameters
addraddress in Flash (unit: byte).
databuffer to hold data.
sizedata size (unit: byte).
Returns
0 for success, non-zero for error.