Documentation ¶
Overview ¶
Package adc provides interface to STM32 Analog to Digital Converter peripheral. Additionaly it provides two drivers for easier use of ADC.
Index ¶
- type CircDriver
- func (d *CircDriver) Bytes(bh int32) []byte
- func (d *CircDriver) DMA() *dma.Channel
- func (d *CircDriver) DMAISR()
- func (d *CircDriver) Enable(calibrate bool)
- func (d *CircDriver) Err() error
- func (d *CircDriver) HandleChan() <-chan int32
- func (d *CircDriver) ISR()
- func (d *CircDriver) P() *Periph
- func (d *CircDriver) Start(wordSize, byteOffset uintptr)
- func (d *CircDriver) Stop()
- func (d *CircDriver) Words16(bh int32) []uint16
- type Driver
- type DriverError
- type Error
- type Event
- type Periph
- func (p *Periph) Bus() system.Bus
- func (p *Periph) Calibrate()
- func (p *Periph) Clear(ev Event, err Error)
- func (p *Periph) Disable()
- func (p *Periph) DisableClock()
- func (p *Periph) DisableDMA()
- func (p *Periph) DisableIRQ(ev Event, err Error)
- func (p *Periph) Enable()
- func (p *Periph) EnableClock(lp bool)
- func (p *Periph) EnableDMA(circural bool)
- func (p *Periph) EnableIRQ(ev Event, err Error)
- func (p *Periph) Enabled() bool
- func (p *Periph) Raw() *adc.ADC_Periph
- func (p *Periph) SetAlignLeft(alignLeft bool)
- func (p *Periph) SetSamplTime(ch int, st SamplTime)
- func (p *Periph) SetSequence(ch ...int)
- func (p *Periph) SetTrigEdge(edge TrigEdge)
- func (p *Periph) SetTrigSrc(src TrigSrc)
- func (p *Periph) Start()
- func (p *Periph) Status() (Event, Error)
- func (p *Periph) Stop()
- type SamplTime
- type TrigEdge
- type TrigSrc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircDriver ¶
type CircDriver struct {
// contains filtered or unexported fields
}
func NewCircDriver ¶
func NewCircDriver(p *Periph, ch *dma.Channel, chunkLen int) *CircDriver
NewCircDriver returns new circural driver using p and ch with internal buffers of total size 4*chunkLen bytes.
func (*CircDriver) Bytes ¶
func (d *CircDriver) Bytes(bh int32) []byte
func (*CircDriver) DMA ¶
func (d *CircDriver) DMA() *dma.Channel
func (*CircDriver) DMAISR ¶
func (d *CircDriver) DMAISR()
func (*CircDriver) Enable ¶
func (d *CircDriver) Enable(calibrate bool)
func (*CircDriver) Err ¶
func (d *CircDriver) Err() error
func (*CircDriver) HandleChan ¶
func (d *CircDriver) HandleChan() <-chan int32
HandleChan returns the channel that can be used to obtain buffer handles.
func (*CircDriver) ISR ¶
func (d *CircDriver) ISR()
func (*CircDriver) P ¶
func (d *CircDriver) P() *Periph
func (*CircDriver) Start ¶
func (d *CircDriver) Start(wordSize, byteOffset uintptr)
func (*CircDriver) Stop ¶
func (d *CircDriver) Stop()
func (*CircDriver) Words16 ¶
func (d *CircDriver) Words16(bh int32) []uint16
type Driver ¶
func (*Driver) SetReadMSB ¶
SetReadMSB sets most significant byte of 16-bit ADC data register to be read by Read and ReadByte methods.
type DriverError ¶
type DriverError byte
const (
ErrDrvOverrun DriverError = 1
)
func (DriverError) Error ¶
func (e DriverError) Error() string
type Periph ¶
type Periph struct {
// contains filtered or unexported fields
}
func (*Periph) Disable ¶
func (p *Periph) Disable()
Disable disables p. Use Enabled to check that p is effectively disabled.
func (*Periph) DisableClock ¶
func (p *Periph) DisableClock()
DisableClock disables clock for p. In some MCUs clock cannot be disabled for only one ADC, then DisableClock can affects a pair of peripherals (eg. ADC1.DisableClock() can affect ADC1 and ADC2 simultaneously).
func (*Periph) DisableDMA ¶
func (p *Periph) DisableDMA()
func (*Periph) DisableIRQ ¶
func (*Periph) EnableClock ¶
EnableClock enables clock for p. Lp determines whether the clock remains on in low power (sleep) mode. In some MCUs clock cannot be enabled for only one ADC, then EnableClock can affects a pair of peripherals (eg. ADC1.EnableClock() can affect ADC1 and ADC2 simultaneously).
func (*Periph) Raw ¶
func (p *Periph) Raw() *adc.ADC_Periph
func (*Periph) SetAlignLeft ¶
func (*Periph) SetSamplTime ¶
SetSamplTime sets sampling time for channel ch.
func (*Periph) SetSequence ¶
SetSequence sets regular sequence of channels.
func (*Periph) SetTrigEdge ¶
func (*Periph) SetTrigSrc ¶
SetTrigSrc selects source of external trigger.
type SamplTime ¶
type SamplTime int8
func MaxSamplTime ¶
MaxSamplTime returns the largest possible value of sampling time that takes no more than hc half clock cycles. If ht is too small MaxSamplTime returns negative value.
func (SamplTime) HalfCycles ¶
HalfCycles returns number of half clock cycles that st corresponds to.