Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
TWI Class Referenceabstract

#include <TWI.h>

Inheritance diagram for TWI:
Inheritance graph
Collaboration diagram for TWI:
Collaboration graph

Classes

class  Device
 

Public Member Functions

 TWI ()
 
virtual bool acquire ()=0
 
virtual bool release ()=0
 
virtual int read (uint8_t addr, void *buf, size_t count)=0
 
virtual int write (uint8_t addr, const void *buf, size_t count)
 
virtual int write (uint8_t addr, iovec_t *vp)=0
 

Static Public Attributes

static const uint32_t DEFAULT_FREQ = 100000L
 

Protected Member Functions

void lock ()
 
void unlock ()
 

Protected Attributes

volatile bool m_busy
 

Detailed Description

Abstract Two-Wire Interface (TWI) class.

Definition at line 28 of file TWI.h.

Constructor & Destructor Documentation

TWI::TWI ( )
inline

Default constructor.

Definition at line 113 of file TWI.h.

Member Function Documentation

virtual bool TWI::acquire ( )
pure virtual

Start bus transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Implemented in Hardware::TWI, Software::TWI< SDA_PIN, SCL_PIN >, and Hardware::TWI.

void TWI::lock ( )
inlineprotected

Lock bus manager.

Definition at line 176 of file TWI.h.

virtual int TWI::read ( uint8_t  addr,
void *  buf,
size_t  count 
)
pure virtual

Read data from device with given address into given buffer.

Parameters
[in]addrdevice address.
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes read or negative error code.

Implemented in Hardware::TWI, Hardware::TWI, and Software::TWI< SDA_PIN, SCL_PIN >.

virtual bool TWI::release ( )
pure virtual

Stop bus transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Implemented in Hardware::TWI, Software::TWI< SDA_PIN, SCL_PIN >, and Hardware::TWI.

void TWI::unlock ( )
inlineprotected

Unlock bus manager.

Definition at line 185 of file TWI.h.

virtual int TWI::write ( uint8_t  addr,
const void *  buf,
size_t  count 
)
inlinevirtual

Write data to device with given address from given buffer.

Parameters
[in]addrdevice address.
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes written or negative error code.

Definition at line 151 of file TWI.h.

virtual int TWI::write ( uint8_t  addr,
iovec_t *  vp 
)
pure virtual

Write data to device with from given io vector.

Parameters
[in]addrdevice address.
[in]vpio vector pointer.
Returns
number of bytes written or negative error code.

Implemented in Hardware::TWI, Hardware::TWI, and Software::TWI< SDA_PIN, SCL_PIN >.

Member Data Documentation

const uint32_t TWI::DEFAULT_FREQ = 100000L
static

Default Two-Wire Interface clock: 100 KHz.

Definition at line 108 of file TWI.h.

volatile bool TWI::m_busy
protected

Bus manager semaphore.

Definition at line 171 of file TWI.h.


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