beaglebone: use universal io cape manager to initialize board setup
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
9323b6e369
commit
165a6f8798
|
@ -36,7 +36,7 @@ type Adaptor struct {
|
|||
pwmPinMap map[string]pwmPinData
|
||||
analogPinMap map[string]string
|
||||
mutex *sync.Mutex
|
||||
findPin func(pinPath string) string
|
||||
findPin func(pinPath string) (string, error)
|
||||
}
|
||||
|
||||
// NewAdaptor returns a new Beaglebone Adaptor
|
||||
|
@ -50,9 +50,9 @@ func NewAdaptor() *Adaptor {
|
|||
pinMap: bbbPinMap,
|
||||
pwmPinMap: bbbPwmPinMap,
|
||||
analogPinMap: bbbAnalogPinMap,
|
||||
findPin: func(pinPath string) string {
|
||||
files, _ := filepath.Glob(pinPath)
|
||||
return files[0]
|
||||
findPin: func(pinPath string) (string, error) {
|
||||
files, err := filepath.Glob(pinPath)
|
||||
return files[0], err
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -77,11 +77,15 @@ func (b *Adaptor) Connect() error {
|
|||
b.mutex.Lock()
|
||||
defer b.mutex.Unlock()
|
||||
|
||||
if err := ensureSlot(b.slots, "BB-ADC"); err != nil {
|
||||
// loads U-Boot Cape Universal
|
||||
// https://github.com/cdsteinkuehler/beaglebone-universal-io
|
||||
if err := ensureSlot(b.slots, "cape-universaln"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
// loads U-Boot ADC
|
||||
err := ensureSlot(b.slots, "BB-ADC")
|
||||
return err
|
||||
}
|
||||
|
||||
// Finalize releases all i2c devices and exported analog, digital, pwm pins.
|
||||
|
@ -207,11 +211,13 @@ func (b *Adaptor) PWMPin(pin string) (sysfsPin sysfs.PWMPinner, err error) {
|
|||
|
||||
if b.pwmPins[pin] == nil {
|
||||
newPin := sysfs.NewPWMPin(pinInfo.channel)
|
||||
newPin.Path = b.findPin(pinInfo.path)
|
||||
|
||||
if err = muxPin(pin, "pwm"); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if newPin.Path, err = b.findPin(pinInfo.path); err != nil {
|
||||
return
|
||||
}
|
||||
if err = newPin.Export(); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -26,18 +26,18 @@ var _ i2c.Connector = (*Adaptor)(nil)
|
|||
|
||||
func initBBBTestAdaptor() (*Adaptor, error) {
|
||||
a := NewAdaptor()
|
||||
a.findPin = func(pinPath string) string {
|
||||
a.findPin = func(pinPath string) (string, error) {
|
||||
switch pinPath {
|
||||
case "/sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip*":
|
||||
return "/sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip4"
|
||||
return "/sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip4", nil
|
||||
case "/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip*":
|
||||
return "/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip2"
|
||||
return "/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip2", nil
|
||||
case "/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip*":
|
||||
return "/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip0"
|
||||
return "/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip0", nil
|
||||
case "/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip*":
|
||||
return "/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0"
|
||||
return "/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0", nil
|
||||
default:
|
||||
return pinPath
|
||||
return pinPath, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue