Embedded Artistry Framework
Embedded Systems C++ Framework
Classes | Namespaces | Typedefs | Enumerations | Variables
i2c.hpp File Reference
#include "driver.hpp"
#include <cstdint>
#include <driver/communication_bus.hpp>
#include <etl/vector.h>
#include <inplace_function/inplace_function.hpp>
Include dependency graph for i2c.hpp:
This graph shows which files directly or indirectly include this file:

Classes

struct  embvm::i2c::op_t
 I2C operation definition. More...
 
class  embvm::i2c::master
 This class provides the I2C master interface definition. More...
 

Namespaces

 embvm
 Embedded framework core interfaces, classes, and definitions.
 
 embvm::i2c
 Definitions, functions, and classes related to I2C communication bus devices.
 

Typedefs

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

Variables

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

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.