summaryrefslogtreecommitdiff
path: root/bsp/efm32/drv_dma.c
blob: a73c5709f145117f7f4d1d05c952faa68b04d91c (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
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date         Author      Notes
 * 2010-12-23   onelife     Initial creation for EFM32
 */

/***************************************************************************//**
 * @addtogroup efm32
 * @{
 ******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "board.h"
#include "drv_dma.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/** DMA control block, requires proper alignment. */
#if defined (__ICCARM__)
#pragma data_alignment=256
DMA_DESCRIPTOR_TypeDef dmaControlBlock[DMA_CHAN_COUNT * 2];
#elif defined (__CC_ARM)
DMA_DESCRIPTOR_TypeDef dmaControlBlock[DMA_CHAN_COUNT * 2] __attribute__ ((aligned(256)));
#elif defined (__GNUC__)
DMA_DESCRIPTOR_TypeDef dmaControlBlock[DMA_CHAN_COUNT * 2] __attribute__ ((aligned(256)));
#else
#error Undefined toolkit, need to define alignment
#endif

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/***************************************************************************//**
 * @brief
 *    Initialize DMA hardware
 *
 * @details
 *
 * @note
 ******************************************************************************/
void rt_hw_dma_init(void)
{
    DMA_Init_TypeDef        dmaInit;

    /* Reset */
    DMA_Reset();

    dmaInit.hprot           = 0;
    dmaInit.controlBlock    = (DMA_DESCRIPTOR_TypeDef *)&dmaControlBlock;
    DMA_Init(&dmaInit);
    NVIC_SetPriority(DMA_IRQn, EFM32_IRQ_PRI_DEFAULT);
}

/***************************************************************************//**
 * @}
 ******************************************************************************/