|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IFlashMemoryDevice
Interface to flash memory devices on the main Spot board and external boards. We assume the device has the concepts of sector (unit of erasure) and page (max size of write, alignment boundary). Not all devices have page alignment restrictions, so a special write operation is provided that does not insist on writing at a page boundary. Devices that require alignment should throw an exception if this is called. For many devices the page size could, in principle, be equal to the sector size, or even larger, but implementors of this interface need to bear in mind: 1) the page size is used for the size of the RAM buffers in streamed I/O 2) flash writing for devices on the main bus often locks out all other processor activity, including interrupts. So for devices like that keeping the page size small is beneficial
Method Summary | |
---|---|
void |
eraseChip()
Erase all data in the chip |
void |
eraseSectorAtAddress(int address)
Erase a sector |
int |
getNumberOfSectors()
Get the number of sectors in the device. |
int |
getNumberOfSectorsInRegion(int addrToFlash,
int dataSize)
Find the number of sectors in a region of the flash memory. |
int |
getPageSize()
Get the page size for writing. |
int |
getSectorContainingAddress(int addrToFlash)
Find the sector associated with a given address in the flash. |
int[] |
getSectorMap()
Get a map of sector numbers to sector addresses |
int |
getSectorSize(int sectorNum)
Get the size of a device sector |
int |
getSize()
Get the capacity of the device |
void |
read(int address,
int numOfBytes,
byte[] buffer,
int offset)
Read data from the flash memory. |
boolean |
sectorErased(int address)
Check whether a sector is erased. |
boolean |
verify(int address,
int numOfBytes,
byte[] buffer)
Verify data in the flash memory. |
void |
write(int address,
int numOfBytes,
byte[] buffer,
int offset)
Write data into the flash memory. |
Method Detail |
---|
void read(int address, int numOfBytes, byte[] buffer, int offset)
address
- address in memory to start readingnumOfBytes
- number of bytes to readbuffer
- the hold the dataoffset
- offset into buffer for first byte readvoid write(int address, int numOfBytes, byte[] buffer, int offset)
address
- address in memory to start writing, no need to be page-alignednumOfBytes
- number of bytes to write, in range 0 to PAGE_SIZEbuffer
- the data to writeoffset
- the offset into the buffer of the first byte to write
IllegalStateException
- if unaligned and this device requires page alignmentboolean verify(int address, int numOfBytes, byte[] buffer)
address
- address in memory to start verifying, must be page-alignednumOfBytes
- number of bytes to write, in range 0 to PAGE_SIZEbuffer
- the data to verify against
void eraseSectorAtAddress(int address)
address
- an address within sector to erase - must be even and in rangeboolean sectorErased(int address)
address
- an address within sector to check
void eraseChip()
int getPageSize()
int[] getSectorMap()
int getSize()
int getSectorSize(int sectorNum)
sectorNum
- The sector whose size is to be returned
int getNumberOfSectors()
int getSectorContainingAddress(int addrToFlash)
addrToFlash
- The address.
int getNumberOfSectorsInRegion(int addrToFlash, int dataSize)
addrToFlash
- The start of the region.dataSize
- The size of the region.
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |