Change SPI and I2C in the same way.

This commit is contained in:
Scott Shawcroft 2020-01-03 15:14:37 -08:00
parent cfd71d9023
commit 6afb8dadbc
No known key found for this signature in database
GPG Key ID: 9349BC7E64B1921E
2 changed files with 2 additions and 16 deletions

View File

@ -63,7 +63,7 @@ void i2c_reset(void) {
if (never_reset[i]) { if (never_reset[i]) {
continue; continue;
} }
nrf_twim_disable(twim_peripherals[i].twim.p_twim); nrfx_twim_uninit(&twim_peripherals[i].twim);
twim_peripherals[i].in_use = false; twim_peripherals[i].in_use = false;
} }
} }
@ -150,13 +150,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *
// About to init. If we fail after this point, common_hal_busio_i2c_deinit() will set in_use to false. // About to init. If we fail after this point, common_hal_busio_i2c_deinit() will set in_use to false.
self->twim_peripheral->in_use = true; self->twim_peripheral->in_use = true;
nrfx_err_t err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL); nrfx_err_t err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL);
// A soft reset doesn't uninit the driver so we might end up with a invalid state
if (err == NRFX_ERROR_INVALID_STATE) {
nrfx_twim_uninit(&self->twim_peripheral->twim);
err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL);
}
if (err != NRFX_SUCCESS) { if (err != NRFX_SUCCESS) {
common_hal_busio_i2c_deinit(self); common_hal_busio_i2c_deinit(self);
mp_raise_OSError(MP_EIO); mp_raise_OSError(MP_EIO);

View File

@ -68,7 +68,7 @@ void spi_reset(void) {
if (never_reset[i]) { if (never_reset[i]) {
continue; continue;
} }
nrf_spim_disable(spim_peripherals[i].spim.p_reg); nrfx_spim_uninit(&spim_peripherals[i].spim);
} }
} }
@ -160,13 +160,6 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
} }
nrfx_err_t err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL); nrfx_err_t err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL);
// A soft reset doesn't uninit the driver so we might end up with a invalid state
if (err == NRFX_ERROR_INVALID_STATE) {
nrfx_spim_uninit(&self->spim_peripheral->spim);
err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL);
}
if (err != NRFX_SUCCESS) { if (err != NRFX_SUCCESS) {
common_hal_busio_spi_deinit(self); common_hal_busio_spi_deinit(self);
mp_raise_OSError(MP_EIO); mp_raise_OSError(MP_EIO);