Subversion Repositories idreammicro-arduino

Rev

Rev 7 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 jlesech 1
/**************************************************************************//**
9 jlesech 2
 * \brief EEPROM 24C128 / 24C256 library for Arduino
7 jlesech 3
 * \author Copyright (C) 2012  Julien Le Sech - www.idreammicro.com
4
 * \version 1.0
5
 * \date 20120203
6
 *
9 jlesech 7
 * This file is part of the EEPROM 24C128 / 24C256 library for Arduino.
7 jlesech 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
/**************************************************************************//**
9 jlesech 24
 * \headerfile Eeprom24C128_256.h
7 jlesech 25
 ******************************************************************************/
26
 
9 jlesech 27
#ifndef Eeprom24C128_256_h
28
#define Eeprom24C128_256_h
7 jlesech 29
 
30
/******************************************************************************
31
 * Header file inclusion.
32
 ******************************************************************************/
33
 
34
#include <Arduino.h>
35
 
36
/**************************************************************************//**
9 jlesech 37
 * \class Eeprom24C128_256
7 jlesech 38
 *
9 jlesech 39
 * \brief EEPROM 24C128 / 24C256 memory driver.
7 jlesech 40
 *
41
 * This driver is mainly designed for 24C128 and 24C256 EEPROM memories. It's
42
 * also suitable for 24C512 memories.
43
 ******************************************************************************/
9 jlesech 44
class Eeprom24C128_256
7 jlesech 45
{
46
    public:
47
 
48
        /******************************************************************//**
9 jlesech 49
         * \fn Eeprom24C128_256(byte deviceAddress)
7 jlesech 50
         *
51
         * \brief Constructor.
52
         *
53
         * \param   deviceAddress   EEPROM address on TWI bus.
54
         **********************************************************************/
9 jlesech 55
        Eeprom24C128_256
7 jlesech 56
        (
57
            byte deviceAddress
58
        );
59
 
60
        /******************************************************************//**
61
         * \fn void initialize()
62
         *
63
         * \brief Initialize library abnd TWI bus.
64
         *
65
         * If several devices are connected to TWI bus, this method mustn't be
66
         * called. TWI bus must be initialized out of this library using
67
         * Wire.begin() method.
68
         **********************************************************************/        
69
        void
70
        initialize();
71
 
72
        /******************************************************************//**
73
         * \fn void writeByte(
74
         * word address,
75
         * byte data)
76
         *
77
         * \brief Write a byte in EEPROM memory.
78
         *
79
         * \remarks A delay of 10 ms is required after write cycle.
80
         *
81
         * \param   address Address.
82
         * \param   data    Byte to write.
83
         **********************************************************************/
84
        void
85
        writeByte
86
        (
87
            word    address,
88
            byte    data
89
        );
90
 
91
        /******************************************************************//**
92
         * \fn void writeBytes(
93
         * word     address,
94
         * word     length,
95
         * byte*    p_data)
96
         *
97
         * \brief Write bytes in EEPROM memory.
98
         *
99
         * \param       address Start address.
100
         * \param       length  Number of bytes to write.
101
         * \param[in]   p_data  Bytes to write.
102
         **********************************************************************/
103
        void
104
        writeBytes
105
        (
106
            word    address,
107
            word    length,
108
            byte*   p_data
109
        );
110
 
111
        /******************************************************************//**
112
         * \fn byte readByte(word address)
113
         *
114
         * \brief Read a byte in EEPROM memory.
115
         *
116
         * \param   address Address.
117
         *
118
         * \return Read byte.
119
         **********************************************************************/
120
        byte
121
        readByte
122
        (
123
            word    address
124
        );
125
 
126
        /******************************************************************//**
127
         * \fn void readBytes(
128
         * word     address,
129
         * word     length,
130
         * byte*    p_data)
131
         *
132
         * \brief Read bytes in EEPROM memory.
133
         *
134
         * \param       address Start address.
135
         * \param       length  Number of bytes to read.
136
         * \patam[in]   p_data  Byte array to fill with read bytes.
137
         **********************************************************************/
138
        void
139
        readBytes
140
        (
141
            word    address,
142
            word    length,
143
            byte*   p_buffer
144
        );
145
 
146
    private:
147
 
148
        byte m_deviceAddress;
149
 
150
        /******************************************************************//**
151
         * \fn void writePage(
152
         * word     address,
153
         * byte     length,
154
         * byte*    p_data)
155
         *
156
         * \brief Write page in EEPROM memory.
157
         *
158
         * \param       address Start address.
159
         * \param       length  Number of bytes (64 bytes max).
160
         * \param[in]   p_data  Data.
161
         **********************************************************************/
162
        void
163
        writePage
164
        (
165
            word    address,
166
            byte    length,
167
            byte*   p_data
168
        );
169
 
170
        /******************************************************************//**
171
         * \fn void writeBuffer(
172
         * word     address,
173
         * byte     length,
174
         * byte*    p_data)
175
         *
176
         * \brief Write bytes into memory.
177
         *
178
         * \param       address Start address.
179
         * \param       length  Number of bytes (30 bytes max).
180
         * \param[in]   p_date  Data.
181
         **********************************************************************/
182
        void
183
        writeBuffer
184
        (
185
            word    address,
186
            byte    length,
187
            byte*   p_data
188
       );
189
 
190
        /******************************************************************//**
191
         * \fn void readBuffer(
192
         * word     address,
193
         * byte     length,
194
         * byte*    p_data)
195
         *
196
         * \brief Read bytes in memory.
197
         *
198
         * \param       address Start address.
199
         * \param       length  Number of bytes to read (32 bytes max).
200
         * \param[in]   p_data  Buffer to fill with read bytes.
201
         **********************************************************************/
202
        void
203
        readBuffer
204
        (
205
            word    address,
206
            byte    length,
207
            byte*   p_data
208
        );
209
};
210
 
9 jlesech 211
#endif // Eeprom24C128_256_h
7 jlesech 212