-
Notifications
You must be signed in to change notification settings - Fork 134
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
[test] Better hardware unit tests using simple on-device logic analyzer #96
Conversation
f4178f6
to
8ca3283
Compare
3da698d
to
01092cf
Compare
45a9d6d
to
a7d096e
Compare
a7d096e
to
6e78c9f
Compare
6e78c9f
to
9ab15d2
Compare
I'm merging this as is, since the GpioSampler won't get any better than this performance and API wise, and while the LogicAnalyzer isn't super useful, it is functional and can already be used to write tests. |
cc @henrikssn this is somewhat related to your SAMD EXTI work, but with a focus on on-device unit testing, ie. having the logic analyzer on the same device as the test. |
I should've probably used the lowest bit for encoding the edge event, since the interrupt latency already masks the lowest 5-7 bits or anyways. A well… |
Very cool! The only suggestion I have here for API is to support tuple-style getters in the
|
This adds the generic
modm::GpioSampler
driver which uses the hardware edge detection features of the Input to generate a EXTI interrupt, which writes theDWT->CYCCNT
value into the sample array. The CYCCNT value is truncated to 31-bits and cast into a signed integer, with the sign bit encoding theGpio::read()
value of the edge event (ie. positive ismodm::Gpio::High
, negative isLow
).This should make it easier to write hwut style tests with the current unittest framework, and most importantly without any external instrumentation.
Note, this approach will not work well on AVRs, since the exti interrupts need to be nested and high-priority to be able to interrupt the HAL interrupt handlers.
This may also not work if the input buffer is disconnected by the Alternate Function (only for Analog mode I believe).
cc @strongly-typed @rleh @chris-durand