runtime: Implement GPIO output

Now we can actually blink a LED!
This commit is contained in:
Ayke van Laethem
2018-04-27 01:29:13 +02:00
parent 5bbd41e9fb
commit 3a4663150e
5 changed files with 66 additions and 4 deletions
+26
View File
@@ -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))
}