forked from jancona/m17
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodem_gpio_linux.go
More file actions
35 lines (31 loc) · 799 Bytes
/
Copy pathmodem_gpio_linux.go
File metadata and controls
35 lines (31 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//go:build linux
package m17
import (
"fmt"
"log"
"time"
"github.com/warthog618/go-gpiocdev"
)
func (m *CC1200Modem) gpioSetup(nRSTPin, boot0Pin int) error {
var err error
log.Print("[DEBUG] Setting up GPIO")
m.nRST, err = gpiocdev.RequestLine("gpiochip0", nRSTPin, gpiocdev.AsOutput(1))
if err != nil {
return fmt.Errorf("request nRST line: %w", err)
}
m.boot0, err = gpiocdev.RequestLine("gpiochip0", boot0Pin, gpiocdev.AsOutput(0))
if err != nil {
return fmt.Errorf("request boot0 line: %w", err)
}
err = m.setNRSTGPIO(false)
if err != nil {
return fmt.Errorf("unset NRST: %w", err)
}
time.Sleep(50 * time.Millisecond)
err = m.setNRSTGPIO(true)
if err != nil {
return fmt.Errorf("set NRST: %w", err)
}
time.Sleep(time.Second) // wait for hat to boot
return nil
}