Interface: tos.chips.at45db.HplAt45db
interface HplAt45db
HPL for Atmel's AT45DB family of serial dataflash chips.
Provides access to all basic AT45DB operations plus operations to
wait for the flash to go idle or finish a comparison. See the AT45DB
family datasheets for full details on these operations.
This interface only supports one operation at a time.
- Author:
-
David Gay
Commands
command void compare(uint8_t cmd, at45page_t page)
command void crc(uint8_t cmd, at45page_t page, at45pageoffset_t offset, at45pageoffset_t n, uint16_t baseCrc)
command void erase(uint8_t cmd, at45page_t page)
command void fill(uint8_t cmd, at45page_t page)
command void flush(uint8_t cmd, at45page_t page)
command void read(uint8_t cmd, at45page_t page, at45pageoffset_t offset, uint8_t *data, at45pageoffset_t n)
command void readBuffer(uint8_t cmd, at45pageoffset_t offset, uint8_t *data, uint16_t n)
command void waitCompare()
command void waitIdle()
command void write(uint8_t cmd, at45page_t page, at45pageoffset_t offset, uint8_t *data, at45pageoffset_t n)
Events
event void compareDone()
event void crcDone(uint16_t computedCrc)
event void eraseDone()
event void fillDone()
event void flushDone()
event void readDone()
event void waitCompareDone(bool compareOk)
event void writeDone()
Commands - Details
compare
command void compare(uint8_t cmd, at45page_t page)
- Parameters:
-
cmd - AT45_C_COMPARE_BUFFER1 to compare buffer 1,
AT45_C_COMPARE_BUFFER2 to compare buffer 2
-
page - Page to compare with (must be less than AT45_MAX_PAGES)
crc
command void crc(uint8_t cmd, at45page_t page, at45pageoffset_t offset, at45pageoffset_t n, uint16_t baseCrc)
- Parameters:
-
cmd - AT45_C_READ_BUFFER1 to compute CRC from buffer 1,
AT45_C_READ_BUFFER2 to compute CRC from buffer 2
-
page - ignored (reserved for future use)
-
offset - Offset in page at which to start reading - must be between
0 and AT45_PAGE_SIZE - 1
-
n - Number of bytes to read (> 0). offset + n must be <=
AT45_PAGE_SIZE
-
baseCrc - initial CRC value - use 0 if computing a "standalone"
CRC, or a previous crc result if computing a CRC over several
flash pages
erase
command void erase(uint8_t cmd, at45page_t page)
- Parameters:
-
cmd - must be AT45_C_ERASE_PAGE
-
page - Page to compare with (must be less than AT45_MAX_PAGES)
fill
command void fill(uint8_t cmd, at45page_t page)
- Parameters:
-
cmd - AT45_C_FILL_BUFFER1 to read into buffer 1,
AT45_C_FILL_BUFFER2 to read into buffer 2
-
page - Page to read (must be less than AT45_MAX_PAGES)
flush
command void flush(uint8_t cmd, at45page_t page)
- Parameters:
-
cmd - AT45_C_FLUSH_BUFFER1 to write buffer 1 to flash,
AT45_C_FLUSH_BUFFER2 to write buffer 2 to flash,
AT45_C_QFLUSH_BUFFER1 to write buffer 1 to flash w/o erase
(page must have been previously erased),
AT45_C_QFLUSH_BUFFER2 to write buffer 2 to flash w/o erase
(page must have been previously erased),
-
page - Page to write (must be less than AT45_MAX_PAGES)
read
command void read(uint8_t cmd, at45page_t page, at45pageoffset_t offset, uint8_t *data, at45pageoffset_t n)
- Parameters:
-
cmd - AT45_C_READ_CONTINUOUS or AT45_C_READ_PAGE. When the end of
a page is read, AT45_C_READ_CONTINUOUS continues on the next page,
while AT45_C_READ_PAGE continues at the start of the same page.
-
page - Page to read from
-
offset - Offset in page at which to start reading - must be between
0 and AT45_PAGE_SIZE - 1
-
data - Buffer in which to place read data. The buffer is "returned"
at readDone time.
-
n - Number of bytes to read (> 0).
readBuffer
command void readBuffer(uint8_t cmd, at45pageoffset_t offset, uint8_t *data, uint16_t n)
- Parameters:
-
cmd - AT45_C_READ_BUFFER1 to read from buffer 1,
AT45_C_READ_BUFFER2 to read from buffer 2
-
offset - Offset in page at which to start reading - must be between
0 and AT45_PAGE_SIZE - 1
-
data - Buffer in which to place read data. The buffer is "returned"
at readDone time.
-
n - Number of bytes to read (> 0). offset + n must be <=
AT45_PAGE_SIZE
waitCompare
command void waitCompare()
waitIdle
command void waitIdle()
write
command void write(uint8_t cmd, at45page_t page, at45pageoffset_t offset, uint8_t *data, at45pageoffset_t n)
- Parameters:
-
cmd - One of AT45_C_WRITE_BUFFER1/2 or AT45_C_WRITE_MEM_BUFFER1/2
to write respectively to buffer 1/2, or to buffer 1/2 and the
specified main memory page.
-
page - Page to write when cmd is AT45_C_WRITE_MEM_BUFFER1/2
-
offset - Offset in page at which to start writing - must be between
0 and AT45_PAGE_SIZE - 1
-
data - Data to write. The buffer is "returned" at writeDone time.
-
n - Number of bytes to write (> 0). offset + n must be <=
AT45_PAGE_SIZE
Events - Details
compareDone
event void compareDone()
crcDone
event void crcDone(uint16_t computedCrc)
- Parameters:
-
computedCrc - CRC value
eraseDone
event void eraseDone()
fillDone
event void fillDone()
flushDone
event void flushDone()
readDone
event void readDone()
waitCompareDone
event void waitCompareDone(bool compareOk)
- Parameters:
-
compareOk - TRUE if the comparison succeeded, FALSE otherwise.
waitIdleDone
event void waitIdleDone()
writeDone
event void writeDone()