DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
|
Represents an I2C bus of a DHCOM Module. Not available on PC. More...
#include <I2CBus.h>
Public Types | |
enum | BUS { BUS_I2C1 = 1, BUS_I2C2 = 2, BUS_I2C3 = 3 } |
Master device enumeration. More... | |
Public Member Functions | |
I2CBus (BUS bus) | |
Constructs the I2CBus object. | |
~I2CBus () | |
Destroys the I2CBus object and releases the resources. | |
STATUS | open () |
Opens the bus, claims the hardware resources. | |
STATUS | close () |
Closes the bus, releases resources. | |
bool | isOpen () const |
Checks if the bus is open and ready for I/O. | |
STATUS | selectSlave (uint16_t address) |
Selects an I2C slave to communicate with. | |
STATUS | read (uint8_t *buffer, uint32_t count) const |
Reads a block of bytes from a slave. | |
uint8_t | read (STATUS *status=NULL) const |
Reads one byte from a slave. | |
STATUS | write (const uint8_t *buffer, uint32_t count) |
Writes a block of bytes to the slave. | |
STATUS | write (uint8_t byte) |
Writes one byte to the I2C slave. | |
Represents an I2C bus of a DHCOM Module. Not available on PC.
enum dhcom::I2CBus::BUS |
dhcom::I2CBus::I2CBus | ( | BUS | bus | ) |
Constructs the I2CBus object.
bus | - the physical I2C bus to open later. |
dhcom::I2CBus::~I2CBus | ( | ) |
Destroys the I2CBus object and releases the resources.
This call also closes the bus if necessary.
STATUS dhcom::I2CBus::close | ( | ) |
Closes the bus, releases resources.
bool dhcom::I2CBus::isOpen | ( | ) | const |
Checks if the bus is open and ready for I/O.
STATUS dhcom::I2CBus::open | ( | ) |
Opens the bus, claims the hardware resources.
Reads a block of bytes from a slave.
buffer | - the pointer to receiving buffer, may not be NULL; |
count | - the number of bytes to receive; |
Reads one byte from a slave.
status | - if NULL - no status returned, otherwise the status is assigned to STATUS_DEVICE_NOT_OPEN, STATUS_DEVICE_READ_FAILED or STATUS_SUCCESS. |
Selects an I2C slave to communicate with.
address | - the slave address. |
Writes a block of bytes to the slave.
buffer | - the pointer to buffer with the data, may not be NULL; |
count | - the number of bytes to send; |
Writes one byte to the I2C slave.
byte | - the value to write. |