1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-03 03:47:33 +02:00

gpio: simplify and test the logic

This commit is contained in:
Karan Misra 2014-03-23 02:32:26 +05:30
parent dfb7e63768
commit f667c93b7a
2 changed files with 27 additions and 12 deletions

View file

@ -32,23 +32,12 @@ func (io *gpioDriver) digitalPin(key interface{}) (*digitalPin, error) {
return nil, fmt.Errorf("gpio: could not find pin matching %q", key)
}
id := pd.ID
p, ok := io.initializedPins[id]
if ok {
dp, ok := p.(*digitalPin)
if !ok {
return nil, fmt.Errorf("gpio: sorry, pin %q is already initialized for a different mode", key)
}
return dp, nil
}
if pd.Caps != CapNormal {
glog.Infof("gpio: pin %q is not a dedicated digital io pin. please refer to the system reference manual for more details", key)
}
dp := newDigitalPin(pd.DigitalLogical)
io.initializedPins[id] = dp
io.initializedPins[pd.ID] = dp
return dp, nil
}