JM9 XRCU Board 0.1.0
Libraries API Reference
Loading...
Searching...
No Matches
TwoWire Class Reference
Inheritance diagram for TwoWire:
Stream Print

Public Types

typedef std::function< void(int)> cb_function_receive_t
 
typedef std::function< void(void)> cb_function_request_t
 

Public Member Functions

 TwoWire (uint32_t sda, uint32_t scl)
 
 ~TwoWire ()
 TwoWire destructor.
 
void setSCL (uint32_t scl)
 
void setSDA (uint32_t sda)
 
void setSCL (PinName scl)
 
void setSDA (PinName sda)
 
void begin (bool generalCall=false)
 
void begin (uint32_t, uint32_t)
 
void begin (uint8_t, bool generalCall=false, bool NoStretchMode=false)
 
void begin (int, bool generalCall=false, bool NoStretchMode=false)
 
void end ()
 
void setClock (uint32_t)
 
void setWireTimeout (uint32_t timeout=25000U, bool reset_with_timeout=false)
 
void beginTransmission (uint8_t)
 
void beginTransmission (int)
 
uint8_t endTransmission (void)
 
uint8_t endTransmission (uint8_t)
 
uint8_t requestFrom (uint8_t, uint8_t)
 
uint8_t requestFrom (uint8_t, uint8_t, uint8_t)
 
uint8_t requestFrom (uint8_t, size_t, bool)
 
uint8_t requestFrom (uint8_t, uint8_t, uint32_t, uint8_t, uint8_t)
 
uint8_t requestFrom (int, int)
 
uint8_t requestFrom (int, int, int)
 
virtual size_t write (uint8_t)
 
virtual size_t write (const uint8_t *, size_t)
 This function must be called in slave Tx event callback or after beginTransmission() and before endTransmission().
 
virtual int available (void)
 
virtual int read (void)
 
virtual int peek (void)
 
virtual void flush (void)
 
void onReceive (cb_function_receive_t callback)
 
void onRequest (cb_function_request_t callback)
 
size_t write (unsigned long n)
 
size_t write (long n)
 
size_t write (unsigned int n)
 
size_t write (int n)
 
I2C_HandleTypeDef * getHandle (void)
 
void setUseSoftTwi (const bool use)
 Sets the flag whether to use software or hardware TWI.
 
bool isUseSoftTwi ()
 Checks whether this object is currently using software or hardware TWI.
 
void switchToPort (const uint32_t port)
 Switches the port used by this object.
 
void switchToPinsSCLSDA (const uint32_t scl, const uint32_t sda)
 Switches the SCL and SDA pins used by this object.
 
void switchToPinsSCLSDA (const PinName scl, const PinName sda)
 Switches the SCL and SDA pins used by this object.
 
bool isSlavePresent (const uint8_t slave_address)
 Scans if the slave of a specific address is connected to the TWI bus of selected port.
 
uint8_t scanSlaves (const uint8_t starting_address=0x01)
 Scans the slaves connected to the TWI bus of selected port.
 
size_t write (const char *str)
 
size_t write (const char *buffer, size_t size)
 
- Public Member Functions inherited from Stream
void setTimeout (unsigned long timeout)
 
unsigned long getTimeout (void)
 
bool find (const char *target)
 
bool find (const uint8_t *target)
 
bool find (const char *target, size_t length)
 
bool find (const uint8_t *target, size_t length)
 
bool find (char target)
 
bool findUntil (const char *target, const char *terminator)
 
bool findUntil (const uint8_t *target, const char *terminator)
 
bool findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen)
 
bool findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
 
long parseInt (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR)
 
float parseFloat (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR)
 
virtual size_t readBytes (char *buffer, size_t length)
 
size_t readBytes (uint8_t *buffer, size_t length)
 
virtual size_t readBytesUntil (char terminator, char *buffer, size_t length)
 
size_t readBytesUntil (char terminator, uint8_t *buffer, size_t length)
 
String readString ()
 
String readStringUntil (char terminator)
 
- Public Member Functions inherited from Print
int getWriteError ()
 
void clearWriteError ()
 
size_t write (const char *str)
 
size_t write (const char *buffer, size_t size)
 
virtual int availableForWrite ()
 
size_t print (const __FlashStringHelper *)
 
size_t print (const String &)
 
size_t print (const char[])
 
size_t print (char)
 
size_t print (unsigned char, int=DEC)
 
size_t print (int, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t print (long long, int=DEC)
 
size_t print (unsigned long long, int=DEC)
 
size_t print (float, int=2)
 
size_t print (double, int=2)
 
size_t print (const Printable &)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const String &s)
 
size_t println (const char[])
 
size_t println (char)
 
size_t println (unsigned char, int=DEC)
 
size_t println (int, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (long long, int=DEC)
 
size_t println (unsigned long long, int=DEC)
 
size_t println (float, int=2)
 
size_t println (double, int=2)
 
size_t println (const Printable &)
 
size_t println (void)
 
int printf (const char *format,...)
 
int printf (const __FlashStringHelper *format,...)
 
int vprintf (const __FlashStringHelper *format, va_list ap)
 
int vprintf (const char *format, va_list ap)
 

Additional Inherited Members

- Protected Member Functions inherited from Stream
int timedRead ()
 
int timedPeek ()
 
int peekNextDigit (LookaheadMode lookahead, bool detectDecimal)
 
long parseInt (char ignore)
 
float parseFloat (char ignore)
 
int findMulti (struct MultiTarget *targets, int tCount)
 
- Protected Member Functions inherited from Print
void setWriteError (int err=1)
 
- Protected Attributes inherited from Stream
unsigned long _timeout
 
unsigned long _startMillis
 

Constructor & Destructor Documentation

◆ ~TwoWire()

TwoWire::~TwoWire ( )

TwoWire destructor.

Return values
None

Member Function Documentation

◆ available()

int TwoWire::available ( void )
virtual

Implements Stream.

◆ flush()

void TwoWire::flush ( void )
virtual

Reimplemented from Print.

◆ isSlavePresent()

bool TwoWire::isSlavePresent ( const uint8_t slave_address)

Scans if the slave of a specific address is connected to the TWI bus of selected port.

Returns
true if the slave is active on the bus, false otherwise
Author
YH Choi @ JM9

◆ isUseSoftTwi()

bool TwoWire::isUseSoftTwi ( )

Checks whether this object is currently using software or hardware TWI.

Returns
true is SW TWI in use, false is HW TWI in use
Author
YH Choi @ JM9

◆ peek()

int TwoWire::peek ( void )
virtual

Implements Stream.

◆ read()

int TwoWire::read ( void )
virtual

Implements Stream.

◆ scanSlaves()

uint8_t TwoWire::scanSlaves ( const uint8_t starting_address = 0x01)

Scans the slaves connected to the TWI bus of selected port.

Parameters
starting_addressthe smallest address to start scanning from
Returns
the smallest address scanned on the TWI bus of selected port, or 0x00 if no slaves were found
Author
YH Choi @ JM9

◆ setUseSoftTwi()

void TwoWire::setUseSoftTwi ( const bool use)

Sets the flag whether to use software or hardware TWI.

Parameters
usetrue to use SW TWI, false to use HW TWI
Author
YH Choi @ JM9

◆ switchToPinsSCLSDA() [1/2]

void TwoWire::switchToPinsSCLSDA ( const PinName scl,
const PinName sda )

Switches the SCL and SDA pins used by this object.

Parameters
sclthe SCL pin to be switched to
sdathe SDA pin to be switched to
Author
YH Choi @ JM9

◆ switchToPinsSCLSDA() [2/2]

void TwoWire::switchToPinsSCLSDA ( const uint32_t scl,
const uint32_t sda )

Switches the SCL and SDA pins used by this object.

Parameters
sclthe SCL pin to be switched to
sdathe SDA pin to be switched to
Author
YH Choi @ JM9

◆ switchToPort()

void TwoWire::switchToPort ( const uint32_t port)

Switches the port used by this object.

Parameters
portthe port to be switched to
Author
YH Choi @ JM9

◆ write() [1/2]

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

This function must be called in slave Tx event callback or after beginTransmission() and before endTransmission().

Parameters
pdatapointer to the buffer data
quantitynumber of bytes to write
Return values
numberof bytes ready to write.

Reimplemented from Print.

◆ write() [2/2]

size_t TwoWire::write ( uint8_t data)
virtual

Implements Print.


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