summaryrefslogtreecommitdiff
path: root/eepromer/24cXX.h
diff options
context:
space:
mode:
Diffstat (limited to 'eepromer/24cXX.h')
-rw-r--r--eepromer/24cXX.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/eepromer/24cXX.h b/eepromer/24cXX.h
new file mode 100644
index 0000000..3b3b3a2
--- /dev/null
+++ b/eepromer/24cXX.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ copyright : (C) by 2002-2003 Stefano Barbato
+ email : stefano@codesink.org
+
+ $Id: 24cXX.h 4495 2007-06-27 12:57:50Z khali $
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef _24CXX_H_
+#define _24CXX_H_
+#include <linux/i2c-dev.h>
+
+#define EEPROM_TYPE_UNKNOWN 0
+#define EEPROM_TYPE_8BIT_ADDR 1
+#define EEPROM_TYPE_16BIT_ADDR 2
+
+struct eeprom
+{
+ char *dev; // device file i.e. /dev/i2c-N
+ int addr; // i2c address
+ int fd; // file descriptor
+ int type; // eeprom type
+};
+
+/*
+ * opens the eeprom device at [dev_fqn] (i.e. /dev/i2c-N) whose address is
+ * [addr] and set the eeprom_24c32 [e]
+ */
+int eeprom_open(char *dev_fqn, int addr, int type, struct eeprom*);
+/*
+ * closees the eeprom device [e]
+ */
+int eeprom_close(struct eeprom *e);
+/*
+ * read and returns the eeprom byte at memory address [mem_addr]
+ * Note: eeprom must have been selected by ioctl(fd,I2C_SLAVE,address)
+ */
+int eeprom_read_byte(struct eeprom* e, __u16 mem_addr);
+/*
+ * read the current byte
+ * Note: eeprom must have been selected by ioctl(fd,I2C_SLAVE,address)
+ */
+int eeprom_read_current_byte(struct eeprom *e);
+/*
+ * writes [data] at memory address [mem_addr]
+ * Note: eeprom must have been selected by ioctl(fd,I2C_SLAVE,address)
+ */
+int eeprom_write_byte(struct eeprom *e, __u16 mem_addr, __u8 data);
+
+#endif
+