Sensor API Platform Bus Interfaces.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <status_codes.h>
Data Structures | |
struct | bus_desc_t |
Platform Bus Interface Descriptor. More... | |
Typedefs | |
typedef status_code_t | bus_status_t |
Platform Bus Status Constants. More... | |
typedef SPI_t * | spi_if |
Enumerations | |
enum | bus_type_t { BUS_TYPE_UNKNOWN, BUS_TYPE_TWI, BUS_TYPE_SPI, BUS_TYPE_PMBUS, BUS_TYPE_SMBUS } |
Platform Bus Type Constants. More... | |
Functions | |
System Bus I/O Access Methods | |
bool | bus_init (volatile void *busif, uint32_t speed) |
size_t | bus_read (bus_desc_t *bus, uint8_t addr, void *data, size_t count) |
Read multiple Bytes from a bus interface. More... | |
size_t | bus_write (bus_desc_t *bus, uint8_t addr, const void *data, size_t count) |
Write multiple Bytes to a bus interface. More... | |
bool | bus_probe (bus_desc_t *bus, int arg) |
Determine the existence of a bus device. More... | |
static uint8_t | bus_get (bus_desc_t *bus, uint8_t addr) |
Read a single Byte from a bus interface. More... | |
static void | bus_put (bus_desc_t *bus, uint8_t addr, uint8_t data) |
Write a single Byte to a bus interface. More... | |
static void | bus_reg_bitclear (bus_desc_t *bus, uint8_t addr, uint8_t mask) |
Clear a bit at a bus device register or memory address. More... | |
static void | bus_reg_bitset (bus_desc_t *bus, uint8_t addr, uint8_t mask) |
Set a bit at a bus device register or memory address. More... | |
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... | |
typedef status_code_t bus_status_t |
Platform Bus Status Constants.
typedef SPI_t* spi_if |
Platform Bus Interface Types
enum bus_type_t |
|
inlinestatic |
Read a single Byte from a bus interface.
bus | An initialized bus interface descriptor. |
addr | The device register or memory address. |
References bus_read(), and data.
Referenced by bus_reg_bitclear(), bus_reg_bitset(), bus_reg_fieldget(), and bus_reg_fieldset().
bool bus_init | ( | volatile void * | busif, |
uint32_t | speed | ||
) |
Initialize the bus I/O interface.
busif | The address of a system bus (registers) interface. |
speed | The bus data rate. |
true | The bus was initialized. |
false | The bus was not initialized. |
bool 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. |
|
inlinestatic |
Write a single Byte to a bus interface.
bus | An initialized bus interface descriptor. |
addr | The device register or memory address. |
data | The value of the Byte to write. |
References bus_write().
Referenced by bus_reg_bitclear(), bus_reg_bitset(), and bus_reg_fieldset().
size_t bus_read | ( | bus_desc_t * | bus, |
uint8_t | addr, | ||
void * | data, | ||
size_t | count | ||
) |
Read multiple Bytes from a bus interface.
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). |
Referenced by bus_get().
|
inlinestatic |
|
inlinestatic |
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.
This 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. |
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. |
size_t bus_write | ( | bus_desc_t * | bus, |
uint8_t | addr, | ||
const void * | data, | ||
size_t | count | ||
) |
Write multiple Bytes to a bus interface.
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). |
Referenced by bus_put().