Pico-Arduino
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pico_arduino::PicoHardwareI2C Class Reference

Arduino I2C implementation using the Pico functionality. In Arduino we can read and write individal characters wheresease in Pico the operations have to be done with arrays. We therefore create a read and write buffer to cache the operations. More...

#include <PicoHardwareI2C.h>

Inheritance diagram for pico_arduino::PicoHardwareI2C:
arduino::HardwareI2C arduino::Stream arduino::Print

Public Member Functions

 PicoHardwareI2C (i2c_inst_t *i2c, int maxBufferSize, int sdaPin, int sclPin)
 Standard Constructor for PicoHardwareI2C class.
 
 ~PicoHardwareI2C ()
 Destructor for PicoHardwareI2C class.
 
virtual int available ()
 Returns the number of bytes available for retrieval with read(). This should be called on a master device after a call to requestFrom() or on a slave inside the onReceive() handler.
 
virtual void begin ()
 Initiate the Wire library and join the I2C bus as a master. This should normally be called only once.
 
virtual void begin (int sdaPin, int sclPin)
 Initiate the Wire library and join the I2C bus as a master. This should normally be called only once.
 
virtual void begin (uint8_t address)
 Initiate the Wire library and join the I2C bus as a slave. This should normally be called only once.
 
virtual void begin (uint8_t address, int sdaPin, int sclPin)
 Initiate the Wire library and join the I2C bus as a slave. This should normally be called only once.
 
virtual void beginTransmission (uint8_t address)
 Begin a transmission to the I2C slave device with the given address. Subsequently, queue bytes for transmission with the write() function and transmit them by calling endTransmission().
 
virtual void end ()
 Closes the Wire Library.
 
virtual uint8_t endTransmission (bool stopBit)
 Ends a transmission to a slave device that was begun by beginTransmission() and transmits the bytes that were queued by write(). If true, endTransmission() sends a stop message after transmission, releasing the I2C bus.
 
virtual uint8_t endTransmission (void)
 Ends a transmission to a slave device that was begun by beginTransmission() and transmits the bytes that were queued by write().
 
virtual void onReceive (void(*recieveHandler)(int))
 Registers a function to be called when a slave device receives a transmission from a master.
 
virtual void onRequest (void(*requestHandler)(void))
 Register a function to be called when a master requests data from this slave device.
 
virtual int peek ()
 Peeks current unread byte that was transmitted from a slave device to a master after a call to requestFrom() or was transmitted from a master to a slave. read() inherits from the Stream utility class.
 
virtual int read ()
 Reads a byte that was transmitted from a slave device to a master after a call to requestFrom() or was transmitted from a master to a slave. read() inherits from the Stream utility class.
 
virtual size_t requestFrom (uint8_t address, size_t len)
 Used by the master to request bytes from a slave device. The bytes may then be retrieved with the available() and read() functions.
 
virtual size_t requestFrom (uint8_t address, size_t len, bool stopBit)
 Used by the master to request bytes from a slave device. The bytes may then be retrieved with the available() and read() functions.
 
virtual void setClock (uint32_t baudrate)
 This function modifies the clock frequency for I2C communication. I2C slave devices have no minimum working clock frequency, however 100KHz is usually the baseline.
 
size_t write (const char *buffer, size_t size)
 Writes data from a slave device in response to a request from a master, or queues bytes for transmission from a master to slave device (in-between calls to beginTransmission() and endTransmission()).
 
virtual size_t write (uint8_t c)
 Writes data from a slave device in response to a request from a master, or queues bytes for transmission from a master to slave device (in-between calls to beginTransmission() and endTransmission()).
 
- Public Member Functions inherited from arduino::Stream
bool find (char target)
 
bool find (const char *target)
 
bool find (const char *target, size_t length)
 
bool find (const uint8_t *target)
 
bool find (const uint8_t *target, size_t length)
 
bool findUntil (const char *target, const char *terminator)
 
bool findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen)
 
bool findUntil (const uint8_t *target, const char *terminator)
 
bool findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
 
unsigned long getTimeout (void)
 
float parseFloat (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR)
 
long parseInt (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR)
 
size_t readBytes (char *buffer, size_t length)
 
size_t readBytes (uint8_t *buffer, size_t length)
 
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)
 
void setTimeout (unsigned long timeout)
 
- Public Member Functions inherited from arduino::Print
virtual int availableForWrite ()
 
void clearWriteError ()
 
virtual void flush ()
 
int getWriteError ()
 
size_t print (char)
 
size_t print (const __FlashStringHelper *)
 
size_t print (const char[])
 
size_t print (const Printable &)
 
size_t print (const String &)
 
size_t print (double, int=2)
 
size_t print (int, int=DEC)
 
size_t print (long long, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned char, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (unsigned long long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t println (char)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const char[])
 
size_t println (const Printable &)
 
size_t println (const String &s)
 
size_t println (double, int=2)
 
size_t println (int, int=DEC)
 
size_t println (long long, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned char, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (unsigned long long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (void)
 
size_t write (const char *buffer, size_t size)
 
size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 

Protected Member Functions

int flush (bool stop=false)
 
void setupPins (int sda, int scl)
 
void setupReadBuffer (int len)
 
void setupWriteBuffer ()
 
- Protected Member Functions inherited from arduino::Stream
int findMulti (struct MultiTarget *targets, int tCount)
 
float parseFloat (char ignore)
 
long parseInt (char ignore)
 
int peekNextDigit (LookaheadMode lookahead, bool detectDecimal)
 
int timedPeek ()
 
int timedRead ()
 
- Protected Member Functions inherited from arduino::Print
void setWriteError (int err=1)
 

Protected Attributes

i2c_inst_t * i2c
 
bool is_slave_mode
 
int maxBufferSize
 
bool pin_is_setup = false
 
uint8_t read_address
 
uint8_t * read_buffer
 
size_t read_len
 
size_t read_pos
 
bool read_stop_bit
 
void(* recieveHandler )(int)
 
void(* requestHandler )(void)
 
int scl_pin
 
int sda_pin
 
uint8_t transmission_address
 
uint8_t * write_buffer
 
int write_pos
 
- Protected Attributes inherited from arduino::Stream
unsigned long _startMillis
 
unsigned long _timeout
 

Detailed Description

Arduino I2C implementation using the Pico functionality. In Arduino we can read and write individal characters wheresease in Pico the operations have to be done with arrays. We therefore create a read and write buffer to cache the operations.

Author
Phil Schatzmann

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