This class provides simplified I2C access to a Microchip 24LCxx Serial EEPROM device: - Rename the class (C2424 -> C24) - Add EraseMemoryArea method - Add DumpMemoryArea method only accessible in DEBUG mode - Add 'const' qualifier in parameters

Committer:
Yann
Date:
Wed Oct 17 07:15:33 2012 +0000
Revision:
0:21c698aa86f6
Child:
1:bdf87ab4cdb8
Bug fixed in Write methods

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yann 0:21c698aa86f6 1 /* mbed simplified access to Microchip 24LCxx Serial EEPROM devices (I2C)
Yann 0:21c698aa86f6 2 * Copyright (c) 2010-2012 ygarcia, MIT License
Yann 0:21c698aa86f6 3 *
Yann 0:21c698aa86f6 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Yann 0:21c698aa86f6 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Yann 0:21c698aa86f6 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Yann 0:21c698aa86f6 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Yann 0:21c698aa86f6 8 * furnished to do so, subject to the following conditions:
Yann 0:21c698aa86f6 9 *
Yann 0:21c698aa86f6 10 * The above copyright notice and this permission notice shall be included in all copies or
Yann 0:21c698aa86f6 11 * substantial portions of the Software.
Yann 0:21c698aa86f6 12 *
Yann 0:21c698aa86f6 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Yann 0:21c698aa86f6 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Yann 0:21c698aa86f6 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Yann 0:21c698aa86f6 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Yann 0:21c698aa86f6 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Yann 0:21c698aa86f6 18 */
Yann 0:21c698aa86f6 19 #if !defined(__24LCXX_I2C_H__)
Yann 0:21c698aa86f6 20 #define __24LCXX_I2C_H__
Yann 0:21c698aa86f6 21
Yann 0:21c698aa86f6 22 #include <string>
Yann 0:21c698aa86f6 23 #include <vector>
Yann 0:21c698aa86f6 24
Yann 0:21c698aa86f6 25 #include "Debug.h" // Include mbed header + debug primitives. See DebugLibrary
Yann 0:21c698aa86f6 26
Yann 0:21c698aa86f6 27 namespace _24LCXX_I2C {
Yann 0:21c698aa86f6 28 /** This class provides simplified I2C access to a Microchip 24LCxx Serial EEPROM device. V0.0.0.3
Yann 0:21c698aa86f6 29 *
Yann 0:21c698aa86f6 30 * Note that if the LPC1768 is powered in 3.3V and Microchip 24LCxx Serial EEPROM device could be powered at 3.3V or 5V.
Yann 0:21c698aa86f6 31 * In this case, you shall use a bi-directional level shifter for I2C-bus. Please refer to AN97055 (http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf)
Yann 0:21c698aa86f6 32 * Microchip 24LCxx Serial EEPROM device reference:
Yann 0:21c698aa86f6 33 * - 24LC256: DS21203K
Yann 0:21c698aa86f6 34 * - 24LC64 : DS21189D
Yann 0:21c698aa86f6 35 *
Yann 0:21c698aa86f6 36 * Note that for I2C details, please visit http://www.datelec.fr/fiches/I2C.htm
Yann 0:21c698aa86f6 37 *
Yann 0:21c698aa86f6 38 * Note that this header file include following headers:
Yann 0:21c698aa86f6 39 * - <string>
Yann 0:21c698aa86f6 40 * - <vector>
Yann 0:21c698aa86f6 41 * - <mbed.h>
Yann 0:21c698aa86f6 42 *
Yann 0:21c698aa86f6 43 * @remark This class was validated with Tektronix TDS2014 oscilloscope in 3.3V and in mixte power mode 3.3V for mbed and 5V for the Microchip 24LCxx Serial EEPROM device
Yann 0:21c698aa86f6 44 * @author Yann Garcia (Don't hesitate to contact me: garcia.yann@gmail.com)
Yann 0:21c698aa86f6 45 */
Yann 0:21c698aa86f6 46 class C24LCXX_I2C { // TODO: Add EE Polling for write methods
Yann 0:21c698aa86f6 47 /** Reference counter used to guarentee unicity of the instance of I2C class
Yann 0:21c698aa86f6 48 */
Yann 0:21c698aa86f6 49 static unsigned char I2CMouduleRefCounter;
Yann 0:21c698aa86f6 50
Yann 0:21c698aa86f6 51 /** Device address input: A0, A1, A2 (Pins <1,3>). See DS21203K/DS21189D - Figure 5-1: Control Byte Format for address format details
Yann 0:21c698aa86f6 52 */
Yann 0:21c698aa86f6 53 unsigned char _slaveAddress;
Yann 0:21c698aa86f6 54 /** WP state indicator (pin 7); true is write protected, false otherwise
Yann 0:21c698aa86f6 55 */
Yann 0:21c698aa86f6 56 DigitalOut *_wp;
Yann 0:21c698aa86f6 57 /** An unique instance of I2C class
Yann 0:21c698aa86f6 58 */
Yann 0:21c698aa86f6 59 I2C *_i2cInstance;
Yann 0:21c698aa86f6 60 public:
Yann 0:21c698aa86f6 61 /** Memory storage mode
Yann 0:21c698aa86f6 62 */
Yann 0:21c698aa86f6 63 enum Mode {
Yann 0:21c698aa86f6 64 LittleEndian, //<! Little Endian mode: 0xA0B70708 is stored as 08: MSB and A0 LSB
Yann 0:21c698aa86f6 65 BigEndian //<! Little Endian mode: 0xA0B70708 is stored as AO: MSB and 08 LSB
Yann 0:21c698aa86f6 66 };
Yann 0:21c698aa86f6 67 public:
Yann 0:21c698aa86f6 68 /** Constructor with Write Protect command pin wired. Use it to manage the first I2C module on 3.3V or 5V network
Yann 0:21c698aa86f6 69 *
Yann 0:21c698aa86f6 70 * @param p_sda: MBed pin for SDA
Yann 0:21c698aa86f6 71 * @param p_scl: MBed pin for SCL
Yann 0:21c698aa86f6 72 * @param p_address: Device address input: A0, A1, A2 (Pins <1,3>)
Yann 0:21c698aa86f6 73 * @param p_wp: MBed pin to manage Write Protect input. If NC, WP is not managed, default value is NC, not connected
Yann 0:21c698aa86f6 74 * @param p_frequency: Frequency of the I2C interface (SCL), default value is 400KHz
Yann 0:21c698aa86f6 75 * Example:
Yann 0:21c698aa86f6 76 * - If A1 and A2 pins are tired to Vdd and A0 is tired to Vss, address shall '00000110'B
Yann 0:21c698aa86f6 77 * - If A0 and A1 pins are tired to Vss and A2 is tired to Vdd, address shall '00000100'B
Yann 0:21c698aa86f6 78 */
Yann 0:21c698aa86f6 79 C24LCXX_I2C(const PinName p_sda, const PinName p_scl, const unsigned char p_address, const PinName p_wp = NC, const int p_frequency = 400000);
Yann 0:21c698aa86f6 80
Yann 0:21c698aa86f6 81 /** Destructor
Yann 0:21c698aa86f6 82 */
Yann 0:21c698aa86f6 83 virtual ~C24LCXX_I2C();
Yann 0:21c698aa86f6 84
Yann 0:21c698aa86f6 85 /** Used to return the unique instance of I2C instance
Yann 0:21c698aa86f6 86 */
Yann 0:21c698aa86f6 87 inline const I2C * operator * () { return (const I2C *)_i2cInstance; };
Yann 0:21c698aa86f6 88
Yann 0:21c698aa86f6 89 /** Erase of memory area starting at the specified address, using the specified pattern to fill the memory area
Yann 0:21c698aa86f6 90 *
Yann 0:21c698aa86f6 91 * @paramp_startAddress The address of the memory area (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 92 * @param p_count The size of the memory area to erase
Yann 0:21c698aa86f6 93 * @param p_pattern The pattern value to use to fill the memory area. Defqult vqlue: 0x00
Yann 0:21c698aa86f6 94 * @return true on success, false otherwise
Yann 0:21c698aa86f6 95 * Exemple:
Yann 0:21c698aa86f6 96 * @code
Yann 0:21c698aa86f6 97 * ...
Yann 0:21c698aa86f6 98 * myEEPROM.EraseMemoryArea(0, 1024); // Set to 0x00 the first 1Kb memory
Yann 0:21c698aa86f6 99 * ...
Yann 0:21c698aa86f6 100 * @endcode
Yann 0:21c698aa86f6 101 */
Yann 0:21c698aa86f6 102 bool EraseMemoryArea(const short p_startAddress, const int p_count, unsigned char const p_pattern = 0x00);
Yann 0:21c698aa86f6 103
Yann 0:21c698aa86f6 104 /** Write a byte at the specified memory address
Yann 0:21c698aa86f6 105 *
Yann 0:21c698aa86f6 106 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 107 * @param p_byte The byte value to save
Yann 0:21c698aa86f6 108 * @return true on success, false otherwise
Yann 0:21c698aa86f6 109 * Exemple:
Yann 0:21c698aa86f6 110 * @code
Yann 0:21c698aa86f6 111 * unsigned char value = 0xaa;
Yann 0:21c698aa86f6 112 * ...
Yann 0:21c698aa86f6 113 * myEEPROM.Write(memoryAddress, value);
Yann 0:21c698aa86f6 114 * ...
Yann 0:21c698aa86f6 115 * @endcode
Yann 0:21c698aa86f6 116 */
Yann 0:21c698aa86f6 117 bool Write(const short p_address, const unsigned char p_byte);
Yann 0:21c698aa86f6 118
Yann 0:21c698aa86f6 119 /** Write a short at the specified memory address according to the specified mode
Yann 0:21c698aa86f6 120 *
Yann 0:21c698aa86f6 121 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 122 * @param p_short The short value to save
Yann 0:21c698aa86f6 123 * @param p_mode The storage mode. Default value: BigEndian
Yann 0:21c698aa86f6 124 * @return true on success, false otherwise
Yann 0:21c698aa86f6 125 * Exemple:
Yann 0:21c698aa86f6 126 * @code
Yann 0:21c698aa86f6 127 * short value = 0xcafe;
Yann 0:21c698aa86f6 128 * ...
Yann 0:21c698aa86f6 129 * myEEPROM.Write(memoryAddress, value, LittleEndian);
Yann 0:21c698aa86f6 130 * ...
Yann 0:21c698aa86f6 131 * @endcode
Yann 0:21c698aa86f6 132 */
Yann 0:21c698aa86f6 133 bool Write(const short p_address, const short p_short, const C24LCXX_I2C::Mode p_mode = BigEndian);
Yann 0:21c698aa86f6 134
Yann 0:21c698aa86f6 135 /** Write an integer at the specified memory address according to the specified mode
Yann 0:21c698aa86f6 136 *
Yann 0:21c698aa86f6 137 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 138 * @param p_int The integer value to save
Yann 0:21c698aa86f6 139 * @param p_mode The storage mode. Default value: BigEndian
Yann 0:21c698aa86f6 140 * @return true on success, false otherwise
Yann 0:21c698aa86f6 141 * Exemple:
Yann 0:21c698aa86f6 142 * @code
Yann 0:21c698aa86f6 143 * int value = 0xcafedeca;
Yann 0:21c698aa86f6 144 * ...
Yann 0:21c698aa86f6 145 * myEEPROM.Write(memoryAddress, value, LittleEndian);
Yann 0:21c698aa86f6 146 * ...
Yann 0:21c698aa86f6 147 * @endcode
Yann 0:21c698aa86f6 148 */
Yann 0:21c698aa86f6 149 bool Write(const short p_address, const int p_int, const C24LCXX_I2C::Mode p_mode = BigEndian);
Yann 0:21c698aa86f6 150
Yann 0:21c698aa86f6 151 /** Write a buffer of bytes at the specified memory address
Yann 0:21c698aa86f6 152 *
Yann 0:21c698aa86f6 153 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 154 * @param p_datas The string to save
Yann 0:21c698aa86f6 155 * @param p_storeLength If true, store also the length of the buffer in Big Endian mode, otherwise the length will be provided by p_length2write parameter. Default value: true.
Yann 0:21c698aa86f6 156 * @param p_length2write The number of bytes to write, -1 for all characters. Default value: -1
Yann 0:21c698aa86f6 157 * @return true on success, false otherwise
Yann 0:21c698aa86f6 158 */
Yann 0:21c698aa86f6 159 bool Write(const short p_address, const std::vector<unsigned char> & p_datas, bool p_storeLength = true, const int p_length2write = -1);
Yann 0:21c698aa86f6 160
Yann 0:21c698aa86f6 161 /** Write a buffer of bytes at the specified memory address
Yann 0:21c698aa86f6 162 *
Yann 0:21c698aa86f6 163 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 164 * @param p_datas The buffer of bytes to save
Yann 0:21c698aa86f6 165 * @param p_storeLength If true, store also the length of the buffer in Big Endian mode, otherwise the length will be provided by p_length2write parameter. Default value: true.
Yann 0:21c698aa86f6 166 * @param p_length2write The number of bytes to write, -1 for all bytes. Default value: -1
Yann 0:21c698aa86f6 167 * @return true on success, false otherwise
Yann 0:21c698aa86f6 168 */
Yann 0:21c698aa86f6 169 bool Write(const short p_address, const unsigned char *p_datas, bool p_storeLength = true, const int p_length2write = -1);
Yann 0:21c698aa86f6 170
Yann 0:21c698aa86f6 171 /** Write a string at the specified memory address
Yann 0:21c698aa86f6 172 *
Yann 0:21c698aa86f6 173 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 174 * @param p_string The string to save
Yann 0:21c698aa86f6 175 * @param p_storeLength If true, store also the length of the string in Big Endian mode, otherwise the length will be provided by p_length2write parameter. Default value: true.
Yann 0:21c698aa86f6 176 * @param p_length2write The number of character to write, -1 for all characters
Yann 0:21c698aa86f6 177 * @return true on success, false otherwise
Yann 0:21c698aa86f6 178 * Exemple:
Yann 0:21c698aa86f6 179 * @code
Yann 0:21c698aa86f6 180 * std::string text2save("CafeDeca");
Yann 0:21c698aa86f6 181 * ...
Yann 0:21c698aa86f6 182 * myEEPROM.Write(memoryAddress, text2save);
Yann 0:21c698aa86f6 183 * ...
Yann 0:21c698aa86f6 184 * @endcode
Yann 0:21c698aa86f6 185 */
Yann 0:21c698aa86f6 186 bool Write(const short p_address, const std::string & p_string, const bool p_storeLength = true, const int p_length2write = -1);
Yann 0:21c698aa86f6 187
Yann 0:21c698aa86f6 188 /** Write a buffer of characters at the specified memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 189 *
Yann 0:21c698aa86f6 190 * Note that the length of the buffer is not saved and the string is saved in Big Endian mode
Yann 0:21c698aa86f6 191 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 192 * @param p_datas The string to save
Yann 0:21c698aa86f6 193 * @param p_storeLength If true, store also the length of the string in Big Endian mode, otherwise the length will be provided by p_length2write parameter. Default value: true.
Yann 0:21c698aa86f6 194 * @param length2write The number of character to write, -1 for all characters
Yann 0:21c698aa86f6 195 * @return true on success, false otherwise
Yann 0:21c698aa86f6 196 */
Yann 0:21c698aa86f6 197 bool Write(const short p_address, const char *p_datas, const bool p_storeLength = true, const int p_length2write = -1);
Yann 0:21c698aa86f6 198
Yann 0:21c698aa86f6 199 /** Read a byte from the specified memory address
Yann 0:21c698aa86f6 200 *
Yann 0:21c698aa86f6 201 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 202 * @param p_byte The byte value to read
Yann 0:21c698aa86f6 203 * @return true on success, false otherwise
Yann 0:21c698aa86f6 204 * Exemple:
Yann 0:21c698aa86f6 205 * @code
Yann 0:21c698aa86f6 206 * unsigned char value;
Yann 0:21c698aa86f6 207 * ...
Yann 0:21c698aa86f6 208 * myEEPROM.Read(memoryAddress, (unsigned char *)&value);
Yann 0:21c698aa86f6 209 * ...
Yann 0:21c698aa86f6 210 * @endcode
Yann 0:21c698aa86f6 211 */
Yann 0:21c698aa86f6 212 bool Read(const short p_address, unsigned char *p_value);
Yann 0:21c698aa86f6 213
Yann 0:21c698aa86f6 214 /** Read a short from the specified memory address
Yann 0:21c698aa86f6 215 *
Yann 0:21c698aa86f6 216 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 217 * @param p_short The short value to read
Yann 0:21c698aa86f6 218 * @return true on success, false otherwise
Yann 0:21c698aa86f6 219 * Exemple:
Yann 0:21c698aa86f6 220 * @code
Yann 0:21c698aa86f6 221 * short value;
Yann 0:21c698aa86f6 222 * ...
Yann 0:21c698aa86f6 223 * myEEPROM.Read(memoryAddress, (short *)&value);
Yann 0:21c698aa86f6 224 * ...
Yann 0:21c698aa86f6 225 * @endcode
Yann 0:21c698aa86f6 226 */
Yann 0:21c698aa86f6 227 bool Read(const short p_address, short *p_short, C24LCXX_I2C::Mode p_mode = BigEndian);
Yann 0:21c698aa86f6 228
Yann 0:21c698aa86f6 229 /** Read an integer from the specified memory address
Yann 0:21c698aa86f6 230 *
Yann 0:21c698aa86f6 231 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 232 * @param p_int The integer value to read
Yann 0:21c698aa86f6 233 * @return true on success, false otherwise
Yann 0:21c698aa86f6 234 * Exemple:
Yann 0:21c698aa86f6 235 * @code
Yann 0:21c698aa86f6 236 * int value;
Yann 0:21c698aa86f6 237 * ...
Yann 0:21c698aa86f6 238 * myEEPROM.Read(memoryAddress, (int *)&value);
Yann 0:21c698aa86f6 239 * ...
Yann 0:21c698aa86f6 240 * @endcode
Yann 0:21c698aa86f6 241 */
Yann 0:21c698aa86f6 242 bool Read(const short p_address, int *p_int, C24LCXX_I2C::Mode p_mode = BigEndian);
Yann 0:21c698aa86f6 243
Yann 0:21c698aa86f6 244 /** Read a buffer of bytes from the specified memory address and store it into a std::vector<unsigned char> object
Yann 0:21c698aa86f6 245 *
Yann 0:21c698aa86f6 246 * Note that the size of the buffer object is used for the number of bytes to read
Yann 0:21c698aa86f6 247 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 248 * @param p_datas The buffer to fill
Yann 0:21c698aa86f6 249 * @param p_readLengthFirst If true, read the length first and p_length2write parameter is ignored, otherwise the length is provided by p_length2write parameter. Default value: true
Yann 0:21c698aa86f6 250 * @param p_length2write The number of character to write, -1 to use the size of the string buffer
Yann 0:21c698aa86f6 251 * @return true on success, false otherwise
Yann 0:21c698aa86f6 252 * Exemple:
Yann 0:21c698aa86f6 253 * @code
Yann 0:21c698aa86f6 254 * std::vector<unsigned char> datas(bufferLength);
Yann 0:21c698aa86f6 255 * ...
Yann 0:21c698aa86f6 256 * myEEPROM.Read(memoryAddress, datas);
Yann 0:21c698aa86f6 257 * ...
Yann 0:21c698aa86f6 258 * @endcode
Yann 0:21c698aa86f6 259 */
Yann 0:21c698aa86f6 260 bool Read(const short p_address, std::vector<unsigned char> & p_datas, bool p_readLengthFirst = true, int p_length2write = -1);
Yann 0:21c698aa86f6 261
Yann 0:21c698aa86f6 262 /** Read a buffer of characters from the specified memory address and store it into a string object
Yann 0:21c698aa86f6 263 *
Yann 0:21c698aa86f6 264 * Note that the size of the string object is used for the number of characters to read
Yann 0:21c698aa86f6 265 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 266 * @param p_string The string buffer to fill
Yann 0:21c698aa86f6 267 * @param p_readLengthFirst If true, read the length first and p_length2write parameter is ignored, otherwise the length is provided by p_length2write parameter. Default value: true
Yann 0:21c698aa86f6 268 * @param p_length2write The number of character to write, -1 to use the size of the string buffer
Yann 0:21c698aa86f6 269 * @return true on success, false otherwise
Yann 0:21c698aa86f6 270 * Exemple:
Yann 0:21c698aa86f6 271 * @code
Yann 0:21c698aa86f6 272 * std::string readtext;
Yann 0:21c698aa86f6 273 * ...
Yann 0:21c698aa86f6 274 * myEEPROM.Read(memoryAddress, readtext);
Yann 0:21c698aa86f6 275 * ...
Yann 0:21c698aa86f6 276 * @endcode
Yann 0:21c698aa86f6 277 */
Yann 0:21c698aa86f6 278 bool Read(const short p_address, std::string & p_string, bool p_readLengthFirst = true, int p_length2write = -1);
Yann 0:21c698aa86f6 279
Yann 0:21c698aa86f6 280 /** Activate or deactivate write protect (pin 7)
Yann 0:21c698aa86f6 281 *
Yann 0:21c698aa86f6 282 * Note that a voltage of 3.3V apply to WP input of 24LCxx device is enough to enable write protect
Yann 0:21c698aa86f6 283 * @param p_writeProtect: Set to true to activate write protection, false otherwise
Yann 0:21c698aa86f6 284 * @return true on success, false otherwise
Yann 0:21c698aa86f6 285 */
Yann 0:21c698aa86f6 286 bool WriteProtect(const bool p_writeProtect);
Yann 0:21c698aa86f6 287
Yann 0:21c698aa86f6 288 /** Indicate the current WP state indicator (pin 7)
Yann 0:21c698aa86f6 289 * @return true is write protected, false otherwise
Yann 0:21c698aa86f6 290 */
Yann 0:21c698aa86f6 291 inline bool IsWriteProtected() {
Yann 0:21c698aa86f6 292 return (_wp != NULL) ? (bool)(_wp->read() == 1) : false;
Yann 0:21c698aa86f6 293 }
Yann 0:21c698aa86f6 294
Yann 0:21c698aa86f6 295 #if defined(__DEBUG)
Yann 0:21c698aa86f6 296 /** Dump a memory area
Yann 0:21c698aa86f6 297 *
Yann 0:21c698aa86f6 298 * Note that this method is available only on debug mode
Yann 0:21c698aa86f6 299 * @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
Yann 0:21c698aa86f6 300 * @param p_count The number of bytes toi dump
Yann 0:21c698aa86f6 301 * @return true on success, false otherwise
Yann 0:21c698aa86f6 302 */
Yann 0:21c698aa86f6 303 void DumpMemoryArea(const int p_address, const int p_count);
Yann 0:21c698aa86f6 304 /** For debug purpose only
Yann 0:21c698aa86f6 305 */
Yann 0:21c698aa86f6 306 inline std::string & ToString() { return _internalId; };
Yann 0:21c698aa86f6 307 #else // __DEBUG
Yann 0:21c698aa86f6 308 inline void DumpMemoryArea(const int p_address, const int p_count) {};
Yann 0:21c698aa86f6 309 #endif // _DEBUG
Yann 0:21c698aa86f6 310
Yann 0:21c698aa86f6 311 private:
Yann 0:21c698aa86f6 312 /** Internal reference identifier
Yann 0:21c698aa86f6 313 */
Yann 0:21c698aa86f6 314 std::string _internalId;
Yann 0:21c698aa86f6 315
Yann 0:21c698aa86f6 316 }; // End of class C24LCXX_I2C
Yann 0:21c698aa86f6 317
Yann 0:21c698aa86f6 318 } // End of namespace _24LCXX_I2C
Yann 0:21c698aa86f6 319
Yann 0:21c698aa86f6 320 using namespace _24LCXX_I2C;
Yann 0:21c698aa86f6 321
Yann 0:21c698aa86f6 322 #endif // __24LCXX_I2C_H__