1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2013, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
30 /** \addtogroup dmad_module
\r
32 * \section DmaHw Dma Hardware Interface Usage
\r
34 * <li> The DMA controller can handle the transfer between peripherals and memory
\r
35 * and so receives the triggers from the peripherals. The hardware interface number
\r
36 * are getting from DMAIF_Get_ChannelNumber().</li>
\r
38 * <li> DMAIF_IsValidatedPeripherOnDma() helps to check if the given DMAC has associated
\r
39 * peripheral identifier coded by the given peripheral.</li>
\r
47 /*----------------------------------------------------------------------------
\r
49 *----------------------------------------------------------------------------*/
\r
52 /*----------------------------------------------------------------------------
\r
54 *----------------------------------------------------------------------------*/
\r
55 /** Array of DMA Channel definition for SAMv7 chip*/
\r
56 static const XdmaHardwareInterface xdmaHwIf[] = {
\r
57 /* dmac, peripheral, T/R, Channel Number*/
\r
58 {0, ID_HSMCI, 0, 0},
\r
59 {0, ID_HSMCI, 1, 0},
\r
66 {0, ID_USART0, 0, 7},
\r
67 {0, ID_USART0, 1, 8},
\r
68 {0, ID_USART1, 0, 9},
\r
69 {0, ID_USART1, 1, 10},
\r
70 {0, ID_USART2, 0, 11},
\r
71 {0, ID_USART2, 1, 12},
\r
72 {0, ID_PWM0, 0, 13},
\r
73 {0, ID_TWI0, 0, 14},
\r
74 {0, ID_TWI0, 1, 15},
\r
75 {0, ID_TWI1, 0, 16},
\r
76 {0, ID_TWI1, 1, 17},
\r
77 {0, ID_TWI2, 0, 18},
\r
78 {0, ID_TWI2, 1, 19},
\r
79 {0, ID_UART0, 0, 20},
\r
80 {0, ID_UART0, 1, 21},
\r
81 {0, ID_UART1, 0, 22},
\r
82 {0, ID_UART1, 1, 23},
\r
83 {0, ID_UART2, 0, 24},
\r
84 {0, ID_UART2, 1, 25},
\r
85 {0, ID_UART3, 0, 26},
\r
86 {0, ID_UART3, 1, 27},
\r
87 {0, ID_UART4, 0, 28},
\r
88 {0, ID_UART4, 1, 29},
\r
89 {0, ID_DACC, 0, 30},
\r
90 {0, ID_DACC, 0, 31},
\r
93 {0, ID_PIOA, 1, 34},
\r
94 {0, ID_AFEC0, 1, 35},
\r
95 {0, ID_AFEC1, 1, 36},
\r
98 {0, ID_PWM1, 0, 39},
\r
100 {0, ID_TC1, 1, 41},
\r
101 {0, ID_TC2, 1, 42},
\r
102 {0, ID_TC3, 1, 43},
\r
109 /*----------------------------------------------------------------------------
\r
110 * Exported functions
\r
111 *----------------------------------------------------------------------------*/
\r
114 * \brief Get peripheral identifier coded for hardware handshaking interface
\r
116 * \param bDmac DMA Controller number.
\r
117 * \param bPeriphID Peripheral ID.
\r
118 * \param bTransfer Transfer type 0: Tx, 1 :Rx.
\r
119 * \return 0-15 peripheral identifier coded.
\r
120 * 0xff : no associated peripheral identifier coded.
\r
122 uint8_t XDMAIF_Get_ChannelNumber (uint8_t bPeriphID,
\r
126 uint8_t NumOfPeripheral = ((XDMAC_GetType(XDMAC) & 0x00FF0000) >> 16);
\r
127 for (i = 0; i <=NumOfPeripheral; i++)
\r
129 if ( (xdmaHwIf[i].bPeriphID == bPeriphID) && (xdmaHwIf[i].bTransfer == bTransfer))
\r
131 return xdmaHwIf[i].bIfID;
\r
138 * \brief Check if the given DMAC has associated peripheral identifier coded by
\r
139 * the given peripheral.
\r
141 * \param bDmac DMA Controller number.
\r
142 * \param bPeriphID Peripheral ID (0xff : memory only).
\r
143 * \return 1: Is a validated peripher. 0: no associated peripheral identifier coded.
\r
145 uint8_t XDMAIF_IsValidatedPeripherOnDma( uint8_t bPeriphID)
\r
148 uint8_t NumOfPeripheral = ((XDMAC_GetType(XDMAC) & 0x00FF0000) >> 16);
\r
149 /* It is always validated when transfer to memory */
\r
150 if (bPeriphID == 0xFF) {
\r
154 for (i = 0; i <=NumOfPeripheral; i++)
\r
156 if ((xdmaHwIf[i].bPeriphID == bPeriphID))
\r