24LCXXX I2C eeprom library
Fork of _24LCXXX by
Embed:
(wiki syntax)
Show/hide line numbers
_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 * 2015/02/26 Akafugu Fixing page write 00015 * 2012/12/06 Hiroshi M init 00016 ***************************************************************************** 00017 * 00018 * Copyright (C) 2013 Hiroshi M, MIT License 00019 * 00020 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00021 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00022 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00023 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00024 * furnished to do so, subject to the following conditions: 00025 * 00026 * The above copyright notice and this permission notice shall be included in all copies or 00027 * substantial portions of the Software. 00028 * 00029 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00030 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00031 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00032 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00033 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00034 * 00035 **/ 00036 00037 #ifndef __24LCXXX_H_ 00038 #define __24LCXXX_H_ 00039 00040 /* Includes ----------------------------------------------------------------- */ 00041 #include "mbed.h" 00042 00043 /* typedef ------------------------------------------------------------------ */ 00044 00045 /* define ------------------------------------------------------------------- */ 00046 #define I2C_ADDR_24LCXXX 0x50 00047 #define __24LC512__ 00048 00049 #if defined(__24LC64__) 00050 #define MAXADR_24LCXXX 8192 00051 #define PAGE_SIZE_24LCXXX 32 00052 #endif 00053 00054 #if defined(__24LC128__) 00055 #define MAXADR_24LCXXX 16384 00056 #define PAGE_SIZE_24LCXXX 64 00057 #endif 00058 00059 #if defined(__24LC256__) 00060 #define MAXADR_24LCXXX 32768 00061 #define PAGE_SIZE_24LCXXX 64 00062 #endif 00063 00064 #if defined(__24LC512__) 00065 #define MAXADR_24LCXXX 65536 00066 #define PAGE_SIZE_24LCXXX 128 00067 #endif 00068 00069 /* macro -------------------------------------------------------------------- */ 00070 /* variables ---------------------------------------------------------------- */ 00071 /* class -------------------------------------------------------------------- */ 00072 00073 class _24LCXXX 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 nbyte_read( int mem_addr, void *data, int size ); 00079 int byte_write( int mem_addr, char data ); 00080 int nbyte_write( int mem_addr, char *data, int size ); 00081 int nbyte_set( int mem_addr, char data, int size ); 00082 00083 private: 00084 int _i2c_address; 00085 I2C *_i2c; 00086 Serial *_pc; 00087 bool _debug; 00088 00089 int page_block( int mem_addr, char *data, uint16_t length, bool incrBuffer ); 00090 int page_write( int mem_addr, char *data, uint16_t length); 00091 }; 00092 00093 #endif /* __24LCXXX_H_ */
Generated on Wed Jul 13 2022 06:10:45 by 1.7.2