theCore C++ embedded framework
ecl::i2c_bus< dev > Class Template Reference

I2C bus based on Particle electron drivers. More...

#include </home/travis/build/forGGe/theCore/platform/stm32/export/aux/i2c_bus.hpp>

Public Types

using channel = bus_channel
 
using event = bus_event
 
using handler_fn = bus_handler
 

Public Member Functions

 i2c_bus ()=delete
 
 ~i2c_bus ()=delete
 

Static Public Member Functions

static err init ()
 Lazy initialization. More...
 
static void set_rx (uint8_t *rx, size_t size)
 Sets rx buffer with given size. More...
 
static void set_tx (size_t size, uint8_t fill_byte=0xff)
 Sets rx buffer made-up from sequence of similar bytes. More...
 
static void set_tx (const uint8_t *tx, size_t size)
 Sets tx buffer with given size. More...
 
static void set_handler (const bus_handler &handler)
 Sets event handler. More...
 
static void reset_buffers ()
 Reset xfer buffers. More...
 
static void reset_handler ()
 Resets previously set handler. More...
 
static err do_xfer ()
 Executes xfer, using buffers previously set. More...
 
static err cancel_xfer ()
 Cancels xfer. More...
 
static void set_slave_addr (uint16_t addr)
 Sets slave address. More...
 
static ecl::err init ()
 Lazy initialization. More...
 
static void set_rx (uint8_t *rx, size_t size)
 Sets rx buffer with given size. More...
 
static void set_tx (size_t size, uint8_t fill_byte=0xff)
 Sets tx buffer made-up from sequence of similar bytes. More...
 
static void set_tx (const uint8_t *tx, size_t size)
 Sets tx buffer with given size. More...
 
static void set_handler (const handler_fn &handler)
 Sets event handler. More...
 
static void reset_buffers ()
 Reset xfer buffers. More...
 
static void reset_handler ()
 Resets previously set handler. More...
 
static ecl::err do_xfer ()
 Executes xfer, using buffers previously set. More...
 
static ecl::err cancel_xfer ()
 Cancels xfer. More...
 
static void set_slave_addr (uint16_t addr)
 Sets slave address. More...
 

Friends

template<class I2C_Dev >
void dispatch ()
 Real dispatch function that operates over given I2C theCore driver. More...
 

Detailed Description

template<i2c_device dev>
class ecl::i2c_bus< dev >

I2C bus based on Particle electron drivers.

I2C bus itself.

Template Parameters
SpeedI2C bus speed in HZ.
StretchClkEnable or disable clock stretching.

Member Typedef Documentation

◆ channel

template<i2c_device dev>
using ecl::i2c_bus< dev >::channel = bus_channel

◆ event

template<i2c_device dev>
using ecl::i2c_bus< dev >::event = bus_event

◆ handler_fn

template<i2c_device dev>
using ecl::i2c_bus< dev >::handler_fn = bus_handler

Constructor & Destructor Documentation

◆ i2c_bus()

template<i2c_device dev>
ecl::i2c_bus< dev >::i2c_bus ( )
delete

◆ ~i2c_bus()

template<i2c_device dev>
ecl::i2c_bus< dev >::~i2c_bus ( )
delete

Member Function Documentation

◆ init() [1/2]

template<class i2c_config >
ecl::err ecl::i2c_bus< i2c_config >::init ( )
static

Lazy initialization.

Returns
Status of operation.

◆ set_rx() [1/2]

template<class i2c_config >
void ecl::i2c_bus< i2c_config >::set_rx ( uint8_t *  rx,
size_t  size 
)
static

Sets rx buffer with given size.

Parameters
[in,out]rxBuffer to write data to. Optional.
[in]sizeSize

◆ set_tx() [1/4]

template<class i2c_config >
void ecl::i2c_bus< i2c_config >::set_tx ( size_t  size,
uint8_t  fill_byte = 0xff 
)
static

Sets rx buffer made-up from sequence of similar bytes.

Parameters
[in]sizeSize of sequence
[in]fill_byteByte to fill a sequence. Optional.

◆ set_tx() [2/4]

template<class i2c_config >
void ecl::i2c_bus< i2c_config >::set_tx ( const uint8_t *  tx,
size_t  size 
)
static

Sets tx buffer with given size.

Parameters
[in]txBuffer to transmit. Optional.
[in]sizeBuffer size.

◆ set_handler() [1/2]

template<class i2c_config >
void ecl::i2c_bus< i2c_config >::set_handler ( const bus_handler handler)
static

Sets event handler.

Handler will be used by the bus, until reset_handler() will be called.

Parameters
[in]handlerHandler itself.

◆ reset_buffers() [1/2]

template<class i2c_config >
void ecl::i2c_bus< i2c_config >::reset_buffers ( )
static

Reset xfer buffers.

Buffers that were set by

See also
set_tx() and
set_rx() will be no longer used after this call.

◆ reset_handler() [1/2]

template<i2c_device dev>
void ecl::i2c_bus< dev >::reset_handler ( )
static

Resets previously set handler.

◆ do_xfer() [1/2]

template<class i2c_config >
ecl::err ecl::i2c_bus< i2c_config >::do_xfer ( )
static

Executes xfer, using buffers previously set.

When it will be done, handler will be invoked.

Returns
Status of operation.
Here is the call graph for this function:

◆ cancel_xfer() [1/2]

template<class i2c_config >
ecl::err ecl::i2c_bus< i2c_config >::cancel_xfer ( )
static

Cancels xfer.

After this call no xfer will occur.

Returns
Status of operation.

◆ set_slave_addr() [1/2]

template<class i2c_config >
void ecl::i2c_bus< i2c_config >::set_slave_addr ( uint16_t  addr)
static

Sets slave address.

This address is used during communication. In case if there is only one device on the bus, this function may be called only once, before first xfer().

◆ init() [2/2]

template<i2c_device dev>
static ecl::err ecl::i2c_bus< dev >::init ( )
static

Lazy initialization.

Returns
Status of operation.

◆ set_rx() [2/2]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::set_rx ( uint8_t *  rx,
size_t  size 
)
static

Sets rx buffer with given size.

Parameters
[in,out]rxBuffer to write data to. Optional.
[in]sizeSize

◆ set_tx() [3/4]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::set_tx ( size_t  size,
uint8_t  fill_byte = 0xff 
)
static

Sets tx buffer made-up from sequence of similar bytes.

Parameters
[in]sizeSize of sequence
[in]fill_byteByte to fill a sequence. Optional.

◆ set_tx() [4/4]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::set_tx ( const uint8_t *  tx,
size_t  size 
)
static

Sets tx buffer with given size.

Parameters
[in]txBuffer to transmit. Optional.
[in]sizeBuffer size.

◆ set_handler() [2/2]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::set_handler ( const handler_fn handler)
static

Sets event handler.

Handler will be used by the bus, until reset_handler() will be called.

Parameters
[in]handlerHandler itself.

◆ reset_buffers() [2/2]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::reset_buffers ( )
static

Reset xfer buffers.

Buffers that were set by

See also
set_tx() and
set_rx() will be no longer used after this call.

◆ reset_handler() [2/2]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::reset_handler ( )
static

Resets previously set handler.

◆ do_xfer() [2/2]

template<i2c_device dev>
static ecl::err ecl::i2c_bus< dev >::do_xfer ( )
static

Executes xfer, using buffers previously set.

When it will be done, handler will be invoked.

Returns
Status of operation.

◆ cancel_xfer() [2/2]

template<i2c_device dev>
static ecl::err ecl::i2c_bus< dev >::cancel_xfer ( )
static

Cancels xfer.

After this call no xfer will occur.

Returns
Status of operation.

◆ set_slave_addr() [2/2]

template<i2c_device dev>
static void ecl::i2c_bus< dev >::set_slave_addr ( uint16_t  addr)
static

Sets slave address.

This address is used during communication. In case there is only one device on the bus, this function may be called only once, before first xfer().

Friends And Related Function Documentation

◆ dispatch

template<i2c_device dev>
template<class I2C_Dev >
void dispatch ( )
friend

Real dispatch function that operates over given I2C theCore driver.

Template Parameters
I2C_DevtheCore I2C driver.

Upon call, it will determine if data should be send or received from the I2C driver.


The documentation for this class was generated from the following file: