projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert to new Doxygen style.
[bertos.git]
/
drv
/
eeprom.c
diff --git
a/drv/eeprom.c
b/drv/eeprom.c
index 8280ef2c75d558ee6ebf5bdf864d0f821d1474be..fb83a07148022570b427da94a059479e167f1ef1 100755
(executable)
--- a/
drv/eeprom.c
+++ b/
drv/eeprom.c
@@
-1,4
+1,4
@@
-/*
!
+/*
*
* \file
* <!--
* Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
* \file
* <!--
* Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
@@
-16,6
+16,12
@@
/*#*
*#* $Log$
/*#*
*#* $Log$
+ *#* Revision 1.20 2006/07/19 12:56:25 bernie
+ *#* Convert to new Doxygen style.
+ *#*
+ *#* Revision 1.19 2006/03/20 17:49:50 bernie
+ *#* Make the TWI driver more generic to work with devices other than EEPROMS.
+ *#*
*#* Revision 1.18 2005/11/27 23:33:40 bernie
*#* Use appconfig.h instead of cfg/config.h.
*#*
*#* Revision 1.18 2005/11/27 23:33:40 bernie
*#* Use appconfig.h instead of cfg/config.h.
*#*
@@
-52,8
+58,20
@@
#error CONFIG_EEPROM_VERIFY must be defined to either 0 or 1
#endif
#error CONFIG_EEPROM_VERIFY must be defined to either 0 or 1
#endif
+/**
+ * EEPROM ID code
+ */
+#define EEPROM_ID 0xA0
+
+/**
+ * This macros form the correct slave address for EEPROMs
+ */
+#define EEPROM_ADDR(x) (EEPROM_ID | (((uint8_t)(x)) << 1))
+
+
+
-/*
!
+/*
*
* Copy \c count bytes from buffer \c buf to
* eeprom at address \c addr.
*/
* Copy \c count bytes from buffer \c buf to
* eeprom at address \c addr.
*/
@@
-80,7
+98,7
@@
static bool eeprom_writeRaw(e2addr_t addr, const void *buf, size_t count)
uint8_t blk_offs = (uint8_t)addr;
result =
uint8_t blk_offs = (uint8_t)addr;
result =
- twi_start_w(
blk_addr
)
+ twi_start_w(
EEPROM_ADDR(blk_addr)
)
&& twi_send(&blk_offs, sizeof blk_offs)
&& twi_send(buf, size);
&& twi_send(&blk_offs, sizeof blk_offs)
&& twi_send(buf, size);
@@
-90,7
+108,7
@@
static bool eeprom_writeRaw(e2addr_t addr, const void *buf, size_t count)
uint16_t addr_be = cpu_to_be16(addr);
result =
uint16_t addr_be = cpu_to_be16(addr);
result =
- twi_start_w(
0
)
+ twi_start_w(
EEPROM_ID
)
&& twi_send((uint8_t *)&addr_be, sizeof addr_be)
&& twi_send(buf, size);
&& twi_send((uint8_t *)&addr_be, sizeof addr_be)
&& twi_send(buf, size);
@@
-119,7
+137,7
@@
static bool eeprom_writeRaw(e2addr_t addr, const void *buf, size_t count)
#if CONFIG_EEPROM_VERIFY
#if CONFIG_EEPROM_VERIFY
-/*
!
+/*
*
* Check that the contents of an EEPROM range
* match with a provided data buffer.
*
* Check that the contents of an EEPROM range
* match with a provided data buffer.
*
@@
-179,7
+197,7
@@
bool eeprom_write(e2addr_t addr, const void *buf, size_t count)
}
}
-/*
!
+/*
*
* Copy \c count bytes at address \c addr
* from eeprom to RAM to buffer \c buf.
*
* Copy \c count bytes at address \c addr
* from eeprom to RAM to buffer \c buf.
*
@@
-198,9
+216,9
@@
bool eeprom_read(e2addr_t addr, void *buf, size_t count)
uint8_t blk_offs = (uint8_t)addr;
bool res =
uint8_t blk_offs = (uint8_t)addr;
bool res =
- twi_start_w(
blk_addr
)
+ twi_start_w(
EEPROM_ADDR(blk_addr)
)
&& twi_send(&blk_offs, sizeof blk_offs)
&& twi_send(&blk_offs, sizeof blk_offs)
- && twi_start_r(
blk_addr
)
+ && twi_start_r(
EEPROM_ADDR(blk_addr)
)
&& twi_recv(buf, count);
#elif CONFIG_EEPROM_TYPE == EEPROM_24XX256
&& twi_recv(buf, count);
#elif CONFIG_EEPROM_TYPE == EEPROM_24XX256
@@
-209,9
+227,9
@@
bool eeprom_read(e2addr_t addr, void *buf, size_t count)
addr = cpu_to_be16(addr);
bool res =
addr = cpu_to_be16(addr);
bool res =
- twi_start_w(
0
)
+ twi_start_w(
EEPROM_ID
)
&& twi_send((uint8_t *)&addr, sizeof(addr))
&& twi_send((uint8_t *)&addr, sizeof(addr))
- && twi_start_r(
0
)
+ && twi_start_r(
EEPROM_ID
)
&& twi_recv(buf, count);
#else
#error Unknown device type
&& twi_recv(buf, count);
#else
#error Unknown device type
@@
-225,7
+243,7
@@
bool eeprom_read(e2addr_t addr, void *buf, size_t count)
}
}
-/*
!
+/*
*
* Write a single character \a c at address \a addr.
*/
bool eeprom_write_char(e2addr_t addr, char c)
* Write a single character \a c at address \a addr.
*/
bool eeprom_write_char(e2addr_t addr, char c)
@@
-234,7
+252,7
@@
bool eeprom_write_char(e2addr_t addr, char c)
}
}
-/*
!
+/*
*
* Read a single character at address \a addr.
*
* \return the requested character or -1 in case of failure.
* Read a single character at address \a addr.
*
* \return the requested character or -1 in case of failure.
@@
-250,7
+268,7
@@
int eeprom_read_char(e2addr_t addr)
}
}
-/*
!
+/*
*
* Erase specified part of eeprom, writing 0xFF.
*
* \param addr starting address
* Erase specified part of eeprom, writing 0xFF.
*
* \param addr starting address
@@
-275,7
+293,7
@@
void eeprom_erase(e2addr_t addr, size_t count)
}
}
-/*
!
+/*
*
* Initialize TWI module.
*/
void eeprom_init(void)
* Initialize TWI module.
*/
void eeprom_init(void)