added loopback example with adc samples and dac playback
[pcm-lib.git] / source / soc-codec / Kinets / dma / edma_mk60f.c
blob782f08933d6b73d7a90b52151f9738d06552abb9
1 **HEADER********************************************************************
3 * Copyright (c) 2013 Freescale Semiconductor;
4 * All Rights Reserved
6 ***************************************************************************
8 * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
9 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
10 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11 * IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
12 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
14 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
15 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
16 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
17 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
18 * THE POSSIBILITY OF SUCH DAMAGE.
20 **************************************************************************
22 * $FileName: edma_mk60f.c$
23 * $Version : 4.0.1.0$
24 * $Date : May-14-2013$
26 * Comments:
28 * This file contains CPU specific eDMA functions.
30 *END************************************************************************/
32 #include <mqx.h>
33 #include <bsp.h>
34 #include "edma.h"
37 static const uint_32 /*PSP_INTERRUPT_TABLE_INDEX*/ edma_done_vectors[][16] =
40 INT_DMA0_DMA16,
41 INT_DMA1_DMA17,
42 INT_DMA2_DMA18,
43 INT_DMA3_DMA19,
44 INT_DMA4_DMA20,
45 INT_DMA5_DMA21,
46 INT_DMA6_DMA22,
47 INT_DMA7_DMA23,
48 INT_DMA8_DMA24,
49 INT_DMA9_DMA25,
50 INT_DMA10_DMA26,
51 INT_DMA11_DMA27,
52 INT_DMA12_DMA28,
53 INT_DMA13_DMA29,
54 INT_DMA14_DMA30,
55 INT_DMA15_DMA31
61 static const uint_32 /*PSP_INTERRUPT_TABLE_INDEX*/ edma_error_vectors[][1] =
64 INT_DMA_Error
70 /*FUNCTION*-------------------------------------------------------------------
72 * Function Name : _bsp_get_edma_done_vectors
73 * Returned Value : Number of vectors associated with the peripheral
74 * Comments :
75 * This function returns desired interrupt vector table indices for specified module.
77 *END*----------------------------------------------------------------------*/
79 int _bsp_get_edma_done_vectors(uint_32 dev_num, const uint_32 _PTR_ _PTR_ vectors_ptr)
81 if (dev_num < ELEMENTS_OF(edma_done_vectors)) {
82 *vectors_ptr = edma_done_vectors[dev_num];
83 return ELEMENTS_OF(edma_done_vectors[0]);
85 return 0;
89 /*FUNCTION*-------------------------------------------------------------------
91 * Function Name : _bsp_get_edma_error_vector
92 * Returned Value : Number of vectors associated with the peripheral
93 * Comments :
94 * This function returns desired interrupt vector table indices for specified module.
96 *END*----------------------------------------------------------------------*/
98 int _bsp_get_edma_error_vectors(uint_32 dev_num, const uint_32 _PTR_ _PTR_ vectors_ptr)
100 if (dev_num < ELEMENTS_OF(edma_error_vectors)) {
101 *vectors_ptr = edma_error_vectors[dev_num];
102 return ELEMENTS_OF(edma_error_vectors[0]);
104 return 0;
108 /*FUNCTION*-------------------------------------------------------------------
110 * Function Name : _bsp_edma_enable
111 * Returned Value :
112 * Comments :
113 * The function performs necessary operations to enable eDMA module
115 *END*----------------------------------------------------------------------*/
117 int _bsp_edma_enable(uint_32 dev_num)
119 /* Enable DMAMUX clock */
120 SIM_SCGC6 |= SIM_SCGC6_DMAMUX0_MASK;
121 SIM_SCGC6 |= SIM_SCGC6_DMAMUX1_MASK;
123 /* Enable DMA clock */
124 SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;
126 return 0;