mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
runtime: Implement GPIO output
Now we can actually blink a LED!
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
|
||||
package machine
|
||||
|
||||
// #include "../runtime/runtime_nrf.h"
|
||||
import "C"
|
||||
|
||||
type GPIO struct {
|
||||
Pin uint32
|
||||
}
|
||||
|
||||
type GPIOConfig struct {
|
||||
Mode uint8
|
||||
}
|
||||
|
||||
const (
|
||||
GPIO_INPUT = iota
|
||||
GPIO_OUTPUT
|
||||
)
|
||||
|
||||
func (p GPIO) Configure(config GPIOConfig) {
|
||||
C.gpio_cfg(C.uint(p.Pin), C.gpio_mode_t(config.Mode))
|
||||
}
|
||||
|
||||
func (p GPIO) Set(value bool) {
|
||||
C.gpio_set(C.uint(p.Pin), C.bool(value))
|
||||
}
|
||||
Reference in New Issue
Block a user