gobot.io/x/gobot/v2@v2.1.0/system/spi_access.go (about) 1 package system 2 3 import ( 4 "gobot.io/x/gobot/v2" 5 ) 6 7 type periphioSpiAccess struct { 8 fs filesystem 9 } 10 11 type gpioSpiAccess struct { 12 cfg spiGpioConfig 13 } 14 15 func (*periphioSpiAccess) createDevice(busNum, chipNum, mode, bits int, maxSpeed int64) (gobot.SpiSystemDevicer, error) { 16 return newSpiPeriphIo(busNum, chipNum, mode, bits, maxSpeed) 17 } 18 19 func (psa *periphioSpiAccess) isSupported() bool { 20 devices, err := psa.fs.find("/dev", "spidev") 21 if err != nil || len(devices) == 0 { 22 return false 23 } 24 return true 25 } 26 27 func (gsa *gpioSpiAccess) createDevice(busNum, chipNum, mode, bits int, maxSpeed int64) (gobot.SpiSystemDevicer, error) { 28 return newSpiGpio(gsa.cfg, maxSpeed) 29 } 30 31 func (gsa *gpioSpiAccess) isSupported() bool { 32 return true 33 }