15 June 2010

Arduino KEYWORDS(6)

Wire.begin()

Wire.begin(address)

Initiate the Wire library
and join the I2C bus as a master or slave.

Parameters:

address: the 7-bit slave address (optional);

if not specified, join the bus as a master.


Wire.requestFrom(address, quantity)

Request bytes from another device.
The bytes may then be retrieved with the
available()
and receive() functions.

Parameters:

address: the 7-bit address of the device to request bytes from

quantity: the number of bytes to request


Wire.available()

Returns the number of bytes available
for retrieval with receive().
This should be called on a master device
after a call to requestFrom()
or on a slave inside the onReceive() handler.

No parameters

Returns:
The number of bytes available for reading.


byte Wire.receive()

Retrieve a byte that was transmitted
from a slave device to a master
after a call to requestFrom
or was transmitted from a master to a slave.

No parameters

Returns:
The next byte received.


Wire.onReceive(handler)

Registers a function to be called
when a slave device receives a transmission
from a master.

Parameters:

handler: the function to be called when the slave receives data;


this should take a single int parameter
(the number of bytes received from the master)
and return nothing,
e.g.: void myHandler(int numBytes)

No return

Wire.beginTransmission(address)

Begin a transmission to the I2C slave device with the given address.
Subsequently, queue bytes for transmission with the send() function
and transmit them by calling endTransmission().

Parameters:

address: the 7-bit address of the device to transmit to

No return


Wire.send(value)

Wire.send(string)

Wire.send(data, quantity)

Sends data from a slave device
in response to a request from a master,
or queues bytes for transmission
from a master to slave device
(in-between calls to beginTransmission()
and endTransmission()).

Parameters:

value: a byte to send (byte)

string: a string to send (char *)

data: an array of data to send (byte *)

quantity: the number of bytes of data to transmit (byte)

No return


Wire.endTransmission()

Ends a transmission to a slave device
that was begun by beginTransmission()
and actually transmits the bytes
that were queued by send().

No parameters
No returns


Wire.onRequest(handler)

Register a function to be called
when a master requests data
from this slave device.

Parameters:

handler: the function to be called,
takes no parameters and returns nothing,
e.g.: void myHandler()

No return

No comments:

Post a Comment