qdec

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package qdec provides access to the registers of Quadrature Decoder (QDEC) peripheral.

Index

Constants

This section is empty.

Variables

View Source
var QDEC = (*Periph)(unsafe.Pointer(mmap.APB_BASE + 0x012000))

Functions

This section is empty.

Types

type Event

type Event byte
const (
	SAMPLERDY Event = 0 // New sample value written to the SAMPLE register.
	REPORTRDY Event = 1 // Non-null report ready.
	ACCOF     Event = 2 // ACC or ACCDBL register overflow.
	DBLRDY    Event = 3 // Double displacement(s) detected (nRF52).
	STOPPED   Event = 4 // QDEC has been stopped (nRF52).
)

type Periph

type Periph struct {
	te.Regs
	// contains filtered or unexported fields
}

func (*Periph) Event

func (p *Periph) Event(e Event) *te.Event

func (*Periph) LoadACC

func (p *Periph) LoadACC() int

LoadACC returns the accumulated valid transitions: [-1024..1023].

func (*Periph) LoadACCDBL

func (p *Periph) LoadACCDBL() int

LoadACCDBL returns the number of detected double transitions: [0..15].

func (*Periph) LoadACCDBLREAD

func (p *Periph) LoadACCDBLREAD() int

LoadACCDBLREAD returns the snapshot of the ACCDBL register, updated by the READCLRACC or RDCLRACC task.

func (*Periph) LoadACCREAD

func (p *Periph) LoadACCREAD() int

LoadACCREAD returns the snapshot of the ACC register, updated by the READCLRACC or RDCLRACC task.

func (*Periph) LoadDBFEN

func (p *Periph) LoadDBFEN() bool

LoadDBFEN reports whether the input debounce filters are enabled.

func (*Periph) LoadENABLE

func (p *Periph) LoadENABLE() bool

LoadENABLE reports whether the QDEC peripheral is enabled.

func (*Periph) LoadLEDPOL

func (p *Periph) LoadLEDPOL() int

LoadLEDPOL returns LED output pin polarity: 0 - active low, 1 - active high.

func (*Periph) LoadLEDPRE

func (p *Periph) LoadLEDPRE() int

LoadLEDPRE returns the time period the LED is switched on prior to sampling: [0..511] µs.

func (*Periph) LoadPSEL

func (p *Periph) LoadPSEL(s Signal) gpio.Pin

func (*Periph) LoadREPORTPER

func (p *Periph) LoadREPORTPER() ReportPeriod

LoadREPORTPER returns the sample period.

func (*Periph) LoadSAMPLE

func (p *Periph) LoadSAMPLE() int

LoadSAMPLE returns the last motion sample: -1, 1 or 2.

func (*Periph) LoadSAMPLEPER

func (p *Periph) LoadSAMPLEPER() SamplePeriod

LoadSAMPLEPER returns the sample period.

func (*Periph) LoadSHORTS

func (p *Periph) LoadSHORTS() Shorts

func (*Periph) StoreDBFEN

func (p *Periph) StoreDBFEN(en bool)

StoreDBFEN enables or disables the input debounce filters.

func (*Periph) StoreENABLE

func (p *Periph) StoreENABLE(en bool)

StoreENABLE enables or disables QDEC peripheral.

func (*Periph) StoreLEDPOL

func (p *Periph) StoreLEDPOL(polarity int)

StoreLEDPOL sets LED output pin polarity: 0 - active low, 1 - active high.

func (*Periph) StoreLEDPRE

func (p *Periph) StoreLEDPRE(us int)

StoreLEDPRE sets the time period the LED is switched on prior to sampling: [0..511] µs.

func (*Periph) StorePSEL

func (p *Periph) StorePSEL(s Signal, pin gpio.Pin)

func (*Periph) StoreREPORTPER

func (p *Periph) StoreREPORTPER(period ReportPeriod)

StoreREPORTPER sets the sample period.

func (*Periph) StoreSAMPLEPER

func (p *Periph) StoreSAMPLEPER(period SamplePeriod)

StoreSAMPLEPER sets the sample period.

func (*Periph) StoreSHORTS

func (p *Periph) StoreSHORTS(s Shorts)

func (*Periph) Task

func (p *Periph) Task(t Task) *te.Task

type ReportPeriod

type ReportPeriod byte
const (
	P10  ReportPeriod = 0 // 10 samples per report.
	P40  ReportPeriod = 1 // 40 samples per report.
	P80  ReportPeriod = 2 // 80 samples per report.
	P120 ReportPeriod = 3 // 120 samples per report.
	P160 ReportPeriod = 4 // 160 samples per report.
	P200 ReportPeriod = 5 // 200 samples per report.
	P240 ReportPeriod = 6 // 240 samples per report.
	P280 ReportPeriod = 7 // 280 samples per report.
	P1   ReportPeriod = 8 // 1 sample per report (nRF52).
)

type SamplePeriod

type SamplePeriod byte
const (
	P128us SamplePeriod = 0  // 128 µs
	P256us SamplePeriod = 1  // 256 µs
	P512us SamplePeriod = 2  // 512 µs
	P1ms   SamplePeriod = 3  // 1024 µs
	P2ms   SamplePeriod = 4  // 2048 µs
	P4ms   SamplePeriod = 5  // 4096 µs
	P8ms   SamplePeriod = 6  // 8192 µs
	P16ms  SamplePeriod = 7  // 16384 µs
	P33ms  SamplePeriod = 8  // 32768 µs (nRF52)
	P66ms  SamplePeriod = 9  // 65536 µs (nRF52)
	P131ms SamplePeriod = 10 // 131072 µs (nRF52)
)

type Shorts

type Shorts uint32
const (
	REPORTRDY_READCLRACC Shorts = 1 << 0
	SAMPLERDY_STOP       Shorts = 1 << 1
	REPORTRDY_RDCLRACC   Shorts = 1 << 2 // (nRF52)
	REPORTRDY_STOP       Shorts = 1 << 3 // (nRF52)
	DBLRDY_RDCLRDBL      Shorts = 1 << 4 // (nRF52)
	DBLRDY_STOP          Shorts = 1 << 5 // (nRF52)
	SAMPLERDY_READCLRACC Shorts = 1 << 6 // (nRF52)
)

type Signal

type Signal byte
const (
	LED Signal = 0 // LED output.
	A   Signal = 1 // Phase A input.
	B   Signal = 2 // Phase B input.
)

type Task

type Task byte
const (
	START      Task = 0 // Start the quadrature decoder.
	STOP       Task = 1 // Stop the quadrature decoder.
	READCLRACC Task = 2 // Read and clear ACC and ACCDBL.
	RDCLRACC   Task = 3 // Read and clear ACC (nRF52).
	RDCLRDBL   Task = 4 // Read and clear ACCDBL (nRF52).
)

Jump to

Keyboard shortcuts

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