X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Feeprom.c;h=cc9b5292ba15c34af47822c37c6d61090149ecab;hb=0f60d6b24cf8ec1c9bd8dca82fed6325932c5aca;hp=3b364f06d14b1fa01ca3a901c44931482feb80c4;hpb=6b7ec5ad0ef104a471ca77e2ded66f686e23150a;p=bertos.git diff --git a/bertos/drv/eeprom.c b/bertos/drv/eeprom.c index 3b364f06..cc9b5292 100644 --- a/bertos/drv/eeprom.c +++ b/bertos/drv/eeprom.c @@ -26,7 +26,7 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/) + * Copyright 2003, 2004, 2005, 2010 Develer S.r.l. (http://www.develer.com/) * * --> * @@ -38,6 +38,8 @@ #include "eeprom.h" +#include "cfg/cfg_i2c.h" + #include // MIN() #include #include // MOD_CHECK() @@ -103,6 +105,7 @@ static const EepromInfo mem_info[] = STATIC_ASSERT(countof(mem_info) == EEPROM_CNT); +#if !CONFIG_I2C_DISABLE_OLD_API /** * Copy \a size bytes from buffer \a buf to @@ -248,20 +251,11 @@ static size_t eeprom_read(struct KFile *_fd, void *_buf, size_t size) return 0; } - while (size--) - { - /* - * The last byte read does not have an ACK - * to stop communication. - */ - int c = i2c_get(size); - if (c == EOF) - break; - - *buf++ = c; - fd->fd.seek_pos++; - rd_len++; + if (i2c_recv(buf, size)) + { + fd->fd.seek_pos += size; + rd_len += size; } i2c_stop(); @@ -398,4 +392,4 @@ void eeprom_init(Eeprom *fd, EepromType type, e2dev_addr_t addr, bool verify) fd->fd.seek = kfile_genericSeek; } -#endif +#endif /* !CONFIG_I2C_DISABLE_OLD_API */