Simplified access to Ramtron (Cypress) FM24Vxx F-RAM devices

Dependents:   FM24Vxx_I2CApp

Committer:
Yann
Date:
Sat Mar 23 15:54:01 2013 +0000
Revision:
0:fa858f79d48d
Child:
1:6a16bddd7222
Create library interface for FM24V10 1Mb Serial 3V F-RAM Memory (Requested by M. Reed Kimble)

Who changed what in which revision?

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