puzzlebox
Loading...
Searching...
No Matches

I²C send/receive handlers. More...

Detailed Description

Functions

void pb_i2c_recv (const uint8_t *buf, size_t sz)
 Handle a received message from the I²C bus (puzzle bus)
 
void pb_i2c_send (i2c_addr_t i2c_addr, const uint8_t *buf, size_t sz)
 Send a message in master-mode on the I²C bus (puzzle bus)
 

Function Documentation

◆ pb_i2c_recv()

void pb_i2c_recv ( const uint8_t * buf,
size_t sz )

This function attempts to parse an I²C message as a puzzle bus message, and calls the appropriate handler for the message if it is considered valid. Invalid messages are silently ignored.

Parameters
bufpointer to message content
szsize of buf
See also
pb_hook_i2c_recv()
Warning
Some platforms produce weird behavior when replying directly from the I²C ISR. Please verify if this function can be called directly on your target platform when writing a new driver. If it does not work as expected, FreeRTOS's xTimerPendFunctionCallFromISR() or a similar scheduler-based deferred function call mechanism may be used as a workaround.

◆ pb_i2c_send()

void pb_i2c_send ( i2c_addr_t i2c_addr,
const uint8_t * buf,
size_t sz )

This function sends an I²C message to the address specified by i2c_addr.

Parameters
i2c_addraddress of slave controller
bufpointer to message content
szsize of buf
See also
pb_hook_i2c_send()
Warning
In the Arduino driver, this function includes a hard-coded 10ms delay before sending. This is to work around a weird issue where the Arduino pulls both SDA and SCL low while attempting to initiate an I²C transmission. We were able to verify that the Arduino correctly handles bus arbitration under a test scenario with 2 Uno's, but ran into issues while integrating the Arduino's with the RP2040.