Skip to content

Commit 6afb8da

Browse files
committed
Change SPI and I2C in the same way.
1 parent cfd71d9 commit 6afb8da

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void i2c_reset(void) {
6363
if (never_reset[i]) {
6464
continue;
6565
}
66-
nrf_twim_disable(twim_peripherals[i].twim.p_twim);
66+
nrfx_twim_uninit(&twim_peripherals[i].twim);
6767
twim_peripherals[i].in_use = false;
6868
}
6969
}
@@ -150,13 +150,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *
150150
// About to init. If we fail after this point, common_hal_busio_i2c_deinit() will set in_use to false.
151151
self->twim_peripheral->in_use = true;
152152
nrfx_err_t err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL);
153-
154-
// A soft reset doesn't uninit the driver so we might end up with a invalid state
155-
if (err == NRFX_ERROR_INVALID_STATE) {
156-
nrfx_twim_uninit(&self->twim_peripheral->twim);
157-
err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL);
158-
}
159-
160153
if (err != NRFX_SUCCESS) {
161154
common_hal_busio_i2c_deinit(self);
162155
mp_raise_OSError(MP_EIO);

ports/nrf/common-hal/busio/SPI.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void spi_reset(void) {
6868
if (never_reset[i]) {
6969
continue;
7070
}
71-
nrf_spim_disable(spim_peripherals[i].spim.p_reg);
71+
nrfx_spim_uninit(&spim_peripherals[i].spim);
7272
}
7373
}
7474

@@ -160,13 +160,6 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
160160
}
161161

162162
nrfx_err_t err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL);
163-
164-
// A soft reset doesn't uninit the driver so we might end up with a invalid state
165-
if (err == NRFX_ERROR_INVALID_STATE) {
166-
nrfx_spim_uninit(&self->spim_peripheral->spim);
167-
err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL);
168-
}
169-
170163
if (err != NRFX_SUCCESS) {
171164
common_hal_busio_spi_deinit(self);
172165
mp_raise_OSError(MP_EIO);

0 commit comments

Comments
 (0)