Embedded Artistry Framework
Embedded Systems C++ Framework
Classes | Typedefs | Enumerations | Variables

Definitions, functions, and classes related to I2C communication bus devices. More...

Classes

class  activeMaster
 
class  master
 This class provides the I2C master interface definition. More...
 
struct  op_t
 I2C operation definition. More...
 

Typedefs

using ao_storage = std::pair< embvm::i2c::op_t, const embvm::i2c::master::cb_t >
 
using addr_t = uint8_t
 I2C address storage type. More...
 
using commBus = commBus< i2c::op_t, i2c::baud, i2c::I2C_MASTER_REQD_STATIC_FUNCTION_SIZE, i2c::status >
 Convenience alias for the declaration of the I2C commBus. More...
 

Enumerations

enum  operation : uint8_t {
  operation::stop = 0, operation::restart, operation::write, operation::read,
  operation::writeRead, operation::writeNoStop, operation::continueWriteNoStop, operation::continueWriteStop,
  operation::ping
}
 I2C operation types. More...
 
enum  state : uint8_t { state::idle = 0, state::busy, state::error }
 Represents the state of the I2C bus. More...
 
enum  status {
  status::ok = 0, status::enqueued, status::busy, status::error,
  status::unknown, status::addrNACK, status::dataNACK, status::bus
}
 I2C bus status. More...
 
enum  baud { baud::lowSpeed = 10000, baud::standard = 100000, baud::fast = 400000 }
 Valid I2C bus baudrate options. More...
 
enum  pullups : uint8_t { pullups::external = 0, pullups::internal }
 Pull-up configuration options for an I2C master device. More...
 

Variables

static constexpr size_t I2C_MASTER_REQD_STATIC_FUNCTION_SIZE = 96
 Maximum size of the I2C master callback functor object. More...
 
static constexpr uint8_t ReadBit = 0x01
 Added to slave address to indicate a read command. More...
 

Detailed Description

Definitions, functions, and classes related to I2C communication bus devices.


Class Documentation

◆ embvm::i2c::op_t

struct embvm::i2c::op_t

I2C operation definition.

The I2C bus operates in half-duplex mode, meaning that reads and writes do not occur simultaneously. The operation type represents a variety of operations which can be performed by an I2C device. The transmit options (tx_buffer and tx_size) are required by any operations using "write". The receive options (rx_buffer and rx_size) are required by any operations using "read".

Class Members
uint8_t address Slave device address (7-bit).
operation op Operation to perform.
uint8_t * rx_buffer Pointer to the receive buffer.

Does not need to be specified for write-only commands.

size_t rx_size Number of bytes to receive.

Does not need to be specified for write-only commands.

const uint8_t * tx_buffer Pointer to the transmit buffer.

Does not need to be specified for read-only commands.

size_t tx_size Number of bytes to transmit.

Does not need to be specified for read-only commands.

Typedef Documentation

◆ addr_t

using embvm::i2c::addr_t = typedef uint8_t

I2C address storage type.

◆ ao_storage

◆ commBus

Convenience alias for the declaration of the I2C commBus.

Enumeration Type Documentation

◆ baud

enum embvm::i2c::baud
strong

Valid I2C bus baudrate options.

Numeric values are in Hz.

Enumerator
lowSpeed 
standard 
fast 

◆ operation

I2C operation types.

The operation enum defines the type of transfer that the op_t structure is to perform.

Enumerator
stop 
restart 

Generate a stop condition.

write 

Generate a bus restart.

Write to slave Performs the following sequence: start - address - write - stop

read 

Read from slave Performs the following sequence: start - address - read - stop.

writeRead 

write to slave and then read from slave Performs the following sequence: start - address - write - restart - address - read - stop

writeNoStop 

start a write to the slave and but do not issue a stop Performs the following sequence: start - address - write

continueWriteNoStop 

continue a write to the slave and do not stop the transaction Performs the following sequence: write

continueWriteStop 

continue a write to the slave and then stop the transaction Performs the following sequence: write - stop

ping 

Send only address to see if there is an ACK Performs the following sequence: start - address.

◆ pullups

Pull-up configuration options for an I2C master device.

Enumerator
external 

External pullups exist for SDA and SCL.

internal 

Use internal pull-ups on SDA and SCL (if supported by the device).

◆ state

enum embvm::i2c::state : uint8_t
strong

Represents the state of the I2C bus.

Enumerator
idle 

The bus is idle and ready to receive work.

busy 

The bus is currently busy executing a transaction.

error 

A bus error occurred and needs to be corrected.

◆ status

enum embvm::i2c::status
strong

I2C bus status.

This enumeration represents the status of an I2C bus. This type extends the default embvm::comm::status definition with additional I2C-specific statuses.

Enumerator
ok 

The operation completed successfully.

enqueued 

The operation was enqueued for later processing.

busy 

The device cannot handle the request at this time; try again.

error 

An error occurred with this transaction.

unknown 

The success/failure status of the transaction could not be determined.

addrNACK 

Addr was transmitted, NACK received.

dataNACK 

Data was transmitted, NACK received.

bus 

Bus error, such as missing start/stop condition.

Variable Documentation

◆ I2C_MASTER_REQD_STATIC_FUNCTION_SIZE

constexpr size_t embvm::i2c::I2C_MASTER_REQD_STATIC_FUNCTION_SIZE = 96
static

Maximum size of the I2C master callback functor object.

◆ ReadBit

constexpr uint8_t embvm::i2c::ReadBit = 0x01
static

Added to slave address to indicate a read command.