Skip to content

Commit 155b61f

Browse files
authored
Merge pull request #4378 from Gadgetoid/patch-remove-rp2040-i2c-bitbang
RP2040: Remove short-write bitbang from I2C
2 parents 5810461 + b8d4f96 commit 155b61f

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

+9-4
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)