Arduino Core for STM32  1.0
HardwareI2C Class Reference

#include <HardwareI2C.h>

Inheritance diagram for HardwareI2C:
Collaboration diagram for HardwareI2C:

Public Member Functions

 HardwareI2C (I2C_HandleTypeDef &hi2c_)
 
bool instanceExists (void)
 Checks if I2C instance exists. More...
 
bool isMaster (void)
 
void setTimeout (uint32_t timeout_)
 
uint32_t errorCode (void)
 
bool begin (uint8_t adress1, uint8_t adress2=0)
 
bool begin ()
 
bool end ()
 
void setClock (uint32_t)
 
void setClockStretchLimit (uint32_t)
 
bool beginTransmission (uint16_t address, uint32_t bytesCountToSend)
 
bool beginTransmission (int address, uint32_t bytesCountToSend)
 
uint8_t endTransmission (void)
 
uint8_t endTransmission (uint8_t)
 
uint8_t requestFrom (uint8_t address, size_t size, bool sendStop)
 
uint8_t status ()
 
uint8_t requestFrom (uint8_t, uint8_t)
 
uint8_t requestFrom (uint8_t, uint8_t, uint8_t)
 
uint8_t requestFrom (int, int)
 
uint8_t requestFrom (int, int, int)
 
size_t write (uint8_t) override
 Writes one unsigned byte (character). More...
 
size_t write (const uint8_t *, size_t) override
 Writes byte array (string). More...
 
int available (void) override
 Checks how many bytes are available in receiving buffer. More...
 
int read (void) override
 Reads one byte from receiving buffer and removes it from buffer. More...
 
int peek (void) override
 Reads one byte from receiving buffer and without removing it from buffer. More...
 
void flush (void)
 
void onReceive (void(*function)(int))
 
void onReceive (void(*function)(size_t))
 
void onRequest (void(*)(void))
 
- Public Member Functions inherited from Stream
 Stream ()
 Constructor. More...
 
Streamoperator>> (char &c)
 This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More...
 
Streamoperator>> (char *buffer)
 This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More...
 
Streamoperator>> (uint8_t *buffer)
 This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More...
 
 __INTEGER_ONLY__ (T, Stream &) operator>>(T &val)
 This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More...
 
 __FLOATING_ONLY__ (T, Stream &) operator>>(T &val)
 This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More...
 
void setTimeout (unsigned long timeout)
 Sets the maximum milliseconds to wait for data transmitting or receiving. More...
 
virtual void width (size_t width_)
 Sets receiving width, that is applied when using operators >> (same as cin.width() method). More...
 
bool find (const char *target)
 Reads and removes data from the stream until the target string is found. More...
 
bool find (uint8_t *target)
 Reads and removes data from the stream until the target string is found. More...
 
bool find (const char *target, size_t length)
 Reads and removes data from the stream until the target string is found. More...
 
bool find (const uint8_t *target, size_t length)
 Reads and removes data from the stream until the target string is found. More...
 
bool find (char target)
 Reads and removes data from the stream until the target character is found. More...
 
bool findUntil (const char *target, const char *terminator)
 Reads data from the stream until a target string or terminator string is found. More...
 
bool findUntil (const uint8_t *target, const char *terminator)
 Reads data from the stream until a target string or terminator string is found. More...
 
bool findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen)
 Reads data from the stream until a target string or terminator string is found. More...
 
bool findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
 Reads data from the stream until a target string or terminator string is found. More...
 
long parseInt ()
 Parses the first valid (long) integer number from the stream. More...
 
 __INTEGER_ONLY__ (T, T) inline parseNum()
 Parses the first valid integer number from the stream. More...
 
float parseFloat ()
 Parses the first valid floating point number from the stream. More...
 
 __FLOATING_ONLY__ (T, T) inline parseNum()
 Parses the first valid floating point number from the stream. More...
 
virtual size_t readBytes (char *buffer, size_t length)
 Reads characters from the stream into a buffer. More...
 
virtual size_t readBytes (uint8_t *buffer, size_t length)
 Reads characters from the stream into a buffer. More...
 
size_t readBytesUntil (char terminator, char *buffer, size_t length)
 Reads characters from the stream into a buffer. More...
 
size_t readBytesUntil (char terminator, uint8_t *buffer, size_t length)
 Reads characters from the stream into a buffer. More...
 
- Public Member Functions inherited from Print
 Print ()
 Constructor. More...
 
int getWriteError ()
 Gets write error. More...
 
void clearWriteError ()
 Clears write error. More...
 
size_t write (const char *str)
 Writes character array (string). More...
 
size_t write (const char *buffer, size_t size)
 Writes character array (string). More...
 
 __INTEGER_ONLY__ (T, size_t) inline write(T val)
 Converts integer type variable to unsigned byte and writes it. More...
 
virtual int availableForWrite ()
 Gets how many bytes can be written, meaning "a single write may block". More...
 
size_t printf (const char *format,...) __attribute__((format(printf
 Prints formatted data. More...
 
size_t size_t print (const String &s)
 Prints string. More...
 
size_t print (const char str[])
 Prints character array (string). More...
 
size_t print (char c)
 Prints one character. More...
 
 __SIGNED_INTEGER_ONLY__ (T, size_t) print(T n
 Converts integer number to character array and prints it. More...
 
size_t println (const String &s)
 Prints string followed by carriage return and new line. More...
 
size_t println (const char[])
 Prints character array (string) followed by carriage return and new line. More...
 
size_t println (char)
 Prints one character followed by carriage return and new line. More...
 
 __INTEGER_ONLY__ (T, size_t) inline println(T n
 Converts integer number to character array followed by carriage return and new line and prints it. More...
 
size_t println (void)
 Prints carriage return and new line. More...
 
template<class T >
Printoperator<< (T value)
 This operator (<<) applied to an output stream is known as insertion operator, it can be used same as cout<< operator. More...
 

Additional Inherited Members

- Public Attributes inherited from Print
int base
 
- Protected Member Functions inherited from Stream
int timedRead ()
 Private method to read stream with timeout. More...
 
int timedPeek ()
 Private method to peek stream with timeout. More...
 
int peekNextDigit ()
 Gets the next numeric digit in the stream or -1 if timeout. More...
 
long parseInt (char skipChar)
 Parses the first valid (long) integer number from the stream. More...
 
 __INTEGER_ONLY__ (T, T) parseNum(char skipChar)
 Parses the first valid integer number from the stream. More...
 
float parseFloat (char skipChar)
 Parses the first valid floating point number from the stream. More...
 
 __FLOATING_ONLY__ (T, T) parseNum(char skipChar)
 Parses the first valid floating point number from the stream. More...
 
virtual size_t widthCheck (size_t width_)
 Checks if the correct width in width() method was set. More...
 
- Protected Member Functions inherited from Print
void setWriteError (int err=1)
 Sets write error. More...
 
- Protected Attributes inherited from Stream
unsigned long _timeout = 1000
 Number of milliseconds to wait for the next char before aborting timed read. More...
 
unsigned long _startMillis
 Used for timeout measurement. More...
 
size_t _width = INT32_MAX
 Maximum operator >> read width. More...
 

Constructor & Destructor Documentation

◆ HardwareI2C()

HardwareI2C::HardwareI2C ( I2C_HandleTypeDef &  hi2c_)
inline

Member Function Documentation

◆ instanceExists()

bool HardwareI2C::instanceExists ( void  )
inline

Checks if I2C instance exists.

Returns
Returns true if I2C instance exists.

◆ isMaster()

bool HardwareI2C::isMaster ( void  )
inline

◆ setTimeout()

void HardwareI2C::setTimeout ( uint32_t  timeout_)
inline

◆ errorCode()

uint32_t HardwareI2C::errorCode ( void  )
inline

◆ begin() [1/2]

bool HardwareI2C::begin ( uint8_t  adress1,
uint8_t  adress2 = 0 
)
Here is the call graph for this function:

◆ begin() [2/2]

bool HardwareI2C::begin ( )
Here is the call graph for this function:

◆ end()

bool HardwareI2C::end ( )
Here is the call graph for this function:

◆ setClock()

void HardwareI2C::setClock ( uint32_t  frequency)

◆ setClockStretchLimit()

void HardwareI2C::setClockStretchLimit ( uint32_t  limit)

◆ beginTransmission() [1/2]

bool HardwareI2C::beginTransmission ( uint16_t  address,
uint32_t  bytesCountToSend 
)
Here is the call graph for this function:

◆ beginTransmission() [2/2]

bool HardwareI2C::beginTransmission ( int  address,
uint32_t  bytesCountToSend 
)
Here is the call graph for this function:

◆ endTransmission() [1/2]

uint8_t HardwareI2C::endTransmission ( void  )

◆ endTransmission() [2/2]

uint8_t HardwareI2C::endTransmission ( uint8_t  sendStop)
Here is the call graph for this function:

◆ requestFrom() [1/5]

uint8_t HardwareI2C::requestFrom ( uint8_t  address,
size_t  size,
bool  sendStop 
)
Here is the call graph for this function:

◆ status()

uint8_t HardwareI2C::status ( )
Here is the call graph for this function:

◆ requestFrom() [2/5]

uint8_t HardwareI2C::requestFrom ( uint8_t  address,
uint8_t  quantity 
)
Here is the call graph for this function:

◆ requestFrom() [3/5]

uint8_t HardwareI2C::requestFrom ( uint8_t  address,
uint8_t  quantity,
uint8_t  sendStop 
)
Here is the call graph for this function:

◆ requestFrom() [4/5]

uint8_t HardwareI2C::requestFrom ( int  address,
int  quantity 
)
Here is the call graph for this function:

◆ requestFrom() [5/5]

uint8_t HardwareI2C::requestFrom ( int  address,
int  quantity,
int  sendStop 
)
Here is the call graph for this function:

◆ write() [1/2]

size_t HardwareI2C::write ( uint8_t  byte)
overridevirtual

Writes one unsigned byte (character).

Parameters
byteByte you want to write.
Returns
Returns count of successfully written bytes.

Implements Print.

Here is the call graph for this function:

◆ write() [2/2]

size_t HardwareI2C::write ( const uint8_t *  buffer,
size_t  size 
)
overridevirtual

Writes byte array (string).

Parameters
bufferData you want to write.
sizeSize of buffer (length of data).
Returns
Returns count of successfully written bytes.

Reimplemented from Print.

Here is the call graph for this function:

◆ available()

int HardwareI2C::available ( void  )
overridevirtual

Checks how many bytes are available in receiving buffer.

Returns
Returns number of available bytes in receiving buffer or 0 if nothing is available.
Note
You should to override this method in derived class.

Implements Stream.

◆ read()

int HardwareI2C::read ( void  )
overridevirtual

Reads one byte from receiving buffer and removes it from buffer.

Returns
Returns one character or -1 if nothing was read.
Note
You should to override this method in derived class.

Implements Stream.

◆ peek()

int HardwareI2C::peek ( void  )
overridevirtual

Reads one byte from receiving buffer and without removing it from buffer.

Returns
Returns one character or -1 if nothing was read.
Note
You should to override this method in derived class.

Implements Stream.

◆ flush()

void HardwareI2C::flush ( void  )

◆ onReceive() [1/2]

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

◆ onReceive() [2/2]

void HardwareI2C::onReceive ( void(*)(size_t)  function)

◆ onRequest()

void HardwareI2C::onRequest ( void(*)(void)  function)

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