arduino-dataflash
|
Modules | |
Chip erase command prevention. | |
SPI transfer speed control. | |
Default pin connections. | |
Default pin values for Chip Select (CS), Reset (RS) and Write Protec (WP). | |
Status register format. | |
The status register can be used to determine device state (ready/busy) or to retrieve the result of an operation. | |
Special sectors ID. | |
The following list gives the number of pages per sector (P) for the AT45 family: | |
Dataflash commands opcodes | |
Dataflash command opcode list. | |
Dataflash flash size. | |
For each flash memory IC these definitions give the page size, block size, sector size and total size in bytes, the number of pages, blocks and sectors, and the number of pages in sector 0A (the remaining pages of the first sector are in sector 0b). | |
Classes | |
class | DataFlash |
AT45DBxxxD Atmel Dataflash device. More... | |
struct | DataFlash::AddressingInfos |
Dataflash read/write addressing infos. More... | |
struct | DataFlash::ID |
ID structure. More... | |
Functions | |
DataFlash::DataFlash () | |
Constructor. | |
DataFlash::~DataFlash () | |
Destructor. | |
void | DataFlash::setup (int8_t csPin, int8_t resetPin=-1, int8_t wpPin=-1) |
Set pin use, with defaults for reset and write-protect if not specified as argument. | |
void | DataFlash::begin () |
Initialise SPI interface for use with the Dataflash, allowing shared use with other SPI devices (which must however use a different chip select pin). | |
void | DataFlash::end () |
Restore SPI configuration, so it can be used by other SPI devices. | |
void | DataFlash::reEnable () |
Disable (deselect) Dataflash, then enable (select) it again. | |
void | DataFlash::autoErase () |
Set erase mode to automatic (default). | |
void | DataFlash::manualErase () |
Set erase mode to manual. | |
uint8_t | DataFlash::isReady () |
Return whether the chip has completed the current operation and is ready for the next. | |
void | DataFlash::waitUntilReady () |
Wait until the chip is ready. | |
uint8_t | DataFlash::status () |
Read status register. | |
void | DataFlash::readID (DataFlash::ID &id) |
Read Manufacturer and Device ID. | |
void | DataFlash::pageRead (uint16_t page, uint16_t offset=0) |
A main memory page read allows the user to read data directly from any one of the pages in the main memory, bypassing both of the data buffers and leaving the contents of the buffers unchanged. | |
void | DataFlash::arrayRead (uint16_t page, uint16_t offset=0) |
Sequentially read a continuous stream of data at the currently set speed. | |
void | DataFlash::bufferRead (uint8_t bufferNum, uint16_t offset=0) |
Read the content of one of the SRAM data buffer at the currently set speed. | |
void | DataFlash::bufferWrite (uint8_t bufferNum, uint16_t offset) |
Write data to one of the SRAM data buffers at the currently set speed. | |
void | DataFlash::bufferToPage (uint8_t bufferNum, uint16_t page) |
Transfer data from buffer 0 or 1 to a main memory page, erasing the page first if auto-erase is set. | |
void | DataFlash::pageToBuffer (uint16_t page, uint8_t bufferNum) |
Transfer a page of data from main memory to buffer 0 or 1. | |
void | DataFlash::pageErase (uint16_t page) |
Erase a page in the main memory array. | |
void | DataFlash::blockErase (uint16_t block) |
Erase a block of pages in a single operation. | |
void | DataFlash::sectorErase (int8_t sector) |
Erase a sector of blocks in a single operation. | |
void | DataFlash::beginPageWriteThroughBuffer (uint16_t page, uint16_t offset, uint8_t bufferNum) |
This a combination of Buffer Write and Buffer to Page with Built-in Erase. | |
int8_t | DataFlash::isPageEqualBuffer (uint16_t page, uint8_t bufferNum) |
Compare a page of data in main memory to the data in buffer 0 or 1. | |
void | DataFlash::deepPowerDown () |
Put the device into the lowest power consumption mode. | |
void | DataFlash::resumeFromDeepPowerDown () |
Takes the device out of Deep Power-down mode. | |
void | DataFlash::hardReset () |
Reset device via the reset pin. | |
void | DataFlash::enable () |
Enable (select) Dataflash. | |
void | DataFlash::disable () |
Disable (deselect) Dataflash. | |
void | DataFlash::writeProtect () |
Enable write protection. | |
void | DataFlash::readWrite () |
Disable write protection. | |
int8_t | DataFlash::chipSelectPin () const |
Get chip Select (CS) pin. | |
int8_t | DataFlash::resetPin () const |
Get reset (RESET) pin. | |
int8_t | DataFlash::writeProtectPin () const |
Get write protect (WP) pin. | |
uint8_t | DataFlash::pageToHiU8 (uint16_t page) const |
Compute page address hi byte. | |
uint8_t | DataFlash::pageToLoU8 (uint16_t page) const |
Compute page address lo byte. | |
void | DataFlash::endAndWait () |
Same as waitUntilReady. | |
Variables | |
static const AddressingInfos | DataFlash::m_infos |
void DataFlash::arrayRead | ( | uint16_t | page, |
uint16_t | offset = 0 |
||
) |
Sequentially read a continuous stream of data at the currently set speed.
Reading past the end of the last page wraps around to the beginning of the first page. The chip must remain enabled by this function; it is the user's responsibility to disable the chip when finished reading.
page | Page of the main memory where the sequential read will start. |
offset | Starting byte address within the page (default value: 0). |
void DataFlash::autoErase | ( | ) |
Set erase mode to automatic (default).
void DataFlash::begin | ( | ) |
Initialise SPI interface for use with the Dataflash, allowing shared use with other SPI devices (which must however use a different chip select pin).
Initialise SPI interface for use with the Dataflash, allowing shared use with other SPI devices (which must however use a different chipselect pin).
void DataFlash::beginPageWriteThroughBuffer | ( | uint16_t | page, |
uint16_t | offset, | ||
uint8_t | bufferNum | ||
) |
This a combination of Buffer Write and Buffer to Page with Built-in Erase.
The global erase flag .manual_erase() is ignored. Writing past the end of the page wraps around to the beginning of the page.
page | Page to which the content of the buffer is written. |
offset | Starting byte address within the buffer. |
bufferNum | Buffer to use (0 or 1). |
void DataFlash::blockErase | ( | uint16_t | block | ) |
Erase a block of pages in a single operation.
block | Block to erase. |
void DataFlash::bufferRead | ( | uint8_t | bufferNum, |
uint16_t | offset = 0 |
||
) |
Read the content of one of the SRAM data buffer at the currently set speed.
Reading past the end of the buffer wraps around to the beginning. The chip must remain enabled by this function; it is the user's responsibility to disable the chip when finished reading.
bufferNum | Buffer to read (0 or 1). |
offset | Starting byte within the buffer (default value: 0). |
void DataFlash::bufferToPage | ( | uint8_t | bufferNum, |
uint16_t | page | ||
) |
Transfer data from buffer 0 or 1 to a main memory page, erasing the page first if auto-erase is set.
If erase is manual, the page must have been erased previously using one of the erase commands.
bufferNum | Buffer to use (0 or 1). |
page | Page to which the content of the buffer is written. |
void DataFlash::bufferWrite | ( | uint8_t | bufferNum, |
uint16_t | offset | ||
) |
Write data to one of the SRAM data buffers at the currently set speed.
Writing past the end of the buffer wraps around to the beginning. The chip must remain enabled by this function; it is the user's responsibility to disable the chip when finished reading.
bufferNum | Buffer to read (0 or 1). |
offset | Starting byte within the buffer (default value: 0). |
|
inline |
Get chip Select (CS) pin.
DataFlash::DataFlash | ( | ) |
Constructor.
Constructor This is not a good place to set the pins, because that causes hardware to be initialised in the variable declaration part a long time before setup() is called by the Arduino start-up code.
void DataFlash::deepPowerDown | ( | ) |
Put the device into the lowest power consumption mode.
Once the device has entered the Deep Power-down mode, all instructions are ignored except the Resume from Deep Power-down command.
|
inline |
Disable (deselect) Dataflash.
Disable device with chipselect.
|
inline |
Enable (select) Dataflash.
Enable device with chipselect.
void DataFlash::end | ( | ) |
Restore SPI configuration, so it can be used by other SPI devices.
Disable device and restore SPI configuration.
|
inline |
Same as waitUntilReady.
void DataFlash::hardReset | ( | ) |
Reset device via the reset pin.
If no reset pint was specified (with begin()), this does nothing.
int8_t DataFlash::isPageEqualBuffer | ( | uint16_t | page, |
uint8_t | bufferNum | ||
) |
Compare a page of data in main memory to the data in buffer 0 or 1.
page | Page to compare. |
bufferNum | Buffer number (0 or 1). |
uint8_t DataFlash::isReady | ( | ) |
Return whether the chip has completed the current operation and is ready for the next.
Set transfer speed (33MHz = low, 66MHz = high).
Note that in some situations read/write access to one of the buffers is permitted although the chip is busy.
Note: Arduino supports 20MHz max, so using "high" is actually slower because additional bytes have to be transferred for no benefit. Return whether the chip has completed the current operation and is ready for the next. Note that in some situations read/write access to one of the buffers is permitted although the chip is busy.
void DataFlash::manualErase | ( | ) |
Set erase mode to manual.
User must erase pages first, using one of the erase commands.
void DataFlash::pageErase | ( | uint16_t | page | ) |
Erase a page in the main memory array.
page | Page to erase. |
void DataFlash::pageRead | ( | uint16_t | page, |
uint16_t | offset = 0 |
||
) |
A main memory page read allows the user to read data directly from any one of the pages in the main memory, bypassing both of the data buffers and leaving the contents of the buffers unchanged.
Reading past the end of the page wraps around to the beginning of the page. The chip must remain enabled by this function; it is the user's responsibility to disable the chip when finished reading.
page | Page of the main memory to read. |
offset | Starting byte address within the page (default value: 0). |
void DataFlash::pageToBuffer | ( | uint16_t | page, |
uint8_t | bufferNum | ||
) |
Transfer a page of data from main memory to buffer 0 or 1.
page | Main memory page to transfer. |
bufferNum | Buffer (0 or 1) to which the data is written. |
|
inlineprivate |
Compute page address hi byte.
Compute page address high byte.
|
inlineprivate |
Compute page address lo byte.
Compute page address low byte.
void DataFlash::readID | ( | DataFlash::ID & | id | ) |
|
inline |
Disable write protection.
void DataFlash::reEnable | ( | ) |
Disable (deselect) Dataflash, then enable (select) it again.
|
inline |
Get reset (RESET) pin.
void DataFlash::resumeFromDeepPowerDown | ( | ) |
Takes the device out of Deep Power-down mode.
void DataFlash::sectorErase | ( | int8_t | sector | ) |
Erase a sector of blocks in a single operation.
sector | Sector to erase. |
void DataFlash::setup | ( | int8_t | csPin, |
int8_t | resetPin = -1 , |
||
int8_t | wpPin = -1 |
||
) |
Set pin use, with defaults for reset and write-protect if not specified as argument.
Set SPI transfer speed to "low" (can be changed with .speed() ).
csPin | Chip select (Slave select) pin. |
resetPin | Reset pin, optional (default none). |
wpPin | Write protect pin, optional (default none). |
uint8_t DataFlash::status | ( | ) |
Read status register.
void DataFlash::waitUntilReady | ( | ) |
Wait until the chip is ready.
Perform a low-to-high transition on the CS pin and then poll the status register until the Dataflash is ready for the next operation.
|
inline |
Enable write protection.
|
inline |
Get write protect (WP) pin.
DataFlash::~DataFlash | ( | ) |
Destructor.
|
staticprivate |