Pico-Arduino
All Classes Namespaces Functions Variables Enumerations Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 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 void begin ()
 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 (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, 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 end ()
 Closes the Wire Library.
 
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.
 
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 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 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()).
 
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 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 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 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 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 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 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.
 
- Public Member Functions inherited from arduino::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)
 
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)
 
- Public Member Functions inherited from arduino::Print
int getWriteError ()
 
void clearWriteError ()
 
size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
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 (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 (double, int=2)
 
size_t println (const Printable &)
 
size_t println (void)
 
virtual void flush ()
 

Protected Member Functions

void setupPins (int sda, int scl)
 
int flush (bool stop=false)
 
void setupWriteBuffer ()
 
void setupReadBuffer (int len)
 
- Protected Member Functions inherited from arduino::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 arduino::Print
void setWriteError (int err=1)
 

Protected Attributes

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

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: