bus

package
v0.0.0-...-7ee4f4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package bus provides low level control over the linux buses.

I²C Device List http://www.coris.org.uk/jdc/Notes/i2c-devices.html

Device                Address range

Bridge/Expander

SUNW,i2c-imax         0x09, 0x0b, 0x0c, 0x12, 0x30

Clock Generator

ICS951601             0x6e
ICS9FG108             0x6e

Controller

PCF8584               [Programmable]
Sun JBus I2C          [N/A]
Mentor Graphics       [N/A]
Sun Fire              [N/A]
Marvell MV78230       [N/A]
Allwinner Sun4i       [N/A]
DECchip 21272         [N/A]

DAC

TDA8444               0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e

EEPROM

AT24C{01,02,04,08,16} 0x50 to 0x57
AT24C32, AT24C64      0x50 to 0x57
AT34C02               0x50 to 0x57, 0x30 to 0x37
PCF8582C              0x50 to 0x57
SPD memory            0x50 to 0x57

GPIO

FM3560                0x37, 0x4e
PCF8574, PCF8574A     0x20 to 0x27, 0x38 to 0x3f
PCA9555               0x20 to 0x27
PCA9556               0x18 to 0x1f

PIC/Microcontroller

PIC16F818/819         0x29

Real-Time Clock

DS1307                0x68

Sensor/Hardware Monitor

ADM1021               0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
ADM1021               0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
ADM1021A              0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
ADM1023               0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
ADM1026               0x2c to 0x2f
ADM1031               0x2c to 0x2f
ADM1032               0x4c, 0x4d
ADM9240               0x2c to 0x2f
ADT7462               0x5b, 0x5c
DS1780                0x2c to 0x2f
DS75                  0x48 to 0x4f
G781                  0x4c
LM75                  0x48 to 0x4f
LM75A                 0x48 to 0x4f
LM76                  0x48 to 0x4d
LM77                  0x48 to 0x4b
LM81                  0x2c to 0x2f
LM84                  0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
LM87                  0x2c to 0x2f
MAX1617               0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
MAX1617A              0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e
NE1617ADS             0x18 to 0x1a, 0x29 to 0x2b, 0x4c to 0x4e

Smart Card Interface

TDA8020HL             0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e

Index

Constants

View Source
const (
	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 */
	/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
	 * are NOT supported! (due to code brokenness)
	 */
	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 */

	I2C_RDRW_IOCTL_MAX_MSGS = 42
)
View Source
const (
	SMBUS_WRITE = iota
	SMBUS_READ
)
View Source
const (
	SMBUS_QUICK = iota
	SMBUS_BYTE
	SMBUS_BYTE_DATA
	SMBUS_WORD_DATA
	SMBUS_PROC_CALL
	SMBUS_BLOCK_DATA
	SMBUS_I2C_BLOCK_BROKEN
	SMBUS_BLOCK_PROC_CALL /* SMBus 2.0 */
	SMBUS_I2C_BLOCK_DATA
)
View Source
const (
	SMBUS_BLOCK_MAX     = 32
	SMBUS_I2C_BLOCK_MAX = 32
)
View Source
const (
	I2C_FUNC_I2C                    = 0x00000001
	I2C_FUNC_10BIT_ADDR             = 0x00000002
	I2C_FUNC_PROTOCOL_MANGLING      = 0x00000004 /* I2C_M_IGNORE_NAK etc. */
	I2C_FUNC_SMBUS_PEC              = 0x00000008
	I2C_FUNC_NOSTART                = 0x00000010 /* I2C_M_NOSTART */
	I2C_FUNC_SMBUS_BLOCK_PROC_CALL  = 0x00008000 /* SMBus 2.0 */
	I2C_FUNC_SMBUS_QUICK            = 0x00010000
	I2C_FUNC_SMBUS_READ_BYTE        = 0x00020000
	I2C_FUNC_SMBUS_WRITE_BYTE       = 0x00040000
	I2C_FUNC_SMBUS_READ_BYTE_DATA   = 0x00080000
	I2C_FUNC_SMBUS_WRITE_BYTE_DATA  = 0x00100000
	I2C_FUNC_SMBUS_READ_WORD_DATA   = 0x00200000
	I2C_FUNC_SMBUS_WRITE_WORD_DATA  = 0x00400000
	I2C_FUNC_SMBUS_PROC_CALL        = 0x00800000
	I2C_FUNC_SMBUS_READ_BLOCK_DATA  = 0x01000000
	I2C_FUNC_SMBUS_WRITE_BLOCK_DATA = 0x02000000
	I2C_FUNC_SMBUS_READ_I2C_BLOCK   = 0x04000000 /* I2C-like block xfer  */
	I2C_FUNC_SMBUS_WRITE_I2C_BLOCK  = 0x08000000 /* w/ 1-byte reg. addr. */

	I2C_FUNC_SMBUS_BYTE       = (I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE)
	I2C_FUNC_SMBUS_BYTE_DATA  = (I2C_FUNC_SMBUS_READ_BYTE_DATA | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
	I2C_FUNC_SMBUS_WORD_DATA  = (I2C_FUNC_SMBUS_READ_WORD_DATA | I2C_FUNC_SMBUS_WRITE_WORD_DATA)
	I2C_FUNC_SMBUS_BLOCK_DATA = (I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
	I2C_FUNC_SMBUS_I2C_BLOCK  = (I2C_FUNC_SMBUS_READ_I2C_BLOCK | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
)
View Source
const I2CCLOCK_CHANGE = 0x0740

Variables

This section is empty.

Functions

func SMBusBlockProcessCall

func SMBusBlockProcessCall(fd uintptr, cmd uint8, b []byte) (v []byte, err error)

func SMBusProcessCall

func SMBusProcessCall(fd uintptr, cmd uint8, b uint16) (v uint16, err error)

func SMBusRead

func SMBusRead(fd uintptr, cmd uint8, size int) (b []byte, err error)

func SMBusWrite

func SMBusWrite(fd uintptr, cmd uint8, b ...uint8) error

func SMBusWriteQuick

func SMBusWriteQuick(fd uintptr, b uint8) error

func SPI_IOC_MESSAGE

func SPI_IOC_MESSAGE(n uintptr) uintptr

Write custom SPI message

func SPI_IOC_RD_BITS_PER_WORD

func SPI_IOC_RD_BITS_PER_WORD() uintptr

Read SPI device word length (1..N)

func SPI_IOC_RD_LSB_FIRST

func SPI_IOC_RD_LSB_FIRST() uintptr

Read SPI bit justification

func SPI_IOC_RD_MAX_SPEED_HZ

func SPI_IOC_RD_MAX_SPEED_HZ() uintptr

Read SPI device default max speed hz

func SPI_IOC_RD_MODE

func SPI_IOC_RD_MODE() uintptr

Read of SPI mode (SPI_MODE_0..SPI_MODE_3)

func SPI_IOC_WR_BITS_PER_WORD

func SPI_IOC_WR_BITS_PER_WORD() uintptr

Write SPI device word length (1..N)

func SPI_IOC_WR_LSB_FIRST

func SPI_IOC_WR_LSB_FIRST() uintptr

Write SPI bit justification

func SPI_IOC_WR_MAX_SPEED_HZ

func SPI_IOC_WR_MAX_SPEED_HZ() uintptr

Write SPI device default max speed hz

func SPI_IOC_WR_MODE

func SPI_IOC_WR_MODE() uintptr

Write of SPI mode (SPI_MODE_0..SPI_MODE_3)

func SPI_MESSAGE_SIZE

func SPI_MESSAGE_SIZE(n uintptr) uintptr

func SetBusFreq

func SetBusFreq(hz uint) error

Types

type I2C

type I2C struct {
	// contains filtered or unexported fields
}

I2C represents a connection to an i2c device.

func NewI2C

func NewI2C(addr uint, dev uint) (i *I2C, err error)

New opens a connection to an i2c device.

func (*I2C) Close

func (this *I2C) Close()

func (*I2C) Fd

func (this *I2C) Fd() uintptr

func (*I2C) Mask

func (this *I2C) Mask() uint64

func (*I2C) Read

func (this *I2C) Read(b []byte) error

Read receives bytes from the i2c device.

func (*I2C) Write

func (this *I2C) Write(buf ...byte) error

Write sends buf to the i2c device.

type SPIBus

type SPIBus interface {
	io.ReadWriteCloser
	WriteAndRead(p []byte) (n int, err error)
}

func OpenSPI

func OpenSPI(channel uint8, speed uint32, mode uint8) (device SPIBus, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL