Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
2 | * File Name : 91x_ahbapb.c |
||
3 | * Author : MCD Application Team |
||
4 | * Date First Issued : 05/18/2006 : Version 1.0 |
||
5 | * Description : This file provides all the AHBAPB software functions. |
||
6 | ******************************************************************************** |
||
7 | * History: |
||
8 | * 05/22/2007 : Version 1.2 |
||
9 | * 05/24/2006 : Version 1.1 |
||
10 | * 05/18/2006 : Version 1.0 |
||
11 | ******************************************************************************** |
||
12 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
||
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
||
14 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
||
15 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
||
16 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
||
17 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
18 | *******************************************************************************/ |
||
19 | |||
20 | /* Includes ------------------------------------------------------------------*/ |
||
21 | #include "91x_ahbapb.h" |
||
22 | |||
23 | /* Private typedef -----------------------------------------------------------*/ |
||
24 | /* Private define ------------------------------------------------------------*/ |
||
25 | |||
26 | /* Private macro -------------------------------------------------------------*/ |
||
27 | /* Private variables ---------------------------------------------------------*/ |
||
28 | /* Private function prototypes -----------------------------------------------*/ |
||
29 | /* Private functions ---------------------------------------------------------*/ |
||
30 | #define AHBAPB_SplitCounter_Mask 0xFFE0FFFF |
||
31 | #define AHBAPB_SetTimeOut_Mask 0xFFFFFFE0 |
||
32 | #define AHBAPB_Address_Mask 0xFEFFFFFF |
||
33 | #define AHBAPB_FLAG_RW_Mask 0x01000000 |
||
34 | /******************************************************************************* |
||
35 | * Function Name : AHBAPB_DeInit |
||
36 | * Description : Deinitializes the AHBAPBx peripheral registers to their default |
||
37 | * reset values. |
||
38 | * Input : AHBAPBx: where x can be 0 or 1 to select the AHBAPB peripheral. |
||
39 | * Output : None |
||
40 | * Return : None |
||
41 | *******************************************************************************/ |
||
42 | void AHBAPB_DeInit(AHBAPB_TypeDef* AHBAPBx) |
||
43 | { |
||
44 | AHBAPBx->BCR = 0x00000000; |
||
45 | AHBAPBx->BSR = 0x00000000; |
||
46 | } |
||
47 | /******************************************************************************* |
||
48 | * Function Name : AHBAPB_Init |
||
49 | * Description : Initializes the AHBAPBx peripheral according to the specified |
||
50 | * parameters in the AHBAPB_InitStruct . |
||
51 | * Input :- AHBAPBx: where x can be 0 or 1 to select the AHBAPB peripheral. |
||
52 | * - AHBAPB_InitStruct: pointer to a AHBAPB_InitTypeDef structure that |
||
53 | * contains the configuration information for the specified AHBAPB |
||
54 | * peripheral. |
||
55 | * Output : None |
||
56 | * Return : None |
||
57 | *******************************************************************************/ |
||
58 | void AHBAPB_Init(AHBAPB_TypeDef* AHBAPBx, AHBAPB_InitTypeDef* AHBAPB_InitStruct) |
||
59 | { |
||
60 | |||
61 | if(AHBAPB_InitStruct->AHBAPB_Split == AHBAPB_Split_Enable) |
||
62 | { |
||
63 | /* Set SPLITEN bit;*/ |
||
64 | AHBAPBx->BCR |= AHBAPB_Split_Enable; |
||
65 | /*Split_CNT bits[20:16]*/ |
||
66 | AHBAPBx->BCR &= AHBAPB_SplitCounter_Mask; |
||
67 | AHBAPBx->BCR |= (AHBAPB_InitStruct->AHBAPB_SplitCounter)<<16; |
||
68 | } |
||
69 | else |
||
70 | { |
||
71 | /*/ Clear SPLITEN bit;*/ |
||
72 | AHBAPBx->BCR &= AHBAPB_Split_Disable; |
||
73 | } |
||
74 | /*APB Time out*/ |
||
75 | if(AHBAPB_InitStruct->AHBAPB_Error == AHBAPB_Error_Enable) |
||
76 | { |
||
77 | /* Set ERREN bit*/ |
||
78 | AHBAPBx->BCR |= AHBAPB_Error_Enable; |
||
79 | /*Time ouit counter*/ |
||
80 | AHBAPBx->BCR &= AHBAPB_SetTimeOut_Mask; |
||
81 | AHBAPBx->BCR |= AHBAPB_InitStruct->AHBAPB_SetTimeOut; |
||
82 | } |
||
83 | else |
||
84 | { |
||
85 | /* Clear ERREN bit*/ |
||
86 | AHBAPBx->BCR &= AHBAPB_Error_Disable; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | /******************************************************************************* |
||
91 | * Function Name : AHBAPB_StructInit |
||
92 | * Description : Initialize the AHBAPB Init Structure parameters |
||
93 | * Input : AHBAPB_InitStruct : pointer to a AHBAPB_InitTypeDef structure |
||
94 | * which will be initialized. |
||
95 | * Output : None |
||
96 | * Return : None |
||
97 | *******************************************************************************/ |
||
98 | void AHBAPB_StructInit(AHBAPB_InitTypeDef* AHBAPB_InitStruct) |
||
99 | { |
||
100 | /* Reset AHBAPB init structure parameters values */ |
||
101 | AHBAPB_InitStruct->AHBAPB_Split = AHBAPB_Split_Enable; |
||
102 | AHBAPB_InitStruct->AHBAPB_SplitCounter = 0xFF; |
||
103 | AHBAPB_InitStruct->AHBAPB_Error = AHBAPB_Error_Enable; |
||
104 | AHBAPB_InitStruct->AHBAPB_SetTimeOut = 0xFF; |
||
105 | |||
106 | } |
||
107 | |||
108 | /******************************************************************************* |
||
109 | * Function Name : AHBAPB_GetFlagStatus |
||
110 | * Description : Checks whether the specified AHBAPB flag is set or not. |
||
111 | * Input : - AHBAPB: where x can be 0 or 1 to select the AHBAPB peripheral |
||
112 | * - AHBAPB_FLAG: specifies the flag to check. |
||
113 | * This parameter can be one of the following values: |
||
114 | * - AHBAPB_FLAG_ERROR: error flag |
||
115 | * - AHBAPB_FLAG_OUTM : Out of Memory flag |
||
116 | * - AHBAPB_FLAG_APBT : APB Time-out flag |
||
117 | * - AHBAPB_FLAG_RW : Access type flag |
||
118 | * Output : None |
||
119 | * Return : The new state of AHBAPB_FLAG (SET or RESET). |
||
120 | *******************************************************************************/ |
||
121 | FlagStatus AHBAPB_GetFlagStatus(AHBAPB_TypeDef* AHBAPBx, u8 AHBAPB_FLAG) |
||
122 | { |
||
123 | if(AHBAPB_FLAG == AHBAPB_FLAG_RW) |
||
124 | { |
||
125 | if ((AHBAPBx->PAER & AHBAPB_FLAG_RW_Mask) == RESET) |
||
126 | { |
||
127 | return RESET; |
||
128 | } |
||
129 | else |
||
130 | { |
||
131 | return SET; |
||
132 | } |
||
133 | } |
||
134 | else |
||
135 | { |
||
136 | if ((AHBAPBx->BSR & AHBAPB_FLAG) == RESET) |
||
137 | { |
||
138 | return RESET; |
||
139 | } |
||
140 | else |
||
141 | { |
||
142 | return SET; |
||
143 | } |
||
144 | } |
||
145 | } |
||
146 | /******************************************************************************* |
||
147 | * Function Name : AHBAPB_ClearFlag |
||
148 | * Description : Clears the AHBAPBx flags. |
||
149 | * Input : - AHBAPB: where x can be 0 or 1 to select the AHBAPB peripheral |
||
150 | * - AHBAPB_FLAG: flags to clear. This parameter one of the |
||
151 | * following values: |
||
152 | * - AHBAPB_FLAG_ERROR: error flag |
||
153 | * - AHBAPB_FLAG_OUTM : Out of Memory flag |
||
154 | * - AHBAPB_FLAG_APBT : APB Time-out flag |
||
155 | * Output : None |
||
156 | * Return : None |
||
157 | *******************************************************************************/ |
||
158 | void AHBAPB_ClearFlag(AHBAPB_TypeDef* AHBAPBx, u8 AHBAPB_FLAG) |
||
159 | { |
||
160 | /* Clear the flag */ |
||
161 | AHBAPBx->BSR &= ~AHBAPB_FLAG; |
||
162 | } |
||
163 | /******************************************************************************* |
||
164 | * Function Name : AHBAPB_GetPeriphAddrError |
||
165 | * Description : Gets the AHBAPB error address peripherals. |
||
166 | * Input : - AHBAPB: where x can be 0 or 1 to select the AHBAPB peripheral |
||
167 | * Output : None |
||
168 | * Return : The Peropheral address error |
||
169 | *******************************************************************************/ |
||
170 | u32 AHBAPB_GetPeriphAddrError(AHBAPB_TypeDef* AHBAPBx) |
||
171 | { |
||
172 | u32 AHBAPB_Address = 0x00000000; |
||
173 | |||
174 | /*Return Oeripheral address without RW bit*/ |
||
175 | AHBAPB_Address = (AHBAPBx->PAER)& AHBAPB_Address_Mask; |
||
176 | return (AHBAPB_Address); |
||
177 | } |
||
178 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |