source: rtems/c/src/lib/libbsp/arm/atsam/libraries/libchip/source/xdma_hardware_interface.c @ e1eeb883

5
Last change on this file since e1eeb883 was e1eeb883, checked in by Sebastian Huber <sebastian.huber@…>, on 01/12/16 at 14:34:31

bsp/atsam: Import SAM Software Package

Import selected files of the "SAM V71 / V70 / E70 / S70 Software
Package" obtained from the "SAMV71-XULT GNU Software Package 1.5".

Converted files via dos2unix before import.

Update #2529.

  • Property mode set to 100644
File size: 6.3 KB
Line 
1/* ---------------------------------------------------------------------------- */
2/*                  Atmel Microcontroller Software Support                      */
3/*                       SAM Software Package License                           */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation                                        */
6/*                                                                              */
7/* All rights reserved.                                                         */
8/*                                                                              */
9/* Redistribution and use in source and binary forms, with or without           */
10/* modification, are permitted provided that the following condition is met:    */
11/*                                                                              */
12/* - Redistributions of source code must retain the above copyright notice,     */
13/* this list of conditions and the disclaimer below.                            */
14/*                                                                              */
15/* Atmel's name may not be used to endorse or promote products derived from     */
16/* this software without specific prior written permission.                     */
17/*                                                                              */
18/* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
28/* ---------------------------------------------------------------------------- */
29
30/** \addtogroup dmad_module
31 *
32 * \section DmaHw Dma Hardware Interface Usage
33 * <ul>
34 * <li> The DMA controller can handle the transfer between peripherals and memory
35 * and so receives the triggers from the peripherals. The hardware interface
36 * number are getting from DMAIF_Get_ChannelNumber().</li>
37
38 * <li> DMAIF_IsValidatedPeripherOnDma() helps to check if the given DMAC has
39 * associated peripheral identifier coded by the given  peripheral.</li>
40 *
41 * </ul>
42 */
43/*@{*/
44/*@}*/
45
46/** \file */
47/*----------------------------------------------------------------------------
48 *        Headers
49 *----------------------------------------------------------------------------*/
50#include "chip.h"
51
52/*----------------------------------------------------------------------------
53 *        Local variables
54 *----------------------------------------------------------------------------*/
55/** Array of DMA Channel definition for SAMv7 chip*/
56static const XdmaHardwareInterface xdmaHwIf[] = {
57        /* xdmac, peripheral,  T/R, HW interface number*/
58        {0,   ID_HSMCI,     0,      0},
59        {0,   ID_HSMCI,     1,      0},
60        {0,   ID_SPI0,      0,      1},
61        {0,   ID_SPI0,      1,      2},
62        {0,   ID_SPI1,      0,      3},
63        {0,   ID_SPI1,      1,      4},
64        {0,   ID_QSPI,      0,      5},
65        {0,   ID_QSPI,      1,      6},
66        {0,   ID_USART0,    0,      7},
67        {0,   ID_USART0,    1,      8},
68        {0,   ID_USART1,    0,      9},
69        {0,   ID_USART1,    1,      10},
70        {0,   ID_USART2,    0,      11},
71        {0,   ID_USART2,    1,      12},
72        {0,   ID_PWM0,      0,      13},
73        {0,   ID_TWIHS0,    0,      14},
74        {0,   ID_TWIHS0,    1,      15},
75        {0,   ID_TWIHS1,    0,      16},
76        {0,   ID_TWIHS1,    1,      17},
77        {0,   ID_TWIHS2,    0,      18},
78        {0,   ID_TWIHS2,    1,      19},
79        {0,   ID_UART0,     0,      20},
80        {0,   ID_UART0,     1,      21},
81        {0,   ID_UART1,     0,      22},
82        {0,   ID_UART1,     1,      23},
83        {0,   ID_UART2,     0,      24},
84        {0,   ID_UART2,     1,      25},
85        {0,   ID_UART3,     0,      26},
86        {0,   ID_UART3,     1,      27},
87        {0,   ID_UART4,     0,      28},
88        {0,   ID_UART4,     1,      29},
89        {0,   ID_DACC,      0,      30},
90        {0,   ID_DACC,      0,      31},
91        {0,   ID_SSC,       0,      32},
92        {0,   ID_SSC,       1,      33},
93        {0,   ID_PIOA,      1,      34},
94        {0,   ID_AFEC0,     1,      35},
95        {0,   ID_AFEC1,     1,      36},
96        {0,   ID_AES,       0,      37},
97        {0,   ID_AES,       1,      38},
98        {0,   ID_PWM1,      0,      39},
99        {0,   ID_TC0,       1,      40},
100        {0,   ID_TC1,       1,      41},
101        {0,   ID_TC2,       1,      42},
102        {0,   ID_TC3,       1,      43},
103};
104
105
106/*----------------------------------------------------------------------------
107 *        Exported functions
108 *----------------------------------------------------------------------------*/
109
110/**
111 * \brief Get peripheral identifier coded for hardware handshaking interface
112 *
113 * \param bDmac      DMA Controller number.
114 * \param bPeriphID  Peripheral ID.
115 * \param bTransfer  Transfer type 0: Tx, 1 :Rx.
116 * \return 0-15 peripheral identifier coded.
117 *         0xff : no associated peripheral identifier coded.
118 */
119uint8_t XDMAIF_Get_ChannelNumber (uint8_t bPeriphID,
120                                                                  uint8_t bTransfer)
121{
122        uint8_t i;
123        uint8_t NumOfPeripheral = ((XDMAC_GetType(XDMAC) & 0x00FF0000) >> 16);
124
125        for (i = 0; i <= NumOfPeripheral; i++) {
126                if ((xdmaHwIf[i].bPeriphID == bPeriphID) &&
127                         (xdmaHwIf[i].bTransfer == bTransfer))
128                        return xdmaHwIf[i].bIfID;
129        }
130
131        return 0xff;
132}
133
134/**
135 * \brief Check if the given DMAC has associated peripheral identifier coded by
136 * the given  peripheral.
137 *
138 * \param bDmac      DMA Controller number.
139 * \param bPeriphID  Peripheral ID (0xff : memory only).
140 * \return 1:  Is a validated peripheral. 0: no associated peripheral identifier
141 * coded.
142 */
143uint8_t XDMAIF_IsValidatedPeripherOnDma(uint8_t bPeriphID)
144{
145        uint8_t i;
146        uint8_t NumOfPeripheral = ((XDMAC_GetType(XDMAC) & 0x00FF0000) >> 16);
147
148        /* It is always validated when transfer to memory */
149        if (bPeriphID == 0xFF)
150                return 1;
151
152        for (i = 0; i <= NumOfPeripheral; i++) {
153                if ((xdmaHwIf[i].bPeriphID == bPeriphID))
154                        return 1;
155        }
156
157        return 0;
158}
Note: See TracBrowser for help on using the repository browser.