Prevent WaitForEdge() returning early after first call to selectCard() (#7)

Calling LowLevel.Init() in selectCard() clears the device interrupt
as a side effect, but another interrupt will occur due to the
subsquent operations. This additional host interrupt must be cleared
before the next call to selectCard.

Fixes https://github.com/google/periph/issues/425
pull/8/head v3.6.8
Bracken 5 years ago committed by GitHub
parent ff2252c545
commit 7cccb95509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -226,6 +226,11 @@ func (r *LowLevel) WaitForEdge(timeout time.Duration) error {
} }
} }
// ClearInterrupt removes any pending host interrupts
func (r *LowLevel) ClearInterrupt() {
r.irqPin.WaitForEdge(0)
}
// Auth authenticate the card fof the sector/block using the provided data. // Auth authenticate the card fof the sector/block using the provided data.
// //
// mode - the authentication mode. // mode - the authentication mode.

@ -388,6 +388,8 @@ func (r *Dev) selectCard(timeout time.Duration) ([]byte, error) {
if err := r.LowLevel.Init(); err != nil { if err := r.LowLevel.Init(); err != nil {
return nil, err return nil, err
} }
defer r.LowLevel.ClearInterrupt()
if _, err := r.request(); err != nil { if _, err := r.request(); err != nil {
return nil, err return nil, err
} }

Loading…
Cancel
Save