Giter VIP home page Giter VIP logo

arduino-dataflash's Introduction

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.
          Arduino     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 for a more detailed API description.

Example
-------------------------------
The following example shows how to write and read on a AT45DB161D DataFlash.

#include <SPI.h>
#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<DF_45DB161_PAGESIZE; i++)
  {
    uint8_t data = SPI.transfer(0xff);
  }
}

void loop()
{
  // nothing
}

arduino-dataflash's People

Contributors

blockos avatar

Watchers

thetazzbot avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.