Subversion Repositories idreammicro-arduino

Rev

Details | Last modification | View Log | RSS feed

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