mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
gpio: adding interrupt
this is inspired by Dave Cheney's gpio library and his work on EPOLL
This commit is contained in:
parent
6ad940090c
commit
0fa1d1b61c
4 changed files with 216 additions and 0 deletions
22
gpio.go
22
gpio.go
|
@ -7,6 +7,9 @@ import "time"
|
|||
// The Direction type indicates the direction of a GPIO pin.
|
||||
type Direction int
|
||||
|
||||
// The Edge trigger for the GPIO Interrupt
|
||||
type Edge string
|
||||
|
||||
const (
|
||||
// In represents read mode.
|
||||
In Direction = iota
|
||||
|
@ -23,8 +26,27 @@ const (
|
|||
High
|
||||
)
|
||||
|
||||
const (
|
||||
EdgeNone Edge = "none"
|
||||
EdgeRising Edge = "rising"
|
||||
EdgeFalling Edge = "falling"
|
||||
EdgeBoth Edge = "both"
|
||||
)
|
||||
|
||||
// InterruptPin implements access to a Interruptable capable GPIO pin.
|
||||
type InterruptPin interface {
|
||||
|
||||
// Start watching this pin for interrupt
|
||||
Watch(edge Edge, handler func(DigitalPin)) error
|
||||
|
||||
// Stop watching this pin for interrupt
|
||||
StopWatching() error
|
||||
}
|
||||
|
||||
// DigitalPin implements access to a digital IO capable GPIO pin.
|
||||
type DigitalPin interface {
|
||||
InterruptPin
|
||||
|
||||
// N returns the logical GPIO number.
|
||||
N() int
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue