Documentation
¶
Index ¶
- Constants
- Variables
- func I2CDetectSlave(fd uintptr, slave uint8, funcs I2CFunction) (bool, error)
- func I2CDevice(bus uint) string
- func I2COpenDevice(bus uint) (*os.File, error)
- func I2CReadBlock(fd uintptr, reg, length uint8, funcs I2CFunction) ([]byte, error)
- func I2CReadInt16(fd uintptr, reg uint8, funcs I2CFunction) (int16, error)
- func I2CReadInt8(fd uintptr, reg uint8, funcs I2CFunction) (int8, error)
- func I2CReadUint16(fd uintptr, reg uint8, funcs I2CFunction) (uint16, error)
- func I2CReadUint8(fd uintptr, reg uint8, funcs I2CFunction) (uint8, error)
- func I2CSetSlave(fd uintptr, slave uint8) error
- func I2CWriteInt16(fd uintptr, reg uint8, value int16, funcs I2CFunction) error
- func I2CWriteInt8(fd uintptr, reg uint8, value int8, funcs I2CFunction) error
- func I2CWriteQuick(fd uintptr, value uint8, funcs I2CFunction) error
- func I2CWriteUint16(fd uintptr, reg uint8, value uint16, funcs I2CFunction) error
- func I2CWriteUint8(fd uintptr, reg, value uint8, funcs I2CFunction) error
- func SPIBitsPerWord(fd uintptr) (uint8, error)
- func SPIDevice(bus, slave uint) string
- func SPIOpenDevice(bus, slave uint) (*os.File, error)
- func SPIRead(fd uintptr, recv []byte, speed uint32, delay uint16, bits uint8) error
- func SPISetBitsPerWord(fd uintptr, bits uint8) error
- func SPISetMode(fd uintptr, mode SPIMode) error
- func SPISetSpeedHz(fd uintptr, speed uint32) error
- func SPISpeedHz(fd uintptr) (uint32, error)
- func SPITransfer(fd uintptr, send []byte, speed uint32, delay uint16, bits uint8) ([]byte, error)
- func SPIWrite(fd uintptr, send []byte, speed uint32, delay uint16, bits uint8) error
- type I2CFunction
- type SPIMode
Constants ¶
View Source
const ( I2C_DEV = "/dev/i2c" I2C_SMBUS_BLOCK_MAX = 32 /* As specified in SMBus standard */ )
View Source
const ( // i2c ioctl commands I2C_RETRIES = 0x0701 /* number of times a device address should be polled when not acknowledging */ I2C_TIMEOUT = 0x0702 /* set timeout in units of 10 ms */ I2C_SLAVE = 0x0703 /* Use this slave address */ I2C_SLAVE_FORCE = 0x0706 /* Use this slave address, even if it is already in use by a driver! */ I2C_TENBIT = 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ I2C_FUNCS = 0x0705 /* Get the adapter functionality mask */ I2C_RDWR = 0x0707 /* Combined R/W transfer (one STOP only) */ I2C_PEC = 0x0708 /* != 0 to use PEC with SMBus */ I2C_SMBUS = 0x0720 /* SMBus transfer */ )
View Source
const ( // i2c_smbus_xfer read or write markers I2C_SMBUS_READ uint8 = 0x01 I2C_SMBUS_WRITE uint8 = 0x00 )
View Source
const ( // SMBus transaction types I2C_SMBUS_QUICK uint32 = 0 I2C_SMBUS_BYTE uint32 = 1 I2C_SMBUS_BYTE_DATA uint32 = 2 I2C_SMBUS_WORD_DATA uint32 = 3 I2C_SMBUS_PROC_CALL uint32 = 4 I2C_SMBUS_BLOCK_DATA uint32 = 5 I2C_SMBUS_I2C_BLOCK_BROKEN uint32 = 6 I2C_SMBUS_BLOCK_PROC_CALL uint32 = 7 I2C_SMBUS_I2C_BLOCK_DATA uint32 = 8 )
View Source
const ( SPI_DEV = "/dev/spidev" SPI_IOC_MAGIC = 107 )
Variables ¶
View Source
var ( SPI_IOC_RD_MODE = uintptr(C._SPI_IOC_RD_MODE()) SPI_IOC_WR_MODE = uintptr(C._SPI_IOC_WR_MODE()) SPI_IOC_RD_LSB_FIRST = uintptr(C._SPI_IOC_RD_LSB_FIRST()) SPI_IOC_WR_LSB_FIRST = uintptr(C._SPI_IOC_WR_LSB_FIRST()) SPI_IOC_RD_BITS_PER_WORD = uintptr(C._SPI_IOC_RD_BITS_PER_WORD()) SPI_IOC_WR_BITS_PER_WORD = uintptr(C._SPI_IOC_WR_BITS_PER_WORD()) SPI_IOC_RD_MAX_SPEED_HZ = uintptr(C._SPI_IOC_RD_MAX_SPEED_HZ()) SPI_IOC_WR_MAX_SPEED_HZ = uintptr(C._SPI_IOC_WR_MAX_SPEED_HZ()) SPI_IOC_RD_MODE32 = uintptr(C._SPI_IOC_RD_MODE32()) SPI_IOC_WR_MODE32 = uintptr(C._SPI_IOC_WR_MODE32()) )
Functions ¶
func I2CDetectSlave ¶
func I2CDetectSlave(fd uintptr, slave uint8, funcs I2CFunction) (bool, error)
func I2CReadBlock ¶
func I2CReadBlock(fd uintptr, reg, length uint8, funcs I2CFunction) ([]byte, error)
func I2CReadInt16 ¶
func I2CReadInt16(fd uintptr, reg uint8, funcs I2CFunction) (int16, error)
func I2CReadInt8 ¶
func I2CReadInt8(fd uintptr, reg uint8, funcs I2CFunction) (int8, error)
func I2CReadUint16 ¶
func I2CReadUint16(fd uintptr, reg uint8, funcs I2CFunction) (uint16, error)
func I2CReadUint8 ¶
func I2CReadUint8(fd uintptr, reg uint8, funcs I2CFunction) (uint8, error)
func I2CSetSlave ¶
func I2CWriteInt16 ¶
func I2CWriteInt16(fd uintptr, reg uint8, value int16, funcs I2CFunction) error
func I2CWriteInt8 ¶
func I2CWriteInt8(fd uintptr, reg uint8, value int8, funcs I2CFunction) error
func I2CWriteQuick ¶
func I2CWriteQuick(fd uintptr, value uint8, funcs I2CFunction) error
func I2CWriteUint16 ¶
func I2CWriteUint16(fd uintptr, reg uint8, value uint16, funcs I2CFunction) error
func I2CWriteUint8 ¶
func I2CWriteUint8(fd uintptr, reg, value uint8, funcs I2CFunction) error
func SPIBitsPerWord ¶
func SPISetBitsPerWord ¶
func SPISetMode ¶
func SPISetSpeedHz ¶
func SPISpeedHz ¶
func SPITransfer ¶
Types ¶
type I2CFunction ¶
type I2CFunction uint32
const ( // i2c functions I2C_FUNC_NONE I2CFunction = 0x00000000 I2C_FUNC_I2C I2CFunction = 0x00000001 I2C_FUNC_10BIT_ADDR I2CFunction = 0x00000002 I2C_FUNC_PROTOCOL_MANGLING I2CFunction = 0x00000004 /* I2C_M_IGNORE_NAK etc. */ I2C_FUNC_SMBUS_PEC I2CFunction = 0x00000008 I2C_FUNC_NOSTART I2CFunction = 0x00000010 /* I2C_M_NOSTART */ I2C_FUNC_SMBUS_BLOCK_PROC_CALL I2CFunction = 0x00008000 /* SMBus 2.0 */ I2C_FUNC_SMBUS_QUICK I2CFunction = 0x00010000 I2C_FUNC_SMBUS_READ_BYTE I2CFunction = 0x00020000 I2C_FUNC_SMBUS_WRITE_BYTE I2CFunction = 0x00040000 I2C_FUNC_SMBUS_READ_BYTE_DATA I2CFunction = 0x00080000 I2C_FUNC_SMBUS_WRITE_BYTE_DATA I2CFunction = 0x00100000 I2C_FUNC_SMBUS_READ_WORD_DATA I2CFunction = 0x00200000 I2C_FUNC_SMBUS_WRITE_WORD_DATA I2CFunction = 0x00400000 I2C_FUNC_SMBUS_PROC_CALL I2CFunction = 0x00800000 I2C_FUNC_SMBUS_READ_BLOCK_DATA I2CFunction = 0x01000000 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA I2CFunction = 0x02000000 I2C_FUNC_SMBUS_READ_I2C_BLOCK I2CFunction = 0x04000000 /* I2C-like block xfer */ I2C_FUNC_SMBUS_WRITE_I2C_BLOCK I2CFunction = 0x08000000 /* w/ 1-byte reg. addr. */ )
func I2CFunctions ¶
func I2CFunctions(fd uintptr) (I2CFunction, error)
func (I2CFunction) FlagString ¶
func (f I2CFunction) FlagString() string
func (I2CFunction) String ¶
func (f I2CFunction) String() string
type SPIMode ¶
type SPIMode uint32 // SPIMode is the SPI Mode
const ( SPI_MODE_CPHA SPIMode = 0x01 SPI_MODE_CPOL SPIMode = 0x02 SPI_MODE_0 SPIMode = 0x00 SPI_MODE_1 SPIMode = (0x00 | SPI_MODE_CPHA) SPI_MODE_2 SPIMode = (SPI_MODE_CPOL | 0x00) SPI_MODE_3 SPIMode = (SPI_MODE_CPOL | SPI_MODE_CPHA) SPI_MODE_NONE SPIMode = 0xFF SPI_MODE_MASK SPIMode = 0x03 )
func SPIGetMode ¶
Click to show internal directories.
Click to hide internal directories.