mFS file system library for EEPROM memory chips.

Committer:
HBP
Date:
Mon Feb 21 18:26:27 2011 +0000
Revision:
5:a0fe74dce80d
Parent:
0:cbf45dde2b49
Child:
7:5ac5121bb4e0
-File::read issues fixed
-rewind/forward functions improved
-Added possibility change I2C speed
-I2C autoreset on failure (P20 wired to SCL)

Now it\s actually realible and useful library :)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HBP 0:cbf45dde2b49 1 /*H****************************************************************************
HBP 0:cbf45dde2b49 2 * FILENAME : i2c_eeprom.h *
HBP 0:cbf45dde2b49 3 * *
HBP 0:cbf45dde2b49 4 * DESCRIPTION : *
HBP 0:cbf45dde2b49 5 * Simple library for external I2C EEEPROM. *
HBP 0:cbf45dde2b49 6 * *
HBP 0:cbf45dde2b49 7 * AUTHOR : Olli Vanhoja START DATE : 2011-02-17 *
HBP 0:cbf45dde2b49 8 *******************************************************************************
HBP 0:cbf45dde2b49 9 *
HBP 0:cbf45dde2b49 10 * CHANGES :
HBP 0:cbf45dde2b49 11 *
HBP 5:a0fe74dce80d 12 * VERSION DATE WHO DETAIL
HBP 5:a0fe74dce80d 13 * 0.1 2011-02-21 Olli Vanhoja Initial release version
HBP 5:a0fe74dce80d 14 * 0.2 2011-02-21 Olli Vanhoja *Added possibility change I2C speed
HBP 5:a0fe74dce80d 15 * *Added external reset pin and autoreset
HBP 5:a0fe74dce80d 16 * for read function. Thanks to Jon Ward.
HBP 5:a0fe74dce80d 17 * *Documentational comments added.
HBP 0:cbf45dde2b49 18 *
HBP 0:cbf45dde2b49 19 *H*/
HBP 0:cbf45dde2b49 20
HBP 0:cbf45dde2b49 21 #ifndef I2C_EEPROM_H
HBP 0:cbf45dde2b49 22 #define I2C_EEPROM_H
HBP 0:cbf45dde2b49 23
HBP 0:cbf45dde2b49 24 typedef unsigned short int uint16;
HBP 0:cbf45dde2b49 25
HBP 5:a0fe74dce80d 26 /** I2C EEPROM access class
HBP 5:a0fe74dce80d 27 *
HBP 5:a0fe74dce80d 28 * This class is used for communication with I2C EEPROM chip.
HBP 5:a0fe74dce80d 29 */
HBP 0:cbf45dde2b49 30 class i2c_eeprom {
HBP 0:cbf45dde2b49 31 private:
HBP 0:cbf45dde2b49 32 int i_i2c_address; // I2C harware address
HBP 0:cbf45dde2b49 33 public:
HBP 5:a0fe74dce80d 34 /** Initialize communication
HBP 5:a0fe74dce80d 35 *
HBP 5:a0fe74dce80d 36 * @param hwAddr Harware address of the I2C EEPROM chip.
HBP 5:a0fe74dce80d 37 * @param speed I2C bus speed.
HBP 5:a0fe74dce80d 38 */
HBP 5:a0fe74dce80d 39 i2c_eeprom(int hwAddr, int speed);
HBP 5:a0fe74dce80d 40
HBP 5:a0fe74dce80d 41 /** Write to I2C EEPROM
HBP 5:a0fe74dce80d 42 *
HBP 5:a0fe74dce80d 43 * Write any length of bytes to external EEPROM.
HBP 5:a0fe74dce80d 44 *
HBP 5:a0fe74dce80d 45 * @param *data Array of bytes.
HBP 5:a0fe74dce80d 46 * @param iAddr Memory address.
HBP 5:a0fe74dce80d 47 * @param n Write n bytes.
HBP 5:a0fe74dce80d 48 */
HBP 5:a0fe74dce80d 49 void write(char *data, uint16 iAddr, unsigned int n);
HBP 5:a0fe74dce80d 50
HBP 5:a0fe74dce80d 51 /** Read from I2C EEPROM
HBP 5:a0fe74dce80d 52 *
HBP 5:a0fe74dce80d 53 * Read any length of bytes from external EEPROM.
HBP 5:a0fe74dce80d 54 *
HBP 5:a0fe74dce80d 55 * @param iAddr Memory address.
HBP 5:a0fe74dce80d 56 * @param n Read n bytes.
HBP 5:a0fe74dce80d 57 * @param *out Returns array of bytes.
HBP 5:a0fe74dce80d 58 */
HBP 5:a0fe74dce80d 59 void read(uint16 iAddr, uint16 n, char *out);
HBP 0:cbf45dde2b49 60 };
HBP 0:cbf45dde2b49 61
HBP 0:cbf45dde2b49 62 #endif