I2C EEPROM 24LCXXX Driver
Dependents: LPC1114FN28_I2C_24LCXXX ILI9341_Clock_Nucleo StormXalike rtc ... more
_24LCXXX.h
00001 /** 00002 ***************************************************************************** 00003 * File Name : _24LCXXX.h 00004 * 00005 * Title : I2C EEPROM 24LCXXX Claass Header File 00006 * Revision : 0.1 00007 * Notes : 00008 * Target Board : mbed NXP LPC1768, mbed LPC1114FN28 etc 00009 * Tool Chain : ???? 00010 * 00011 * Revision History: 00012 * When Who Description of change 00013 * ----------- ----------- ----------------------- 00014 * 2012/12/06 Hiroshi M init 00015 ***************************************************************************** 00016 * 00017 * Copyright (C) 2013 Hiroshi M, MIT License 00018 * 00019 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00020 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00021 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00022 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00023 * furnished to do so, subject to the following conditions: 00024 * 00025 * The above copyright notice and this permission notice shall be included in all copies or 00026 * substantial portions of the Software. 00027 * 00028 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00029 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00030 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00031 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00032 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00033 * 00034 **/ 00035 00036 #ifndef __24LCXXX_H_ 00037 #define __24LCXXX_H_ 00038 00039 /* Includes ----------------------------------------------------------------- */ 00040 #include "mbed.h" 00041 00042 /* typedef ------------------------------------------------------------------ */ 00043 00044 /* define ------------------------------------------------------------------- */ 00045 #define I2C_ADDR_24LCXXX 0x50 00046 #define __24LC256__ 00047 00048 #if defined(__24LC64__) 00049 #define MAXADR_24LCXXX 8192 00050 #define PAGE_SIZE_24LCXXX 32 00051 #endif 00052 00053 #if defined(__24LC128__) 00054 #define MAXADR_24LCXXX 16384 00055 #define PAGE_SIZE_24LCXXX 64 00056 #endif 00057 00058 #if defined(__24LC256__) 00059 #define MAXADR_24LCXXX 32768 00060 #define PAGE_SIZE_24LCXXX 64 00061 #endif 00062 00063 /* macro -------------------------------------------------------------------- */ 00064 /* variables ---------------------------------------------------------------- */ 00065 /* class -------------------------------------------------------------------- */ 00066 00067 class _24LCXXX 00068 { 00069 private: 00070 int _i2c_address; 00071 I2C *_i2c; 00072 Serial *_pc; 00073 bool _debug; 00074 00075 public: 00076 _24LCXXX(I2C *i2c, const int address=I2C_ADDR_24LCXXX ); 00077 _24LCXXX(I2C *i2c, Serial *pc, const int address=I2C_ADDR_24LCXXX ); 00078 int byte_write( int mem_addr, char data ); 00079 int nbyte_write( int mem_addr, void *data, int size ); 00080 int page_write( int mem_addr, char *data ); 00081 int nbyte_read( int mem_addr, void *data, int size ); 00082 }; 00083 00084 #endif /* __24LCXXX_H_ */
Generated on Tue Jul 26 2022 15:15:31 by 1.7.2