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
Revision 1:bdf87ab4cdb8, committed 2013-01-25
- Comitter:
- Yann
- Date:
- Fri Jan 25 09:24:05 2013 +0000
- Parent:
- 0:21c698aa86f6
- Child:
- 2:16ce7dae9019
- Commit message:
- Fix bad ariable naming
Changed in this revision
| 24LCxx_I2C.cpp | Show annotated file Show diff for this revision Revisions of this file |
| 24LCxx_I2C.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/24LCxx_I2C.cpp Wed Oct 17 07:15:33 2012 +0000
+++ b/24LCxx_I2C.cpp Fri Jan 25 09:24:05 2013 +0000
@@ -23,23 +23,23 @@
namespace _24LCXX_I2C {
- unsigned char C24LCXX_I2C::I2CMouduleRefCounter = 0;
+ unsigned char C24LCXX_I2C::I2CModuleRefCounter = 0;
C24LCXX_I2C::C24LCXX_I2C(const PinName p_sda, const PinName p_scl, const unsigned char p_address, const PinName p_wp, const int p_frequency) : _internalId("") {
DEBUG_ENTER("C24LCXX_I2C")
- if (C24LCXX_I2C::I2CMouduleRefCounter != 0) {
+ if (C24LCXX_I2C::I2CModuleRefCounter != 0) {
error("C24LCXX_I2C: Wrong params");
}
#ifdef __DEBUG
std::ostringstream out(std::ostringstream::out);
- out << "C24LCXX_I2C #" << C24LCXX_I2C::I2CMouduleRefCounter;
+ out << "C24LCXX_I2C #" << C24LCXX_I2C::I2CModuleRefCounter;
_internalId.assign(out.str());
DEBUG("C24LCXX_I2C: _internalId='%s'", _internalId.c_str())
#endif // __DEBUG
_i2cInstance = new I2C(p_sda, p_scl, "24LCxx_I2C");
- C24LCXX_I2C::I2CMouduleRefCounter += 1;
- DEBUG_ENTER("C24LCXX_I2C: refCounter=%d", C24LCXX_I2C::I2CMouduleRefCounter)
+ C24LCXX_I2C::I2CModuleRefCounter += 1;
+ DEBUG_ENTER("C24LCXX_I2C: refCounter=%d", C24LCXX_I2C::I2CModuleRefCounter)
_slaveAddress = (p_address << 1) | 0xa0; // Slave address format is: 1 0 1 0 A3 A2 A1 R/W
DEBUG("C24LCXX_I2C: I2C slave adress: 0x%02x", _slaveAddress)
@@ -60,9 +60,9 @@
DEBUG_ENTER("~C24LCXX_I2C")
// Release I2C instance
- DEBUG_ENTER("~C24LCXX_I2C: refCounter=%d", C24LCXX_I2C::I2CMouduleRefCounter)
- C24LCXX_I2C::I2CMouduleRefCounter -= 1;
- if (C24LCXX_I2C::I2CMouduleRefCounter == 0) {
+ DEBUG_ENTER("~C24LCXX_I2C: refCounter=%d", C24LCXX_I2C::I2CModuleRefCounter)
+ C24LCXX_I2C::I2CModuleRefCounter -= 1;
+ if (C24LCXX_I2C::I2CModuleRefCounter == 0) {
delete _i2cInstance;
_i2cInstance = NULL;
}
--- a/24LCxx_I2C.h Wed Oct 17 07:15:33 2012 +0000
+++ b/24LCxx_I2C.h Fri Jan 25 09:24:05 2013 +0000
@@ -46,7 +46,7 @@
class C24LCXX_I2C { // TODO: Add EE Polling for write methods
/** Reference counter used to guarentee unicity of the instance of I2C class
*/
- static unsigned char I2CMouduleRefCounter;
+ static unsigned char I2CModuleRefCounter;
/** Device address input: A0, A1, A2 (Pins <1,3>). See DS21203K/DS21189D - Figure 5-1: Control Byte Format for address format details
*/
@@ -90,7 +90,7 @@
*
* @paramp_startAddress The address of the memory area (from 0 to N - 1, N is the number of cells of the memory)
* @param p_count The size of the memory area to erase
- * @param p_pattern The pattern value to use to fill the memory area. Defqult vqlue: 0x00
+ * @param p_pattern The pattern value to use to fill the memory area. Default vqlue: 0x00
* @return true on success, false otherwise
* Exemple:
* @code
@@ -247,7 +247,7 @@
* @param p_address The memory address (from 0 to N - 1, N is the number of cells of the memory)
* @param p_datas The buffer to fill
* @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
- * @param p_length2write The number of character to write, -1 to use the size of the string buffer
+ * @param p_length2read The number of character to write, -1 to use the size of the string buffer
* @return true on success, false otherwise
* Exemple:
* @code
@@ -257,7 +257,7 @@
* ...
* @endcode
*/
- bool Read(const short p_address, std::vector<unsigned char> & p_datas, bool p_readLengthFirst = true, int p_length2write = -1);
+ bool Read(const short p_address, std::vector<unsigned char> & p_datas, bool p_readLengthFirst = true, int p_length2read = -1);
/** Read a buffer of characters from the specified memory address and store it into a string object
*
Yann Garcia
24LCxx Serial EEPROM library