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
45#ifndef _SAMD51_
46
47typedef struct {
48 uint8_t channel; // (0 to DMAC_CH_NUM-1, or 0xFF)
49 volatile dma_status_t jobStatus; // Last known DMA job status
50 bool hasDescriptors; // 'true' if one or more descriptors assigned
51 bool loopFlag; // 'true' if descriptor chain loops back to start
52 void (*callbacks[DMA_CALLBACK_N])(void *); // Callback function (is passed an instance of this struct)
54
61void dma_init(void);
62
79bool dma_configure(gossamer_dma_job_t *dmaJob, uint8_t peripheralTrigger, dma_trigger_action_t triggerAction, dma_configuration_flags_t flags);
80
109DmacDescriptor *dma_add_descriptor(gossamer_dma_job_t *dmaJob, void *src, void *dst, uint32_t count, dma_beat_size_t size, dma_address_increment_t addressIncrement, dma_stepsize_t stepSize, dma_stepsel_t stepSel);
110
111bool dma_start_job(gossamer_dma_job_t *dmaJob);
112
113#endif
114
void dma_init(void)
Initialize the DMA system.
Definition dma.c:88
DmacDescriptor * dma_add_descriptor(gossamer_dma_job_t *dmaJob, void *src, void *dst, uint32_t count, dma_beat_size_t size, dma_address_increment_t addressIncrement, dma_stepsize_t stepSize, dma_stepsel_t stepSel)
Adds a descriptor to a DMA job.
Definition dma.c:153
bool dma_configure(gossamer_dma_job_t *dmaJob, uint8_t peripheralTrigger, dma_trigger_action_t triggerAction, dma_configuration_flags_t flags)
Configures a DMA job.
Definition dma.c:112
Definition dma.h:47