mirror of
https://github.com/stianeikeland/go-rpio.git
synced 2025-01-23 10:41:03 +01:00
Improve doc of edge detection
This commit is contained in:
parent
250b0836f8
commit
3084a4df91
16
rpio.go
16
rpio.go
|
@ -6,6 +6,7 @@ Supports simple operations such as:
|
||||||
- Pin mode/direction (input/output/clock/pwm)
|
- Pin mode/direction (input/output/clock/pwm)
|
||||||
- Pin write (high/low)
|
- Pin write (high/low)
|
||||||
- Pin read (high/low)
|
- Pin read (high/low)
|
||||||
|
- Pin edge detection (no/rise/fall/any)
|
||||||
- Pull up/down/off
|
- Pull up/down/off
|
||||||
And clock/pwm related oparations:
|
And clock/pwm related oparations:
|
||||||
- Set Clock frequency
|
- Set Clock frequency
|
||||||
|
@ -321,15 +322,17 @@ func TogglePin(pin Pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable edge event detection on pin
|
// Enable edge event detection on pin.
|
||||||
//
|
//
|
||||||
// Combine with pin.EdgeDetected() to check whether event occured.
|
// Combine with pin.EdgeDetected() to check whether event occured.
|
||||||
//
|
//
|
||||||
|
// Note that using this function might conflict with the same functionality of other gpio library.
|
||||||
|
//
|
||||||
// It also clears previously detected event of this pin if any.
|
// It also clears previously detected event of this pin if any.
|
||||||
//
|
//
|
||||||
// Note that call with RiseEdge will disable previously set FallEdge detection and vice versa
|
// Note that call with RiseEdge will disable previously set FallEdge detection and vice versa.
|
||||||
// You have to call with AnyEdge, to enable detection for both edges
|
// You have to call with AnyEdge, to enable detection for both edges.
|
||||||
// To disable previously enabled detection call it with NoEdge
|
// To disable previously enabled detection call it with NoEdge.
|
||||||
func DetectEdge(pin Pin, edge Edge) {
|
func DetectEdge(pin Pin, edge Edge) {
|
||||||
p := uint8(pin)
|
p := uint8(pin)
|
||||||
|
|
||||||
|
@ -356,7 +359,10 @@ func DetectEdge(pin Pin, edge Edge) {
|
||||||
gpioMem[edsReg] = bit // to clear outdated detection
|
gpioMem[edsReg] = bit // to clear outdated detection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether edge event occured
|
// Check whether edge event occured since last call
|
||||||
|
// or since detection was enabled
|
||||||
|
//
|
||||||
|
// There is no way (yet) to handle interruption caused by edge event, you have to use polling.
|
||||||
//
|
//
|
||||||
// Event detection has to be enabled first, by pin.Detect(edge)
|
// Event detection has to be enabled first, by pin.Detect(edge)
|
||||||
func EdgeDetected(pin Pin) bool {
|
func EdgeDetected(pin Pin) bool {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user