mirror of
https://github.com/kidoman/embd
synced 2024-12-22 04:40:04 +01:00
Support SPI minor devices >255 (PR #33)
This commit is contained in:
parent
56cb934dbf
commit
6cfa481f30
@ -95,7 +95,7 @@ var ledMap = embd.LEDMap{
|
|||||||
"beaglebone:green:usr3": []string{"3", "USR3", "usr3"},
|
"beaglebone:green:usr3": []string{"3", "USR3", "usr3"},
|
||||||
}
|
}
|
||||||
|
|
||||||
var spiDeviceMinor byte = 1
|
var spiDeviceMinor int = 1
|
||||||
|
|
||||||
func ensureFeatureEnabled(id string) error {
|
func ensureFeatureEnabled(id string) error {
|
||||||
glog.V(3).Infof("bbb: enabling feature %v", id)
|
glog.V(3).Infof("bbb: enabling feature %v", id)
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/kidoman/embd/host/generic"
|
"github.com/kidoman/embd/host/generic"
|
||||||
)
|
)
|
||||||
|
|
||||||
var spiDeviceMinor = byte(0)
|
var spiDeviceMinor = 32766
|
||||||
|
|
||||||
var chipPins = embd.PinMap{
|
var chipPins = embd.PinMap{
|
||||||
// official GPIO pins (U14 connector) using the pcf8574a
|
// official GPIO pins (U14 connector) using the pcf8574a
|
||||||
|
@ -245,7 +245,7 @@ func (b *i2cBus) WriteToReg(addr, reg byte, value []byte) error {
|
|||||||
message.addr = uint16(addr)
|
message.addr = uint16(addr)
|
||||||
message.flags = 0
|
message.flags = 0
|
||||||
message.len = uint16(len(outbuf))
|
message.len = uint16(len(outbuf))
|
||||||
message.buf = uintptr(unsafe.Pointer(&hdrp.Data))
|
message.buf = uintptr(unsafe.Pointer(hdrp.Data))
|
||||||
|
|
||||||
var packets i2c_rdwr_ioctl_data
|
var packets i2c_rdwr_ioctl_data
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ type spiIOCTransfer struct {
|
|||||||
type spiBus struct {
|
type spiBus struct {
|
||||||
file *os.File
|
file *os.File
|
||||||
|
|
||||||
spiDevMinor byte
|
spiDevMinor int
|
||||||
|
|
||||||
channel byte
|
channel byte
|
||||||
mode byte
|
mode byte
|
||||||
@ -63,7 +63,7 @@ func spiIOCMessageN(n uint32) uint32 {
|
|||||||
return (spiIOCMessage0 + (n * spiIOCIncrementor))
|
return (spiIOCMessage0 + (n * spiIOCIncrementor))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSPIBus(spiDevMinor, mode, channel byte, speed, bpw, delay int, i func() error) embd.SPIBus {
|
func NewSPIBus(spiDevMinor int, mode, channel byte, speed, bpw, delay int, i func() error) embd.SPIBus {
|
||||||
return &spiBus{
|
return &spiBus{
|
||||||
spiDevMinor: spiDevMinor,
|
spiDevMinor: spiDevMinor,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/kidoman/embd/host/generic"
|
"github.com/kidoman/embd/host/generic"
|
||||||
)
|
)
|
||||||
|
|
||||||
var spiDeviceMinor = byte(0)
|
var spiDeviceMinor = 0
|
||||||
|
|
||||||
var rev1Pins = embd.PinMap{
|
var rev1Pins = embd.PinMap{
|
||||||
&embd.PinDesc{ID: "P1_3", Aliases: []string{"0", "GPIO_0", "SDA", "I2C0_SDA"}, Caps: embd.CapDigital | embd.CapI2C, DigitalLogical: 0},
|
&embd.PinDesc{ID: "P1_3", Aliases: []string{"0", "GPIO_0", "SDA", "I2C0_SDA"}, Caps: embd.CapDigital | embd.CapI2C, DigitalLogical: 0},
|
||||||
|
@ -2,10 +2,10 @@ package embd
|
|||||||
|
|
||||||
import "sync"
|
import "sync"
|
||||||
|
|
||||||
type spiBusFactory func(byte, byte, byte, int, int, int, func() error) SPIBus
|
type spiBusFactory func(int, byte, byte, int, int, int, func() error) SPIBus
|
||||||
|
|
||||||
type spiDriver struct {
|
type spiDriver struct {
|
||||||
spiDevMinor byte
|
spiDevMinor int
|
||||||
initializer func() error
|
initializer func() error
|
||||||
|
|
||||||
busMap map[byte]SPIBus
|
busMap map[byte]SPIBus
|
||||||
@ -16,7 +16,7 @@ type spiDriver struct {
|
|||||||
|
|
||||||
// NewSPIDriver returns a SPIDriver interface which allows control
|
// NewSPIDriver returns a SPIDriver interface which allows control
|
||||||
// over the SPI bus.
|
// over the SPI bus.
|
||||||
func NewSPIDriver(spiDevMinor byte, sbf spiBusFactory, i func() error) SPIDriver {
|
func NewSPIDriver(spiDevMinor int, sbf spiBusFactory, i func() error) SPIDriver {
|
||||||
return &spiDriver{
|
return &spiDriver{
|
||||||
spiDevMinor: spiDevMinor,
|
spiDevMinor: spiDevMinor,
|
||||||
sbf: sbf,
|
sbf: sbf,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user