Skip to content
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

Fix GPIOTE crashes by checking everything is ok #5253

Merged
merged 2 commits into from
Aug 31, 2021

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Aug 27, 2021

Fixes #5240 and fixes #5211

dhalbert
dhalbert previously approved these changes Aug 28, 2021
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.

LGTM; I fast-forwarded through your stream and followed the thinking. It would be great if others could test this on hardware.

@jpconstantineau
Copy link

I'll be able to check the encoders on my hardware once it lands on S3.

@microdev1
Copy link
Collaborator

@jpconstantineau You can test the build artifacts from this PR. They are here.

@jpconstantineau
Copy link

The BlueMicro840 built fine. Tested it with 5 and 4 encoders.
5th initialization fails and RuntimeError: All channels in use exception comes out as expected.

With 4 encoders only, all 4 work as expected.

Haven't tested with using other GPIOTE consumers but I expect rotaryio will be fine if the above test is good.

@mrdalgaard
Copy link

Tested that countio.deinit() works (does not crash), and alarm + countio can run concurrently

@mrdalgaard
Copy link

It is however possible to initialize both pin_alarm and countio on the same pin if done in specific order

alarm_pin = alarm.pin.PinAlarm(pin=board.A2, value=False)
counter = countio.Counter(board.A2)

Will run, but alarm will not trigger on light sleep (it will on deep sleep)

counter = countio.Counter(board.A2)
alarm_pin = alarm.pin.PinAlarm(pin=board.A2, value=False)

Will error with:


Traceback (most recent call last):
  File "code.py", line 7, in <module>
ValueError: A2 in use

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.

👍

@microdev1 microdev1 merged commit 1dbeed8 into adafruit:main Aug 31, 2021
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.

nRF52840 hardfaults on countio.deinit() nRF52 RotaryIO: raise error when more than 4 encoders are used
5 participants