Out-of-office display, GFX
 All Classes Files Functions Variables Enumerations Enumerator Groups
Files | Macros | Functions
M29w320FlashDriver

Files

file  m29w320FlashDriver.h

Macros

#define M29_EPMP_CS_BASE_ADDRESS   GFX_EPMP_CS2_BASE_ADDRESS
 Flash memory device address.
#define M29W320_FLASH_SIZE   0x200000
 Capacity of flash memory device.
#define SST_ENABLE_STDOUT_ERRORS
 Allows this driver to report errors to stdout.

Functions

int m29w320_writeWord (uint32_t address, uint16_t data)
 Write a word (16 bit) to the flash memory.
int m29w320_writeBytes (uint32_t address, const uint8_t *data, size_t len)
 Write a series of bytes to the flash memory.
uint16_t m29w320_readWord (uint32_t address)
 Read a word (16 bit) from the flash memory.
void m29w320_readBytes (uint32_t address, uint8_t *buffer, size_t bufferLen)
 Read a series of bytes from the flash memory.
void m29w320_readBytesBlocking (uint32_t address, uint8_t *buffer, size_t bufferLen)
 Read a series of bytes from the flash memory, not re-enabling EPMP bypass mode between writes.
void m29w320_eraseChip ()
 Erase everything in the flash memory.
void m29w320_eraseBlock (uint32_t address)
 Erase a given block in the flash memory.
int m29w320_size ()
 Get the size of the device.
int m29w320_test ()
 Checks the device's manufacture and device ID.

Detailed Description

Macro Definition Documentation

#define M29_EPMP_CS_BASE_ADDRESS   GFX_EPMP_CS2_BASE_ADDRESS

Flash memory device address.

This define is required.

#define M29W320_FLASH_SIZE   0x200000

Capacity of flash memory device.

Not required. If defined, and if SST_ENABLE_STDOUT_ERRORS is defined, attempts to write and write outside the address range of the device will be logged as errors to stdout.

Function Documentation

void m29w320_eraseBlock ( uint32_t  address)

Erase a given block in the flash memory.

Parameters
addressaddress of the block to erase
void m29w320_readBytes ( uint32_t  address,
uint8_t *  buffer,
size_t  bufferLen 
)

Read a series of bytes from the flash memory.

This function does the same as m29w320_readWord(), but it operates on a series of bytes instead of one word. EPMP bypass will be disabled and re-enabled between every read operation.

See Also
m29w320_readWord()
Parameters
addressthe address to data that will be read
bufferbuffer to store data in
bufferLenlength of buffer
void m29w320_readBytesBlocking ( uint32_t  address,
uint8_t *  buffer,
size_t  bufferLen 
)

Read a series of bytes from the flash memory, not re-enabling EPMP bypass mode between writes.

This function does the same as m29w320_readBytes(), but is only disables and re-enables EPMP bypass mode once.

See Also
m29w320_readBytes()
Parameters
addressthe address to data that will be read
bufferbuffer to store data in
bufferLenlength of buffer
uint16_t m29w320_readWord ( uint32_t  address)

Read a word (16 bit) from the flash memory.

This function will temporarily disable EPMP bypass mode, request a read from the flash, wait until the EPMP module is ready and return the data from the EPMP buffer.

Parameters
addressthe address to data that will be read
Returns
the requested data
int m29w320_size ( )

Get the size of the device.

$2^n$, where $n$ is the return value of this function, gives number of bytes the device can contain.

int m29w320_writeBytes ( uint32_t  address,
const uint8_t *  data,
size_t  len 
)

Write a series of bytes to the flash memory.

This functions does the same as m29w320_writeWord(), but it operates on a series of bytes instead of one word. EPMP bypass will be disabled and re-enabled between every write operation.

See Also
m29w320_writeWord()
Parameters
addressthe address to where the data should be stored
dataan array of bytes to write
lenlength of the data array
Returns
0 if the write succeeded, non-zero if the data could not be verified after the write operation
int m29w320_writeWord ( uint32_t  address,
uint16_t  data 
)

Write a word (16 bit) to the flash memory.

This function will temporarily disable EPMP bypass mode, wait until the EPMP module is ready and write the data. It will then busy-wait until the data is written and check that the data was successfully written by reading the same address twice from the flash.

Parameters
addressthe address to where the data should be stored
datathe data to write
Returns
0 if the write succeeded, non-zero if the data could not be verified after the write operation