Skip to content

Fix nRF UART reset #2432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 4, 2020
Merged

Fix nRF UART reset #2432

merged 3 commits into from
Jan 4, 2020

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Dec 28, 2019

disable only turns off ENABLE but doesn't set the init tracking that
nrfx uses. uninit hangs if ENABLE is off and is called because it
waits forever for TX to stop.

disable only turns off ENABLE but doesn't set the init tracking that
nrfx uses. uninit hangs if ENABLE is off and is called because it
waits forever for TX to stop.
@tannewt tannewt added this to the 5.x.x - Bug Fixes milestone Dec 28, 2019
@tannewt tannewt requested a review from dhalbert December 28, 2019 04:21
@dhalbert
Copy link
Collaborator

dhalbert commented Dec 28, 2019

SPI and I2C do it a different way, like this, in the constructor. They do disable in deinit(), and in the constructor, they try to do do an nrfx init(), and only if that fails do they do the uninit(). I can't remember exactly why, but this was a better choice at the time. Is UARTE different for some reason? Maybe it should follow the pattern in SPI and I2C.

    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);
    }

@tannewt
Copy link
Member Author

tannewt commented Jan 2, 2020

I think the I2C and SPI pattern is an artifact of the early code that didn't correctly reset the peripherals on soft reset. Want me to update the other two as well?

It looks like the I2C disable was added here: https://github.com/adafruit/circuitpython/pull/1277/files#diff-0fadf6b9ea8a38a03206d10c865959c3R59

@dhalbert
Copy link
Collaborator

dhalbert commented Jan 2, 2020

OK, that makes sense to me. The point is that nrfx_..._uninit() is now idempotent in our fork of nrfx. I guess I changed that but didn't go back and utilize the new capability. So yes, please fix the other busio impls. Thank you.

@tannewt
Copy link
Member Author

tannewt commented Jan 3, 2020

@dhalbert Done!

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thank you for clear thinking on all of this, and debugging the neopixel PWM issue.

@tannewt tannewt merged commit 776c9b0 into adafruit:master Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants