libdragon
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
eeprom.h File Reference

EEPROM support. More...

Go to the source code of this file.

Macros

#define EEPROM_BLOCK_SIZE   8
 Size of an EEPROM save block in bytes.
 

Enumerations

enum  eeprom_type_t { EEPROM_NONE = 0 , EEPROM_4K = 1 , EEPROM_16K = 2 }
 EEPROM Probe Values. More...
 

Functions

eeprom_type_t eeprom_present (void)
 Probe the EEPROM interface on the cartridge.
 
size_t eeprom_total_blocks (void)
 Determine how many blocks of EEPROM exist on the cartridge.
 
void eeprom_read (uint8_t block, uint8_t *dest)
 Read a block from EEPROM.
 
uint8_t eeprom_write (uint8_t block, const uint8_t *src)
 Write a block to EEPROM.
 
void eeprom_read_bytes (uint8_t *dest, size_t start, size_t len)
 Read a buffer of bytes from EEPROM.
 
void eeprom_write_bytes (const uint8_t *src, size_t start, size_t len)
 Write a buffer of bytes to EEPROM.
 

Detailed Description

EEPROM support.

Enumeration Type Documentation

◆ eeprom_type_t

EEPROM Probe Values.

See also
eeprom_present
Enumerator
EEPROM_NONE 

No EEPROM present.

EEPROM_4K 

4 kilobit (64-block) EEPROM present

EEPROM_16K 

16 kilobit (256-block) EEPROM present

Function Documentation

◆ eeprom_present()

eeprom_type_t eeprom_present ( void  )

Probe the EEPROM interface on the cartridge.

Inspect the identifier half-word of the EEPROM status response to determine which EEPROM save type is available (if any).

Returns
which EEPROM type was detected on the cartridge.

◆ eeprom_total_blocks()

size_t eeprom_total_blocks ( void  )

Determine how many blocks of EEPROM exist on the cartridge.

Returns
0 if EEPROM was not detected or the number of EEPROM 8-byte save blocks available.

◆ eeprom_read()

void eeprom_read ( uint8_t  block,
uint8_t *  dest 
)

Read a block from EEPROM.

Parameters
[in]blockBlock to read data from. Joybus accesses EEPROM in 8-byte blocks.
[out]destDestination buffer for the eight bytes read from EEPROM.

◆ eeprom_write()

uint8_t eeprom_write ( uint8_t  block,
const uint8_t *  src 
)

Write a block to EEPROM.

Parameters
[in]blockBlock to write data to. Joybus accesses EEPROM in 8-byte blocks.
[in]srcSource buffer for the eight bytes of data to write to EEPROM.
Returns
the EEPROM status byte

◆ eeprom_read_bytes()

void eeprom_read_bytes ( uint8_t *  dest,
size_t  start,
size_t  len 
)

Read a buffer of bytes from EEPROM.

This is a high-level convenience helper that abstracts away the one-at-a-time EEPROM block access pattern.

Parameters
[out]destDestination buffer to read data into
[in]startByte offset in EEPROM to start reading data from
[in]lenByte length of data to read into buffer

◆ eeprom_write_bytes()

void eeprom_write_bytes ( const uint8_t *  src,
size_t  start,
size_t  len 
)

Write a buffer of bytes to EEPROM.

This is a high-level convenience helper that abstracts away the one-at-a-time EEPROM block access pattern.

Each EEPROM block write takes approximately 15 milliseconds; this operation may block for a while with large buffer sizes:

  • 4k EEPROM: 64 blocks * 15ms = 960ms!
  • 16k EEPROM: 256 blocks * 15ms = 3840ms!

You may want to pause audio before calling this.

Parameters
[in]srcSource buffer containing data to write
[in]startByte offset in EEPROM to start writing data to
[in]lenByte length of the src buffer