-
-/**
- * Send a sequence of bytes in master transmitter mode
- * to the selected slave device through the TWI bus.
- *
- * \return true on success, false on error.
- */
-bool i2c_send(const void *_buf, size_t count)
-{
- const uint8_t *buf = (const uint8_t *)_buf;
-
- while (count--)
- {
- if (!i2c_put(*buf++))
- return false;
- }
- return true;
-}
-
-
-/**
- * Receive a sequence of one or more bytes from the
- * selected slave device in master receive mode through
- * the TWI bus.
- *
- * Received data is placed in \c buf.
- *
- * \note a NACK is automatically given on the last received
- * byte.
- *
- * \return true on success, false on error
- */
-bool i2c_recv(void *_buf, size_t count)
-{
- uint8_t *buf = (uint8_t *)_buf;
-
- /*
- * When reading the last byte the TWEA bit is not
- * set, and the eeprom should answer with NACK
- */
- while (count--)
- {
- /*
- * The last byte read does not has an ACK
- * to stop communication.
- */
- int c = i2c_get(count);
-
- if (c == EOF)
- return false;
- else
- *buf++ = c;
- }
-
- return true;
-}
-
-