seesaw

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package seesaw provides a driver implementation to communicate with Adafruit's seesaw chip. There are many Adafruit boards that use a seesaw. Soil moisture sensors, LED keyboards, etc.

Index

Constants

View Source
const DefaultAddress = 0x49

DefaultAddress is the I2C address the chips have by default. Most boards built on top of it come with their own respective default addresses.

View Source
const DefaultReadDelay = 100 * time.Millisecond

DefaultReadDelay is an empirically determined delay used when reading from the device, the one from the official library seems to be too short (250us)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Address   uint16
	ReadDelay time.Duration
	// contains filtered or unexported fields
}

func New

func New(bus drivers.I2C) *Device

func (*Device) Read

func (d *Device) Read(module ModuleBaseAddress, function FunctionAddress, buf []byte) error

Read reads a number of bytes from the device after sending the read command and waiting 'ReadDelay'. The delays depend on the module and function and are documented in the seesaw datasheet

func (*Device) ReadRegister

func (d *Device) ReadRegister(module ModuleBaseAddress, function FunctionAddress) (byte, error)

ReadRegister reads a single register from seesaw

func (*Device) SoftReset

func (d *Device) SoftReset() error

SoftReset triggers a soft-reset of seesaw and waits for it to be ready

func (*Device) Write

func (d *Device) Write(module ModuleBaseAddress, function FunctionAddress, buf []byte) error

Write writes data into a given module and function

func (*Device) WriteRegister

func (d *Device) WriteRegister(module ModuleBaseAddress, function FunctionAddress, value byte) error

WriteRegister writes a single seesaw register

type FunctionAddress

type FunctionAddress byte
const (
	FunctionGpioDirsetBulk FunctionAddress = 0x02
	FunctionGpioDirclrBulk FunctionAddress = 0x03
	FunctionGpioBulk       FunctionAddress = 0x04
	FunctionGpioBulkSet    FunctionAddress = 0x05
	FunctionGpioBulkClr    FunctionAddress = 0x06
	FunctionGpioBulkToggle FunctionAddress = 0x07
	FunctionGpioIntenset   FunctionAddress = 0x08
	FunctionGpioIntenclr   FunctionAddress = 0x09
	FunctionGpioIntflag    FunctionAddress = 0x0A
	FunctionGpioPullenset  FunctionAddress = 0x0B
	FunctionGpioPullenclr  FunctionAddress = 0x0C
)

GPIO module function address registers

const (
	FunctionStatusHwId    FunctionAddress = 0x01
	FunctionStatusVersion FunctionAddress = 0x02
	FunctionStatusOptions FunctionAddress = 0x03
	FunctionStatusTemp    FunctionAddress = 0x04
	FunctionStatusSwrst   FunctionAddress = 0x7F
)

status module function address registers

const (
	FunctionTimerStatus FunctionAddress = 0x00
	FunctionTimerPwm    FunctionAddress = 0x01
	FunctionTimerFreq   FunctionAddress = 0x02
)

timer module function address registers

const (
	FunctionAdcStatus        FunctionAddress = 0x00
	FunctionAdcInten         FunctionAddress = 0x02
	FunctionAdcIntenclr      FunctionAddress = 0x03
	FunctionAdcWinmode       FunctionAddress = 0x04
	FunctionAdcWinthresh     FunctionAddress = 0x05
	FunctionAdcChannelOffset FunctionAddress = 0x07
)

ADC module function address registers

const (
	FunctionSercomStatus   FunctionAddress = 0x00
	FunctionSercomInten    FunctionAddress = 0x02
	FunctionSercomIntenclr FunctionAddress = 0x03
	FunctionSercomBaud     FunctionAddress = 0x04
	FunctionSercomData     FunctionAddress = 0x05
)

Sercom module function address registers

const (
	FunctionNeopixelStatus    FunctionAddress = 0x00
	FunctionNeopixelPin       FunctionAddress = 0x01
	FunctionNeopixelSpeed     FunctionAddress = 0x02
	FunctionNeopixelBufLength FunctionAddress = 0x03
	FunctionNeopixelBuf       FunctionAddress = 0x04
	FunctionNeopixelShow      FunctionAddress = 0x05
)

neopixel module function address registers

const (
	FunctionKeypadStatus   FunctionAddress = 0x00
	FunctionKeypadEvent    FunctionAddress = 0x01
	FunctionKeypadIntenset FunctionAddress = 0x02
	FunctionKeypadIntenclr FunctionAddress = 0x03
	FunctionKeypadCount    FunctionAddress = 0x04
	FunctionKeypadFifo     FunctionAddress = 0x10
)

keypad module function address registers

const (
	FunctionTouchChannelOffset FunctionAddress = 0x10
)

touch module function address registers

type ModuleBaseAddress

type ModuleBaseAddress byte
const (
	ModuleStatusBase  ModuleBaseAddress = 0x00
	ModuleGpioBase    ModuleBaseAddress = 0x01
	ModuleSercom0Base ModuleBaseAddress = 0x02

	ModuleTimerBase     ModuleBaseAddress = 0x08
	ModuleAdcBase       ModuleBaseAddress = 0x09
	ModuleDacBase       ModuleBaseAddress = 0x0A
	ModuleInterruptBase ModuleBaseAddress = 0x0B
	ModuleDapBase       ModuleBaseAddress = 0x0C
	ModuleEepromBase    ModuleBaseAddress = 0x0D
	ModuleNeoPixelBase  ModuleBaseAddress = 0x0E
	ModuleTouchBase     ModuleBaseAddress = 0x0F
	ModuleKeypadBase    ModuleBaseAddress = 0x10
	ModuleEncoderBase   ModuleBaseAddress = 0x11
	ModuleSpectrumBase  ModuleBaseAddress = 0x12
)

Module Base Addreses The module base addresses for different seesaw modules.

Jump to

Keyboard shortcuts

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