Nut/OS  4.10.3
API Reference
SPI Flash Devices

Programs SPI attached flash devices. More...

Collaboration diagram for SPI Flash Devices:

Functions

int SpiFlashEnable (void)
 Enable SPI device flash programming.
void SpiFlashId (uint8_t *id)
int SpiFlashWriteByte (uint8_t high, uint16_t addr, uint8_t data)
 Write byte to the target's flash memory.
int SpiFlashWriteWord (uint16_t addr, uint16_t data)
 Write word to the target's flash memory.
void SpiFlashErase (void)
 Erase target's flash memory.

Detailed Description

Programs SPI attached flash devices.

When AVR CPUs are attached to the SPI, then the routines in this module can be used to write to the flash ROM of these devices.

These routines are poorly supported and may not work as expected.


Function Documentation

int SpiFlashEnable ( void  )

Enable SPI device flash programming.

Returns:
0 if device could be located, -1 otherwise.

Definition at line 93 of file spiflash.c.

References BV, cbi, outb, and sbi.

void SpiFlashId ( uint8_t id)

Read SPI device ID.

Parameters:
idThree byte character array, which receives the CPU ID.

Definition at line 168 of file spiflash.c.

int SpiFlashWriteByte ( uint8_t  high,
uint16_t  addr,
uint8_t  data 
)

Write byte to the target's flash memory.

The target must have been erased by a previous call to SpiFlashErase().

Parameters:
highMust be 0 to write the low byte or 8 to write the high byte.
addrWord address to write to.
dataByte value to write.
Returns:
0 on success, -1 otherwise.

Definition at line 193 of file spiflash.c.

References NutDelay().

Referenced by SpiFlashWriteWord().

Here is the call graph for this function:

int SpiFlashWriteWord ( uint16_t  addr,
uint16_t  data 
)

Write word to the target's flash memory.

Parameters:
addrWord address to write to.
dataWord value to write.
Returns:
0 on success, -1 otherwise.

Definition at line 238 of file spiflash.c.

References SpiFlashWriteByte().

Here is the call graph for this function:

void SpiFlashErase ( void  )

Erase target's flash memory.

Sets all bytes on the target's flash memory to 0xFF. In addtion all lock bits are set to 1 (unprogrammed).

Definition at line 254 of file spiflash.c.

References NutDelay().

Here is the call graph for this function: