eBoard 🐩  ①⑧⑨
Written for SIA 2017/2018
TwoWire Class Reference

This is used to avoid path resolving issues and defines the common known Arduino Wire-Interface
        Don't use manually More...

#include <eBoard.h>

Inheritance diagram for TwoWire:
[legend]
Collaboration diagram for TwoWire:
[legend]

Public Member Functions

 TwoWire ()
 The constructor of the TwoWire class. More...
 
void begin ()
 begin the TwoWire communcation without any data set More...
 
void begin (uint8_t address)
 begin the TwoWire communication with a special address More...
 
void begin (int address)
 begin the TwoWire communication with a special address More...
 
void beginTransmission (uint8_t address)
 this will start a new transmission to a specific address => master mode More...
 
void beginTransmission (int address)
 this will start a new transmission to a specific address => master mode More...
 
uint8_t endTransmission (void)
 this will end the transmission and send the STOP-sequence More...
 
uint8_t endTransmission (uint8_t sendStop)
 this will end the transmission and send the STOP-sequence dependent on sendStop More...
 
uint8_t requestFrom (uint8_t address, uint8_t quantity)
 this will read a specific quantity of bytes from a specific address More...
 
uint8_t requestFrom (uint8_t address, uint8_t quantity, uint8_t sendStop)
 this will read a specific quantity of bytes from a specific address More...
 
uint8_t requestFrom (int address, int quantity)
 this will read a specific quantity of bytes from a specific address More...
 
uint8_t requestFrom (int address, int quantity, int sendStop)
 this will read a specific quantity of bytes from a specific address More...
 
virtual size_t write (uint8_t data)
 this will write a single unsigned 8-bit value to address More...
 
virtual size_t write (const uint8_t *data, size_t quantity)
 this will write an array of unsigned 8-bit values to address More...
 
virtual int available (void)
 this will return the amount of rxBuffer left More...
 
virtual int read (void)
 this will read a single byte from rxBuffer and increment the Index More...
 
virtual int peek (void)
 this will read a single byte from rxBuffer without increment the Index More...
 
virtual void flush (void)
 as this isn't implemented in the offical Wire library, this does nothing xD More...
 
void onReceive (void(*function)(int))
 this will set the user_onReceive method More...
 
void onRequest (void(*function)(void))
 this will set the user_onRequest method More...
 

Static Private Member Functions

static void onRequestService (void)
 twi slave [Tx]transmitting-event handler More...
 
static void onReceiveService (uint8_t *inBytes, int numBytes)
 twi slave [Rx]receive-event handler More...
 

Static Private Attributes

static uint8_t rxBuffer []
 this defines the rxBuffer used to enable delayed read More...
 
static uint8_t rxBufferIndex
 this defines the rxBuffer Index - current position in rxBuffer array More...
 
static uint8_t rxBufferLength
 this defines the length of rxBuffer More...
 
static uint8_t txAddress
 this defines the txAddress the transmitting Dta More...
 
static uint8_t txBuffer []
 this defines the txBuffer used to enable delayed read More...
 
static uint8_t txBufferIndex
 this defines the txBuffer Index - current position in txBuffer array More...
 
static uint8_t txBufferLength
 this defines the length of txBuffer More...
 
static uint8_t transmitting
 'boolean' value. Set to 1 if transmitting => in master write mode More...
 
static void(* user_onRequest )(void)
 twi slave [Tx]transmitting-event user def handler More...
 
static void(* user_onReceive )(int numBytes)
 twi slave [Rx]receive-event user def handler More...
 

Detailed Description

This is used to avoid path resolving issues and defines the common known Arduino Wire-Interface
        Don't use manually

Authors
Nicholas Zambetti for Arduino
[mod] Todd Krein
Note
this code was documented and modified by EagleoutIce in 2018 for custom use!

Definition at line 496 of file eBoard.h.

Constructor & Destructor Documentation

◆ TwoWire()

TwoWire::TwoWire ( )

The constructor of the TwoWire class.

Member Function Documentation

◆ available()

virtual int TwoWire::available ( void  )
virtual

this will return the amount of rxBuffer left

Returns
(rxBufferLength-rxBufferIndex)

◆ begin() [1/3]

void TwoWire::begin ( )

begin the TwoWire communcation without any data set

◆ begin() [2/3]

void TwoWire::begin ( uint8_t  address)

begin the TwoWire communication with a special address

Parameters
addressthe address the TwoWire Interface should use

◆ begin() [3/3]

void TwoWire::begin ( int  address)
inline

begin the TwoWire communication with a special address

Parameters
addressthe address the TwoWire Interface should use
Note
this will cast the address to an uint8_t type and call the same TwoWire::begin()

◆ beginTransmission() [1/2]

void TwoWire::beginTransmission ( uint8_t  address)

this will start a new transmission to a specific address => master mode

Parameters
addressthe address to talk to

◆ beginTransmission() [2/2]

void TwoWire::beginTransmission ( int  address)
inline

this will start a new transmission to a specific address => master mode

Parameters
addressthe address to talk to
Note
this will cast the address to an uint8_t type and call the same TwoWire::beginTransmission()

◆ endTransmission() [1/2]

uint8_t TwoWire::endTransmission ( void  )
inline

this will end the transmission and send the STOP-sequence

Returns
The following unsigned values:
  • 0 in case of success
  • 1 if data was too long for transmit buffer
  • 2 if received a NACK on transmit of address
  • 3 if received a NACK on transmit of data
  • 4 if an 'other'/unknown error occured
Note
this will call TwoWire::endTransmission() with 'true' as param internally

◆ endTransmission() [2/2]

uint8_t TwoWire::endTransmission ( uint8_t  sendStop)

this will end the transmission and send the STOP-sequence dependent on sendStop

Parameters
sendStopset this to true (0x1) if STOP should be send.
Some devices will behave oddly if you set this to false (0x0)!
Returns
The following unsigned values:
  • 0 in case of success
  • 1 if data was too long for transmit buffer
  • 2 if received a NACK on transmit of address
  • 3 if received a NACK on transmit of data
  • 4 if an 'other'/unknown error occured

◆ flush()

virtual void TwoWire::flush ( void  )
virtual

as this isn't implemented in the offical Wire library, this does nothing xD

◆ onReceive()

void TwoWire::onReceive ( void(*)(int)  function)

this will set the user_onReceive method

Parameters
functionthe function to link

For further uses see TwoWire::user_onReceive()

◆ onReceiveService()

static void TwoWire::onReceiveService ( uint8_t *  inBytes,
int  numBytes 
)
staticprivate

twi slave [Rx]receive-event handler

Parameters
inBytesarray of receive Bytes
numByteslength of inBytes array

◆ onRequest()

void TwoWire::onRequest ( void(*)(void)  function)

this will set the user_onRequest method

Parameters
functionthe function to link

For further uses see TwoWire::user_onRequest()

◆ onRequestService()

static void TwoWire::onRequestService ( void  )
staticprivate

twi slave [Tx]transmitting-event handler

◆ peek()

virtual int TwoWire::peek ( void  )
virtual

this will read a single byte from rxBuffer without increment the Index

Note
this has to be called after TwoWire::requestFrom() [or in slave rx event callback]
Returns
the read value (-1 if failed)

◆ read()

virtual int TwoWire::read ( void  )
virtual

this will read a single byte from rxBuffer and increment the Index

Note
this has to be called after TwoWire::requestFrom() [or in slave rx event callback]
Returns
the read value (-1 if failed)

◆ requestFrom() [1/4]

uint8_t TwoWire::requestFrom ( uint8_t  address,
uint8_t  quantity 
)
inline

this will read a specific quantity of bytes from a specific address

Parameters
addressthe address to read from
quantitythe amount if bytes to read
Returns
the amount of read bytes
Note
this will call the 3*uint8_t (sendStop = true) variant of TwoWire::requestFrom() internally

◆ requestFrom() [2/4]

uint8_t TwoWire::requestFrom ( uint8_t  address,
uint8_t  quantity,
uint8_t  sendStop 
)

this will read a specific quantity of bytes from a specific address

Parameters
addressthe address to read from
quantitythe amount if bytes to read
sendStopset this to true (0x1) if STOP should be send.
Some devices will behave oddly if you set this to false (0x0)!
Returns
the amount of read bytes

◆ requestFrom() [3/4]

uint8_t TwoWire::requestFrom ( int  address,
int  quantity 
)
inline

this will read a specific quantity of bytes from a specific address

Parameters
addressthe address to read from
quantitythe amount if bytes to read
Returns
the amount of read bytes
Note
this will call the 3*uint8_t (sendStop = true) variant of TwoWire::requestFrom() internally

◆ requestFrom() [4/4]

uint8_t TwoWire::requestFrom ( int  address,
int  quantity,
int  sendStop 
)
inline

this will read a specific quantity of bytes from a specific address

Parameters
addressthe address to read from
quantitythe amount if bytes to read
sendStopset this to true (0x1) if STOP should be send.
Some devices will behave oddly if you set this to false (0x0)!
Returns
the amount of read bytes
Note
this will call the 3*uint8_t (sendStop = true) variant of TwoWire::requestFrom() internally

◆ write() [1/2]

virtual size_t TwoWire::write ( uint8_t  data)
virtual

this will write a single unsigned 8-bit value to address

Note
this has to be called after TwoWire::beginTransmission() [or in slave tx event callback]
Parameters
datathe data that should be send if in master-mode it will be stored in buffer!
Returns
  • 0 in case of an overflow
  • 1 when everything worked fine ;)

◆ write() [2/2]

virtual size_t TwoWire::write ( const uint8_t *  data,
size_t  quantity 
)
virtual

this will write an array of unsigned 8-bit values to address

Note
this has to be called after TwoWire::beginTransmission() [or in slave tx event callback]
Parameters
datathe data array that should be send if in master-mode it will be stored in buffer!
quantitythe length of the array
Returns
the quantity sent

Member Data Documentation

◆ rxBuffer

uint8_t TwoWire::rxBuffer[]
staticprivate

this defines the rxBuffer used to enable delayed read

Definition at line 499 of file eBoard.h.

◆ rxBufferIndex

uint8_t TwoWire::rxBufferIndex
staticprivate

this defines the rxBuffer Index - current position in rxBuffer array

Definition at line 501 of file eBoard.h.

◆ rxBufferLength

uint8_t TwoWire::rxBufferLength
staticprivate

this defines the length of rxBuffer

Definition at line 503 of file eBoard.h.

◆ transmitting

uint8_t TwoWire::transmitting
staticprivate

'boolean' value. Set to 1 if transmitting => in master write mode

Definition at line 515 of file eBoard.h.

◆ txAddress

uint8_t TwoWire::txAddress
staticprivate

this defines the txAddress the transmitting Dta

Definition at line 506 of file eBoard.h.

◆ txBuffer

uint8_t TwoWire::txBuffer[]
staticprivate

this defines the txBuffer used to enable delayed read

Definition at line 508 of file eBoard.h.

◆ txBufferIndex

uint8_t TwoWire::txBufferIndex
staticprivate

this defines the txBuffer Index - current position in txBuffer array

Definition at line 510 of file eBoard.h.

◆ txBufferLength

uint8_t TwoWire::txBufferLength
staticprivate

this defines the length of txBuffer

Definition at line 512 of file eBoard.h.

◆ user_onReceive

void(* TwoWire::user_onReceive) (int numBytes)
staticprivate

twi slave [Rx]receive-event user def handler

Parameters
numBytesamount of received bytes stored in rxBuffer

Definition at line 522 of file eBoard.h.

◆ user_onRequest

void(* TwoWire::user_onRequest) (void)
staticprivate

twi slave [Tx]transmitting-event user def handler

Definition at line 517 of file eBoard.h.


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