mcp23xxx

package
v0.0.0-...-ec12ae0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mcp23xxx controls a Microchip MCP23xxx series I/O Expander over I²C or SPI.

Datasheets for supported devices

MCP23008 / MCP23S08 :

http://ww1.microchip.com/downloads/en/DeviceDoc/MCP23008-MCP23S08-Data-Sheet-20001919F.pdf

MCP23009 / MCP23S09 :

http://ww1.microchip.com/downloads/en/DeviceDoc/20002121C.pdf

MCP23017 / MCP23S17 :

http://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf

MCP23018 / MCP23S18 :

http://ww1.microchip.com/downloads/en/DeviceDoc/22103a.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dev

type Dev struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Dev is a handle to an initialized MCP23xxx device.

It implements conn.Resource.

func New

func New(opts *Opts) (*Dev, error)

New returns a handle to a MCP23xxx I/O expander.

func (*Dev) Halt

func (d *Dev) Halt() error

Halt halts each GPIO pin (implements conn.Resource).

func (*Dev) String

func (d *Dev) String() string

String returns a human readable identifier representing this resource in a descriptive way for the user (implements conn.Resource).

type IFCfg

type IFCfg func(*Dev) error

IFCfg represents a function to configure the communication interface.

func I2C

func I2C(bus i2c.Bus) IFCfg

I2C configures the device to work on I²C.

func SPI

func SPI(port spi.Port, f physic.Frequency) IFCfg

SPI configures the device to work on SPI.

type INTPinFunc

type INTPinFunc int

INTPinFunc represents the configuration of INT pin. Refer to datasheet for possible modes.

const (
	// Active driver, active-low (default).
	INTActiveLow INTPinFunc = iota
	// Active driver, active-high.
	INTActiveHigh
	// Open-drain.
	INTOpenDrain
)

Possible INT pin configurations.

type Opts

type Opts struct {
	// Chip model.
	Model string
	// Hardware address (refer to datasheet).
	HWAddr uint8
	// Interface configuration function.
	IFCfg
	// GPIO pin for capturing interrupts. If given, it must be already configured.
	IRQPin gpio.PinIn
	// INT pin configuration.
	INTPinFunc
}

Opts holds the configuration options for the device.

Jump to

Keyboard shortcuts

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