mcp2210

package module
v0.0.0-...-54466c0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2015 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

A wrapper library for Microchip's MCP2210 USB-to-SPI Bridge. It is heavly based on github.com/GeertJohan/go.hid.

Index

Constants

View Source
const (
	// Pin direction: input
	DirectionIn = 0x00
	// Pin direction: output
	DirectionOut = 0x01

	// Pin value: inactive/low
	ValueInactive = 0x00
	// Pin value: active/high
	ValueActive = 0x01

	// Pin function: GPIO
	FunctionGPIO = 0x00
	// Pin function: SPI Chip-Select
	FunctionChipSelect = 0x01
	// Pin function: Alternative
	FunctionAlternative = 0x02
)

GPIO constants

Variables

This section is empty.

Functions

This section is empty.

Types

type MCP2210

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

func Open

func Open(vendorId uint16, productId uint16) (*MCP2210, error)

Opens a MCP2210 device with the given VendorId and ProductId.

func (*MCP2210) Close

func (this *MCP2210) Close()

Closes the connection to the device.

func (*MCP2210) GetBytesPerTransfer

func (this *MCP2210) GetBytesPerTransfer() int

func (*MCP2210) GetGPIOValue

func (this *MCP2210) GetGPIOValue(pin uint16) (uint8, error)

Get the current value of a GPIO pin. Returns ValueInactive or ValueActive.

func (*MCP2210) GetInterruptCount

func (this *MCP2210) GetInterruptCount() (uint16, error)

Gets the external interrupt counter value and resets it to zero. Interrupt signaling is available on GP6, if it is configured with alternative pin function.

func (*MCP2210) GetSPIClock

func (this *MCP2210) GetSPIClock() uint32

Returns the currently used SPI clock in Hz.

func (*MCP2210) ReadEEPROM

func (this *MCP2210) ReadEEPROM(address byte) (byte, error)

Reads the byte stored at a specific address in EEPROM.

func (*MCP2210) SetGPIOValue

func (this *MCP2210) SetGPIOValue(pin uint16, state uint16) error

Sets the value of a GPIO pin. pin Number of the pin to set. state New pinstate, use ValueInactive or ValueActive

func (*MCP2210) WriteEEPROM

func (this *MCP2210) WriteEEPROM(address byte, data byte) error

Writes data to the specified Address in EEPROM.

func (*MCP2210) Xfer

func (this *MCP2210) Xfer(sendBuffer []byte) ([]byte, error)

Sends some bytes and returns the received bytes

Jump to

Keyboard shortcuts

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