Skip to content

Commit d0044c7

Browse files
committed
bitbangio.SPI was not setting direction of output pins
1 parent ab6fd34 commit d0044c7

File tree

1 file changed

+5
-0
lines changed
  • shared-module/bitbangio

1 file changed

+5
-0
lines changed

shared-module/bitbangio/SPI.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,20 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self,
4343
if (result != DIGITALINOUT_OK) {
4444
mp_raise_ValueError(translate("Clock pin init failed."));
4545
}
46+
common_hal_digitalio_digitalinout_switch_to_output(&self->clock, self->polarity == 1, DRIVE_MODE_PUSH_PULL);
47+
4648
if (mosi != mp_const_none) {
4749
result = common_hal_digitalio_digitalinout_construct(&self->mosi, mosi);
4850
if (result != DIGITALINOUT_OK) {
4951
common_hal_digitalio_digitalinout_deinit(&self->clock);
5052
mp_raise_ValueError(translate("MOSI pin init failed."));
5153
}
5254
self->has_mosi = true;
55+
common_hal_digitalio_digitalinout_switch_to_output(&self->mosi, false, DRIVE_MODE_PUSH_PULL);
5356
}
57+
5458
if (miso != mp_const_none) {
59+
// Starts out as input by default, no need to change.
5560
result = common_hal_digitalio_digitalinout_construct(&self->miso, miso);
5661
if (result != DIGITALINOUT_OK) {
5762
common_hal_digitalio_digitalinout_deinit(&self->clock);

0 commit comments

Comments
 (0)