Skip to content

Commit e3d1302

Browse files
authored
Merge pull request #9075 from kbsriram/spi-polarity-1
Set SPI clock line idle polarity for CPOL=1
2 parents 50c504d + bed6483 commit e3d1302

File tree

1 file changed

+6
-1
lines changed
  • shared-module/bitbangio

1 file changed

+6
-1
lines changed

shared-module/bitbangio/SPI.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ void shared_module_bitbangio_spi_configure(bitbangio_spi_obj_t *self,
9696
self->delay_half += 1;
9797
}
9898

99-
self->polarity = polarity;
99+
if (polarity != self->polarity) {
100+
// If the polarity has changed, make sure we re-initialize the idle state
101+
// of the clock as well.
102+
self->polarity = polarity;
103+
common_hal_digitalio_digitalinout_switch_to_output(&self->clock, polarity == 1, DRIVE_MODE_PUSH_PULL);
104+
}
100105
self->phase = phase;
101106
}
102107

0 commit comments

Comments
 (0)