Use DMA for SCSI and SD card transfers for a massive performance boost.
[SCSI2SD-V6.git] / software / SCSI2SD / SCSI2SD.cydsn / Generated_Source / PSoC5 / SD_RX_DMA_dma.c
1 /***************************************************************************
2 * File Name: SD_RX_DMA_dma.c  
3 * Version 1.70
4 *
5 *  Description:
6 *   Provides an API for the DMAC component. The API includes functions
7 *   for the DMA controller, DMA channels and Transfer Descriptors.
8 *
9 *
10 *   Note:
11 *     This module requires the developer to finish or fill in the auto
12 *     generated funcions and setup the dma channel and TD's.
13 *
14 ********************************************************************************
15 * Copyright 2008-2010, Cypress Semiconductor Corporation.  All rights reserved.
16 * You may use this file only in accordance with the license, terms, conditions, 
17 * disclaimers, and limitations in the end user license agreement accompanying 
18 * the software package with which this file was provided.
19 ********************************************************************************/
20 #include <CYLIB.H>
21 #include <CYDMAC.H>
22 #include <SD_RX_DMA_dma.H>
23
24
25
26 /****************************************************************************
27
28 * The following defines are available in Cyfitter.h
29
30
31
32 * SD_RX_DMA__DRQ_CTL_REG
33
34
35 * SD_RX_DMA__DRQ_NUMBER
36
37 * Number of TD's used by this channel.
38 * SD_RX_DMA__NUMBEROF_TDS
39
40 * Priority of this channel.
41 * SD_RX_DMA__PRIORITY
42
43 * True if SD_RX_DMA_TERMIN_SEL is used.
44 * SD_RX_DMA__TERMIN_EN
45
46 * TERMIN interrupt line to signal terminate.
47 * SD_RX_DMA__TERMIN_SEL
48
49
50 * True if SD_RX_DMA_TERMOUT0_SEL is used.
51 * SD_RX_DMA__TERMOUT0_EN
52
53
54 * TERMOUT0 interrupt line to signal completion.
55 * SD_RX_DMA__TERMOUT0_SEL
56
57
58 * True if SD_RX_DMA_TERMOUT1_SEL is used.
59 * SD_RX_DMA__TERMOUT1_EN
60
61
62 * TERMOUT1 interrupt line to signal completion.
63 * SD_RX_DMA__TERMOUT1_SEL
64
65 ****************************************************************************/
66
67
68 /* Zero based index of SD_RX_DMA dma channel */
69 uint8 SD_RX_DMA_DmaHandle = DMA_INVALID_CHANNEL;
70
71 /*********************************************************************
72 * Function Name: uint8 SD_RX_DMA_DmaInitalize
73 **********************************************************************
74 * Summary:
75 *   Allocates and initialises a channel of the DMAC to be used by the
76 *   caller.
77 *
78 * Parameters:
79 *   BurstCount.
80 *       
81 *       
82 *   ReqestPerBurst.
83 *       
84 *       
85 *   UpperSrcAddress.
86 *       
87 *       
88 *   UpperDestAddress.
89 *       
90 *
91 * Return:
92 *   The channel that can be used by the caller for DMA activity.
93 *   DMA_INVALID_CHANNEL (0xFF) if there are no channels left. 
94 *
95 *
96 *******************************************************************/
97 uint8 SD_RX_DMA_DmaInitialize(uint8 BurstCount, uint8 ReqestPerBurst, uint16 UpperSrcAddress, uint16 UpperDestAddress) 
98 {
99
100     /* Allocate a DMA channel. */
101     SD_RX_DMA_DmaHandle = (uint8)SD_RX_DMA__DRQ_NUMBER;
102
103     /* Configure the channel. */
104     (void)CyDmaChSetConfiguration(SD_RX_DMA_DmaHandle,
105                                   BurstCount,
106                                   ReqestPerBurst,
107                                   (uint8)SD_RX_DMA__TERMOUT0_SEL,
108                                   (uint8)SD_RX_DMA__TERMOUT1_SEL,
109                                   (uint8)SD_RX_DMA__TERMIN_SEL);
110
111     /* Set the extended address for the transfers */
112     (void)CyDmaChSetExtendedAddress(SD_RX_DMA_DmaHandle, UpperSrcAddress, UpperDestAddress);
113
114     /* Set the priority for this channel */
115     (void)CyDmaChPriority(SD_RX_DMA_DmaHandle, (uint8)SD_RX_DMA__PRIORITY);
116     
117     return SD_RX_DMA_DmaHandle;
118 }
119
120 /*********************************************************************
121 * Function Name: void SD_RX_DMA_DmaRelease
122 **********************************************************************
123 * Summary:
124 *   Frees the channel associated with SD_RX_DMA.
125 *
126 *
127 * Parameters:
128 *   void.
129 *
130 *
131 *
132 * Return:
133 *   void.
134 *
135 *******************************************************************/
136 void SD_RX_DMA_DmaRelease(void) 
137 {
138     /* Disable the channel */
139     (void)CyDmaChDisable(SD_RX_DMA_DmaHandle);
140 }
141