Class definition for the Arduino Wire library implementation. More...
Class definition for the Arduino Wire library implementation.
Definition at line 70 of file wireport.hpp.
#include <wireport.hpp>
Public Member Functions | |
TwoWire (void) | |
Constructor. | |
void | begin (void) |
Initializes the I2C device defined by ARDUINO_I2C_DEV as master. | |
void | begin (uint8_t addr) |
Initializes the I2C device defined by ARDUINO_I2C_DEV as slave. | |
void | setClock (uint32_t clk) |
Set the clock speed of the I2C device defined by ARDUINO_I2C_DEV. | |
void | beginTransmission (uint8_t addr) |
Begin a transmission to a I2C slave device. | |
uint8_t | endTransmission (void) |
End a transmission to a I2C slave device. | |
uint8_t | endTransmission (uint8_t stop) |
End a transmission to a I2C slave device. | |
uint8_t | requestFrom (uint8_t addr, uint8_t size) |
Request bytes from a I2C slave device. | |
uint8_t | requestFrom (uint8_t addr, uint8_t size, uint8_t stop) |
Request bytes from a I2C slave device. | |
virtual size_t | write (uint8_t data) |
Queue a byte for transmission from a master to slave device. | |
virtual size_t | write (const uint8_t *data, size_t size) |
Queue bytes for transmission from a master to slave device. | |
virtual int | available (void) |
Return the number of bytes available for retrieval. | |
virtual int | read (void) |
Reads one byte transmitted from slave device to the master. | |
virtual size_t | readBytes (uint8_t *buffer, size_t length) |
Read bytes transmitted from slave device to the master. | |
virtual int | peek (void) |
Peeks one byte transmitted from slave device to the master. | |
virtual void | flush (void) |
Flush the RX and TX buffer. | |
|
virtual |
Return the number of bytes available for retrieval.
Returns the number of bytes available for retrieval with read. This should be called on a master device after a call to requestFrom.
Copied from https://www.arduino.cc/en/Reference/WireAvailable
void TwoWire::begin | ( | uint8_t | addr | ) |
Initializes the I2C device defined by ARDUINO_I2C_DEV as slave.
[in] | addr | Address of the device initialized as slave |
void TwoWire::beginTransmission | ( | uint8_t | addr | ) |
Begin a transmission to a I2C slave device.
This method begins a transmission to the I2C slave device with the given address. Subsequently, queue bytes for transmission with the write method and transmit them by calling endTransmission.
Copied from https://www.arduino.cc/en/Reference/WireBeginTransmission
[in] | addr | Address of the slave device |
uint8_t TwoWire::endTransmission | ( | uint8_t | stop | ) |
End a transmission to a I2C slave device.
Ends a transmission to a slave device that was begun by beginTransmission() and transmits the bytes that were queued by write.
Copied from https://www.arduino.cc/en/Reference/WireEndTransmission
stop | Send STOP condition after transmission if true or nothing if false. |
0 | success |
1 | data too long to fit in transmit buffer |
2 | received NACK on transmit of address |
3 | received NACK on transmit of data |
4 | other error |
uint8_t TwoWire::endTransmission | ( | void | ) |
End a transmission to a I2C slave device.
Ends a transmission to a slave device that was begun by beginTransmission() and transmits the bytes that were queued by write. Sends always a STOP condition after the request.
Copied from https://www.arduino.cc/en/Reference/WireEndTransmission
0 | success |
1 | data too long to fit in transmit buffer |
2 | received NACK on transmit of address |
3 | received NACK on transmit of data |
4 | other error |
|
virtual |
Flush the RX and TX buffer.
This method clears the RX as well as the TX buffer. It is not necessary to call this method explicitly. RX buffer is flushed implicitly when method requestFrom is called. Tx buffer is flushed implicitly when method beginTransmission is called.
|
virtual |
Peeks one byte transmitted from slave device to the master.
Reads a byte that was transmitted from a slave device to the master after a call to requestFrom without advancing to the next one. That is, successive calls to peek will return the same value, as will the next call to read.
Copied from https://www.arduino.cc/en/Reference/WireRead and https://www.arduino.cc/en/Reference/StreamPeek
|
virtual |
Reads one byte transmitted from slave device to the master.
Reads a byte that was transmitted from a slave device to the master after a call to requestFrom and removes it from receive buffer.
Copied from https://www.arduino.cc/en/Reference/WireRead
|
virtual |
Read bytes transmitted from slave device to the master.
Reads a number of bytes that were transmitted from a slave device to the master after a call to requestFrom and removes them from receive buffer.
[out] | buffer | buffer to store the bytes |
[in] | length | number of bytes to read |
uint8_t TwoWire::requestFrom | ( | uint8_t | addr, |
uint8_t | size | ||
) |
Request bytes from a I2C slave device.
Used by the master to request bytes from a slave device. The bytes may then be retrieved with the available and read methods. Sends always a STOP condition after the request.
Copied from https://www.arduino.cc/en/Reference/WireRequestFrom
[in] | addr | 7-bit address of the device to request bytes from |
[in] | size | Number of bytes to request |
uint8_t TwoWire::requestFrom | ( | uint8_t | addr, |
uint8_t | size, | ||
uint8_t | stop | ||
) |
Request bytes from a I2C slave device.
Used by the master to request bytes from a slave device. The bytes may then be retrieved with the available and read methods.
[in] | addr | 7-bit address of the device to request bytes from |
[in] | size | Number of bytes to request |
[in] | stop | Send STOP condition after the request if true or nothing if false. |
Copied from https://www.arduino.cc/en/Reference/WireRequestFrom
void TwoWire::setClock | ( | uint32_t | clk | ) |
Set the clock speed of the I2C device defined by ARDUINO_I2C_DEV.
[in] | clk | I2C clock speed in Hz |
|
virtual |
Queue bytes for transmission from a master to slave device.
The method queues bytes for transmission from a master to slave device in-between calls to beginTransmission and endTransmission.
[in] | data | Array of data to send as bytes |
[in] | size | Number of bytes to transmit |
Copied from https://www.arduino.cc/en/Reference/WireWrite
|
virtual |
Queue a byte for transmission from a master to slave device.
The method queues a byte for transmission from a master to slave device in-between calls to beginTransmission and endTransmission.
[in] | data | Data byte |
Copied from https://www.arduino.cc/en/Reference/WireWrite