aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/AVR/XMEGA/LLD/DMAv1/xmega_dma_lld.h
blob: 5ffd1ec14717b4831ad84b70b94c719dae919da8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
    ChibiOS - Copyright (C) 2016..2018 Theodore Ateba

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

/**
 * @file    DMAv1/xmega_dma_lld.h
 * @brief   AVR XMEGA DMA low level driver header file.
 *
 * @addtogroup DMA
 * @{
 */

#ifndef XMEGA_DMA_LLD_H
#define XMEGA_DMA_LLD_H

/*==========================================================================*/
/* Driver constants.                                                        */
/*==========================================================================*/

/*==========================================================================*/
/* Driver pre-compile time settings.                                        */
/*==========================================================================*/

/*==========================================================================*/
/* Derived constants and error checks.                                      */
/*==========================================================================*/

/*==========================================================================*/
/* Driver data structures and types.                                        */
/*==========================================================================*/


/**
 * @brief   Programmable channel priority
 */

/**
 * @brief   DMA channels index
 */
typedef enum {
  DMA_CHANNEL0 = 0, /**< DMA channel 0. */
  DMA_CHANNEL1 = 1, /**< DMA channel 1. */
  DMA_CHANNEL2 = 2, /**< DMA channel 2. */
  DMA_CHANNEL3 = 3, /**< DMA channel 3. */
} dmachannelid_t;

/**
 * @brief   DMA possible addressing modes.
 */
typedef enum {
  DMA_ADDRMODE_STATIC = 0, /* Static addressing mode.       */
  DMA_ADDRMODE_INCRE  = 1, /* Incremental addressing mode.  */
  DMA_ADDRMODE_DECRE  = 2, /* Decremental addressing mode.  */
} dmaaddrmode_t;

/**
 * @brief   DMA possible double buffer modes settings.
 */
typedef enum {
  DMA_DBUFMODE_DISABLE  = 0, /* No double buffer enabled.                   */
  DMA_DBUFMODE_CH01     = 1, /* Double buffer enabled on channel01.         */
  DMA_DBUFMODE_CH23     = 2, /* Double buffer enabled on channel23.         */
  DMA_DBUFMODE_CH01CH23 = 3, /* Double buffer enabled on channe01 and 2/3.  */
} dmadbufmode_t;

/**
 * @brief   DMA possible channel burst mode.
 */
typedef enum {
  DMA_BURSTMODE_1BYTE = 0,  /* Burst mode is 1 byte.                        */
  DMA_BURSTMODE_2BYTE = 1,  /* Burst mode is 2 byte.                        */
  DMA_BURSTMODE_4BYTE = 2,  /* Burst mode is 4 byte.                        */
  DMA_BURSTMODE_8BYTE = 3,  /* Burst mode is 8 byte.                        */
} dmachannelburstmode_t;

/*==========================================================================*/
/* Driver macros.                                                           */
/*==========================================================================*/

/*==========================================================================*/
/* External declarations.                                                   */
/*==========================================================================*/

#ifdef __cplusplus
extern "C" {
#endif
void damReset(void);
void dmaConfigDoubleBuffering(DMA_DBUFMODE_t dbufMode);
void dmaSetPriority(DMA_PRIMODE_t priMode);
uint8_t dmaChannelIsOngoing(DMA_CH_t * channel);
uint8_t dmaIsOngoing(void);
uint8_t dmaChannelIsPending(DMA_CH_t * channel);
uint8_t dmaIsPending(void);
uint8_t dmaReturnStatusNonBlocking(DMA_CH_t * channel);
uint8_t dmaReturnStatusBlocking(DMA_CH_t * channel);

void dmaChannelEnable(DMA_CH_t * channel);
void dmaChannelDisable(DMA_CH_t * channel);
void dmaChannelReset(DMA_CH_t * channel);
void dmaSetIntLevel(DMA_CH_t * channel,
                      DMA_CH_TRNINTLVL_t transferInt,
                      DMA_CH_ERRINTLVL_t errorInt);
void dmaSetupBlock(DMA_CH_t * channel,
                     const void * srcAddr,
                     DMA_CH_SRCRELOAD_t srcReload,
                     DMA_CH_SRCDIR_t srcDirection,
                     void * destAddr,
                     DMA_CH_DESTRELOAD_t destReload,
                     DMA_CH_DESTDIR_t destDirection,
                     uint16_t blockSize,
                     DMA_CH_BURSTLEN_t burstMode,
                     uint8_t repeatCount,
                     bool useRepeat);
void dmaEnableSingleShot(DMA_CH_t * channel);
void dmaDisableSingleShot(DMA_CH_t * channel);
void dmaSetTriggerSource(DMA_CH_t * channel, uint8_t trigger);
void dmaStartTransfer(DMA_CH_t * channel);

#ifdef __cplusplus
}
#endif
//#endif /* HAL_USE_DMA */

#endif /* XMEGA_DMA_LLD_H */

/** @} */