Sensor API Platform Bus Interfaces.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | twi_bus_init bus_init |
#define | twi_bus_probe bus_probe |
#define | twi_bus_read bus_read |
#define | twi_bus_write bus_write |
Functions | |
uint8_t | bus_reg_fieldget (bus_desc_t *bus, uint8_t addr, uint8_t mask) |
Read a field stored at a device register or memory address. More... | |
void | bus_reg_fieldset (bus_desc_t *bus, uint8_t addr, uint8_t mask, uint8_t value) |
Write a field stored at a device register or memory address. More... | |
bool | twi_bus_init (volatile void *bus, uint32_t bus_speed) |
bool | twi_bus_probe (bus_desc_t *bus, int arg) |
size_t | twi_bus_read (bus_desc_t *bus, uint8_t addr, void *data, size_t count) |
size_t | twi_bus_write (bus_desc_t *bus, uint8_t addr, const void *data, size_t count) |
#define twi_bus_init bus_init |
Sensor API Bus I/O Implementations
#define twi_bus_probe bus_probe |
#define twi_bus_read bus_read |
#define twi_bus_write bus_write |
uint8_t bus_reg_fieldget | ( | bus_desc_t * | bus, |
uint8_t | addr, | ||
uint8_t | mask | ||
) |
Read a field stored at a device register or memory address.
Sensor Platform Board ConfigurationThis routine reads a specified value from a bit field within a 1-Byte device register or memory address. The set bits in the mask parameter determine the field location. For example, if the mask is 30h and the value AFh is stored in the register, the value 2h will be returned.
bus | An initialized bus interface descriptor. |
addr | The device register or memory address. |
mask | The mask of the field to set. |
References bus_get().
void bus_reg_fieldset | ( | bus_desc_t * | bus, |
uint8_t | addr, | ||
uint8_t | mask, | ||
uint8_t | value | ||
) |
Write a field stored at a device register or memory address.
This routine writes a specified value to a bit field within a 1-Byte device register or memory address. The set bits in the mask parameter determine the field location. For example, if the mask is 30h and the value is 2h, the value 20h will be bitwise logically OR'd into the 1-Byte register value after clearing the bit values in the field.
bus | An initialized bus interface descriptor. |
addr | The device register or memory address. |
mask | The mask of the field to set. |
value | The value of the field to set. |
bool twi_bus_init | ( | volatile void * | bus, |
uint32_t | bus_speed | ||
) |
Initialize the TWI (master) bus I/O interface.
bus | The address of an AVR or AVR32 bus interface descriptor. |
bus_speed | The bus data rate. |
true | The bus was initialized. |
false | The bus was not initialized. |
References twi_options_t::speed, STATUS_OK, and twi_master_setup().
bool twi_bus_probe | ( | bus_desc_t * | bus, |
int | arg | ||
) |
Determine the existence of a bus device
This routine determines the existence of a device located at a bus interface and address specified by an initialized bus
descriptor. Implementations are only required to return true
when it can be determined that a device is installed at the bus interface address.
bus | An initialized bus interface descriptor. |
arg | Ignored reserved argument. |
true | A device responded to the bus address. |
false | A device did not respond to the bus address. |
References ERR_UNSUPPORTED_DEV, and bus_desc_t::status.
size_t twi_bus_read | ( | bus_desc_t * | bus, |
uint8_t | addr, | ||
void * | data, | ||
size_t | count | ||
) |
Read bytes from remote device using TWI (master) interface
This routine reads "count" Bytes of data into location "data" from a specified TWI "bus_id" device register or memory address, "addr".
The caller must ensure that "data" specifies a valid memory address that is capable of storing the specified "count" Bytes of data.
bus | An initialized bus interface descriptor. |
addr | The device register or memory address. |
data | The destination read buffer address. |
count | The destination read buffer size (Bytes). |
References bus_desc_t::addr, twi_package_t::chip, bus_desc_t::id, bus_desc_t::no_wait, pkg, bus_desc_t::status, STATUS_OK, and twi_master_read().
size_t twi_bus_write | ( | bus_desc_t * | bus, |
uint8_t | addr, | ||
const void * | data, | ||
size_t | count | ||
) |
Write bytes to remote device using TWI (master) interface
This routine writes "count" Bytes of data from location "data" to a specified TWI "bus_id" device register or memory address, "addr".
The caller must ensure that "data" specifies a valid memory address.
bus | An initialized bus interface descriptor. |
addr | The device register or memory address. |
data | The source write buffer address. |
count | The source write buffer size (Bytes). |
References bus_desc_t::addr, twi_package_t::chip, bus_desc_t::id, bus_desc_t::no_wait, pkg, bus_desc_t::status, STATUS_OK, and twi_master_write().