Skip to content

Commit 8b448eb

Browse files
committed
Merge remote-tracking branch 'origin/main' into main
2 parents abdc6d5 + 155b61f commit 8b448eb

File tree

1 file changed

+9
-4
lines changed
  • ports/raspberrypi/common-hal/busio

1 file changed

+9
-4
lines changed

ports/raspberrypi/common-hal/busio/I2C.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
9898
}
9999
#endif
100100

101-
// Create a bitbangio.I2C object to do short writes.
101+
// Create a bitbangio.I2C object to do 0 byte writes.
102+
//
103+
// These are used to non-invasively detect I2C devices by sending
104+
// the address and confirming an ACK.
105+
// They are not supported by the RP2040 hardware.
106+
//
102107
// Must be done before setting up the I2C pins, since they will be
103108
// set up as GPIO by the bitbangio.I2C object.
104109
//
@@ -157,9 +162,9 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
157162
}
158163

159164
uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr,
160-
const uint8_t *data, size_t len, bool transmit_stop_bit) {
161-
if (len <= 2) {
162-
// The RP2040 I2C peripheral will not do writes 2 bytes or less long.
165+
const uint8_t *data, size_t len, bool transmit_stop_bit) {
166+
if (len == 0) {
167+
// The RP2040 I2C peripheral will not perform 0 byte writes.
163168
// So use bitbangio.I2C to do the write.
164169

165170
gpio_set_function(self->scl_pin, GPIO_FUNC_SIO);

0 commit comments

Comments
 (0)