https://github.com/blockos/arduino-dataflash
Support for Atmel Dataflash for the Arduino
https://github.com/blockos/arduino-dataflash
arduino arduino-library c-plus-plus dataflash
Last synced: 9 months ago
JSON representation
Support for Atmel Dataflash for the Arduino
- Host: GitHub
- URL: https://github.com/blockos/arduino-dataflash
- Owner: BlockoS
- Created: 2009-09-06T13:46:19.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2024-03-17T18:14:30.000Z (almost 2 years ago)
- Last Synced: 2024-03-17T19:28:30.254Z (almost 2 years ago)
- Topics: arduino, arduino-library, c-plus-plus, dataflash
- Language: C++
- Homepage: http://blockos.github.com/arduino-dataflash
- Size: 815 KB
- Stars: 23
- Watchers: 8
- Forks: 14
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Arduino DataFlash library
================================
This is library adds support for the AT45DB SPI flash memory from Adesto Technology (which bought it from Atmel in 2012).
At the moment only the D version is supported.
Hardware setup
-------------------------------
DataFlash is 5V tolerant but you must power it with 3.3V.
| Signal | Arduino pin | Dataflash |
|--------|--------------|-----------|
| MISO | 11 | 1 |
| MOSI | 12 | 8 |
| SCK | 13 | 2 |
| SS | 10 | 4 |
| RESET | user defined | 3 |
| WP | user defined | 5 |
Software setup
-------------------------------
Copy the following filesto your library or sketch folder.
* DataFlash.cpp
* DataFlash.h
* DataFlashCommands.h
* DataFlashInlines.h
* DataFlashSizes.h
DataFlash_test.cpp is a simple unit test program. It is built upon the [arduino-tests library](https://github.com/BlockoS/arduino-tests).
The /examples/ directory contains some sample sketches.
Please refer to the [doxygen documentation](http://blockos.github.io/arduino-dataflash/doxygen/html/) for a more detailed API description.
Example
-------------------------------
The following example shows how to write and read on a AT45DB161D DataFlash.
```cpp
#include
#include "DataFlash.h"
static const int csPin = 10;
static const int resetPin = 8;
static const int wpPin = 7;
DataFlash dataflash;
void setup()
{
uint8_t status;
DataFlash::ID id;
const char* dummyMessage = "Hello world";
SPI.begin();
dataflash.setup(csPin, resetPin, wpPin);
dataflash.begin();
status = dataflash.status();
dataflash.readID(id);
// For a brand new AT45DB161D dataflash
// status = BIN(00101100)
// id.manufacturer = 0x1F;
// id.device[0] = 0x26;
// id.device[1] = 0x00;
// id.extendedInfoLength = 0x00;
// Write "Hello world" to buffer 1.
dataflash.bufferWrite(1, 0);
for(int i=0; dummyMessage[i] != '\0'; i++)
{
SPI.transfer(dummyMessage[i]);
}
// Transfer buffer 1 to page 7.
dataflash.bufferToPage(1, 7);
// Read page 5.
dataflash.pageRead(5, 0);
for(int i=0; i