Documentation ¶
Overview ¶
Package hwio implements a simple Arduino-like interface for controlling hardware I/O, with configurable backends depending on the device.
Index ¶
- Constants
- func AnalogRead(pin Pin) (int, error)
- func AssignPin(pin Pin, module Module) error
- func AssignPins(pins PinList, module Module) error
- func CloseAll()
- func ClosePin(pin Pin) error
- func CpuInfo(cpu int, property string) string
- func DebugPinMap()
- func Delay(duration int)
- func DelayMicroseconds(duration int)
- func DigitalRead(pin Pin) (result int, e error)
- func DigitalWrite(pin Pin, value int) (e error)
- func Led(name string, on bool) error
- func Map(value int, fromLow int, fromHigh int, toLow int, toHigh int) int
- func Negate(logicLevel int) int
- func PinMode(pin Pin, mode PinIOMode) error
- func PinName(pin Pin) string
- func Pulse(pin Pin, active int, durationMicroseconds int) error
- func ReverseBytes16(value uint16) uint16
- func ReverseBytes32(value uint32) uint32
- func SetDriver(d HardwareDriver)
- func SetErrorChecking(check bool)
- func ShiftOut(dataPin Pin, clockPin Pin, value uint, order BitShiftOrder) error
- func ShiftOutSize(dataPin Pin, clockPin Pin, value uint, order BitShiftOrder, n uint) error
- func UInt16FromUInt8(highByte byte, lowByte byte) uint16
- func UnassignPin(pin Pin) error
- func UnassignPins(pins PinList) (er error)
- func WriteStringToFile(filename string, value string) error
- func WriteUIntToPins(value uint32, pins []Pin) error
- type AnalogModule
- type BBAnalogModule
- type BBAnalogModuleOpenPin
- type BBAnalogModulePinDef
- type BBAnalogModulePinDefMap
- type BBPWMModule
- func (module *BBPWMModule) Disable() error
- func (module *BBPWMModule) Enable() error
- func (module *BBPWMModule) EnablePin(pin Pin, enabled bool) error
- func (module *BBPWMModule) GetName() string
- func (module *BBPWMModule) SetDuty(pin Pin, ns int64) error
- func (module *BBPWMModule) SetOptions(options map[string]interface{}) error
- func (module *BBPWMModule) SetPeriod(pin Pin, ns int64) error
- type BBPWMModuleOpenPin
- type BBPWMModulePinDef
- type BBPWMModulePinDefMap
- type BeagleBoneBlackDriver
- type BeaglePin
- type BitShiftOrder
- type DTGPIOModule
- func (module *DTGPIOModule) ClosePin(pin Pin) error
- func (module *DTGPIOModule) DigitalRead(pin Pin) (value int, e error)
- func (module *DTGPIOModule) DigitalWrite(pin Pin, value int) (e error)
- func (module *DTGPIOModule) Disable() error
- func (module *DTGPIOModule) Enable() error
- func (module *DTGPIOModule) GetName() string
- func (module *DTGPIOModule) PinMode(pin Pin, mode PinIOMode) error
- func (module *DTGPIOModule) SetOptions(options map[string]interface{}) error
- type DTGPIOModuleOpenPin
- type DTGPIOModulePinDef
- type DTGPIOModulePinDefMap
- type DTI2CDevice
- type DTI2CModule
- type DTI2CModulePins
- type DTLEDModule
- type DTLEDModuleLED
- type DTLEDModulePins
- type DTPinConfig
- type GPIOModule
- type HardwareDriver
- type HardwarePinMap
- type I2CDevice
- type I2CModule
- type LEDModule
- type LEDModuleLED
- type Module
- type ODroidC1AnalogModule
- func (module *ODroidC1AnalogModule) AnalogRead(pin Pin) (value int, e error)
- func (module *ODroidC1AnalogModule) Disable() error
- func (module *ODroidC1AnalogModule) Enable() error
- func (module *ODroidC1AnalogModule) GetName() string
- func (module *ODroidC1AnalogModule) SetOptions(options map[string]interface{}) error
- type ODroidC1AnalogModuleOpenPin
- type ODroidC1AnalogModulePinDef
- type ODroidC1AnalogModulePinDefMap
- type OdroidC1Driver
- type PWMModule
- type Pin
- type PinDef
- type PinIOMode
- type PinList
- type PreassignedModule
- type RaspberryPiDTDriver
- func (d *RaspberryPiDTDriver) BoardRevision() pinoutRevision
- func (d *RaspberryPiDTDriver) Close()
- func (d *RaspberryPiDTDriver) GetModules() map[string]Module
- func (d *RaspberryPiDTDriver) Init() error
- func (d *RaspberryPiDTDriver) MatchesHardwareConfig() bool
- func (d *RaspberryPiDTDriver) PinMap() (pinMap HardwarePinMap)
- type SPIModule
- type TestDriver
Constants ¶
const ( I2C_SMBUS_READ = 1 I2C_SMBUS_WRITE = 0 I2C_SMBUS_BYTE_DATA = 2 I2C_SMBUS_I2C_BLOCK_DATA = 8 I2C_SMBUS_BLOCK_MAX = 32 // Talk to bus I2C_SMBUS = 0x0720 // Set bus slave I2C_SLAVE = 0x0703 )
Constants used by ioctl, from i2c-dev.h
const ( HIGH = 1 LOW = 0 )
Convenience constants for digital pin values.
Variables ¶
This section is empty.
Functions ¶
func AnalogRead ¶
Read an analog value from a pin. The range of values is hardware driver dependent.
func AssignPin ¶
Assign a pin to a module. This is typically called by modules when they allocate pins. If the pin is already assigned, an error is generated. ethod is public in case it is needed to hack around default driver settings.
func AssignPins ¶
Assign a set of pins. Method is public in case it is needed to hack around default driver settings.
func CloseAll ¶
func CloseAll()
Ensure that any resources external to the program that have been allocated are tidied up.
func Delay ¶
func Delay(duration int)
Delay execution by the specified number of milliseconds. This is a helper function for similarity with Arduino. It is implemented using standard go time package.
func DelayMicroseconds ¶
func DelayMicroseconds(duration int)
Delay execution by the specified number of microseconds. This is a helper function for similarity with Arduino. It is implemented using standard go time package
func Negate ¶
given a logic level of HIGH or LOW, return the opposite. Invalid values returned as LOW.
func PinName ¶
Given an internal pin number, return the canonical name for the pin, as defined by the driver. If the pin is not to the driver, return "".
func Pulse ¶
Helper function to pulse a pin, which must have been set as GPIO. 'active' is LOW or HIGH. Pulse sets pin to inactive, then active for 'durationMicroseconds' and the back to inactive.
func ReverseBytes16 ¶
func ReverseBytes32 ¶
func SetDriver ¶
func SetDriver(d HardwareDriver)
Set the driver. Also calls Init on the driver, and loads the capabilities of the device.
func SetErrorChecking ¶
func SetErrorChecking(check bool)
Set error checking. This should be called before pin assignments.
func ShiftOut ¶
func ShiftOut(dataPin Pin, clockPin Pin, value uint, order BitShiftOrder) error
The approximate mapping of Arduino shiftOut, this shifts a byte out on the data pin, pulsing the clock pin high and then low.
func ShiftOutSize ¶
More generic version of ShiftOut which shifts out n of data from value. The value shifted out is always the lowest n bits of the value, but 'order' determines whether the msb or lsb from that value are shifted first
func UInt16FromUInt8 ¶
Given a high and low byte, combine to form a single 16-bit value
func UnassignPin ¶
Unassign a pin. Method is public in case it is needed to hack around default driver settings.
func UnassignPins ¶
Unassign a set of pins. Method is public in case it is needed to hack around default driver settings.
func WriteStringToFile ¶
Write a string to a file and close it again.
func WriteUIntToPins ¶
Given an integer and a list of GPIO pins (that must have been set up as outputs), write the integer across the pins. The number of bits is determined by the length of the pins. The most-significant output pin is first. Bits are written MSB first. Maximum number of bits that can be shifted is 32. Note that the bits are not written out instantaneously, although very quickly. If you need instantaneous changing of all pins, you need to consider an output buffer.
Types ¶
type AnalogModule ¶
func GetAnalogModule ¶
func GetAnalogModule() (AnalogModule, error)
Helper function to get GPIO module
type BBAnalogModule ¶
type BBAnalogModule struct {
// contains filtered or unexported fields
}
BBAnalogModule handles BeagleBone-specific analog.
func NewBBAnalogModule ¶
func NewBBAnalogModule(name string) (result *BBAnalogModule)
func (*BBAnalogModule) AnalogRead ¶
func (module *BBAnalogModule) AnalogRead(pin Pin) (int, error)
func (*BBAnalogModule) Disable ¶
func (module *BBAnalogModule) Disable() error
disables module and release any pins assigned.
func (*BBAnalogModule) Enable ¶
func (module *BBAnalogModule) Enable() error
enable GPIO module. It doesn't allocate any pins immediately.
func (*BBAnalogModule) GetName ¶
func (module *BBAnalogModule) GetName() string
func (*BBAnalogModule) SetOptions ¶
func (module *BBAnalogModule) SetOptions(options map[string]interface{}) error
Set options of the module. Parameters we look for include: - "pins" - an object of type BBAnalogModulePinDefMap
type BBAnalogModuleOpenPin ¶
type BBAnalogModuleOpenPin struct {
// contains filtered or unexported fields
}
type BBAnalogModulePinDef ¶
type BBAnalogModulePinDef struct {
// contains filtered or unexported fields
}
Represents the definition of an analog pin, which should contain all the info required to open, close, read and write the pin using FS drivers.
type BBAnalogModulePinDefMap ¶
type BBAnalogModulePinDefMap map[Pin]*BBAnalogModulePinDef
A map of GPIO pin definitions.
type BBPWMModule ¶
type BBPWMModule struct {
// contains filtered or unexported fields
}
func NewBBPWMModule ¶
func NewBBPWMModule(name string) (result *BBPWMModule)
func (*BBPWMModule) Disable ¶
func (module *BBPWMModule) Disable() error
disables module and release any pins assigned.
func (*BBPWMModule) Enable ¶
func (module *BBPWMModule) Enable() error
enable PWM module. It doesn't allocate any pins immediately. It does check of am33xx_pwm is present in the capemgr slots, and adds it if not. By default, this is not enabled on the BB but can be added easily.
func (*BBPWMModule) EnablePin ¶
func (module *BBPWMModule) EnablePin(pin Pin, enabled bool) error
Enable a specific PWM pin. You need to call this explicitly after enabling the module, as the module will not by default allocate all pins, since there are a few.
func (*BBPWMModule) GetName ¶
func (module *BBPWMModule) GetName() string
func (*BBPWMModule) SetDuty ¶
func (module *BBPWMModule) SetDuty(pin Pin, ns int64) error
Set the duty time, the amount of time during each period that that output is HIGH.
func (*BBPWMModule) SetOptions ¶
func (module *BBPWMModule) SetOptions(options map[string]interface{}) error
Set options of the module. Parameters we look for include: - "pins" - an object of type DTGPIOModulePinDefMap
type BBPWMModuleOpenPin ¶
type BBPWMModuleOpenPin struct {
// contains filtered or unexported fields
}
type BBPWMModulePinDef ¶
type BBPWMModulePinDef struct {
// contains filtered or unexported fields
}
type BBPWMModulePinDefMap ¶
type BBPWMModulePinDefMap map[Pin]*BBPWMModulePinDef
type BeagleBoneBlackDriver ¶
type BeagleBoneBlackDriver struct {
// contains filtered or unexported fields
}
func NewBeagleboneBlackDTDriver ¶
func NewBeagleboneBlackDTDriver() *BeagleBoneBlackDriver
func (*BeagleBoneBlackDriver) Close ¶
func (d *BeagleBoneBlackDriver) Close()
func (*BeagleBoneBlackDriver) GetModules ¶
func (d *BeagleBoneBlackDriver) GetModules() map[string]Module
func (*BeagleBoneBlackDriver) Init ¶
func (d *BeagleBoneBlackDriver) Init() error
func (*BeagleBoneBlackDriver) MatchesHardwareConfig ¶
func (d *BeagleBoneBlackDriver) MatchesHardwareConfig() bool
Examine the hardware environment and determine if this driver will handle it. Note: this replaces the old detection which mostly used "uname -a" for BeagleBone detection, but this was unreliable with too many edge cases. Now, it looks for specific driver config. This becomes less based on disto etc and more based on capability surfaced via device drivers.
func (*BeagleBoneBlackDriver) PinMap ¶
func (d *BeagleBoneBlackDriver) PinMap() (pinMap HardwarePinMap)
type DTGPIOModule ¶
type DTGPIOModule struct {
// contains filtered or unexported fields
}
func NewDTGPIOModule ¶
func NewDTGPIOModule(name string) (result *DTGPIOModule)
func (*DTGPIOModule) ClosePin ¶
func (module *DTGPIOModule) ClosePin(pin Pin) error
func (*DTGPIOModule) DigitalRead ¶
func (module *DTGPIOModule) DigitalRead(pin Pin) (value int, e error)
func (*DTGPIOModule) DigitalWrite ¶
func (module *DTGPIOModule) DigitalWrite(pin Pin, value int) (e error)
func (*DTGPIOModule) Disable ¶
func (module *DTGPIOModule) Disable() error
disables module and release any pins assigned.
func (*DTGPIOModule) Enable ¶
func (module *DTGPIOModule) Enable() error
enable GPIO module. It doesn't allocate any pins immediately.
func (*DTGPIOModule) GetName ¶
func (module *DTGPIOModule) GetName() string
func (*DTGPIOModule) SetOptions ¶
func (module *DTGPIOModule) SetOptions(options map[string]interface{}) error
Set options of the module. Parameters we look for include: - "pins" - an object of type DTGPIOModulePinDefMap
type DTGPIOModuleOpenPin ¶
type DTGPIOModuleOpenPin struct {
// contains filtered or unexported fields
}
type DTGPIOModulePinDef ¶
type DTGPIOModulePinDef struct {
// contains filtered or unexported fields
}
Represents the definition of a GPIO pin, which should contain all the info required to open, close, read and write the pin using FS drivers.
type DTGPIOModulePinDefMap ¶
type DTGPIOModulePinDefMap map[Pin]*DTGPIOModulePinDef
A map of GPIO pin definitions.
type DTI2CDevice ¶
type DTI2CDevice struct {
// contains filtered or unexported fields
}
func NewDTI2CDevice ¶
func NewDTI2CDevice(module *DTI2CModule, address int) *DTI2CDevice
func (*DTI2CDevice) Read ¶
func (device *DTI2CDevice) Read(command byte, numBytes int) ([]byte, error)
type DTI2CModule ¶
func NewDTI2CModule ¶
func NewDTI2CModule(name string) (result *DTI2CModule)
func (*DTI2CModule) Disable ¶
func (module *DTI2CModule) Disable() error
disables module and release any pins assigned.
func (*DTI2CModule) GetDevice ¶
func (module *DTI2CModule) GetDevice(address int) I2CDevice
func (*DTI2CModule) GetName ¶
func (module *DTI2CModule) GetName() string
func (*DTI2CModule) SetOptions ¶
func (module *DTI2CModule) SetOptions(options map[string]interface{}) error
Accept options for the I2C module. Expected options include:
- "device" - a string that identifies the device file, e.g. "/dev/i2c-1".
- "pins" - an object of type DTI2CModulePins that identifies the pins that will be assigned when this module is enabled.
type DTI2CModulePins ¶
type DTI2CModulePins []Pin
A list of the pins that are allocated when the bus is enabled. We don't need to know what these mean within the module. We just need them so we can mark them allocated.
type DTLEDModule ¶
type DTLEDModule struct {
// contains filtered or unexported fields
}
This is a module to support the onboard LED functions. While these are actually attached to GPIO pins that are not exposed on the expansion headers, we can't use GPIO, as a driver is present that provides ways to map what is displayed on the LEDs.
func NewDTLEDModule ¶
func NewDTLEDModule(name string) *DTLEDModule
func (*DTLEDModule) Disable ¶
func (m *DTLEDModule) Disable() error
func (*DTLEDModule) Enable ¶
func (m *DTLEDModule) Enable() error
func (*DTLEDModule) GetLED ¶
func (m *DTLEDModule) GetLED(led string) (LEDModuleLED, error)
Get a LED to manipulate. 'led' must be 0 to 3.
func (*DTLEDModule) GetName ¶
func (m *DTLEDModule) GetName() string
func (*DTLEDModule) SetOptions ¶
func (m *DTLEDModule) SetOptions(options map[string]interface{}) error
type DTLEDModuleLED ¶
type DTLEDModuleLED struct {
// contains filtered or unexported fields
}
This is a module to support the onboard LED functions. While these are actually attached to GPIO pins that are not exposed on the expansion headers, we can't use GPIO, as a driver is present that provides ways to map what is displayed on the LEDs.
func (*DTLEDModuleLED) SetOn ¶
func (led *DTLEDModuleLED) SetOn(on bool) error
func (*DTLEDModuleLED) SetTrigger ¶
func (led *DTLEDModuleLED) SetTrigger(trigger string) error
Set the trigger for the LED. The values come from /sys/class/leds/*/trigger. This tells the driver what should be displayed on the LED. The useful values include:
- none The LED can be set up programmatic control. If you want to turn a LED on and off yourself, you want this mode.
- nand-disk Automatically displays nand disk activity
- mmc0 Show MMC0 activity.
- mmc1 Show MMC1 activity. By default, USR3 is configured for mmc1.
- timer
- heartbeat Show a heartbeat for system functioning. By default, USR0 is configured for heartbeat.
- cpu0 Show CPU activity. By default, USR2 is configured for cpu0.
For BeagleBone black system defaults (at least for Angstrom are): - USR0: heartbeat - USR1: mmc0 - USR2: cpu0 - USR3: mmc1 For Raspberry Pi is mmc0.
type DTLEDModulePins ¶
A map of pin names (e.g. "USR0") to their path e.g. /sys/class/leds/{led}/
type DTPinConfig ¶
type DTPinConfig struct {
// contains filtered or unexported fields
}
DTPinConfig represents configuration information for a pin used in a device-tree based driver, which typically hold the same details.
type GPIOModule ¶
type HardwareDriver ¶
type HardwareDriver interface { // Each driver is responsible for evaluating whether it applies to the current hardware // configuration or not. If this function returns false, the driver will not be used and Init // will not be called. If this function returns true, the driver may be called, in which case // Init will then be called MatchesHardwareConfig() bool // Initialise the driver. Init() (e error) // Return a module by name, or nil if undefined. The module names can be different between types of boards. GetModules() map[string]Module // Return the pin map for the driver, listing all supported pins and their capabilities PinMap() (pinMap HardwarePinMap) // Close the driver before destruction Close() }
This is the interface that hardware drivers implement. Generally all drivers are created but not initialised. If MatchesHardwareConfig() is true and the driver is selected, Init() will be called.
type HardwarePinMap ¶
func GetDefinedPins ¶
func GetDefinedPins() HardwarePinMap
Returns a map of the hardware pins. This will only work once the driver is set.
func (HardwarePinMap) Add ¶
func (m HardwarePinMap) Add(pin Pin, names []string, modules []string)
Add a pin to the map
func (HardwarePinMap) GetPin ¶
func (m HardwarePinMap) GetPin(pin Pin) *PinDef
Given a pin number, return it's PinDef, or nil if that pin is not defined in the map
type I2CDevice ¶
type I2CDevice interface { // Read a single byte from a register on the device. ReadByte(command byte) (byte, error) // Write a single byte to a register on the device. WriteByte(command byte, value byte) error // Read one or more bytes from the selected slave. Read(command byte, numBytes int) ([]byte, error) // Write one or more bytes to the selected slave. Write(command byte, buffer []byte) (e error) }
An object that represents a device on a bus. Once an i2c module has been enabled, you can use GetDevice to get an instance of i2c device. You can then talk to the device directly with the supported operations.
type I2CModule ¶
Interface for I2C implementations. Assumes that this device is the only bus master, so initiates all transactions. An I2C module supports exactly one i2c bus, so for systems with multiple i2c busses, the driver will create an instance for each accessible i2c bus.
type LEDModule ¶
type LEDModule interface { Module GetLED(led string) (LEDModuleLED, error) }
Interface for controlling on-board LEDs, modelled on /sys/class/leds
type LEDModuleLED ¶
LED from the an LEDModule
type Module ¶
type Module interface { // Set parameters require to initialise the module. Generally should be called before Enable() is called, // but this may depend on the module. SetOptions(map[string]interface{}) error // enables the module for use. Enable() error // disables module and releases pins. Disable() error // Return the module name so it can be used for error reporting GetName() string }
Generic interface type for all modules.
type ODroidC1AnalogModule ¶
type ODroidC1AnalogModule struct {
// contains filtered or unexported fields
}
ODroidC1AnalogModule is a module for handling the Odroid C1 analog hardware, which is not generic.
func NewODroidC1AnalogModule ¶
func NewODroidC1AnalogModule(name string) (result *ODroidC1AnalogModule)
func (*ODroidC1AnalogModule) AnalogRead ¶
func (module *ODroidC1AnalogModule) AnalogRead(pin Pin) (value int, e error)
func (*ODroidC1AnalogModule) Disable ¶
func (module *ODroidC1AnalogModule) Disable() error
disables module and release any pins assigned.
func (*ODroidC1AnalogModule) Enable ¶
func (module *ODroidC1AnalogModule) Enable() error
enable GPIO module. It doesn't allocate any pins immediately.
func (*ODroidC1AnalogModule) GetName ¶
func (module *ODroidC1AnalogModule) GetName() string
func (*ODroidC1AnalogModule) SetOptions ¶
func (module *ODroidC1AnalogModule) SetOptions(options map[string]interface{}) error
Set options of the module. Parameters we look for include: - "pins" - an object of type ODroidC1AnalogModulePinDefMap
type ODroidC1AnalogModuleOpenPin ¶
type ODroidC1AnalogModuleOpenPin struct {
// contains filtered or unexported fields
}
type ODroidC1AnalogModulePinDef ¶
type ODroidC1AnalogModulePinDef struct {
// contains filtered or unexported fields
}
Represents the definition of an analog pin, which should contain all the info required to open, close, read and write the pin using FS drivers.
type ODroidC1AnalogModulePinDefMap ¶
type ODroidC1AnalogModulePinDefMap map[Pin]*ODroidC1AnalogModulePinDef
A map of GPIO pin definitions.
type OdroidC1Driver ¶
type OdroidC1Driver struct {
// contains filtered or unexported fields
}
func NewOdroidC1Driver ¶
func NewOdroidC1Driver() *OdroidC1Driver
func (*OdroidC1Driver) Close ¶
func (d *OdroidC1Driver) Close()
func (*OdroidC1Driver) GetModules ¶
func (d *OdroidC1Driver) GetModules() map[string]Module
func (*OdroidC1Driver) Init ¶
func (d *OdroidC1Driver) Init() error
func (*OdroidC1Driver) MatchesHardwareConfig ¶
func (d *OdroidC1Driver) MatchesHardwareConfig() bool
Examine the hardware environment and determine if this driver will handle it. For Odroid C1, it's easy: /proc/cpuinfo identifies it.
func (*OdroidC1Driver) PinMap ¶
func (d *OdroidC1Driver) PinMap() (pinMap HardwarePinMap)
type Pin ¶
type Pin int
func GetPin ¶
Returns a Pin given a canonical name for the pin. e.g. to get the pin number of P8.13 on a beaglebone,
pin := hwio.GetPin("P8.13")
Order of search is: - search hwRefs in the pin map in order. This function should not generally be relied on for performance. For max speed, call this for each pin you use once on init, and use the returned Pin values thereafter. Search is case sensitive at the moment @todo GetPin: consider making it case-insensitive on name @todo GetPin: consider allowing an int or int as string to identify logical pin directly
type PinDef ¶
type PinDef struct {
// contains filtered or unexported fields
}
type PreassignedModule ¶
type PreassignedModule struct {
// contains filtered or unexported fields
}
This is a dummy module for devices that have pins that are pre-assigned, but not to any of the supported modules on the device. It is passed a list of these pre-assigned pins. e.g. on BeagleBone Black, it covers pins that are defined for HDMI, MMC and mcasp0. On the default configuration, these pins are pre-assigned with device tree configuration, so they cannot be assigned for gpio (without custom device tree)
func NewPreassignedModule ¶
func NewPreassignedModule(name string) (result *PreassignedModule)
func (*PreassignedModule) Disable ¶
func (module *PreassignedModule) Disable() error
func (*PreassignedModule) Enable ¶
func (module *PreassignedModule) Enable() error
func (*PreassignedModule) GetName ¶
func (module *PreassignedModule) GetName() string
func (*PreassignedModule) SetOptions ¶
func (module *PreassignedModule) SetOptions(options map[string]interface{}) error
type RaspberryPiDTDriver ¶
type RaspberryPiDTDriver struct {
// contains filtered or unexported fields
}
func NewRaspPiDTDriver ¶
func NewRaspPiDTDriver() *RaspberryPiDTDriver
func (*RaspberryPiDTDriver) BoardRevision ¶
func (d *RaspberryPiDTDriver) BoardRevision() pinoutRevision
Determine the version of Raspberry Pi. This discussion http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=23989 was used to determine the algorithm, specifically the comment by gordon@drogon.net It will return 1 or 2.
func (*RaspberryPiDTDriver) Close ¶
func (d *RaspberryPiDTDriver) Close()
func (*RaspberryPiDTDriver) GetModules ¶
func (d *RaspberryPiDTDriver) GetModules() map[string]Module
func (*RaspberryPiDTDriver) Init ¶
func (d *RaspberryPiDTDriver) Init() error
func (*RaspberryPiDTDriver) MatchesHardwareConfig ¶
func (d *RaspberryPiDTDriver) MatchesHardwareConfig() bool
func (*RaspberryPiDTDriver) PinMap ¶
func (d *RaspberryPiDTDriver) PinMap() (pinMap HardwarePinMap)
type SPIModule ¶
type SPIModule interface { Module // Select the device, and send data to it Write(slaveSelect int, data []byte) (e error) // Select the device, and read data from it Read(slaveSelect int, data []byte) (nBytes int, e error) }
Interface for SPI implementations
type TestDriver ¶
type TestDriver struct {
// contains filtered or unexported fields
}
func (*TestDriver) Close ¶
func (d *TestDriver) Close()
func (*TestDriver) GetModules ¶
func (d *TestDriver) GetModules() map[string]Module
func (*TestDriver) Init ¶
func (d *TestDriver) Init() error
func (*TestDriver) MatchesHardwareConfig ¶
func (d *TestDriver) MatchesHardwareConfig() bool
func (*TestDriver) PinMap ¶
func (d *TestDriver) PinMap() HardwarePinMap
// Mock has a fixed set of hardcoded pins with different capabilities