#include <cfg/module.h> // MOD_CHECK()
#include <cpu/attr.h>
-#include CPU_HEADER(twi)
+#include <drv/i2c.h>
#include <drv/wdt.h>
}
- if (!(twi_start_w(EEPROM_ADDR(dev_addr))
- && twi_send(addr_buf, addr_len)
- && twi_send(buf, count)))
+ if (!(i2c_start_w(EEPROM_ADDR(dev_addr))
+ && i2c_send(addr_buf, addr_len)
+ && i2c_send(buf, count)))
{
- twi_stop();
+ i2c_stop();
return wr_len;
}
- twi_stop();
+ i2c_stop();
/* Update count and addr for next operation */
size -= count;
}
- if (!(twi_start_w(EEPROM_ADDR(dev_addr))
- && twi_send(addr_buf, addr_len)
- && twi_start_r(EEPROM_ADDR(dev_addr))))
+ if (!(i2c_start_w(EEPROM_ADDR(dev_addr))
+ && i2c_send(addr_buf, addr_len)
+ && i2c_start_r(EEPROM_ADDR(dev_addr))))
{
- twi_stop();
+ i2c_stop();
return 0;
}
while (size--)
{
/*
- * The last byte read does not has an ACK
+ * The last byte read does not have an ACK
* to stop communication.
*/
- int c = twi_get(size);
+ int c = i2c_get(size);
if (c == EOF)
break;
*/
void eeprom_init(Eeprom *fd, EepromType type, e2dev_addr_t addr, bool verify)
{
- MOD_CHECK(twi);
+ MOD_CHECK(i2c);
ASSERT(type < EEPROM_CNT);
memset(fd, 0, sizeof(*fd));