mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
i2c: added debug logs
This commit is contained in:
parent
2ee0cbc899
commit
68ba342e1b
@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/kidoman/embd"
|
"github.com/kidoman/embd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ func (b *i2cBus) init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glog.V(2).Infof("i2c: bus %v initialized", b.l)
|
||||||
|
|
||||||
b.initialized = true
|
b.initialized = true
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -65,6 +68,7 @@ func (b *i2cBus) init() error {
|
|||||||
|
|
||||||
func (b *i2cBus) setAddress(addr byte) error {
|
func (b *i2cBus) setAddress(addr byte) error {
|
||||||
if addr != b.addr {
|
if addr != b.addr {
|
||||||
|
glog.V(2).Infof("i2c: setting bus %v address to %#02x", b.l, addr)
|
||||||
if _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, b.file.Fd(), slaveCmd, uintptr(addr)); errno != 0 {
|
if _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, b.file.Fd(), slaveCmd, uintptr(addr)); errno != 0 {
|
||||||
return syscall.Errno(errno)
|
return syscall.Errno(errno)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user