dma

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package dma provides uniform interface to the DMA controllers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

func (Channel) Clear

func (c Channel) Clear(ev Event, err Error)

Clear clears specified flags.

func (Channel) Disable

func (c Channel) Disable()

Disable disables channel.

func (Channel) DisableIRQ

func (c Channel) DisableIRQ(ev Event, err Error)

DisableIRQ disables IRQs generation by ev, err.

func (Channel) Enable

func (c Channel) Enable()

Enable enables the channel c. All events and errors should be cleared before call this method.

func (Channel) EnableIRQ

func (c Channel) EnableIRQ(ev Event, err Error)

EnableIRQ enables generation of IRQs by ev, err. Documentation does not mention it, but IRQ can be not generated if an event was asserted before enable IRQ for it. So always enable IRQs before channel. Typically, the correct sequence is as follows:

c.Clear(EvAll, ErrAll)
c.EnableIRQ(ev, err)
c.Enable()

func (Channel) Enabled

func (c Channel) Enabled() bool

Returns true if channel is enabled.

func (Channel) IRQEnabled

func (c Channel) IRQEnabled() (Event, Error)

IRQEnabled returns events that are enabled to generate interrupt requests.

func (Channel) Len

func (c Channel) Len() int

Len returns current number of words to transfer.

func (Channel) Prio

func (c Channel) Prio() Prio

func (Channel) SetAddrM

func (c Channel) SetAddrM(a unsafe.Pointer)

SetAddrM sets memory address.

func (Channel) SetAddrP

func (c Channel) SetAddrP(a unsafe.Pointer)

SetAddrP sets peripheral address (or memory source address in case of MTM).

func (Channel) SetLen

func (c Channel) SetLen(n int)

SetLen sets number of words to transfer (n <= 65535).

func (Channel) SetPrio

func (c Channel) SetPrio(prio Prio)

func (Channel) SetWordSize

func (c Channel) SetWordSize(p, m uintptr)

SetWordSize sets the word size (in bytes) for peripheral and memory side of transfer.

func (Channel) Setup

func (c Channel) Setup(m Mode)

Setup configures channel.

func (Channel) Status

func (c Channel) Status() (Event, Error)

Status returns current event and error flags.

func (Channel) WordSize

func (c Channel) WordSize() (p, m uintptr)

WordSize returns the current word size (in bytes) for peripheral and memory side of transfer.

type Controller

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

func DMA

func DMA(n int) *Controller

DMA returns n-th DMA controller. The first controller number is 1.

func (*Controller) Channel

func (d *Controller) Channel(sn, rn int) Channel

Channel returns the value that represents sn-th stream (channel in F1/Lx series nomenclature) with cn-th request channel (ignored in case of F1/Lx series). Channels with the same sn points to the same DMA stream so they can not be used concurently.

func (*Controller) DisableClock

func (d *Controller) DisableClock()

func (*Controller) EnableClock

func (d *Controller) EnableClock(lp bool)

EnableClock enables clock for port p. lp determines whether the clock remains on in low power (sleep) mode.

func (*Controller) Reset

func (d *Controller) Reset()

type Error

type Error uint8
const (
	ErrTransfer   Error = trerr // Transfer Error.
	ErrDirectMode Error = dmerr // Direct Mode Error.
	ErrFIFO       Error = fferr // FIFO Error.

	ErrAll = ErrTransfer | ErrDirectMode | ErrFIFO
)

func (Error) Error

func (err Error) Error() string

type Event

type Event uint8
const (
	Complete     Event = trce // Transfer Complete Event.
	HalfComplete Event = htce // Half Transfer Complete Event.

	EvAll = Complete | HalfComplete
)

type Mode

type Mode uint32
const (
	PTM Mode = 0   // Read from peripheral, write to memory.
	MTP Mode = mtp // Read from memory, write to peripheral.
	MTM Mode = mtm // Read from memory (AddrP), write to memory.

	Circ Mode = circ // Enable circular mode.
	IncP Mode = incP // Peripheral increment mode.
	IncM Mode = incM // Memory increment mode.
	PFC  Mode = pfc  // Peripheral flow controller.

	FT1 Mode = ft1 // FIFO mode, threshold 1/4.
	FT2 Mode = ft2 // FIFO mode, threshold 2/4.
	FT3 Mode = ft3 // FIFO mode, threshold 3/4.
	FT4 Mode = ft4 // FIFO mode, threshold 4/4.

	PB4  Mode = pb4  // Peripheral burst transfer, 4 beats.
	PB8  Mode = pb8  // Peripheral burst transfer, 8 beats.
	PB16 Mode = pb16 // Peripheral burst transfer, 16 beats.
	MB4  Mode = mb4  // Memory burst transfer, 4 beats.
	MB8  Mode = mb4  // Memory burst transfer, 4 beats.
	MB16 Mode = mb4  // Memory burst transfer, 4 beats.
)

type Prio

type Prio uint8

Prio describes DMA stream priority level.

const (
	Low      Prio = 0     // Low priority.
	Medium   Prio = prioM // Medium priority.
	High     Prio = prioH // High priority.
	VeryHigh Prio = prioV // Very high priority.
)

Jump to

Keyboard shortcuts

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