mcp3w0c

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mcp3w0c provides bit bashed device drivers for MCP3004/3008/3204/3208 SPI ADCs.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("closed")

ErrClosed indicates the ADC is closed.

Functions

This section is empty.

Types

type MCP3w0c

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

MCP3w0c reads ADC values from a connected Microchip MCP3xxx family device.

Supported variants are MCP3004/3008/3204/3208. The w indicates the width of the device (0 => 10, 2 => 12) and the c the number of channels.

func New

func New(c *gpiod.Chip, clk, csz, di, do int, width uint, options ...Option) (*MCP3w0c, error)

New creates a MCP3w0c.

func NewMCP3008

func NewMCP3008(c *gpiod.Chip, clk, csz, di, do int, options ...Option) (*MCP3w0c, error)

NewMCP3008 creates a MCP3008.

func NewMCP3208

func NewMCP3208(c *gpiod.Chip, clk, csz, di, do int, options ...Option) (*MCP3w0c, error)

NewMCP3208 creates a MCP3208.

func (*MCP3w0c) Close

func (adc *MCP3w0c) Close() error

Close releases all resources allocated to the ADC.

func (*MCP3w0c) Read

func (adc *MCP3w0c) Read(ch int) (uint16, error)

Read returns the value of a single channel read from the ADC.

func (*MCP3w0c) ReadDifferential

func (adc *MCP3w0c) ReadDifferential(ch int) (uint16, error)

ReadDifferential returns the value of a differential pair read from the ADC.

type Option

type Option func(*MCP3w0c)

Option specifies a construction option for the ADC.

func WithTclk

func WithTclk(tclk time.Duration) Option

WithTclk sets the clock period for the ADC.

Note that this is the half-cycle period.

func WithTset

func WithTset(tset time.Duration) Option

WithTset sets the settling period for the ADC.

Jump to

Keyboard shortcuts

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