Subversion Repositories idreammicro-arduino

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
16 jlesech 1
/**************************************************************************//**
2
 * \brief EEPROM 24C512 library for Arduino - Demonstration program
3
 * \author Copyright (C) 2012  Julien Le Sech - www.idreammicro.com
4
 * \version 1.0
5
 * \date 20120218
6
 *
7
 * This file is part of the EEPROM 24C512 library for Arduino.
8
 *
9
 * This library is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU Lesser General Public License as published by the Free
11
 * Software Foundation, either version 3 of the License, or (at your option) any
12
 * later version.
13
 *
14
 * This library is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with this program. If not, see http://www.gnu.org/licenses/
21
 ******************************************************************************/
22
 
23
/**************************************************************************//**
24
 * \file WriteReadByte.ino
25
 ******************************************************************************/
26
 
27
/******************************************************************************
28
 * Header file inclusions.
29
 ******************************************************************************/
30
 
31
#include <Wire.h>
32
 
33
#include <Eeprom24C512.h>
34
 
35
/******************************************************************************
36
 * Private macro definitions.
37
 ******************************************************************************/
38
 
39
/**************************************************************************//**
40
 * \def EEPROM_ADDRESS
41
 * \brief Address of EEPROM memory on TWI bus.
42
 ******************************************************************************/
43
#define EEPROM_ADDRESS  0x50
44
 
45
/******************************************************************************
46
 * Private variable definitions.
47
 ******************************************************************************/
48
 
49
static Eeprom24C512 eeprom(EEPROM_ADDRESS);
50
 
51
/******************************************************************************
52
 * Public function definitions.
53
 ******************************************************************************/
54
 
55
/**************************************************************************//**
56
 * \fn void setup()
57
 *
58
 * \brief
59
 ******************************************************************************/
60
void setup()
61
{
62
    // Initialize serial communication.
63
    Serial.begin(9600);
64
 
65
    // Initialize EEPROM library.
66
    eeprom.initialize();
67
 
68
    // Write a byte at address 0 in EEPROM memory.
69
    Serial.println("Write byte to EEPROM memory...");
70
    eeprom.writeByte(0, 0xAA);
71
 
72
    // Write cycle time (tWR). See EEPROM memory datasheet for more details.
73
    delay(10);
74
 
75
    // Read a byte at address 0 in EEPROM memory.
76
    Serial.println("Read byte from EEPROM memory...");
77
    byte data = eeprom.readByte(0);
78
 
79
    // Print read byte.
80
    Serial.print("Read byte = 0x");
81
    Serial.print(data, HEX);
82
    Serial.println("");
83
}
84
 
85
/**************************************************************************//**
86
 * \fn void loop()
87
 *
88
 * \brief
89
 ******************************************************************************/
90
void loop()
91
{
92
 
93
}