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

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

#include <eagle_TwoWire.h>

Inherits Stream.

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...
 
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

[I2C] 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 42 of file eagle_TwoWire.h.

Constructor & Destructor Documentation

◆ TwoWire()

eagle_impl::TwoWire::TwoWire ( )

The constructor of the TwoWire class.

Member Function Documentation

◆ available()

virtual int eagle_impl::TwoWire::available ( void  )
virtual

this will return the amount of rxBuffer left

Returns
(rxBufferLength-rxBufferIndex)

◆ begin() [1/3]

void eagle_impl::TwoWire::begin ( )

begin the TwoWire communcation without any data set

◆ begin() [2/3]

void eagle_impl::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 eagle_impl::TwoWire::begin ( int  address)

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 eagle_impl::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 eagle_impl::TwoWire::beginTransmission ( int  address)

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 eagle_impl::TwoWire::endTransmission ( void  )

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 eagle_impl::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

◆ onReceive()

void eagle_impl::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 eagle_impl::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 eagle_impl::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 eagle_impl::TwoWire::onRequestService ( void  )
staticprivate

twi slave [Tx]transmitting-event handler

◆ peek()

virtual int eagle_impl::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 eagle_impl::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 eagle_impl::TwoWire::requestFrom ( uint8_t  address,
uint8_t  quantity 
)

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 eagle_impl::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 eagle_impl::TwoWire::requestFrom ( int  address,
int  quantity 
)

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 eagle_impl::TwoWire::requestFrom ( int  address,
int  quantity,
int  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
Note
this will call the 3*uint8_t (sendStop = true) variant of TwoWire::requestFrom() internally

◆ write() [1/2]

virtual size_t eagle_impl::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 eagle_impl::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 eagle_impl::TwoWire::rxBuffer[]
staticprivate

this defines the rxBuffer used to enable delayed read

Definition at line 45 of file eagle_TwoWire.h.

◆ rxBufferIndex

uint8_t eagle_impl::TwoWire::rxBufferIndex
staticprivate

this defines the rxBuffer Index - current position in rxBuffer array

Definition at line 47 of file eagle_TwoWire.h.

◆ rxBufferLength

uint8_t eagle_impl::TwoWire::rxBufferLength
staticprivate

this defines the length of rxBuffer

Definition at line 49 of file eagle_TwoWire.h.

◆ transmitting

uint8_t eagle_impl::TwoWire::transmitting
staticprivate

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

Definition at line 61 of file eagle_TwoWire.h.

◆ txAddress

uint8_t eagle_impl::TwoWire::txAddress
staticprivate

this defines the txAddress the transmitting Dta

Definition at line 52 of file eagle_TwoWire.h.

◆ txBuffer

uint8_t eagle_impl::TwoWire::txBuffer[]
staticprivate

this defines the txBuffer used to enable delayed read

Definition at line 54 of file eagle_TwoWire.h.

◆ txBufferIndex

uint8_t eagle_impl::TwoWire::txBufferIndex
staticprivate

this defines the txBuffer Index - current position in txBuffer array

Definition at line 56 of file eagle_TwoWire.h.

◆ txBufferLength

uint8_t eagle_impl::TwoWire::txBufferLength
staticprivate

this defines the length of txBuffer

Definition at line 58 of file eagle_TwoWire.h.

◆ user_onReceive

void(* eagle_impl::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 68 of file eagle_TwoWire.h.

◆ user_onRequest

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

twi slave [Tx]transmitting-event user def handler

Definition at line 63 of file eagle_TwoWire.h.


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