utl::i2c_i< virtual_tag > Class Template Referenceabstract

A virtual base class specialization. More...

`#include <i2c.h>`

Inheritance diagram for utl::i2c_i< virtual_tag >:

## Public Types

enum | Sequence { Sequence::BYTE =0, Sequence::ACK, Sequence::BYTEnACK }
| I2C transmit/receive sequence. More...
using | type = i2c_i< virtual_tag >
| Export type as identity meta-function. More...

## Public Member Functions

Get/Set functions
uint32_t | clock () const
void | clock (uint32_t c)
| set clock frequency of the bus [Hz] More...
User functions
void | start ()
void | stop ()
byte_t | rx_data (bool ack, Sequence seq=Sequence::BYTEnACK)
| Receive a byte from the i2c bus. More...
bool | tx_data (byte_t byte, Sequence seq=Sequence::BYTEnACK)
| Transmit a byte to the i2c bus. More...

## Private Member Functions

Implementation requirements
virtual uint32_t | _clock () const =0
virtual void | _clock (uint32_t)=0
| set clock frequency of the bus [Hz] More...
virtual void | _start ()=0
| Send start functionality. More...
virtual void | _stop ()=0
| Send stop functionality. More...
virtual byte_t | _rx_data (bool ack, Sequence seq)=0
| Receive a byte from the i2c bus. More...
virtual bool | _tx_data (byte_t byte, Sequence seq)=0

## Object lifetime

| i2c_i ()=default
| Allow constructor from derived only. More...
| i2c_i (const type &)=delete
| No copies. More...
type & | operator= (const type &)=delete
virtual | ~i2c_i ()=default

## Detailed Description

### template<>
class utl::i2c_i< virtual_tag >

A virtual base class specialization.

Parameters

  impl_t | = virtual_tag

Definition at line 140 of file i2c.h.

## Member Typedef Documentation

## type

using utl::i2c_i< virtual_tag >::type = i2c_i <virtual_tag>

Export type as identity meta-function.

Definition at line 142 of file i2c.h.

## Member Enumeration Documentation

## Sequence

enum utl::i2c_i< virtual_tag >::Sequence

strong

I2C transmit/receive sequence.

Enumerator
BYTE | Only read/write byte [8 clocks].
ACK | Only send/receive ack [1 clock].
BYTEnACK | Read/Write byte and ack [9 clocks].

Definition at line 145 of file i2c.h.

## Constructor & Destructor Documentation

## i2c_i() [1/2]

utl::i2c_i< virtual_tag >::i2c_i | ( |  | ) |

protecteddefault

Allow constructor from derived only.

## i2c_i() [2/2]

utl::i2c_i< virtual_tag >::i2c_i | ( | const type & |  | ) |

protecteddelete

No copies.

## ~i2c_i()

virtual utl::i2c_i< virtual_tag >::~i2c_i | ( |  | ) |

virtualdefault

Virtual default destructor

## Member Function Documentation

## _clock() [1/2]

virtual uint32_t utl::i2c_i< virtual_tag >::_clock | ( |  | ) | const

privatepure virtual

Returns
  clock frequency of the bus [Hz]

Implemented in utl::i2c_bb_i< virtual_tag >.

## _clock() [2/2]

virtual void utl::i2c_i< virtual_tag >::_clock | ( | uint32_t |  | ) |

privatepure virtual

set clock frequency of the bus [Hz]

Implemented in utl::i2c_bb_i< virtual_tag >.

## _rx_data()

virtual byte_t utl::i2c_i< virtual_tag >::_rx_data | ( | bool | ack,
|  | Sequence | seq
| ) |  |

privatepure virtual

Receive a byte from the i2c bus.

Implemented in utl::i2c_bb_i< virtual_tag >.

## _start()

virtual void utl::i2c_i< virtual_tag >::_start | ( |  | ) |

privatepure virtual

Send start functionality.

Implemented in utl::i2c_bb_i< virtual_tag >.

## _stop()

virtual void utl::i2c_i< virtual_tag >::_stop | ( |  | ) |

privatepure virtual

Send stop functionality.

Implemented in utl::i2c_bb_i< virtual_tag >.

## _tx_data()

virtual bool utl::i2c_i< virtual_tag >::_tx_data | ( | byte_t | byte,
|  | Sequence | seq
| ) |  |

privatepure virtual

Transmit a byte to the i2c bus.

Implemented in utl::i2c_bb_i< virtual_tag >.

## clock() [1/2]

uint32_t utl::i2c_i< virtual_tag >::clock | ( |  | ) | const

inline

Returns
  clock frequency of the bus [Hz]

Definition at line 180 of file i2c.h.

## clock() [2/2]

void utl::i2c_i< virtual_tag >::clock | ( | uint32_t | c | ) |

inline

set clock frequency of the bus [Hz]

Definition at line 181 of file i2c.h.

## operator=()

type& utl::i2c_i< virtual_tag >::operator= | ( | const type & |  | ) |

protecteddelete

## rx_data()

byte_t utl::i2c_i< virtual_tag >::rx_data | ( | bool | ack,
|  | Sequence | seq = `Sequence::BYTEnACK`
| ) |  |

inline

Receive a byte from the i2c bus.

Parameters

  ack

  Optional ack bit.
  - 1 ACK the reception
  - 0 Don't ACK the reception.

  seq

  The operation sequence to execute
  - Sequence::BYTE Receive only the byte, do not send ack clock
  - Sequence::ACK Send only the ack bit
  - Sequence::BYTEnACK Receive the byte and send the ack bit

Returns
  The byte received.

Definition at line 203 of file i2c.h.

## start()

void utl::i2c_i< virtual_tag >::start | ( |  | ) |

inline

Definition at line 189 of file i2c.h.

## stop()

void utl::i2c_i< virtual_tag >::stop | ( |  | ) |

inline

Definition at line 190 of file i2c.h.

## tx_data()

bool utl::i2c_i< virtual_tag >::tx_data | ( | byte_t | byte,
|  | Sequence | seq = `Sequence::BYTEnACK`
| ) |  |

inline

Transmit a byte to the i2c bus.

Parameters

  byte | The byte to send.

  seq

  The operation sequence to execute
  - Sequence::BYTE Transmit only the byte, do not read ack bit
  - Sequence::ACK Read only the ack bit
  - Sequence::BYTEnACK Transmit the byte and read the ack bit

Returns
  Slave's ACK bit
  - false Slave didn't ACK
  - true Slave did ACK

Definition at line 218 of file i2c.h.

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

- include/utl/com/i2c.h