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.
- Documentation: https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout/overview
- Arduino driver: https://github.com/adafruit/Adafruit_Seesaw
- Seesaw firmware: https://github.com/adafruit/seesaw
Index ¶
- Constants
- type Device
- func (d *Device) Read(module ModuleBaseAddress, function FunctionAddress, buf []byte) error
- func (d *Device) ReadRegister(module ModuleBaseAddress, function FunctionAddress) (byte, error)
- func (d *Device) SoftReset() error
- func (d *Device) Write(module ModuleBaseAddress, function FunctionAddress, buf []byte) error
- func (d *Device) WriteRegister(module ModuleBaseAddress, function FunctionAddress, value byte) error
- type FunctionAddress
- type ModuleBaseAddress
Constants ¶
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.
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 (*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) 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.