summaryrefslogtreecommitdiffstats
path: root/uc_str912/prj_blinky_simple_startup/str91x_lib/include/91x_dma.h
blob: 6a383aafe3189d41c3623fc7f60468560f32eabb (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
* File Name          : template.h
* Author             : MCD Application Team
* Date First Issued  : 05/18/2006 : Version 1.0
* Description        : provide a short description of the source file indicating
*                      its purpose.
********************************************************************************
* History:
* 05/24/2006 : Version 1.1
* 05/18/2006 : Version 1.0
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __91x_DMA_H
#define __91x_DMA_H

/* Includes ------------------------------------------------------------------*/
#include"91x_map.h"


/* Exported types ------------------------------------------------------------*/

typedef struct
{
 u32 DMA_Channel_SrcAdd;    /* The current source address (byte-aligned) of the data to be transferred.*/

 u32 DMA_Channel_DesAdd;    /* The current destination address (byte-aligned) of the data to be transferred.*/

 u32 DMA_Channel_LLstItm;   /* The word- aligned address for the next Linked List Item. */

 u32 DMA_Channel_DesWidth;   /* Destination transfer width. */

 u32 DMA_Channel_SrcWidth;   /* Source transfer width. */

 u32 DMA_Channel_DesBstSize; /* The destination burst size which indicates the number of transfers that make up a destination burst transfer request.*/

 u32 DMA_Channel_SrcBstSize; /* The source burst size.Indicates the number of transfers that make up a source burst */

 u32 DMA_Channel_TrsfSize;   /* Transfer size which indicates the size of the transfer when the DMA controller is the flow controller*/

 u32 DMA_Channel_FlowCntrl;  /* Flow control and transfer type. */

 u32 DMA_Channel_Src;        /* Source peripheral: selects the DMA source request peripheral. */

 u32 DMA_Channel_Des;        /* Destination peripheral:selects the DMA destination request peripheral. */

} DMA_InitTypeDef;

/* Exported constants --------------------------------------------------------*/

    /* Interrupts masks */

#define    DMA_ITMask_IE	        0x4000	/* Interrupt error mask. */
#define    DMA_ITMask_ITC	        0x8000	/* Terminal count interrupt mask.*/
#define    DMA_ITMask_ALL	        0xC000	/* All DMA_Channelx interrupts enable/disable mask*/

  /* Sources Request (used as masks) */

#define   DMA_USB_RX_Mask	            0x0001
#define   DMA_USB_TX_Mask	            0x0002
#define   DMA_TIM0_Mask	                0x0004
#define   DMA_TIM1_Mask	                0x0008
#define   DMA_UART0_RX_Mask             0x0010
#define   DMA_UART0_TX_Mask             0x0020
#define   DMA_UART1_RX_Mask             0x0040
#define   DMA_UART1_TX_Mask             0x0080
#define   DMA_External_Req0_Mask        0x0100
#define   DMA_External_Req1_Mask	    0x0200
#define   DMA_I2C0_Mask	                0x0400
#define   DMA_I2C1_Mask	                0x0800
#define   DMA_SSP0_RX_Mask	            0x1000
#define   DMA_SSP0_TX_Mask	            0x2000
#define   DMA_SSP1_RX_Mask	            0x4000
#define   DMA_SSP1_TX_Mask	            0x8000


/* Previleged Mode and user mode */

#define   DMA_PrevilegedMode	        0x10000000
#define   DMA_UserMode	                0xEFFFFFFF


/* Error and Terminal Count interrupts Status, after and before"raw" masking */
#define   DMA_IS	                0x01
#define   DMA_TCS	                0x02
#define   DMA_ES	                0x03
#define   DMA_TCRS	                0x04
#define   DMA_ERS	                0x05


/* interrupt clear: Terminal Count flag Clear and Error flag clear*/

#define   DMA_TCC	                0x01
#define   DMA_EC	                0x02

/* channel index "0...7"*/

#define   Channel0                      0
#define   Channel1                      1
#define   Channel2                      2
#define   Channel3                      3
#define   Channel4                      4
#define   Channel5                      5
#define   Channel6                      6
#define   Channel7                      7



/* Destination request selection: selects the DMA Destination request peripheral */

#define   DMA_DES_USB_RX	        0x00
#define   DMA_DES_USB_TX	        0x40
#define   DMA_DES_TIM1	            0x80
#define   DMA_DES_TIM2	            0xC0
#define   DMA_DES_UART0_RX	 	    0x100
#define   DMA_DES_UART0_TX		    0x140
#define   DMA_DES_UART1_RX	        0x180
#define   DMA_DES_UART1_TX	        0x1C0
#define   DMA_DES_External_Req0	    0x200
#define   DMA_DES_External_Req1	    0x240
#define   DMA_DES_I2C0	            0x280
#define   DMA_DES_I2C1	            0x2C0
#define   DMA_DES_SSP0_RX	        0x300
#define   DMA_DES_SSP0_TX	        0x340
#define   DMA_DES_SSP1_RX	        0x380
#define   DMA_DES_SSP1_TX	        0x3C0




/* Source request selection: selects the DMA Source request peripheral */

#define   DMA_SRC_USB_RX	        0x00
#define   DMA_SRC_USB_TX	        0x02
#define   DMA_SRC_TIM1	            0x04
#define   DMA_SRC_TIM2	            0x06
#define   DMA_SRC_UART0_RX	 	    0x08
#define   DMA_SRC_UART0_TX		    0x0A
#define   DMA_SRC_UART1_RX	        0x0C
#define   DMA_SRC_UART1_TX	        0x0E
#define   DMA_SRC_External_Req0	    0x10
#define   DMA_SRC_External_Req1	    0x12
#define   DMA_SRC_I2C0	            0x14
#define   DMA_SRC_I2C1	            0x16
#define   DMA_SRC_SSP0_RX	        0x18
#define   DMA_SRC_SSP0_TX	        0x1A
#define   DMA_SRC_SSP1_RX	        0x1C
#define   DMA_SRC_SSP1_TX	        0x1E





#define   DMA_FlowCntrlt0_DMA	       0x00000000	   /* transfer type :Memory-to-memory, flow controller:DMA */
#define   DMA_FlowCntrl1_DMA	       0x00000800	   /* transfer type :Memory-to-peripheral, flow controller:DMA */
#define   DMA_FlowCntrl2_DMA	       0x00001000	   /* transfer type :Peripheral-to-memory, flow controller:DMA */
#define   DMA_FlowCntrl3_DMA	       0x00001800	   /* transfer type :Source peripheral-to-destination peripheral, flow controller:DMA */	
#define   DMA_FlowCntrl_DestPerip	   0x00002000      /* transfer type :Source peripheral-to-destination peripheral, flow controller:Destination peripheral */	
#define   DMA_FlowCntrl_Perip1	       0x00002800      /* transfer type :Memory-to-peripheral, flow controller:peripheral */		
#define   DMA_FlowCntrl_Perip2	       0x00003000      /* transfer  type : Peripheral-to-memory, flow controller:peripheral */	
#define   DMA_FlowCntrl_SrcPerip	   0x00003800      /* transfer  type :Source peripheral-to-destination peripheral, flow controller:Source peripheral */	




#define   DMA_SrcBst_1Data	          0x00000000	/* Source Burst transfer request IS 1 Data ( DATA = Source transfer width ) */
#define   DMA_SrcBst_4Data	          0x00001000	/* Source Burst transfer request IS 4 Data  */
#define   DMA_SrcBst_8Data	          0x00002000	/* Source Burst transfer request IS 8 Data   */
#define   DMA_SrcBst_16Data	          0x00003000    /* Source Burst transfer request IS 16 Data  */
#define   DMA_SrcBst_32Data	          0x00004000	/* Source Burst transfer request IS 32 Data  */
#define   DMA_SrcBst_64Data	          0x00005000	/* Source Burst transfer request IS 64Data   */
#define   DMA_SrcBst_128Data	      0x00006000	/* Source Burst transfer request IS 128 Data */
#define   DMA_SrcBst_256Data 	      0x00007000	/* Source Burst transfer request IS 256 Data */




#define   DMA_DesBst_1Data	          0x00000000	/*Destination Burst transfer request IS 1Data ( DATA = destination transfer width ) */
#define   DMA_DesBst_4Data	          0x00008000	/*Destination Burst transfer request IS 1 Data   */
#define   DMA_DesBst_8Data	          0x00010000	/*Destination Burst transfer request IS 4 Data   */
#define   DMA_DesBst_16Data	          0x00018000	/*Destination Burst transfer request IS 8 Data   */
#define   DMA_DesBst_32Data	          0x00020000	/*Destination Burst transfer request IS 16 Data  */
#define   DMA_DesBst_64Data	          0x00028000	/*Destination Burst transfer request IS 32 Data  */
#define   DMA_DesBst_128Data	      0x00030000	/*Destination Burst transfer request IS 128 Data */
#define   DMA_DesBst_256Data	      0x00038000	/*Destination Burst transfer request IS 256 Data */





#define   DMA_SrcWidth_Byte	          0x00000000  /* source Width is one Byte */
#define   DMA_SrcWidth_HalfWord	      0x00040000  /* source Width is one HalfWord */
#define   DMA_SrcWidth_Word	          0x00080000  /*  source Width is one Word  */




#define   DMA_DesWidth_Byte	          0x00000000  /* Destination Width is one Byte */
#define   DMA_DesWidth_HalfWord	      0x00200000  /* Destination Width is one HalfWord */
#define   DMA_DesWidth_Word	          0x00400000	/* Destination Width is one Word */






/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

void DMA_DeInit(void);
void DMA_Init(DMA_Channel_TypeDef * DMA_Channelx, DMA_InitTypeDef * DMA_InitStruct);
void DMA_StructInit(DMA_InitTypeDef *DMA_InitStruct);
void DMA_Cmd(FunctionalState NewState);
void DMA_ITMaskConfig(DMA_Channel_TypeDef * DMA_Channelx, u16 DMA_ITMask, FunctionalState NewState);
void DMA_ITConfig(DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState);
FlagStatus DMA_GetChannelStatus(u8 ChannelIndx );
ITStatus DMA_GetITStatus(u8 ChannelIndx,u8 DMA_ITReq);
void DMA_ClearIT(u8 ChannelIndx,u8 DMA_ITClr);
void DMA_SyncConfig(u16 DMA_SrcReq, FunctionalState NewState);
FlagStatus DMA_GetSReq(u16 DMA_SrcReq);
FlagStatus DMA_GetLSReq(u16 DMA_SrcReq);
FlagStatus DMA_GetBReq(u16 DMA_SrcReq);
FlagStatus DMA_GetLBReq(u16 DMA_SrcReq);
FlagStatus DMA_GetChannelActiveStatus( DMA_Channel_TypeDef * DMA_Channelx);
void DMA_SetSReq(u16 DMA_SrcReq);
void DMA_SetLSReq(u16 DMA_SrcReq);
void DMA_SetBReq(u16 DMA_SrcReq);
void DMA_SetLBReq(u16 DMA_SrcReq);
void DMA_ChannelCmd (DMA_Channel_TypeDef * DMA_Channelx,FunctionalState NewState);
void DMA_ChannelHalt (DMA_Channel_TypeDef * DMA_Channelx,FunctionalState NewState);
void DMA_ChannelBuffering (DMA_Channel_TypeDef * DMA_Channelx,FunctionalState NewState);
void DMA_ChannelLockTrsf(DMA_Channel_TypeDef * DMA_Channelx,FunctionalState NewState);
void DMA_ChannelCache(DMA_Channel_TypeDef * DMA_Channelx,FunctionalState NewState);
void DMA_ChannelProt0Mode(DMA_Channel_TypeDef * DMA_Channelx,u32 Prot0Mode);
void DMA_ChannelSRCIncConfig (DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState);
void DMA_ChannelDESIncConfig (DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState);

#endif /* __91x_DMA_H */

/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
OpenPOWER on IntegriCloud