Giter Site home page Giter Site logo

tyzjames / at24cx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luffykesh/at24cx

0.0 0.0 0.0 13 KB

Library for using the Atmel's EEPROM AT24C32/AT24C64/AT24C128/AT24C256/AT24C512/AT24CM01/AT24CM02 in Arduino projects.

License: MIT License

C++ 100.00%

at24cx's Introduction

AT24CX Library

Library for using the Atmels EEPROM AT24C32/AT24C64/AT24C128/AT24C256/AT24C512 in Arduino projects. See https://oberguru.net/elektronik/eeprom/at24cx-at24c32-at24c64-at24c128-at24c256-at24c512.html for definitons and differences.

Written by Christian Paul, 2014 - 2015.

Modified by Rushikesh Patel, 2019

This software is released under the terms of the MIT license. See the file LICENSE or LIZENZ for details, please.

You can use any of the eight possibles EEPROM devices on the I2C bus.

Constructor

For AT24C32-512:
 AT24CX(byte pageSize);
For AT24CM01,AT24CM02:
 AT24CM01(byte index);
 AT24CM02(byte index);

use the device with index 0 and given page size. You can select a device with given index between 0 and 8 with constructor

AT24CX(byte index, byte pageSize); //for AT24C32-512

Then, you can write or read single byte from the EEPROM with

void write(unsigned int address, byte data);
byte read(unsigned int address);

or write and read an array of bytes with

void write(unsigned int address, byte *data, int n);
void read(unsigned int address, byte *data, int n);

For writing integers, long, float, double or sequences of chars you can use the following functions

void writeInt(unsigned int address, unsigned int data);
void writeLong(unsigned int address, unsigned long data);
void writeFloat(unsigned int address, float data);
void writeDouble(unsigned int address, double data);
void writeChars(unsigned int address, char *data, int length);

Reading the values is done by using

unsigned int readInt(unsigned int address);
unsigned long readLong(unsigned int address);
float readFloat(unsigned int address);
double readDouble(unsigned int address);
void readChars(unsigned int address, char *data, int n);

Alternative you can use the individual classes with predefined page sizes:

AT24C32();
AT24C64();
AT24C128();
AT24C256();
AT24C512();
AT24CM01();
AT24CM02();

or with different index than 0:

AT24C32(byte index);
AT24C64(byte index);
AT24C128(byte index);
AT24C256(byte index);
AT24C512(byte index);
AT24CM01(byte index);
AT24CM02(byte index);

For AT24CM01/02 individual classes should be used rather than using the AT24CX class, because they have the logic for modifying the i2c address according to the data word address being read/written.

at24cx's People

Contributors

luffykesh avatar cyberp 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.