gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
dma.h
1
2/*
3 * MIT License
4 *
5 * Copyright (c) 2022 Joey Castillo
6 * Based heavily on Adafruit_ZeroDMA
7 * Written by Phil "PaintYourDragon" Burgess for Adafruit Industries,
8 * based partly on DMA insights from Atmel ASFCORE 3.
9 *
10 * Adafruit invests time and resources providing this open source code,
11 * please support Adafruit and open-source hardware by purchasing
12 * products from Adafruit!
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this software and associated documentation files (the "Software"), to deal
16 * in the Software without restriction, including without limitation the rights
17 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 * copies of the Software, and to permit persons to whom the Software is
19 * furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in all
22 * copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#pragma once
34
35#include <stdint.h>
36#include <stdbool.h>
37#include "dma_util.h"
38
45typedef struct {
46 uint8_t channel;
47 volatile dma_status_t jobStatus;
48 bool hasDescriptors;
49 bool loopFlag;
50 void (*callbacks[DMA_CALLBACK_N])(void *);
51 dma_beat_size_t beatSize;
52 dma_address_increment_t addressIncrement;
53 dma_stepsize_t stepSize;
54 dma_stepsel_t stepSel;
55 dma_block_action_t blockAction;
56 dma_event_output_selection_t eventOutputSelection;
58
61void dma_init(void);
62
65void dma_enable(void);
66
69void dma_disable(void);
70
92bool dma_configure(gossamer_dma_job_t *dmaJob, uint8_t peripheralTrigger, dma_trigger_action_t triggerAction, dma_configuration_flags_t flags);
93
98void dma_set_priority(gossamer_dma_job_t *dmaJob, dma_priority_t priority);
99
118DmacDescriptor *dma_add_descriptor(gossamer_dma_job_t *dmaJob, void *src, void *dst, uint32_t count);
119
128
132void dma_stop_job(gossamer_dma_job_t *dmaJob);
133
139
144
150void dma_trigger(gossamer_dma_job_t *dmaJob);
151
156void dma_set_event_input(gossamer_dma_job_t *dmaJob, dma_event_input_action_t action);
157
162void dma_set_event_output(gossamer_dma_job_t *dmaJob, bool enabled);
163
void dma_set_priority(gossamer_dma_job_t *dmaJob, dma_priority_t priority)
Sets the priority level for a DMA channel.
Definition dma.c:311
bool dma_start_job(gossamer_dma_job_t *dmaJob)
Starts a configured DMA job.
Definition dma.c:382
void dma_init(void)
Initializes the DMA system (clocks, descriptor memory, interrupts), but does not enable it.
Definition dma.c:232
void dma_disable(void)
Disables the DMA controller.
Definition dma.c:270
void dma_set_event_output(gossamer_dma_job_t *dmaJob, bool enabled)
Enables or disables event output for a DMA channel.
Definition dma.c:323
void dma_set_event_input(gossamer_dma_job_t *dmaJob, dma_event_input_action_t action)
Configures event input action for a DMA channel.
Definition dma.c:317
void dma_stop_job(gossamer_dma_job_t *dmaJob)
Stops a running DMA job and aborts the transfer.
Definition dma.c:408
DmacDescriptor * dma_add_descriptor(gossamer_dma_job_t *dmaJob, void *src, void *dst, uint32_t count)
Adds a transfer descriptor to a DMA job.
Definition dma.c:329
void dma_trigger(gossamer_dma_job_t *dmaJob)
Issues a software trigger to a DMA channel.
Definition dma.c:430
bool dma_configure(gossamer_dma_job_t *dmaJob, uint8_t peripheralTrigger, dma_trigger_action_t triggerAction, dma_configuration_flags_t flags)
Allocates a DMA channel and configures a job.
Definition dma.c:274
void dma_suspend_job(gossamer_dma_job_t *dmaJob)
Suspends a running DMA job.
Definition dma.c:416
void dma_resume_job(gossamer_dma_job_t *dmaJob)
Resumes a suspended DMA job.
Definition dma.c:423
void dma_enable(void)
Enables the DMA controller.
Definition dma.c:266
Definition dma.h:45