Skip to content

Prevent freezing USB during high frequency PulseIn. #901

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 7 commits into from
Jun 8, 2018

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Jun 5, 2018

We now track the last time the background task ran and bail on the
PulseIn if it starves the background work. In practice, this
happens after the numbers from pulsein are no longer accurate.

This also adjusts interrupt priorities so most are the lowest level
except for the tick and USB interrupts.

Fixes #516 and #876

@tannewt tannewt added this to the 3.0 milestone Jun 5, 2018
@tannewt tannewt requested a review from dhalbert June 5, 2018 21:42
tannewt added 5 commits June 8, 2018 12:56
We now track the last time the background task ran and bail on the
PulseIn if it starves the background work. In practice, this
happens after the numbers from pulsein are no longer accurate.

This also adjusts interrupt priorities so most are the lowest level
except for the tick and USB interrupts.

Fixes micropython#516 and micropython#876
@tannewt tannewt force-pushed the pulseio_too_fast branch from 8505cb0 to 66b7972 Compare June 8, 2018 20:02
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.

Looks good! One minor change.

@@ -118,6 +125,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
self->first_edge = true;
self->last_us = 0;
self->last_ms = 0;
self->errored_too_fast = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

= false

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.

OK, great! I will not wait for travis this time.

@dhalbert dhalbert merged commit b2d98ed into adafruit:master Jun 8, 2018
jerryneedell added a commit that referenced this pull request Jun 10, 2018
Add stub for common_hal_pulseio_pulsein_get_paused  to make ESP8266 build compatible with PR #901
@jerryneedell jerryneedell mentioned this pull request Jun 10, 2018
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