Skip to content

Commit d07abf3

Browse files
Setup clock pin when starting SPI comms. (#1236)
Because the clock pin (29) also has to be used to read vsys, its properties might be changed. So reset when starting a spi transaction. Fixes #1141
1 parent 756c4f2 commit d07abf3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ int cyw43_spi_init(cyw43_int_t *self) {
140140
pio_sm_set_config(bus_data->pio, bus_data->pio_sm, &config);
141141
pio_sm_set_consecutive_pindirs(bus_data->pio, bus_data->pio_sm, CLOCK_PIN, 1, true);
142142
gpio_set_function(DATA_OUT_PIN, bus_data->pio_func_sel);
143-
gpio_set_function(CLOCK_PIN, bus_data->pio_func_sel);
144143

145144
// Set data pin to pull down and schmitt
146145
gpio_set_pulls(DATA_IN_PIN, false, true);
@@ -189,9 +188,11 @@ static __noinline void ns_delay(uint32_t ns) {
189188

190189
static void start_spi_comms(cyw43_int_t *self) {
191190
bus_data_t *bus_data = (bus_data_t *)self->bus_data;
191+
gpio_set_function(DATA_OUT_PIN, bus_data->pio_func_sel);
192+
gpio_set_function(CLOCK_PIN, bus_data->pio_func_sel);
193+
gpio_pull_down(CLOCK_PIN);
192194
// Pull CS low
193195
cs_set(false);
194-
gpio_set_function(DATA_OUT_PIN, bus_data->pio_func_sel);
195196
}
196197

197198
// we need to atomically de-assert CS and enable IRQ

0 commit comments

Comments
 (0)