mFS file system library for EEPROM memory chips.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers i2c_eeprom.h Source File

i2c_eeprom.h

00001 /*H****************************************************************************
00002  * FILENAME :        i2c_eeprom.h                                             *
00003  *                                                                            *
00004  * DESCRIPTION :                                                              *
00005  *       Simple library for external I2C EEEPROM.                             *
00006  *                                                                            *
00007  * AUTHOR :    Olli Vanhoja        START DATE :    2011-02-17                 *
00008  ******************************************************************************
00009  *
00010  * CHANGES :
00011  *
00012  * VERSION DATE       WHO            DETAIL
00013  * 0.1     2011-02-21 Olli Vanhoja   Initial release version
00014  * 0.2     2011-02-21 Olli Vanhoja   *Added possibility change I2C speed
00015  *                                   *Added external reset pin and autoreset
00016  *                                    for read function. Thanks to Jon Ward.
00017  *                                   *Documentational comments added.
00018  * 0.3     2011-02-21 Olli Vanhoja   *Auto-reset for all error conditions
00019  *
00020  *H*/
00021 
00022 #ifndef I2C_EEPROM_H
00023 #define I2C_EEPROM_H
00024 
00025 /** I2C EEPROM access class
00026  * 
00027  * This class is used for communication with I2C EEPROM chip.
00028  */
00029 class i2c_eeprom {
00030 private:
00031     int i_i2c_address; // I2C harware address
00032     void autoreset();
00033 public:
00034     /** Initialize communication
00035     *
00036     * @param hwAddr Harware address of the I2C EEPROM chip.
00037     * @param speed I2C bus speed.
00038     */
00039     i2c_eeprom(int hwAddr, int speed);
00040     
00041     /** Write to I2C EEPROM
00042     *
00043     * Write any length of bytes to external EEPROM.
00044     *
00045     * @param *data Array of bytes.
00046     * @param iAddr Memory address.
00047     * @param n Write n bytes.
00048     */
00049     void write(char *data, uint16_t iAddr, unsigned int n);
00050     
00051     /** Read from I2C EEPROM
00052     *
00053     * Read any length of bytes from external EEPROM.
00054     *
00055     * @param iAddr Memory address.
00056     * @param n Read n bytes.
00057     * @param *out Returns array of bytes.
00058     */
00059     void read(uint16_t iAddr, uint16_t n, char *out);
00060 };
00061 
00062 #endif