Flair
Framework Libre Air
flair::core::I2cPort Class Referenceabstract

Base class for i2c port. More...

#include <I2cPort.h>

+ Inheritance diagram for flair::core::I2cPort:

Public Member Functions

 I2cPort (const Object *parent, std::string name)
 Constructor. More...
 
 ~I2cPort ()
 Destructor. More...
 
virtual int SetSlave (uint16_t address)=0
 Set slave's address. More...
 
virtual ssize_t Write (const void *buf, size_t nbyte)=0
 Write datas. More...
 
virtual ssize_t Read (void *buf, size_t nbyte)=0
 Read datas. More...
 
virtual void SetRxTimeout (Time timeout_ns)=0
 Set RX timeout. More...
 
virtual void SetTxTimeout (Time timeout_ns)=0
 Set TX timeout. More...
 
- Public Member Functions inherited from flair::core::Mutex
 Mutex (const Object *parent, std::string name="")
 Constructor. More...
 
 ~Mutex ()
 Destructor. More...
 
void GetMutex (void) const
 GetMutex. More...
 
void ReleaseMutex (void) const
 ReleaseMutex. More...
 
- Public Member Functions inherited from flair::core::Object
 Object (const Object *parent=NULL, std::string name="", std::string type="")
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
std::string ObjectName (void) const
 Name. More...
 
std::string ObjectType (void) const
 Type. More...
 
const ObjectParent (void) const
 Parent. More...
 
std::vector< const Object * > * TypeChilds (void) const
 Childs of the same type. More...
 
std::vector< const Object * > * Childs (void) const
 Childs. More...
 
void Information (const char *function, int line, const char *format,...) const
 Formatted information. More...
 
void Warning (const char *function, const char *format,...) const
 Formatted warning. More...
 
void Error (const char *function, const char *format,...) const
 Formatted error. More...
 
bool ErrorOccured (bool recursive=true) const
 Has an errror occured? More...
 

Additional Inherited Members

- Public Types inherited from flair::core::Object
enum  color_t { Auto = 0, Red = 31, Green = 32, Orange = 33 }
 

Detailed Description

Base class for i2c port.

This class has a Mutex which must be used to protect access to the port in case that more than one Thread is using it. Lock the Mutex before any communication (including SetSlave) and release it after communication.

Constructor & Destructor Documentation

flair::core::I2cPort::I2cPort ( const Object parent,
std::string  name 
)
inline

Constructor.

Construct an i2c port.

Parameters
parentparent
namename
flair::core::I2cPort::~I2cPort ( )
inline

Destructor.

Member Function Documentation

virtual int flair::core::I2cPort::SetSlave ( uint16_t  address)
pure virtual

Set slave's address.

This function need to be called before any communication.

Parameters
addressslave's address

Implemented in flair::core::RTDM_I2cPort, and flair::core::Unix_I2cPort.

virtual ssize_t flair::core::I2cPort::Write ( const void *  buf,
size_t  nbyte 
)
pure virtual

Write datas.

Parameters
bufpointer to datas
nbytelength of datas
Returns
amount of written datas

Implemented in flair::core::Unix_I2cPort, and flair::core::RTDM_I2cPort.

virtual ssize_t flair::core::I2cPort::Read ( void *  buf,
size_t  nbyte 
)
pure virtual

Read datas.

Parameters
bufpointer to datas
nbytelength of datas
Returns
amount of read datas

Implemented in flair::core::Unix_I2cPort, and flair::core::RTDM_I2cPort.

virtual void flair::core::I2cPort::SetRxTimeout ( Time  timeout_ns)
pure virtual

Set RX timeout.

Timeout for waiting an ACK from the slave.

Parameters
timeout_nstimeout in nano second

Implemented in flair::core::RTDM_I2cPort, and flair::core::Unix_I2cPort.

virtual void flair::core::I2cPort::SetTxTimeout ( Time  timeout_ns)
pure virtual

Set TX timeout.

Timeout for waiting an ACK from the slave.

Parameters
timeout_nstimeout in nano second

Implemented in flair::core::RTDM_I2cPort, and flair::core::Unix_I2cPort.