]> git.sur5r.net Git - freertos/blob - Demo/ARM7_STR75x_IAR/STLibrary/src/75x_ssp.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / ARM7_STR75x_IAR / STLibrary / src / 75x_ssp.c
1 /******************** (C) COPYRIGHT 2006 STMicroelectronics ********************\r
2 * File Name          : 75x_ssp.c\r
3 * Author             : MCD Application Team\r
4 * Date First Issued  : 03/10/2006 \r
5 * Description        : This file provides all the SSP software functions.\r
6 ********************************************************************************\r
7 * History:\r
8 * 07/17/2006 : V1.0\r
9 * 03/10/2006 : V0.1\r
10 ********************************************************************************\r
11 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.\r
13 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, \r
14 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE\r
15 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING \r
16 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
17 *******************************************************************************/\r
18 \r
19 /* Includes ------------------------------------------------------------------*/\r
20 #include "75x_ssp.h"\r
21 #include "75x_mrcc.h"\r
22 \r
23 /* Private typedef -----------------------------------------------------------*/\r
24 /* Private define ------------------------------------------------------------*/\r
25 /* Private macro -------------------------------------------------------------*/\r
26 /* Private variables ---------------------------------------------------------*/\r
27 \r
28 /* SSP peripheral Enable */\r
29 #define SSP_Enable   0x0002\r
30 #define SSP_Disable  0xFFFD\r
31 \r
32 /* SSP Loop Back Mode Enable */\r
33 #define SSP_LoopBackMode_Enable   0x0001\r
34 #define SSP_LoopBackMode_Disable  0xFFFE\r
35 \r
36 /* SSP Flag Mask */\r
37 #define SSP_Flag_Mask  0x001F\r
38 \r
39 /* SSP DMA transmit/ receive enable/disable Masks */\r
40 #define SSP0_DMA_TransmitEnable   0x0002\r
41 #define SSP0_DMA_TransmitDisable  0xFFFD\r
42 #define SSP0_DMA_ReceiveEnable    0x0001\r
43 #define SSP0_DMA_ReceiveDisable   0xFFFE\r
44 \r
45 /* SSP Masks */\r
46 #define SSP_FrameFormat_Mask     0xFFCF\r
47 #define SSP_DataSize_Mask        0xFFF0\r
48 #define SSP_ClockRate_Mask       0x00FF\r
49 #define SSP_ClockPrescaler_Mask  0xFF00\r
50 #define SSP_SSI_Set_Mask         0x0020\r
51 #define SSP_SSI_Reset_Mask       0xFFDF\r
52 \r
53 \r
54 /* Private function prototypes -----------------------------------------------*/\r
55 /* Private functions ---------------------------------------------------------*/\r
56 \r
57 /*******************************************************************************\r
58 * Function Name  : SSP_DeInit\r
59 * Description    : Deinitializes the SSPx peripheral registers to their default\r
60 *                  reset values.\r
61 * Input          : SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
62 * Output         : None\r
63 * Return         : None\r
64 *******************************************************************************/\r
65 void SSP_DeInit(SSP_TypeDef* SSPx)\r
66 {\r
67   if(SSPx == SSP0)\r
68   {\r
69     /* Reset the SSP0 registers values*/\r
70     MRCC_PeripheralSWResetConfig(MRCC_Peripheral_SSP0,ENABLE);\r
71     MRCC_PeripheralSWResetConfig(MRCC_Peripheral_SSP0,DISABLE); \r
72   }\r
73   else if (SSPx == SSP1)\r
74   {\r
75     /* Reset the SSP1 registers values*/\r
76     MRCC_PeripheralSWResetConfig(MRCC_Peripheral_SSP1,ENABLE);\r
77     MRCC_PeripheralSWResetConfig(MRCC_Peripheral_SSP1,DISABLE); \r
78   } \r
79 }\r
80 \r
81 /*******************************************************************************\r
82 * Function Name  : SSP_Init\r
83 * Description    : Initializes the SSPx  peripheral according to the specified\r
84 *                  parameters in the SSP_InitTypeDef structure.\r
85 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
86 *                  - SSP_InitStruct: pointer to a SSP_InitTypeDef structure that\r
87 *                    contains the configuration information for the specified SSP\r
88 *                    peripheral.\r
89 * Output         : None\r
90 * Return         : None\r
91 *******************************************************************************/\r
92 void SSP_Init(SSP_TypeDef* SSPx, SSP_InitTypeDef* SSP_InitStruct)\r
93\r
94   /* Configure the Frame format */\r
95   if(SSP_InitStruct->SSP_FrameFormat == SSP_FrameFormat_TI)\r
96   {   \r
97     /* Clear the FRF[1:0] bits */\r
98     SSPx->CR0 &= SSP_FrameFormat_Mask;\r
99     /* Set the TI frame format */\r
100     SSPx->CR0 |= SSP_FrameFormat_TI;\r
101   }\r
102   else\r
103   {\r
104     /* Set the Motorola frame format */\r
105     SSPx->CR0 &= SSP_FrameFormat_Motorola;\r
106     /* Configure the Clock polarity */\r
107     if(SSP_InitStruct->SSP_CPOL == SSP_CPOL_High)\r
108     {   \r
109       /* SCK is held high when no data is being transfered */    \r
110       SSPx->CR0 |= SSP_CPOL_High;\r
111     }\r
112     else\r
113     {\r
114       /* SCK is held low when no data is being transfered */ \r
115       SSPx->CR0 &= SSP_CPOL_Low;\r
116     }\r
117     /* Configure the Clock Phase */\r
118     if(SSP_InitStruct->SSP_CPHA == SSP_CPHA_2Edge)\r
119     {    \r
120       /* Data captured on second clock edge */   \r
121       SSPx->CR0 |= SSP_CPHA_2Edge;\r
122     }\r
123     else\r
124     {\r
125       /* Data captured on first clock edge */\r
126       SSPx->CR0 &= SSP_CPHA_1Edge;\r
127     }\r
128   }\r
129   \r
130   /* Configure the Mode */\r
131   if(SSP_InitStruct->SSP_Mode == SSP_Mode_Slave)\r
132   {  \r
133     /* Set the slave mode */ \r
134     SSPx->CR1 |= SSP_Mode_Slave;\r
135     /* Configure the Slave output */\r
136     if(SSP_InitStruct->SSP_SlaveOutput == SSP_SlaveOutput_Disable)\r
137     {  \r
138       /* Slave output disabled */     \r
139       SSPx->CR1 |= SSP_SlaveOutput_Disable;\r
140     }\r
141     else\r
142     {\r
143       /* Slave output enabled */     \r
144       SSPx->CR1 &= SSP_SlaveOutput_Enable;\r
145     }\r
146     /* Configure the NSS pin */\r
147     if(SSP_InitStruct->SSP_NSS == SSP_NSS_Soft)\r
148     {  \r
149       /* Slave selected by software through SSI bit */     \r
150       SSPx->CR1 |= SSP_NSS_Soft;\r
151       SSPx->CR1 &= SSP_SSI_Reset_Mask;\r
152     }\r
153     else\r
154     {\r
155       /* Slave selected by hardware through external SSpin */\r
156       SSPx->CR1 &= SSP_NSS_Hard;\r
157     }\r
158     /* Configure the Clock rate and prescaler in TI slave mode */\r
159     if(SSP_InitStruct->SSP_FrameFormat == SSP_FrameFormat_TI)\r
160     { \r
161       /* Clear clock rate SCR[7:0] bits */\r
162       SSPx->CR0 &= SSP_ClockRate_Mask; \r
163       /* Set the serial clock rate */\r
164       SSPx->CR0 |= (SSP_InitStruct->SSP_ClockRate<<8);\r
165       /* Clear clock prescaler CPSDVSR[7:0] bits */\r
166       SSPx->PR &= SSP_ClockPrescaler_Mask;\r
167       /* Set the serial clock prescaler */\r
168       SSPx->PR |= SSP_InitStruct->SSP_ClockPrescaler;\r
169     }\r
170   }\r
171   else\r
172   {\r
173     /* Set the master mode */\r
174     SSPx->CR1 &= SSP_Mode_Master;\r
175     /* Configure the NSS pin */\r
176     if(SSP_InitStruct->SSP_NSS == SSP_NSS_Soft)\r
177     {  \r
178       /* Master selected by software through SSI bit */     \r
179       SSPx->CR1 |= SSP_NSS_Soft;\r
180       SSPx->CR1 |= SSP_SSI_Set_Mask;\r
181     }\r
182     else\r
183     {\r
184       /* Master selected by hardware through external SSpin */\r
185       SSPx->CR1 &= SSP_NSS_Hard;\r
186     }\r
187     /* Clear clock rate SCR[7:0] bits */\r
188     SSPx->CR0 &= SSP_ClockRate_Mask; \r
189     /* Set the serial clock rate */\r
190     SSPx->CR0 |= (SSP_InitStruct->SSP_ClockRate<<8);\r
191     /* Clear clock prescaler CPSDVSR[7:0] bits */\r
192     SSPx->PR &= SSP_ClockPrescaler_Mask;\r
193     /* Set the serial clock prescaler */\r
194     SSPx->PR |= SSP_InitStruct->SSP_ClockPrescaler;\r
195   }\r
196   \r
197   /* Clear data size DSS[3:0] bits */\r
198   SSPx->CR0 &= SSP_DataSize_Mask;\r
199   /* Set the data size */\r
200   SSPx->CR0 |= SSP_InitStruct->SSP_DataSize;\r
201 }\r
202 \r
203 /*******************************************************************************\r
204 * Function Name  : SSP_StructInit\r
205 * Description    : Fills each SSP_InitStruct member with its default value.\r
206 * Input          : SSP_InitStruct : pointer to a SSP_InitTypeDef structure\r
207                    which will be initialized.\r
208 * Output         : None\r
209 * Return         : None\r
210 *******************************************************************************/\r
211 void SSP_StructInit(SSP_InitTypeDef* SSP_InitStruct)\r
212 {\r
213   /* Initialize the SSP_FrameFormat member */\r
214   SSP_InitStruct->SSP_FrameFormat = SSP_FrameFormat_Motorola;\r
215 \r
216   /* Initialize the SSP_Mode member */\r
217   SSP_InitStruct->SSP_Mode = SSP_Mode_Master;\r
218 \r
219   /* Initialize the SSP_CPOL member */\r
220   SSP_InitStruct->SSP_CPOL = SSP_CPOL_Low;\r
221 \r
222   /* Initialize the SSP_CPHA member */\r
223   SSP_InitStruct->SSP_CPHA = SSP_CPHA_1Edge;\r
224 \r
225   /* Initialize the SSP_DataSize member */\r
226   SSP_InitStruct->SSP_DataSize = SSP_DataSize_8b;\r
227   \r
228   /* Initialize the SSP_NSS  member */\r
229   SSP_InitStruct->SSP_NSS = SSP_NSS_Hard;\r
230   \r
231   /* Initialize the SSP_SlaveOutput member */\r
232   SSP_InitStruct->SSP_SlaveOutput = SSP_SlaveOutput_Enable;\r
233   \r
234   /* Initialize the SSP_ClockRate member */\r
235   SSP_InitStruct->SSP_ClockRate = 0;\r
236   \r
237   /* Initialize the SSP_ClockPrescaler member */\r
238   SSP_InitStruct->SSP_ClockPrescaler = 0;\r
239 }\r
240 \r
241 /*******************************************************************************\r
242 * Function Name  : SSP_Cmd\r
243 * Description    : Enables or disables the specified SSP peripheral.\r
244 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
245 *                  - NewState: new state of the SSPx peripheral. \r
246 *                    This parameter can be: ENABLE or DISABLE.\r
247 * Output         : None\r
248 * Return         : None\r
249 *******************************************************************************/\r
250 void SSP_Cmd(SSP_TypeDef* SSPx, FunctionalState NewState)\r
251 {\r
252   if(NewState == ENABLE)\r
253   {\r
254     /* Enable the SSP peripheral */\r
255     SSPx->CR1 |= SSP_Enable;\r
256   }\r
257   else\r
258   {\r
259     /* Disable the SSP peripheral */\r
260     SSPx->CR1 &= SSP_Disable;\r
261   }\r
262 }\r
263 \r
264 /*******************************************************************************\r
265 * Function Name  : SSP_ITConfig\r
266 * Description    : Enables or disables the specified SSP interrupts.\r
267 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
268 *                  - SSP_IT: specifies the SSP interrupts sources to be enabled\r
269 *                    or disabled. This parameter can be any combination of the\r
270 *                    following values:\r
271 *                         - SSP_IT_TxFifo: Transmit FIFO half empty or less interrupt \r
272 *                         - SSP_IT_RxFifo: Receive FIFO half full or less interrupt \r
273 *                         - SSP_IT_RxTimeOut: Receive timeout interrupt \r
274 *                         - SSP_IT_RxOverrun: Receive overrun interrupt \r
275 *                  - NewState: new state of the specified SSP interrupts.\r
276 *                    This parameter can be: ENABLE or DISABLE.\r
277 * Output         : None\r
278 * Return         : None\r
279 *******************************************************************************/\r
280 void SSP_ITConfig(SSP_TypeDef* SSPx, u16 SSP_IT, FunctionalState NewState)\r
281 {\r
282   if(NewState == ENABLE)\r
283   {\r
284     /* Enable the selected SSP interrupts */\r
285     SSPx->IMSCR |= SSP_IT;\r
286   }\r
287   else\r
288   {\r
289     /* Disable the selected SSP interrupts */\r
290     SSPx->IMSCR &= ~SSP_IT;\r
291   }\r
292 }\r
293 \r
294 /*******************************************************************************\r
295 * Function Name  : SSP_DMACmd\r
296 * Description    : Configures the SSP0 DMA interface.\r
297 * Input          : - SSP0_DMAtransfer : specifies the DMA transfer to be \r
298 *                    enabled or disabled. This parameter can be one of the\r
299 *                    following values:\r
300 *                         - SSP0_DMA_Transmit: transmit Fifo DMA transfer\r
301 *                         - SSP0_DMA_Receive: receive Fifo DMA transfer \r
302 *                  - NewState: new state of SSP0 DMA transfer.\r
303 *                    This parameter can be: ENABLE or DISABLE.\r
304 * Output         : None\r
305 * Return         : None\r
306 *******************************************************************************/\r
307 void SSP_DMACmd(u16 SSP0_DMAtransfer, FunctionalState NewState)\r
308 {\r
309   if(NewState == ENABLE) \r
310   {\r
311     if(SSP0_DMAtransfer == SSP0_DMA_Transmit) \r
312     {\r
313       /* Enable DMA for the transmit FIFO */\r
314       SSP0->DMACR |= SSP0_DMA_TransmitEnable;\r
315     }\r
316     else \r
317     {\r
318       /* Enable DMA for the receive FIFO */\r
319       SSP0->DMACR |= SSP0_DMA_ReceiveEnable;\r
320     }\r
321   }\r
322   else \r
323   {\r
324     if(SSP0_DMAtransfer == SSP0_DMA_Transmit) \r
325     {\r
326       /* Disable DMA for the transmit FIFO */\r
327       SSP0->DMACR &= SSP0_DMA_TransmitDisable;\r
328     }\r
329     else \r
330     {\r
331       /* Disable DMA for the receive FIFO */\r
332       SSP0->DMACR &= SSP0_DMA_ReceiveDisable;\r
333     }\r
334   }\r
335 }\r
336 \r
337 /*******************************************************************************\r
338 * Function Name  : SSP_DMATxConfig\r
339 * Description    : Configures the SSP0 DMA transmit transfer.\r
340 * Input          : - SSP0_DMATxReq : specifies the SSP0 DMA transmit request to  \r
341 *                    be enabled. This parameter can be one of the following\r
342 *                    values:\r
343 *                         - SSP0_DMATxReq_Single: Transmit FIFO DMA single \r
344 *                           request enabled\r
345 *                         - SSP0_DMATxReq_Burst: Transmit FIFO DMA burst request\r
346 *                           enabled\r
347 * Output         : None\r
348 * Return         : None\r
349 *******************************************************************************/\r
350 void SSP_DMATxConfig(u16 SSP0_DMATxReq)\r
351 {\r
352   if(SSP0_DMATxReq == SSP0_DMATxReq_Burst) \r
353   {\r
354     /* Enable DMA transmit burst request */\r
355     SSP0->DMACR |= SSP0_DMATxReq_Burst;\r
356   }\r
357   else   \r
358   {\r
359     /* Enable DMA transmit single request */\r
360     SSP0->DMACR &= SSP0_DMATxReq_Single;\r
361   }\r
362 }\r
363 \r
364 /*******************************************************************************\r
365 * Function Name  : SSP_DMARxConfig\r
366 * Description    : Configures the SSP0 DMA receive transfer.\r
367 * Input          : - SSP0_DMARxReq : specifies the SSP0 DMA receive request to  \r
368 *                    be enabled. This parameter can be one of the following\r
369 *                    values:\r
370 *                         - SSP0_DMARxReq_Single: Receive FIFO DMA burst request\r
371 *                           enabled\r
372 *                         - SSP0_DMARxReq_Burst: Receive FIFO DMA single request\r
373 *                          enabled\r
374 * Output         : None\r
375 * Return         : None\r
376 *******************************************************************************/\r
377 void SSP_DMARxConfig(u16 SSP0_DMARxReq)\r
378 {\r
379   if(SSP0_DMARxReq == SSP0_DMARxReq_Burst) \r
380   {\r
381     /* Enable DMA receive burst request */\r
382     SSP0->DMACR |= SSP0_DMARxReq_Burst;\r
383   }\r
384   else   \r
385   {\r
386     /* Enable DMA receive single request */\r
387     SSP0->DMACR &= SSP0_DMARxReq_Single;\r
388   }  \r
389 }\r
390 \r
391 /*******************************************************************************\r
392 * Function Name  : SSP_SendData\r
393 * Description    : Transmits a Data through the SSP peripheral.\r
394 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
395 *                  - Data : Data to be transmitted.\r
396 * Output         : None\r
397 * Return         : None\r
398 *******************************************************************************/\r
399 void SSP_SendData(SSP_TypeDef* SSPx, u16 Data)\r
400 {\r
401   /* Write in the DR register the data to be sent */\r
402   SSPx->DR = Data;\r
403 }\r
404 \r
405 /*******************************************************************************\r
406 * Function Name  : SSP_ReceiveData\r
407 * Description    : Returns the most recent received data by the SSP peripheral.\r
408 * Input          : SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
409 * Output         : None\r
410 * Return         : The value of the received data.\r
411 *******************************************************************************/\r
412 u16 SSP_ReceiveData(SSP_TypeDef* SSPx)\r
413 {\r
414   /* Return the data in the DR register */      \r
415   return SSPx->DR;\r
416 }\r
417 \r
418 /*******************************************************************************\r
419 * Function Name  : SSP_LoopBackConfig\r
420 * Description    : Enables or disables the Loop back mode for the selected SSP\r
421 *                  peripheral.\r
422 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
423 *                  - NewState: new state of the Loop Back mode.\r
424 *                    This parameter can be: ENABLE or DISABLE.\r
425 * Output         : None\r
426 * Return         : None\r
427 *******************************************************************************/\r
428 void SSP_LoopBackConfig(SSP_TypeDef* SSPx, FunctionalState NewState)\r
429 {\r
430   if(NewState == ENABLE)\r
431   {\r
432     /* Enable loop back mode */\r
433     SSPx->CR1 |= SSP_LoopBackMode_Enable;\r
434   }\r
435   else\r
436   {\r
437     /* Disable loop back mode */\r
438     SSPx->CR1 &= SSP_LoopBackMode_Disable;\r
439   }\r
440 }\r
441 \r
442 /*******************************************************************************\r
443 * Function Name  : SSP_NSSInternalConfig\r
444 * Description    : Configures by software the NSS pin.\r
445 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
446 *                  - SSP_NSSState: NSS internal state.This parameter can be one\r
447 *                    of the following values:\r
448 *                         - SSP_NSSInternal_Set: Set NSS pin internally\r
449 *                         - SSP_NSSInternal_Reset: Reset NSS pin internally\r
450 * Output         : None\r
451 * Return         : None\r
452 *******************************************************************************/\r
453 void SSP_NSSInternalConfig(SSP_TypeDef* SSPx, u16 SSP_NSSState)\r
454 {\r
455   if(SSP_NSSState == SSP_NSSInternal_Set)\r
456   {\r
457     /* Set NSS pin internally */\r
458     SSPx->CR1 |= SSP_NSSInternal_Set;\r
459   }\r
460   else\r
461   {\r
462     /* Reset NSS pin internally */\r
463     SSPx->CR1 &= SSP_NSSInternal_Reset;\r
464   }\r
465 }\r
466 \r
467 /*******************************************************************************\r
468 * Function Name  : SSP_GetFlagStatus\r
469 * Description    : Checks whether the specified SSP flag is set or not.\r
470 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
471 *                  - SSP_FLAG: specifies the flag to check.  This parameter can \r
472 *                    be one of the following values:\r
473 *                         - SSP_FLAG_Busy: busy flag\r
474 *                         - SSP_FLAG_RxFifoFull: Receive FIFO full flag\r
475 *                         - SSP_FLAG_RxFifoNotEmpty: Receive FIFO not empty flag \r
476 *                         - SSP_FLAG_TxFifoNotFull: Transmit FIFO not full flag \r
477 *                         - SSP_FLAG_TxFifoEmpty: Transmit FIFO empty flag \r
478 *                         - SSP_FLAG_TxFifo: Transmit FIFO half empty or less flag\r
479 *                         - SSP_FLAG_RxFifo: Receive FIFO half full or less flag\r
480 *                         - SSP_FLAG_RxTimeOut: Receive timeout flag\r
481 *                         - SSP_FLAG_RxOverrun: Receive overrun flag\r
482 * Output         : None\r
483 * Return         : The new state of SSP_FLAG(SET or RESET).\r
484 *******************************************************************************/\r
485 FlagStatus SSP_GetFlagStatus(SSP_TypeDef* SSPx, u16 SSP_FLAG)\r
486 {\r
487   u32 SSPReg = 0, FlagPos = 0;\r
488   u32 StatusReg = 0;\r
489 \r
490   /* Get the SSP register index */\r
491   SSPReg = SSP_FLAG >> 5;\r
492 \r
493   /* Get the flag position */\r
494   FlagPos = SSP_FLAG & SSP_Flag_Mask;\r
495 \r
496   /* Find the register of the flag to check */\r
497   if(SSPReg == 1) \r
498   {\r
499     /* The flag to check is in SR register */\r
500     StatusReg = SSPx->SR;       \r
501   }\r
502   else if (SSPReg == 2) \r
503   {\r
504     /* The flag to check is in RISR register */\r
505     StatusReg = SSPx->RISR;\r
506   }\r
507   \r
508   /* Check the status of the specified SSP flag */\r
509   if((StatusReg & (1 << FlagPos)) != RESET)\r
510   {\r
511     /* Return SET if the SSP flag is set */\r
512     return SET;\r
513   }\r
514   else\r
515   {\r
516     /* Return RESET if the SSP flag is reset */\r
517     return RESET;\r
518   }\r
519 }\r
520 \r
521 /*******************************************************************************\r
522 * Function Name  : SSP_ClearFlag\r
523 * Description    : Clears the SSPx\92s pending flags.\r
524 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
525 *                  - SSP_FLAG: specifies the flag to clear.  This parameter can  \r
526 *                    be one of the following values:\r
527 *                         - SSP_FLAG_RxTimeOut: Receive timeout flag \r
528 *                         - SSP_FLAG_RxOverrun: Receive overrun flag \r
529 * Output         : None\r
530 * Return         : None\r
531 *******************************************************************************/\r
532 void SSP_ClearFlag(SSP_TypeDef* SSPx, u16 SSP_FLAG)\r
533\r
534   u8 FlagPos = 0;\r
535 \r
536   /* Get the flag position */\r
537   FlagPos = SSP_FLAG & SSP_Flag_Mask;\r
538   \r
539   /* Clear the selected SSP flag */  \r
540   SSPx->ICR = (1 << FlagPos);  \r
541 }\r
542 \r
543 /*******************************************************************************\r
544 * Function Name  : SSP_GetITStatus\r
545 * Description    : Checks whether the specified SSP interrupt has occurred or not.\r
546 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
547 *                  - SSP_IT: specifies the interrupt source to check.   \r
548 *                    This parameter can be one of the following values:\r
549 *                         - SSP_IT_TxFifo: Transmit FIFO half empty or less interrupt \r
550 *                         - SSP_IT_RxFifo: Receive FIFO half full or less interrupt \r
551 *                         - SSP_IT_RxTimeOut: Receive timeout interrupt \r
552 *                         - SSP_IT_RxOverrun: Receive overrun interrupt \r
553 * Output         : None\r
554 * Return         : The new state of SSP_IT(SET or RESET).\r
555 *******************************************************************************/\r
556 ITStatus SSP_GetITStatus(SSP_TypeDef* SSPx, u16 SSP_IT)\r
557 {\r
558   /* Check the status of the specified interrupt flag */\r
559   if((SSPx->MISR & SSP_IT) != RESET)\r
560   {\r
561     /* Return SET if the SSP interrupt flag is set */\r
562     return SET;\r
563   }\r
564   else\r
565   {\r
566     /* Return RESET if SSP interrupt flag is reset */\r
567     return RESET;\r
568   }\r
569 }\r
570 \r
571 /*******************************************************************************\r
572 * Function Name  : SSP_ClearITPendingBit\r
573 * Description    : Clears the SSPx\92s interrupt pending bits.\r
574 * Input          : - SSPx: where x can be 0 or 1 to select the SSP peripheral.\r
575 *                  - SSP_IT: specifies the interrupt pending bit to clear.  \r
576 *                    This parameter can be any combination of the following values:\r
577 *                         - SSP_IT_RxTimeOut: Receive timeout interrupt \r
578 *                         - SSP_IT_RxOverrun: Receive overrun interrupt \r
579 * Output         : None\r
580 * Return         : None\r
581 *******************************************************************************/\r
582 void SSP_ClearITPendingBit(SSP_TypeDef* SSPx, u16 SSP_IT)\r
583 {\r
584   /* Clear the selected SSP interrupts pending bits */\r
585   SSPx->ICR = SSP_IT;\r
586 }\r
587 \r
588 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/\r