forked from google/periph
/
driver.go
45 lines (34 loc) · 960 Bytes
/
driver.go
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
36
37
38
39
40
41
42
43
44
45
// Copyright 2018 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
// Package mt7688 interfaces with the MediaTek MT7688 MIPS CPU used on low cost board.
package mt7688
import (
"errors"
"periph.io/x/periph/host/sysfs"
)
// driverGPIO implements periph.Driver.
type driverGPIO struct {
// gpioMemory is the memory map of the CPU GPIO registers.
gpioMemory *gpioMap
}
func (d driverGPIO) String() string {
return "mt7688-gpio"
}
func (d driverGPIO) Prerequisites() []string {
return nil
}
func (d driverGPIO) After() []string {
return []string{"sysfs-gpio"}
}
func (d *driverGPIO) Init() (bool, error) {
if !Present() {
return false, errors.New("mt7688 board not detected")
}
for _, p := range cpuPins {
// Initialize sysfs access right away.
p.sysfsPin = sysfs.Pins[p.number]
}
return true, nil
}
var drvGPIO driverGPIO