arduino-dataflash
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataFlash Class Reference

AT45DBxxxD Atmel Dataflash device. More...

#include <DataFlash.h>

Classes

struct  AddressingInfos
 Dataflash read/write addressing infos. More...
 
struct  ID
 ID structure. More...
 

Public Types

enum  erasemode { ERASE_AUTO, ERASE_MANUAL }
 Erase mode. More...
 
enum  IOspeed { SPEED_LOW, SPEED_HIGH }
 IO speed. More...
 

Public Member Functions

 DataFlash ()
 Constructor.
 
 ~DataFlash ()
 Destructor.
 
void 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 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 end ()
 Restore SPI configuration, so it can be used by other SPI devices.
 
void enable ()
 Enable (select) Dataflash.
 
void disable ()
 Disable (deselect) Dataflash.
 
void reEnable ()
 Disable (deselect) Dataflash, then enable (select) it again.
 
void autoErase ()
 Set erase mode to automatic (default).
 
void manualErase ()
 Set erase mode to manual.
 
uint8_t isReady ()
 Return whether the chip has completed the current operation and is ready for the next.
 
void waitUntilReady ()
 Wait until the chip is ready.
 
void endAndWait ()
 Same as waitUntilReady.
 
uint8_t status ()
 Read status register.
 
void readID (DataFlash::ID &id)
 Read Manufacturer and Device ID.
 
void 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 arrayRead (uint16_t page, uint16_t offset=0)
 Sequentially read a continuous stream of data at the currently set speed.
 
void bufferRead (uint8_t bufferNum, uint16_t offset=0)
 Read the content of one of the SRAM data buffer at the currently set speed.
 
void bufferWrite (uint8_t bufferNum, uint16_t offset)
 Write data to one of the SRAM data buffers at the currently set speed.
 
void 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 pageToBuffer (uint16_t page, uint8_t bufferNum)
 Transfer a page of data from main memory to buffer 0 or 1.
 
void pageErase (uint16_t page)
 Erase a page in the main memory array.
 
void blockErase (uint16_t block)
 Erase a block of pages in a single operation.
 
void sectorErase (int8_t sector)
 Erase a sector of blocks in a single operation.
 
void 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 isPageEqualBuffer (uint16_t page, uint8_t bufferNum)
 Compare a page of data in main memory to the data in buffer 0 or 1.
 
void deepPowerDown ()
 Put the device into the lowest power consumption mode.
 
void resumeFromDeepPowerDown ()
 Takes the device out of Deep Power-down mode.
 
void hardReset ()
 Reset device via the reset pin.
 
void writeProtect ()
 Enable write protection.
 
void readWrite ()
 Disable write protection.
 
int8_t chipSelectPin () const
 Get chip Select (CS) pin.
 
int8_t resetPin () const
 Get reset (RESET) pin.
 
int8_t writeProtectPin () const
 Get write protect (WP) pin.
 

Private Member Functions

uint8_t pageToHiU8 (uint16_t page) const
 Compute page address hi byte.
 
uint8_t pageToLoU8 (uint16_t page) const
 Compute page address lo byte.
 

Private Attributes

int8_t m_chipSelectPin
 Chip select pin (CS).
 
int8_t m_resetPin
 Reset pin (RESET).
 
int8_t m_writeProtectPin
 Write protect pin (WP).
 
uint8_t m_SPCR
 SPI register backup.
 
uint8_t m_SPSR
 SPI register backup.
 
uint8_t m_bufferSize
 Size of the buffer address bits.
 
uint8_t m_pageSize
 Size of the page address bits.
 
uint8_t m_sectorSize
 Size of the sector address bits.
 
enum erasemode m_erase
 Erase mode - auto or manual.
 

Static Private Attributes

static const AddressingInfos m_infos
 

Detailed Description

AT45DBxxxD Atmel Dataflash device.

Member Enumeration Documentation

Erase mode.

Whether pages are erased automatically before being written, or whether this is expected to be done explicitly first.

Enumerator:
ERASE_AUTO 

Pages are erased automatically.

ERASE_MANUAL 

Pages are erased by the user first.

IO speed.

The max SPI SCK frequency an ATmega 328P or 1280 can generate is 10MHz. The limit for low-speed SCK for AT45DBxxxD Dataflash is 33MHz (66MHz for high-speed). Supporting high-speed for Arduino is a waste of time...

Enumerator:
SPEED_LOW 

Low speed transfers up to 33MHz.

SPEED_HIGH 

High speed transfers up to 66MHz.

Member Data Documentation

uint8_t DataFlash::m_bufferSize
private

Size of the buffer address bits.

int8_t DataFlash::m_chipSelectPin
private

Chip select pin (CS).

enum erasemode DataFlash::m_erase
private

Erase mode - auto or manual.

uint8_t DataFlash::m_pageSize
private

Size of the page address bits.

int8_t DataFlash::m_resetPin
private

Reset pin (RESET).

uint8_t DataFlash::m_sectorSize
private

Size of the sector address bits.

uint8_t DataFlash::m_SPCR
private

SPI register backup.

uint8_t DataFlash::m_SPSR
private

SPI register backup.

int8_t DataFlash::m_writeProtectPin
private

Write protect pin (WP).


The documentation for this class was generated from the following files: