Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
Twi Class Reference

Class that implements twi/i2c. More...

#include <cs_Twi.h>

Inheritance diagram for Twi:
Collaboration diagram for Twi:

Public Member Functions

void init (const boards_config_t &board)
 Init twi with board configuration (nothing is happening to the pins yet). More...
 
void initBus (cs_twi_init_t &twi)
 Init twi as master on the i2c bus. More...
 
void write (uint8_t address, uint8_t *data, size_t length, bool stop)
 Write data to given address. More...
 
void read (uint8_t address, uint8_t *data, size_t &length)
 Read data from given address. More...
 
void handleEvent (event_t &event)
 Incoming events. More...
 
void isrEvent (TwiIsrEvent event)
 Events from the hardware. More...
 
- Public Member Functions inherited from EventListener
 EventListener ()
 
virtual ~EventListener ()
 unregisters the listener. More...
 
virtual void handleEvent (event_t &event)=0
 Handle events. More...
 
void listen ()
 Registers this with the EventDispatcher. More...
 

Static Public Member Functions

static TwigetInstance ()
 Construct twi/i2c instance. More...
 

Static Protected Attributes

static const nrfx_twi_t _twi
 

Private Member Functions

 Twi ()
 
 Twi (Twi const &)
 
void operator= (Twi const &)
 

Private Attributes

nrfx_twi_config_t _config
 
bool _initialized
 
bool _initializedBus
 
bool _eventRead
 
bool _eventError
 

Detailed Description

Class that implements twi/i2c.

This on the moment only implements twi as master.

Constructor & Destructor Documentation

◆ Twi() [1/2]

Twi::Twi ( )
private

◆ Twi() [2/2]

Twi::Twi ( Twi const &  )
private

Member Function Documentation

◆ getInstance()

static Twi & Twi::getInstance ( )
static

Construct twi/i2c instance.

◆ handleEvent()

void Twi::handleEvent ( event_t event)
virtual

Incoming events.

Parameters
[in]eventEvent from other modules in bluenet.

Implements EventListener.

◆ init()

void Twi::init ( const boards_config_t board)

Init twi with board configuration (nothing is happening to the pins yet).

Parameters
[in]boardHardware board.

◆ initBus()

void Twi::initBus ( cs_twi_init_t twi)

Init twi as master on the i2c bus.

Parameters
[in]twiConfiguration (frequency, etc.)

◆ isrEvent()

void Twi::isrEvent ( TwiIsrEvent  event)

Events from the hardware.

◆ operator=()

void Twi::operator= ( Twi const &  )
private

◆ read()

void Twi::read ( uint8_t  address,
uint8_t *  data,
size_t &  length 
)

Read data from given address.

Parameters
[in]addressThe address of the device to read from.
[out]dataPointer to data array where result will be received.
[in,out]lengthNumber of items to read, and returns number of items actually read.

◆ write()

void Twi::write ( uint8_t  address,
uint8_t *  data,
size_t  length,
bool  stop 
)

Write data to given address.

Parameters
[in]addressThe address of the device to write to.
[in]dataPointer to data to be written.
[in]lengthThe number of items to be written.
[in]stopRelease the bus after a write (for e.g. another i2c master).

Member Data Documentation

◆ _config

nrfx_twi_config_t Twi::_config
private

◆ _eventError

bool Twi::_eventError
private

◆ _eventRead

bool Twi::_eventRead
private

◆ _initialized

bool Twi::_initialized
private

◆ _initializedBus

bool Twi::_initializedBus
private

◆ _twi

const nrfx_twi_t Twi::_twi
staticprotected

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