This section covers functions related to the SAM L22's built-I2C driver, including configuring the I2C bus, putting values directly on the bus and reading data from registers on I2C devices.
More...
|
void | watch_enable_i2c (void) |
| Enables the I2C peripheral. Call this before attempting to interface with I2C devices.
|
|
void | watch_disable_i2c (void) |
| Disables the I2C peripheral.
|
|
void | watch_i2c_send (int16_t addr, uint8_t *buf, uint16_t length) |
| Sends a series of values to a device on the I2C bus.
|
|
void | watch_i2c_receive (int16_t addr, uint8_t *buf, uint16_t length) |
| Receives a series of values from a device on the I2C bus.
|
|
void | watch_i2c_write8 (int16_t addr, uint8_t reg, uint8_t data) |
| Writes a byte to a register in an I2C device.
|
|
uint8_t | watch_i2c_read8 (int16_t addr, uint8_t reg) |
| Reads a byte from a register in an I2C device.
|
|
uint16_t | watch_i2c_read16 (int16_t addr, uint8_t reg) |
| Reads an unsigned little-endian word from a register in an I2C device.
|
|
uint32_t | watch_i2c_read24 (int16_t addr, uint8_t reg) |
| Reads three bytes as an unsigned little-endian int from a register in an I2C device.
|
|
uint32_t | watch_i2c_read32 (int16_t addr, uint8_t reg) |
| Reads an unsigned little-endian int from a register in an I2C device.
|
|
This section covers functions related to the SAM L22's built-I2C driver, including configuring the I2C bus, putting values directly on the bus and reading data from registers on I2C devices.
◆ watch_i2c_read16()
uint16_t watch_i2c_read16 |
( |
int16_t |
addr, |
|
|
uint8_t |
reg |
|
) |
| |
Reads an unsigned little-endian word from a register in an I2C device.
- Parameters
-
addr | The address of the device you wish to address. |
reg | The register on the device that you wish to read. |
- Returns
- An unsigned word representing the value of the register that was read.
- Note
- This reads two bytes into the word in bus order. If the device returns the LSB first and then the MSB, you can use this value as returned. If the device returns the data in big-endian order or uses some other kind of fancy bit packing, you may need to shuffle some bits around.
◆ watch_i2c_read24()
uint32_t watch_i2c_read24 |
( |
int16_t |
addr, |
|
|
uint8_t |
reg |
|
) |
| |
Reads three bytes as an unsigned little-endian int from a register in an I2C device.
- Parameters
-
addr | The address of the device you wish to address. |
reg | The register on the device that you wish to read. |
- Returns
- An unsigned word representing the value of the register that was read.
- Note
- This reads three bytes into the word in bus order. If the device returns these bytes LSB first, you can use this value as returned. If there is a sign bit, the device returns the data in big-endian order, or it uses some other kind of fancy bit packing, you may need to shuffle some bits around.
◆ watch_i2c_read32()
uint32_t watch_i2c_read32 |
( |
int16_t |
addr, |
|
|
uint8_t |
reg |
|
) |
| |
Reads an unsigned little-endian int from a register in an I2C device.
- Parameters
-
addr | The address of the device you wish to address. |
reg | The register on the device that you wish to read. |
- Returns
- An unsigned word representing the value of the register that was read.
- Note
- This reads three bytes into the word in bus order. If the device returns these bytes LSB first, you can use this value as returned. If the device returns the data in big-endian order, or it uses some other kind of fancy bit packing, you may need to shuffle some bits around.
◆ watch_i2c_read8()
uint8_t watch_i2c_read8 |
( |
int16_t |
addr, |
|
|
uint8_t |
reg |
|
) |
| |
Reads a byte from a register in an I2C device.
- Parameters
-
addr | The address of the device you wish to address. |
reg | The register on the device that you wish to read. |
- Returns
- An unsigned byte representing the value of the register that was read.
◆ watch_i2c_receive()
void watch_i2c_receive |
( |
int16_t |
addr, |
|
|
uint8_t * |
buf, |
|
|
uint16_t |
length |
|
) |
| |
Receives a series of values from a device on the I2C bus.
- Parameters
-
addr | The address of the device you wish to hear from. |
buf | Storage for the incoming bytes; on return, it will contain the received data. |
length | The number of bytes that you wish to receive. |
◆ watch_i2c_send()
void watch_i2c_send |
( |
int16_t |
addr, |
|
|
uint8_t * |
buf, |
|
|
uint16_t |
length |
|
) |
| |
Sends a series of values to a device on the I2C bus.
- Parameters
-
addr | The address of the device you wish to talk to. |
buf | A series of unsigned bytes; the data you wish to transmit. |
length | The number of bytes in buf that you wish to send. |
◆ watch_i2c_write8()
void watch_i2c_write8 |
( |
int16_t |
addr, |
|
|
uint8_t |
reg, |
|
|
uint8_t |
data |
|
) |
| |
Writes a byte to a register in an I2C device.
- Parameters
-
addr | The address of the device you wish to address. |
reg | The register on the device that you wish to set. |
data | The value that you wish to set the register to. |