Documentation
¶
Index ¶
- Constants
- Variables
- type Gpio
- type HwPwm
- type I2C
- func (i2 *I2C) Addr(addr uint16) error
- func (i2 *I2C) Close()
- func (i2 *I2C) Message(msgs []I2cMsg) error
- func (i2 *I2C) Read(reg byte, b []byte) error
- func (i2 *I2C) ReadReg(reg byte) (byte, error)
- func (i2 *I2C) Retries(r int) error
- func (i2 *I2C) TenBit(ten bool) error
- func (i2 *I2C) Timeout(tout time.Duration) error
- func (i2 *I2C) Write(reg byte, data []byte) error
- func (i2 *I2C) WriteReg(reg, data byte) error
- type I2cMsg
- type PWM
- type Setter
- type Spi
Constants ¶
const ( IN = iota // Default OUT = iota )
Mode
const ( NONE = iota // Default RISING = iota FALLING = iota BOTH = iota )
Edge
const ( I2cFlagRead = 1 << iota // Message is to be read, not written I2cFlagTenBit // Address is 10 bit address )
Flags
const ( SPI_MODE_0 = 0 SPI_MODE_1 = 1 SPI_MODE_2 = 2 SPI_MODE_3 = 3 SPI_MODE_CS_HIGH = 0x04 SPI_MODE_LSB_FIRST = 0x08 // SPI_MODE_3WIRE = 0x10 3 wire mode is not supported. SPI_MODE_LOOP = 0x20 SPI_MODE_NO_CS = 0x40 SPI_MODE_READY = 0x80 )
Spi driver modes.
const I2cMaxMsgs = 42 // Maximum number of messages allowed in transaction
Variables ¶
var (
ErrRetriesExceeded = errors.New("retries exceeded")
)
var Verify = false
Verify will enable waiting for exported files to become writable. This is necessary if the process is not running as root - systemd and udev will change the group permissions on the exported files, but this takes some time to do. If we try and access the files before the file group/modes are changed, we will get a permission error. This can be overridden.
Functions ¶
This section is empty.
Types ¶
type Gpio ¶
type Gpio struct {
// contains filtered or unexported fields
}
Gpio represents one GPIO pin.
func (*Gpio) GetTimeout ¶
GetTimeout is used when detecting edges, and a timeout is required. A timeout of 0 is interpreted as no timeout.
type HwPwm ¶
type HwPwm struct {
// contains filtered or unexported fields
}
type I2C ¶
type I2C struct {
// contains filtered or unexported fields
}
I2C represents one I2C device
func (*I2C) Read ¶
Read builds a message slice that writes an 8 bit register value to the device and then reads data from the peripheral device.
func (*I2C) ReadReg ¶
ReadReg reads one 8 bit register from the peripheral device by writing a register address and then reading 1 byte from the device.
type Spi ¶
type Spi struct {
// contains filtered or unexported fields
}