1 |
572 |
jeremybenn |
//* ----------------------------------------------------------------------------
|
2 |
|
|
//* ATMEL Microcontroller Software Support - ROUSSET -
|
3 |
|
|
//* ----------------------------------------------------------------------------
|
4 |
|
|
//* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
5 |
|
|
//* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
6 |
|
|
//* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
7 |
|
|
//* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
8 |
|
|
//* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
9 |
|
|
//* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
10 |
|
|
//* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
11 |
|
|
//* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
12 |
|
|
//* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
13 |
|
|
//* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
14 |
|
|
//* ----------------------------------------------------------------------------
|
15 |
|
|
//* File Name : lib_AT91SAM7X256.h
|
16 |
|
|
//* Object : AT91SAM7X256 inlined functions
|
17 |
|
|
//* Generated : AT91 SW Application Group 05/20/2005 (16:22:29)
|
18 |
|
|
//*
|
19 |
|
|
//* CVS Reference : /lib_dbgu.h/1.1/Fri Jan 31 12:18:40 2003//
|
20 |
|
|
//* CVS Reference : /lib_pmc_SAM7X.h/1.1/Tue Feb 1 08:32:10 2005//
|
21 |
|
|
//* CVS Reference : /lib_VREG_6085B.h/1.1/Tue Feb 1 16:20:47 2005//
|
22 |
|
|
//* CVS Reference : /lib_rstc_6098A.h/1.1/Wed Oct 6 10:39:20 2004//
|
23 |
|
|
//* CVS Reference : /lib_ssc.h/1.4/Fri Jan 31 12:19:20 2003//
|
24 |
|
|
//* CVS Reference : /lib_wdtc_6080A.h/1.1/Wed Oct 6 10:38:30 2004//
|
25 |
|
|
//* CVS Reference : /lib_usart.h/1.5/Thu Nov 21 16:01:54 2002//
|
26 |
|
|
//* CVS Reference : /lib_spi2.h/1.1/Mon Aug 25 14:23:52 2003//
|
27 |
|
|
//* CVS Reference : /lib_pitc_6079A.h/1.2/Tue Nov 9 14:43:56 2004//
|
28 |
|
|
//* CVS Reference : /lib_aic_6075b.h/1.1/Fri May 20 14:01:19 2005//
|
29 |
|
|
//* CVS Reference : /lib_aes_6149a.h/1.1/Mon Jan 17 07:43:09 2005//
|
30 |
|
|
//* CVS Reference : /lib_twi.h/1.3/Mon Jul 19 14:27:58 2004//
|
31 |
|
|
//* CVS Reference : /lib_adc.h/1.6/Fri Oct 17 09:12:38 2003//
|
32 |
|
|
//* CVS Reference : /lib_rttc_6081A.h/1.1/Wed Oct 6 10:39:38 2004//
|
33 |
|
|
//* CVS Reference : /lib_udp.h/1.4/Wed Feb 16 08:39:34 2005//
|
34 |
|
|
//* CVS Reference : /lib_des3_6150a.h/1.1/Mon Jan 17 09:19:19 2005//
|
35 |
|
|
//* CVS Reference : /lib_tc_1753b.h/1.1/Fri Jan 31 12:20:02 2003//
|
36 |
|
|
//* CVS Reference : /lib_MC_SAM7X.h/1.1/Thu Mar 25 15:19:14 2004//
|
37 |
|
|
//* CVS Reference : /lib_pio.h/1.3/Fri Jan 31 12:18:56 2003//
|
38 |
|
|
//* CVS Reference : /lib_can_AT91.h/1.4/Fri Oct 17 09:12:50 2003//
|
39 |
|
|
//* CVS Reference : /lib_PWM_SAM.h/1.3/Thu Jan 22 10:10:50 2004//
|
40 |
|
|
//* CVS Reference : /lib_pdc.h/1.2/Tue Jul 2 13:29:40 2002//
|
41 |
|
|
//* ----------------------------------------------------------------------------
|
42 |
|
|
|
43 |
|
|
#ifndef lib_AT91SAM7X256_H
|
44 |
|
|
#define lib_AT91SAM7X256_H
|
45 |
|
|
|
46 |
|
|
/* *****************************************************************************
|
47 |
|
|
SOFTWARE API FOR AIC
|
48 |
|
|
***************************************************************************** */
|
49 |
|
|
#define AT91C_AIC_BRANCH_OPCODE ((void (*) ()) 0xE51FFF20) // ldr, pc, [pc, #-&F20]
|
50 |
|
|
|
51 |
|
|
//*----------------------------------------------------------------------------
|
52 |
|
|
//* \fn AT91F_AIC_ConfigureIt
|
53 |
|
|
//* \brief Interrupt Handler Initialization
|
54 |
|
|
//*----------------------------------------------------------------------------
|
55 |
|
|
__inline unsigned int AT91F_AIC_ConfigureIt (
|
56 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
57 |
|
|
unsigned int irq_id, // \arg interrupt number to initialize
|
58 |
|
|
unsigned int priority, // \arg priority to give to the interrupt
|
59 |
|
|
unsigned int src_type, // \arg activation and sense of activation
|
60 |
|
|
void (*newHandler) (void) ) // \arg address of the interrupt handler
|
61 |
|
|
{
|
62 |
|
|
unsigned int oldHandler;
|
63 |
|
|
unsigned int mask ;
|
64 |
|
|
|
65 |
|
|
oldHandler = pAic->AIC_SVR[irq_id];
|
66 |
|
|
|
67 |
|
|
mask = 0x1 << irq_id ;
|
68 |
|
|
//* Disable the interrupt on the interrupt controller
|
69 |
|
|
pAic->AIC_IDCR = mask ;
|
70 |
|
|
//* Save the interrupt handler routine pointer and the interrupt priority
|
71 |
|
|
pAic->AIC_SVR[irq_id] = (unsigned int) newHandler ;
|
72 |
|
|
//* Store the Source Mode Register
|
73 |
|
|
pAic->AIC_SMR[irq_id] = src_type | priority ;
|
74 |
|
|
//* Clear the interrupt on the interrupt controller
|
75 |
|
|
pAic->AIC_ICCR = mask ;
|
76 |
|
|
|
77 |
|
|
return oldHandler;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
//*----------------------------------------------------------------------------
|
81 |
|
|
//* \fn AT91F_AIC_EnableIt
|
82 |
|
|
//* \brief Enable corresponding IT number
|
83 |
|
|
//*----------------------------------------------------------------------------
|
84 |
|
|
__inline void AT91F_AIC_EnableIt (
|
85 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
86 |
|
|
unsigned int irq_id ) // \arg interrupt number to initialize
|
87 |
|
|
{
|
88 |
|
|
//* Enable the interrupt on the interrupt controller
|
89 |
|
|
pAic->AIC_IECR = 0x1 << irq_id ;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
//*----------------------------------------------------------------------------
|
93 |
|
|
//* \fn AT91F_AIC_DisableIt
|
94 |
|
|
//* \brief Disable corresponding IT number
|
95 |
|
|
//*----------------------------------------------------------------------------
|
96 |
|
|
__inline void AT91F_AIC_DisableIt (
|
97 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
98 |
|
|
unsigned int irq_id ) // \arg interrupt number to initialize
|
99 |
|
|
{
|
100 |
|
|
unsigned int mask = 0x1 << irq_id;
|
101 |
|
|
//* Disable the interrupt on the interrupt controller
|
102 |
|
|
pAic->AIC_IDCR = mask ;
|
103 |
|
|
//* Clear the interrupt on the Interrupt Controller ( if one is pending )
|
104 |
|
|
pAic->AIC_ICCR = mask ;
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
//*----------------------------------------------------------------------------
|
108 |
|
|
//* \fn AT91F_AIC_ClearIt
|
109 |
|
|
//* \brief Clear corresponding IT number
|
110 |
|
|
//*----------------------------------------------------------------------------
|
111 |
|
|
__inline void AT91F_AIC_ClearIt (
|
112 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
113 |
|
|
unsigned int irq_id) // \arg interrupt number to initialize
|
114 |
|
|
{
|
115 |
|
|
//* Clear the interrupt on the Interrupt Controller ( if one is pending )
|
116 |
|
|
pAic->AIC_ICCR = (0x1 << irq_id);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
//*----------------------------------------------------------------------------
|
120 |
|
|
//* \fn AT91F_AIC_AcknowledgeIt
|
121 |
|
|
//* \brief Acknowledge corresponding IT number
|
122 |
|
|
//*----------------------------------------------------------------------------
|
123 |
|
|
__inline void AT91F_AIC_AcknowledgeIt (
|
124 |
|
|
AT91PS_AIC pAic) // \arg pointer to the AIC registers
|
125 |
|
|
{
|
126 |
|
|
pAic->AIC_EOICR = pAic->AIC_EOICR;
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
//*----------------------------------------------------------------------------
|
130 |
|
|
//* \fn AT91F_AIC_SetExceptionVector
|
131 |
|
|
//* \brief Configure vector handler
|
132 |
|
|
//*----------------------------------------------------------------------------
|
133 |
|
|
__inline unsigned int AT91F_AIC_SetExceptionVector (
|
134 |
|
|
unsigned int *pVector, // \arg pointer to the AIC registers
|
135 |
|
|
void (*Handler) () ) // \arg Interrupt Handler
|
136 |
|
|
{
|
137 |
|
|
unsigned int oldVector = *pVector;
|
138 |
|
|
|
139 |
|
|
if ((unsigned int) Handler == (unsigned int) AT91C_AIC_BRANCH_OPCODE)
|
140 |
|
|
*pVector = (unsigned int) AT91C_AIC_BRANCH_OPCODE;
|
141 |
|
|
else
|
142 |
|
|
*pVector = (((((unsigned int) Handler) - ((unsigned int) pVector) - 0x8) >> 2) & 0x00FFFFFF) | 0xEA000000;
|
143 |
|
|
|
144 |
|
|
return oldVector;
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
//*----------------------------------------------------------------------------
|
148 |
|
|
//* \fn AT91F_AIC_Trig
|
149 |
|
|
//* \brief Trig an IT
|
150 |
|
|
//*----------------------------------------------------------------------------
|
151 |
|
|
__inline void AT91F_AIC_Trig (
|
152 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
153 |
|
|
unsigned int irq_id) // \arg interrupt number
|
154 |
|
|
{
|
155 |
|
|
pAic->AIC_ISCR = (0x1 << irq_id) ;
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
//*----------------------------------------------------------------------------
|
159 |
|
|
//* \fn AT91F_AIC_IsActive
|
160 |
|
|
//* \brief Test if an IT is active
|
161 |
|
|
//*----------------------------------------------------------------------------
|
162 |
|
|
__inline unsigned int AT91F_AIC_IsActive (
|
163 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
164 |
|
|
unsigned int irq_id) // \arg Interrupt Number
|
165 |
|
|
{
|
166 |
|
|
return (pAic->AIC_ISR & (0x1 << irq_id));
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
//*----------------------------------------------------------------------------
|
170 |
|
|
//* \fn AT91F_AIC_IsPending
|
171 |
|
|
//* \brief Test if an IT is pending
|
172 |
|
|
//*----------------------------------------------------------------------------
|
173 |
|
|
__inline unsigned int AT91F_AIC_IsPending (
|
174 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
175 |
|
|
unsigned int irq_id) // \arg Interrupt Number
|
176 |
|
|
{
|
177 |
|
|
return (pAic->AIC_IPR & (0x1 << irq_id));
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
//*----------------------------------------------------------------------------
|
181 |
|
|
//* \fn AT91F_AIC_Open
|
182 |
|
|
//* \brief Set exception vectors and AIC registers to default values
|
183 |
|
|
//*----------------------------------------------------------------------------
|
184 |
|
|
__inline void AT91F_AIC_Open(
|
185 |
|
|
AT91PS_AIC pAic, // \arg pointer to the AIC registers
|
186 |
|
|
void (*IrqHandler) (), // \arg Default IRQ vector exception
|
187 |
|
|
void (*FiqHandler) (), // \arg Default FIQ vector exception
|
188 |
|
|
void (*DefaultHandler) (), // \arg Default Handler set in ISR
|
189 |
|
|
void (*SpuriousHandler) (), // \arg Default Spurious Handler
|
190 |
|
|
unsigned int protectMode) // \arg Debug Control Register
|
191 |
|
|
{
|
192 |
|
|
int i;
|
193 |
|
|
|
194 |
|
|
// Disable all interrupts and set IVR to the default handler
|
195 |
|
|
for (i = 0; i < 32; ++i) {
|
196 |
|
|
AT91F_AIC_DisableIt(pAic, i);
|
197 |
|
|
AT91F_AIC_ConfigureIt(pAic, i, AT91C_AIC_PRIOR_LOWEST, AT91C_AIC_SRCTYPE_HIGH_LEVEL, DefaultHandler);
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
// Set the IRQ exception vector
|
201 |
|
|
AT91F_AIC_SetExceptionVector((unsigned int *) 0x18, IrqHandler);
|
202 |
|
|
// Set the Fast Interrupt exception vector
|
203 |
|
|
AT91F_AIC_SetExceptionVector((unsigned int *) 0x1C, FiqHandler);
|
204 |
|
|
|
205 |
|
|
pAic->AIC_SPU = (unsigned int) SpuriousHandler;
|
206 |
|
|
pAic->AIC_DCR = protectMode;
|
207 |
|
|
}
|
208 |
|
|
/* *****************************************************************************
|
209 |
|
|
SOFTWARE API FOR PDC
|
210 |
|
|
***************************************************************************** */
|
211 |
|
|
//*----------------------------------------------------------------------------
|
212 |
|
|
//* \fn AT91F_PDC_SetNextRx
|
213 |
|
|
//* \brief Set the next receive transfer descriptor
|
214 |
|
|
//*----------------------------------------------------------------------------
|
215 |
|
|
__inline void AT91F_PDC_SetNextRx (
|
216 |
|
|
AT91PS_PDC pPDC, // \arg pointer to a PDC controller
|
217 |
|
|
char *address, // \arg address to the next bloc to be received
|
218 |
|
|
unsigned int bytes) // \arg number of bytes to be received
|
219 |
|
|
{
|
220 |
|
|
pPDC->PDC_RNPR = (unsigned int) address;
|
221 |
|
|
pPDC->PDC_RNCR = bytes;
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
//*----------------------------------------------------------------------------
|
225 |
|
|
//* \fn AT91F_PDC_SetNextTx
|
226 |
|
|
//* \brief Set the next transmit transfer descriptor
|
227 |
|
|
//*----------------------------------------------------------------------------
|
228 |
|
|
__inline void AT91F_PDC_SetNextTx (
|
229 |
|
|
AT91PS_PDC pPDC, // \arg pointer to a PDC controller
|
230 |
|
|
char *address, // \arg address to the next bloc to be transmitted
|
231 |
|
|
unsigned int bytes) // \arg number of bytes to be transmitted
|
232 |
|
|
{
|
233 |
|
|
pPDC->PDC_TNPR = (unsigned int) address;
|
234 |
|
|
pPDC->PDC_TNCR = bytes;
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
//*----------------------------------------------------------------------------
|
238 |
|
|
//* \fn AT91F_PDC_SetRx
|
239 |
|
|
//* \brief Set the receive transfer descriptor
|
240 |
|
|
//*----------------------------------------------------------------------------
|
241 |
|
|
__inline void AT91F_PDC_SetRx (
|
242 |
|
|
AT91PS_PDC pPDC, // \arg pointer to a PDC controller
|
243 |
|
|
char *address, // \arg address to the next bloc to be received
|
244 |
|
|
unsigned int bytes) // \arg number of bytes to be received
|
245 |
|
|
{
|
246 |
|
|
pPDC->PDC_RPR = (unsigned int) address;
|
247 |
|
|
pPDC->PDC_RCR = bytes;
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
//*----------------------------------------------------------------------------
|
251 |
|
|
//* \fn AT91F_PDC_SetTx
|
252 |
|
|
//* \brief Set the transmit transfer descriptor
|
253 |
|
|
//*----------------------------------------------------------------------------
|
254 |
|
|
__inline void AT91F_PDC_SetTx (
|
255 |
|
|
AT91PS_PDC pPDC, // \arg pointer to a PDC controller
|
256 |
|
|
char *address, // \arg address to the next bloc to be transmitted
|
257 |
|
|
unsigned int bytes) // \arg number of bytes to be transmitted
|
258 |
|
|
{
|
259 |
|
|
pPDC->PDC_TPR = (unsigned int) address;
|
260 |
|
|
pPDC->PDC_TCR = bytes;
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
//*----------------------------------------------------------------------------
|
264 |
|
|
//* \fn AT91F_PDC_EnableTx
|
265 |
|
|
//* \brief Enable transmit
|
266 |
|
|
//*----------------------------------------------------------------------------
|
267 |
|
|
__inline void AT91F_PDC_EnableTx (
|
268 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
269 |
|
|
{
|
270 |
|
|
pPDC->PDC_PTCR = AT91C_PDC_TXTEN;
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
//*----------------------------------------------------------------------------
|
274 |
|
|
//* \fn AT91F_PDC_EnableRx
|
275 |
|
|
//* \brief Enable receive
|
276 |
|
|
//*----------------------------------------------------------------------------
|
277 |
|
|
__inline void AT91F_PDC_EnableRx (
|
278 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
279 |
|
|
{
|
280 |
|
|
pPDC->PDC_PTCR = AT91C_PDC_RXTEN;
|
281 |
|
|
}
|
282 |
|
|
|
283 |
|
|
//*----------------------------------------------------------------------------
|
284 |
|
|
//* \fn AT91F_PDC_DisableTx
|
285 |
|
|
//* \brief Disable transmit
|
286 |
|
|
//*----------------------------------------------------------------------------
|
287 |
|
|
__inline void AT91F_PDC_DisableTx (
|
288 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
289 |
|
|
{
|
290 |
|
|
pPDC->PDC_PTCR = AT91C_PDC_TXTDIS;
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
//*----------------------------------------------------------------------------
|
294 |
|
|
//* \fn AT91F_PDC_DisableRx
|
295 |
|
|
//* \brief Disable receive
|
296 |
|
|
//*----------------------------------------------------------------------------
|
297 |
|
|
__inline void AT91F_PDC_DisableRx (
|
298 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
299 |
|
|
{
|
300 |
|
|
pPDC->PDC_PTCR = AT91C_PDC_RXTDIS;
|
301 |
|
|
}
|
302 |
|
|
|
303 |
|
|
//*----------------------------------------------------------------------------
|
304 |
|
|
//* \fn AT91F_PDC_IsTxEmpty
|
305 |
|
|
//* \brief Test if the current transfer descriptor has been sent
|
306 |
|
|
//*----------------------------------------------------------------------------
|
307 |
|
|
__inline int AT91F_PDC_IsTxEmpty ( // \return return 1 if transfer is complete
|
308 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
309 |
|
|
{
|
310 |
|
|
return !(pPDC->PDC_TCR);
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
//*----------------------------------------------------------------------------
|
314 |
|
|
//* \fn AT91F_PDC_IsNextTxEmpty
|
315 |
|
|
//* \brief Test if the next transfer descriptor has been moved to the current td
|
316 |
|
|
//*----------------------------------------------------------------------------
|
317 |
|
|
__inline int AT91F_PDC_IsNextTxEmpty ( // \return return 1 if transfer is complete
|
318 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
319 |
|
|
{
|
320 |
|
|
return !(pPDC->PDC_TNCR);
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
//*----------------------------------------------------------------------------
|
324 |
|
|
//* \fn AT91F_PDC_IsRxEmpty
|
325 |
|
|
//* \brief Test if the current transfer descriptor has been filled
|
326 |
|
|
//*----------------------------------------------------------------------------
|
327 |
|
|
__inline int AT91F_PDC_IsRxEmpty ( // \return return 1 if transfer is complete
|
328 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
329 |
|
|
{
|
330 |
|
|
return !(pPDC->PDC_RCR);
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
//*----------------------------------------------------------------------------
|
334 |
|
|
//* \fn AT91F_PDC_IsNextRxEmpty
|
335 |
|
|
//* \brief Test if the next transfer descriptor has been moved to the current td
|
336 |
|
|
//*----------------------------------------------------------------------------
|
337 |
|
|
__inline int AT91F_PDC_IsNextRxEmpty ( // \return return 1 if transfer is complete
|
338 |
|
|
AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
|
339 |
|
|
{
|
340 |
|
|
return !(pPDC->PDC_RNCR);
|
341 |
|
|
}
|
342 |
|
|
|
343 |
|
|
//*----------------------------------------------------------------------------
|
344 |
|
|
//* \fn AT91F_PDC_Open
|
345 |
|
|
//* \brief Open PDC: disable TX and RX reset transfer descriptors, re-enable RX and TX
|
346 |
|
|
//*----------------------------------------------------------------------------
|
347 |
|
|
__inline void AT91F_PDC_Open (
|
348 |
|
|
AT91PS_PDC pPDC) // \arg pointer to a PDC controller
|
349 |
|
|
{
|
350 |
|
|
//* Disable the RX and TX PDC transfer requests
|
351 |
|
|
AT91F_PDC_DisableRx(pPDC);
|
352 |
|
|
AT91F_PDC_DisableTx(pPDC);
|
353 |
|
|
|
354 |
|
|
//* Reset all Counter register Next buffer first
|
355 |
|
|
AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);
|
356 |
|
|
AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);
|
357 |
|
|
AT91F_PDC_SetTx(pPDC, (char *) 0, 0);
|
358 |
|
|
AT91F_PDC_SetRx(pPDC, (char *) 0, 0);
|
359 |
|
|
|
360 |
|
|
//* Enable the RX and TX PDC transfer requests
|
361 |
|
|
AT91F_PDC_EnableRx(pPDC);
|
362 |
|
|
AT91F_PDC_EnableTx(pPDC);
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
//*----------------------------------------------------------------------------
|
366 |
|
|
//* \fn AT91F_PDC_Close
|
367 |
|
|
//* \brief Close PDC: disable TX and RX reset transfer descriptors
|
368 |
|
|
//*----------------------------------------------------------------------------
|
369 |
|
|
__inline void AT91F_PDC_Close (
|
370 |
|
|
AT91PS_PDC pPDC) // \arg pointer to a PDC controller
|
371 |
|
|
{
|
372 |
|
|
//* Disable the RX and TX PDC transfer requests
|
373 |
|
|
AT91F_PDC_DisableRx(pPDC);
|
374 |
|
|
AT91F_PDC_DisableTx(pPDC);
|
375 |
|
|
|
376 |
|
|
//* Reset all Counter register Next buffer first
|
377 |
|
|
AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);
|
378 |
|
|
AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);
|
379 |
|
|
AT91F_PDC_SetTx(pPDC, (char *) 0, 0);
|
380 |
|
|
AT91F_PDC_SetRx(pPDC, (char *) 0, 0);
|
381 |
|
|
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
//*----------------------------------------------------------------------------
|
385 |
|
|
//* \fn AT91F_PDC_SendFrame
|
386 |
|
|
//* \brief Close PDC: disable TX and RX reset transfer descriptors
|
387 |
|
|
//*----------------------------------------------------------------------------
|
388 |
|
|
__inline unsigned int AT91F_PDC_SendFrame(
|
389 |
|
|
AT91PS_PDC pPDC,
|
390 |
|
|
char *pBuffer,
|
391 |
|
|
unsigned int szBuffer,
|
392 |
|
|
char *pNextBuffer,
|
393 |
|
|
unsigned int szNextBuffer )
|
394 |
|
|
{
|
395 |
|
|
if (AT91F_PDC_IsTxEmpty(pPDC)) {
|
396 |
|
|
//* Buffer and next buffer can be initialized
|
397 |
|
|
AT91F_PDC_SetTx(pPDC, pBuffer, szBuffer);
|
398 |
|
|
AT91F_PDC_SetNextTx(pPDC, pNextBuffer, szNextBuffer);
|
399 |
|
|
return 2;
|
400 |
|
|
}
|
401 |
|
|
else if (AT91F_PDC_IsNextTxEmpty(pPDC)) {
|
402 |
|
|
//* Only one buffer can be initialized
|
403 |
|
|
AT91F_PDC_SetNextTx(pPDC, pBuffer, szBuffer);
|
404 |
|
|
return 1;
|
405 |
|
|
}
|
406 |
|
|
else {
|
407 |
|
|
//* All buffer are in use...
|
408 |
|
|
return 0;
|
409 |
|
|
}
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
//*----------------------------------------------------------------------------
|
413 |
|
|
//* \fn AT91F_PDC_ReceiveFrame
|
414 |
|
|
//* \brief Close PDC: disable TX and RX reset transfer descriptors
|
415 |
|
|
//*----------------------------------------------------------------------------
|
416 |
|
|
__inline unsigned int AT91F_PDC_ReceiveFrame (
|
417 |
|
|
AT91PS_PDC pPDC,
|
418 |
|
|
char *pBuffer,
|
419 |
|
|
unsigned int szBuffer,
|
420 |
|
|
char *pNextBuffer,
|
421 |
|
|
unsigned int szNextBuffer )
|
422 |
|
|
{
|
423 |
|
|
if (AT91F_PDC_IsRxEmpty(pPDC)) {
|
424 |
|
|
//* Buffer and next buffer can be initialized
|
425 |
|
|
AT91F_PDC_SetRx(pPDC, pBuffer, szBuffer);
|
426 |
|
|
AT91F_PDC_SetNextRx(pPDC, pNextBuffer, szNextBuffer);
|
427 |
|
|
return 2;
|
428 |
|
|
}
|
429 |
|
|
else if (AT91F_PDC_IsNextRxEmpty(pPDC)) {
|
430 |
|
|
//* Only one buffer can be initialized
|
431 |
|
|
AT91F_PDC_SetNextRx(pPDC, pBuffer, szBuffer);
|
432 |
|
|
return 1;
|
433 |
|
|
}
|
434 |
|
|
else {
|
435 |
|
|
//* All buffer are in use...
|
436 |
|
|
return 0;
|
437 |
|
|
}
|
438 |
|
|
}
|
439 |
|
|
/* *****************************************************************************
|
440 |
|
|
SOFTWARE API FOR DBGU
|
441 |
|
|
***************************************************************************** */
|
442 |
|
|
//*----------------------------------------------------------------------------
|
443 |
|
|
//* \fn AT91F_DBGU_InterruptEnable
|
444 |
|
|
//* \brief Enable DBGU Interrupt
|
445 |
|
|
//*----------------------------------------------------------------------------
|
446 |
|
|
__inline void AT91F_DBGU_InterruptEnable(
|
447 |
|
|
AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
|
448 |
|
|
unsigned int flag) // \arg dbgu interrupt to be enabled
|
449 |
|
|
{
|
450 |
|
|
pDbgu->DBGU_IER = flag;
|
451 |
|
|
}
|
452 |
|
|
|
453 |
|
|
//*----------------------------------------------------------------------------
|
454 |
|
|
//* \fn AT91F_DBGU_InterruptDisable
|
455 |
|
|
//* \brief Disable DBGU Interrupt
|
456 |
|
|
//*----------------------------------------------------------------------------
|
457 |
|
|
__inline void AT91F_DBGU_InterruptDisable(
|
458 |
|
|
AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
|
459 |
|
|
unsigned int flag) // \arg dbgu interrupt to be disabled
|
460 |
|
|
{
|
461 |
|
|
pDbgu->DBGU_IDR = flag;
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
//*----------------------------------------------------------------------------
|
465 |
|
|
//* \fn AT91F_DBGU_GetInterruptMaskStatus
|
466 |
|
|
//* \brief Return DBGU Interrupt Mask Status
|
467 |
|
|
//*----------------------------------------------------------------------------
|
468 |
|
|
__inline unsigned int AT91F_DBGU_GetInterruptMaskStatus( // \return DBGU Interrupt Mask Status
|
469 |
|
|
AT91PS_DBGU pDbgu) // \arg pointer to a DBGU controller
|
470 |
|
|
{
|
471 |
|
|
return pDbgu->DBGU_IMR;
|
472 |
|
|
}
|
473 |
|
|
|
474 |
|
|
//*----------------------------------------------------------------------------
|
475 |
|
|
//* \fn AT91F_DBGU_IsInterruptMasked
|
476 |
|
|
//* \brief Test if DBGU Interrupt is Masked
|
477 |
|
|
//*----------------------------------------------------------------------------
|
478 |
|
|
__inline int AT91F_DBGU_IsInterruptMasked(
|
479 |
|
|
AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
|
480 |
|
|
unsigned int flag) // \arg flag to be tested
|
481 |
|
|
{
|
482 |
|
|
return (AT91F_DBGU_GetInterruptMaskStatus(pDbgu) & flag);
|
483 |
|
|
}
|
484 |
|
|
|
485 |
|
|
/* *****************************************************************************
|
486 |
|
|
SOFTWARE API FOR PIO
|
487 |
|
|
***************************************************************************** */
|
488 |
|
|
//*----------------------------------------------------------------------------
|
489 |
|
|
//* \fn AT91F_PIO_CfgPeriph
|
490 |
|
|
//* \brief Enable pins to be drived by peripheral
|
491 |
|
|
//*----------------------------------------------------------------------------
|
492 |
|
|
__inline void AT91F_PIO_CfgPeriph(
|
493 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
494 |
|
|
unsigned int periphAEnable, // \arg PERIPH A to enable
|
495 |
|
|
unsigned int periphBEnable) // \arg PERIPH B to enable
|
496 |
|
|
|
497 |
|
|
{
|
498 |
|
|
pPio->PIO_ASR = periphAEnable;
|
499 |
|
|
pPio->PIO_BSR = periphBEnable;
|
500 |
|
|
pPio->PIO_PDR = (periphAEnable | periphBEnable); // Set in Periph mode
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
//*----------------------------------------------------------------------------
|
504 |
|
|
//* \fn AT91F_PIO_CfgOutput
|
505 |
|
|
//* \brief Enable PIO in output mode
|
506 |
|
|
//*----------------------------------------------------------------------------
|
507 |
|
|
__inline void AT91F_PIO_CfgOutput(
|
508 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
509 |
|
|
unsigned int pioEnable) // \arg PIO to be enabled
|
510 |
|
|
{
|
511 |
|
|
pPio->PIO_PER = pioEnable; // Set in PIO mode
|
512 |
|
|
pPio->PIO_OER = pioEnable; // Configure in Output
|
513 |
|
|
}
|
514 |
|
|
|
515 |
|
|
//*----------------------------------------------------------------------------
|
516 |
|
|
//* \fn AT91F_PIO_CfgInput
|
517 |
|
|
//* \brief Enable PIO in input mode
|
518 |
|
|
//*----------------------------------------------------------------------------
|
519 |
|
|
__inline void AT91F_PIO_CfgInput(
|
520 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
521 |
|
|
unsigned int inputEnable) // \arg PIO to be enabled
|
522 |
|
|
{
|
523 |
|
|
// Disable output
|
524 |
|
|
pPio->PIO_ODR = inputEnable;
|
525 |
|
|
pPio->PIO_PER = inputEnable;
|
526 |
|
|
}
|
527 |
|
|
|
528 |
|
|
//*----------------------------------------------------------------------------
|
529 |
|
|
//* \fn AT91F_PIO_CfgOpendrain
|
530 |
|
|
//* \brief Configure PIO in open drain
|
531 |
|
|
//*----------------------------------------------------------------------------
|
532 |
|
|
__inline void AT91F_PIO_CfgOpendrain(
|
533 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
534 |
|
|
unsigned int multiDrvEnable) // \arg pio to be configured in open drain
|
535 |
|
|
{
|
536 |
|
|
// Configure the multi-drive option
|
537 |
|
|
pPio->PIO_MDDR = ~multiDrvEnable;
|
538 |
|
|
pPio->PIO_MDER = multiDrvEnable;
|
539 |
|
|
}
|
540 |
|
|
|
541 |
|
|
//*----------------------------------------------------------------------------
|
542 |
|
|
//* \fn AT91F_PIO_CfgPullup
|
543 |
|
|
//* \brief Enable pullup on PIO
|
544 |
|
|
//*----------------------------------------------------------------------------
|
545 |
|
|
__inline void AT91F_PIO_CfgPullup(
|
546 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
547 |
|
|
unsigned int pullupEnable) // \arg enable pullup on PIO
|
548 |
|
|
{
|
549 |
|
|
// Connect or not Pullup
|
550 |
|
|
pPio->PIO_PPUDR = ~pullupEnable;
|
551 |
|
|
pPio->PIO_PPUER = pullupEnable;
|
552 |
|
|
}
|
553 |
|
|
|
554 |
|
|
//*----------------------------------------------------------------------------
|
555 |
|
|
//* \fn AT91F_PIO_CfgDirectDrive
|
556 |
|
|
//* \brief Enable direct drive on PIO
|
557 |
|
|
//*----------------------------------------------------------------------------
|
558 |
|
|
__inline void AT91F_PIO_CfgDirectDrive(
|
559 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
560 |
|
|
unsigned int directDrive) // \arg PIO to be configured with direct drive
|
561 |
|
|
|
562 |
|
|
{
|
563 |
|
|
// Configure the Direct Drive
|
564 |
|
|
pPio->PIO_OWDR = ~directDrive;
|
565 |
|
|
pPio->PIO_OWER = directDrive;
|
566 |
|
|
}
|
567 |
|
|
|
568 |
|
|
//*----------------------------------------------------------------------------
|
569 |
|
|
//* \fn AT91F_PIO_CfgInputFilter
|
570 |
|
|
//* \brief Enable input filter on input PIO
|
571 |
|
|
//*----------------------------------------------------------------------------
|
572 |
|
|
__inline void AT91F_PIO_CfgInputFilter(
|
573 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
574 |
|
|
unsigned int inputFilter) // \arg PIO to be configured with input filter
|
575 |
|
|
|
576 |
|
|
{
|
577 |
|
|
// Configure the Direct Drive
|
578 |
|
|
pPio->PIO_IFDR = ~inputFilter;
|
579 |
|
|
pPio->PIO_IFER = inputFilter;
|
580 |
|
|
}
|
581 |
|
|
|
582 |
|
|
//*----------------------------------------------------------------------------
|
583 |
|
|
//* \fn AT91F_PIO_GetInput
|
584 |
|
|
//* \brief Return PIO input value
|
585 |
|
|
//*----------------------------------------------------------------------------
|
586 |
|
|
__inline unsigned int AT91F_PIO_GetInput( // \return PIO input
|
587 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
588 |
|
|
{
|
589 |
|
|
return pPio->PIO_PDSR;
|
590 |
|
|
}
|
591 |
|
|
|
592 |
|
|
//*----------------------------------------------------------------------------
|
593 |
|
|
//* \fn AT91F_PIO_IsInputSet
|
594 |
|
|
//* \brief Test if PIO is input flag is active
|
595 |
|
|
//*----------------------------------------------------------------------------
|
596 |
|
|
__inline int AT91F_PIO_IsInputSet(
|
597 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
598 |
|
|
unsigned int flag) // \arg flag to be tested
|
599 |
|
|
{
|
600 |
|
|
return (AT91F_PIO_GetInput(pPio) & flag);
|
601 |
|
|
}
|
602 |
|
|
|
603 |
|
|
|
604 |
|
|
//*----------------------------------------------------------------------------
|
605 |
|
|
//* \fn AT91F_PIO_SetOutput
|
606 |
|
|
//* \brief Set to 1 output PIO
|
607 |
|
|
//*----------------------------------------------------------------------------
|
608 |
|
|
__inline void AT91F_PIO_SetOutput(
|
609 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
610 |
|
|
unsigned int flag) // \arg output to be set
|
611 |
|
|
{
|
612 |
|
|
pPio->PIO_SODR = flag;
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
//*----------------------------------------------------------------------------
|
616 |
|
|
//* \fn AT91F_PIO_ClearOutput
|
617 |
|
|
//* \brief Set to 0 output PIO
|
618 |
|
|
//*----------------------------------------------------------------------------
|
619 |
|
|
__inline void AT91F_PIO_ClearOutput(
|
620 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
621 |
|
|
unsigned int flag) // \arg output to be cleared
|
622 |
|
|
{
|
623 |
|
|
pPio->PIO_CODR = flag;
|
624 |
|
|
}
|
625 |
|
|
|
626 |
|
|
//*----------------------------------------------------------------------------
|
627 |
|
|
//* \fn AT91F_PIO_ForceOutput
|
628 |
|
|
//* \brief Force output when Direct drive option is enabled
|
629 |
|
|
//*----------------------------------------------------------------------------
|
630 |
|
|
__inline void AT91F_PIO_ForceOutput(
|
631 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
632 |
|
|
unsigned int flag) // \arg output to be forced
|
633 |
|
|
{
|
634 |
|
|
pPio->PIO_ODSR = flag;
|
635 |
|
|
}
|
636 |
|
|
|
637 |
|
|
//*----------------------------------------------------------------------------
|
638 |
|
|
//* \fn AT91F_PIO_Enable
|
639 |
|
|
//* \brief Enable PIO
|
640 |
|
|
//*----------------------------------------------------------------------------
|
641 |
|
|
__inline void AT91F_PIO_Enable(
|
642 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
643 |
|
|
unsigned int flag) // \arg pio to be enabled
|
644 |
|
|
{
|
645 |
|
|
pPio->PIO_PER = flag;
|
646 |
|
|
}
|
647 |
|
|
|
648 |
|
|
//*----------------------------------------------------------------------------
|
649 |
|
|
//* \fn AT91F_PIO_Disable
|
650 |
|
|
//* \brief Disable PIO
|
651 |
|
|
//*----------------------------------------------------------------------------
|
652 |
|
|
__inline void AT91F_PIO_Disable(
|
653 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
654 |
|
|
unsigned int flag) // \arg pio to be disabled
|
655 |
|
|
{
|
656 |
|
|
pPio->PIO_PDR = flag;
|
657 |
|
|
}
|
658 |
|
|
|
659 |
|
|
//*----------------------------------------------------------------------------
|
660 |
|
|
//* \fn AT91F_PIO_GetStatus
|
661 |
|
|
//* \brief Return PIO Status
|
662 |
|
|
//*----------------------------------------------------------------------------
|
663 |
|
|
__inline unsigned int AT91F_PIO_GetStatus( // \return PIO Status
|
664 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
665 |
|
|
{
|
666 |
|
|
return pPio->PIO_PSR;
|
667 |
|
|
}
|
668 |
|
|
|
669 |
|
|
//*----------------------------------------------------------------------------
|
670 |
|
|
//* \fn AT91F_PIO_IsSet
|
671 |
|
|
//* \brief Test if PIO is Set
|
672 |
|
|
//*----------------------------------------------------------------------------
|
673 |
|
|
__inline int AT91F_PIO_IsSet(
|
674 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
675 |
|
|
unsigned int flag) // \arg flag to be tested
|
676 |
|
|
{
|
677 |
|
|
return (AT91F_PIO_GetStatus(pPio) & flag);
|
678 |
|
|
}
|
679 |
|
|
|
680 |
|
|
//*----------------------------------------------------------------------------
|
681 |
|
|
//* \fn AT91F_PIO_OutputEnable
|
682 |
|
|
//* \brief Output Enable PIO
|
683 |
|
|
//*----------------------------------------------------------------------------
|
684 |
|
|
__inline void AT91F_PIO_OutputEnable(
|
685 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
686 |
|
|
unsigned int flag) // \arg pio output to be enabled
|
687 |
|
|
{
|
688 |
|
|
pPio->PIO_OER = flag;
|
689 |
|
|
}
|
690 |
|
|
|
691 |
|
|
//*----------------------------------------------------------------------------
|
692 |
|
|
//* \fn AT91F_PIO_OutputDisable
|
693 |
|
|
//* \brief Output Enable PIO
|
694 |
|
|
//*----------------------------------------------------------------------------
|
695 |
|
|
__inline void AT91F_PIO_OutputDisable(
|
696 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
697 |
|
|
unsigned int flag) // \arg pio output to be disabled
|
698 |
|
|
{
|
699 |
|
|
pPio->PIO_ODR = flag;
|
700 |
|
|
}
|
701 |
|
|
|
702 |
|
|
//*----------------------------------------------------------------------------
|
703 |
|
|
//* \fn AT91F_PIO_GetOutputStatus
|
704 |
|
|
//* \brief Return PIO Output Status
|
705 |
|
|
//*----------------------------------------------------------------------------
|
706 |
|
|
__inline unsigned int AT91F_PIO_GetOutputStatus( // \return PIO Output Status
|
707 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
708 |
|
|
{
|
709 |
|
|
return pPio->PIO_OSR;
|
710 |
|
|
}
|
711 |
|
|
|
712 |
|
|
//*----------------------------------------------------------------------------
|
713 |
|
|
//* \fn AT91F_PIO_IsOuputSet
|
714 |
|
|
//* \brief Test if PIO Output is Set
|
715 |
|
|
//*----------------------------------------------------------------------------
|
716 |
|
|
__inline int AT91F_PIO_IsOutputSet(
|
717 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
718 |
|
|
unsigned int flag) // \arg flag to be tested
|
719 |
|
|
{
|
720 |
|
|
return (AT91F_PIO_GetOutputStatus(pPio) & flag);
|
721 |
|
|
}
|
722 |
|
|
|
723 |
|
|
//*----------------------------------------------------------------------------
|
724 |
|
|
//* \fn AT91F_PIO_InputFilterEnable
|
725 |
|
|
//* \brief Input Filter Enable PIO
|
726 |
|
|
//*----------------------------------------------------------------------------
|
727 |
|
|
__inline void AT91F_PIO_InputFilterEnable(
|
728 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
729 |
|
|
unsigned int flag) // \arg pio input filter to be enabled
|
730 |
|
|
{
|
731 |
|
|
pPio->PIO_IFER = flag;
|
732 |
|
|
}
|
733 |
|
|
|
734 |
|
|
//*----------------------------------------------------------------------------
|
735 |
|
|
//* \fn AT91F_PIO_InputFilterDisable
|
736 |
|
|
//* \brief Input Filter Disable PIO
|
737 |
|
|
//*----------------------------------------------------------------------------
|
738 |
|
|
__inline void AT91F_PIO_InputFilterDisable(
|
739 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
740 |
|
|
unsigned int flag) // \arg pio input filter to be disabled
|
741 |
|
|
{
|
742 |
|
|
pPio->PIO_IFDR = flag;
|
743 |
|
|
}
|
744 |
|
|
|
745 |
|
|
//*----------------------------------------------------------------------------
|
746 |
|
|
//* \fn AT91F_PIO_GetInputFilterStatus
|
747 |
|
|
//* \brief Return PIO Input Filter Status
|
748 |
|
|
//*----------------------------------------------------------------------------
|
749 |
|
|
__inline unsigned int AT91F_PIO_GetInputFilterStatus( // \return PIO Input Filter Status
|
750 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
751 |
|
|
{
|
752 |
|
|
return pPio->PIO_IFSR;
|
753 |
|
|
}
|
754 |
|
|
|
755 |
|
|
//*----------------------------------------------------------------------------
|
756 |
|
|
//* \fn AT91F_PIO_IsInputFilterSet
|
757 |
|
|
//* \brief Test if PIO Input filter is Set
|
758 |
|
|
//*----------------------------------------------------------------------------
|
759 |
|
|
__inline int AT91F_PIO_IsInputFilterSet(
|
760 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
761 |
|
|
unsigned int flag) // \arg flag to be tested
|
762 |
|
|
{
|
763 |
|
|
return (AT91F_PIO_GetInputFilterStatus(pPio) & flag);
|
764 |
|
|
}
|
765 |
|
|
|
766 |
|
|
//*----------------------------------------------------------------------------
|
767 |
|
|
//* \fn AT91F_PIO_GetOutputDataStatus
|
768 |
|
|
//* \brief Return PIO Output Data Status
|
769 |
|
|
//*----------------------------------------------------------------------------
|
770 |
|
|
__inline unsigned int AT91F_PIO_GetOutputDataStatus( // \return PIO Output Data Status
|
771 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
772 |
|
|
{
|
773 |
|
|
return pPio->PIO_ODSR;
|
774 |
|
|
}
|
775 |
|
|
|
776 |
|
|
//*----------------------------------------------------------------------------
|
777 |
|
|
//* \fn AT91F_PIO_InterruptEnable
|
778 |
|
|
//* \brief Enable PIO Interrupt
|
779 |
|
|
//*----------------------------------------------------------------------------
|
780 |
|
|
__inline void AT91F_PIO_InterruptEnable(
|
781 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
782 |
|
|
unsigned int flag) // \arg pio interrupt to be enabled
|
783 |
|
|
{
|
784 |
|
|
pPio->PIO_IER = flag;
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
//*----------------------------------------------------------------------------
|
788 |
|
|
//* \fn AT91F_PIO_InterruptDisable
|
789 |
|
|
//* \brief Disable PIO Interrupt
|
790 |
|
|
//*----------------------------------------------------------------------------
|
791 |
|
|
__inline void AT91F_PIO_InterruptDisable(
|
792 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
793 |
|
|
unsigned int flag) // \arg pio interrupt to be disabled
|
794 |
|
|
{
|
795 |
|
|
pPio->PIO_IDR = flag;
|
796 |
|
|
}
|
797 |
|
|
|
798 |
|
|
//*----------------------------------------------------------------------------
|
799 |
|
|
//* \fn AT91F_PIO_GetInterruptMaskStatus
|
800 |
|
|
//* \brief Return PIO Interrupt Mask Status
|
801 |
|
|
//*----------------------------------------------------------------------------
|
802 |
|
|
__inline unsigned int AT91F_PIO_GetInterruptMaskStatus( // \return PIO Interrupt Mask Status
|
803 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
804 |
|
|
{
|
805 |
|
|
return pPio->PIO_IMR;
|
806 |
|
|
}
|
807 |
|
|
|
808 |
|
|
//*----------------------------------------------------------------------------
|
809 |
|
|
//* \fn AT91F_PIO_GetInterruptStatus
|
810 |
|
|
//* \brief Return PIO Interrupt Status
|
811 |
|
|
//*----------------------------------------------------------------------------
|
812 |
|
|
__inline unsigned int AT91F_PIO_GetInterruptStatus( // \return PIO Interrupt Status
|
813 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
814 |
|
|
{
|
815 |
|
|
return pPio->PIO_ISR;
|
816 |
|
|
}
|
817 |
|
|
|
818 |
|
|
//*----------------------------------------------------------------------------
|
819 |
|
|
//* \fn AT91F_PIO_IsInterruptMasked
|
820 |
|
|
//* \brief Test if PIO Interrupt is Masked
|
821 |
|
|
//*----------------------------------------------------------------------------
|
822 |
|
|
__inline int AT91F_PIO_IsInterruptMasked(
|
823 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
824 |
|
|
unsigned int flag) // \arg flag to be tested
|
825 |
|
|
{
|
826 |
|
|
return (AT91F_PIO_GetInterruptMaskStatus(pPio) & flag);
|
827 |
|
|
}
|
828 |
|
|
|
829 |
|
|
//*----------------------------------------------------------------------------
|
830 |
|
|
//* \fn AT91F_PIO_IsInterruptSet
|
831 |
|
|
//* \brief Test if PIO Interrupt is Set
|
832 |
|
|
//*----------------------------------------------------------------------------
|
833 |
|
|
__inline int AT91F_PIO_IsInterruptSet(
|
834 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
835 |
|
|
unsigned int flag) // \arg flag to be tested
|
836 |
|
|
{
|
837 |
|
|
return (AT91F_PIO_GetInterruptStatus(pPio) & flag);
|
838 |
|
|
}
|
839 |
|
|
|
840 |
|
|
//*----------------------------------------------------------------------------
|
841 |
|
|
//* \fn AT91F_PIO_MultiDriverEnable
|
842 |
|
|
//* \brief Multi Driver Enable PIO
|
843 |
|
|
//*----------------------------------------------------------------------------
|
844 |
|
|
__inline void AT91F_PIO_MultiDriverEnable(
|
845 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
846 |
|
|
unsigned int flag) // \arg pio to be enabled
|
847 |
|
|
{
|
848 |
|
|
pPio->PIO_MDER = flag;
|
849 |
|
|
}
|
850 |
|
|
|
851 |
|
|
//*----------------------------------------------------------------------------
|
852 |
|
|
//* \fn AT91F_PIO_MultiDriverDisable
|
853 |
|
|
//* \brief Multi Driver Disable PIO
|
854 |
|
|
//*----------------------------------------------------------------------------
|
855 |
|
|
__inline void AT91F_PIO_MultiDriverDisable(
|
856 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
857 |
|
|
unsigned int flag) // \arg pio to be disabled
|
858 |
|
|
{
|
859 |
|
|
pPio->PIO_MDDR = flag;
|
860 |
|
|
}
|
861 |
|
|
|
862 |
|
|
//*----------------------------------------------------------------------------
|
863 |
|
|
//* \fn AT91F_PIO_GetMultiDriverStatus
|
864 |
|
|
//* \brief Return PIO Multi Driver Status
|
865 |
|
|
//*----------------------------------------------------------------------------
|
866 |
|
|
__inline unsigned int AT91F_PIO_GetMultiDriverStatus( // \return PIO Multi Driver Status
|
867 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
868 |
|
|
{
|
869 |
|
|
return pPio->PIO_MDSR;
|
870 |
|
|
}
|
871 |
|
|
|
872 |
|
|
//*----------------------------------------------------------------------------
|
873 |
|
|
//* \fn AT91F_PIO_IsMultiDriverSet
|
874 |
|
|
//* \brief Test if PIO MultiDriver is Set
|
875 |
|
|
//*----------------------------------------------------------------------------
|
876 |
|
|
__inline int AT91F_PIO_IsMultiDriverSet(
|
877 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
878 |
|
|
unsigned int flag) // \arg flag to be tested
|
879 |
|
|
{
|
880 |
|
|
return (AT91F_PIO_GetMultiDriverStatus(pPio) & flag);
|
881 |
|
|
}
|
882 |
|
|
|
883 |
|
|
//*----------------------------------------------------------------------------
|
884 |
|
|
//* \fn AT91F_PIO_A_RegisterSelection
|
885 |
|
|
//* \brief PIO A Register Selection
|
886 |
|
|
//*----------------------------------------------------------------------------
|
887 |
|
|
__inline void AT91F_PIO_A_RegisterSelection(
|
888 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
889 |
|
|
unsigned int flag) // \arg pio A register selection
|
890 |
|
|
{
|
891 |
|
|
pPio->PIO_ASR = flag;
|
892 |
|
|
}
|
893 |
|
|
|
894 |
|
|
//*----------------------------------------------------------------------------
|
895 |
|
|
//* \fn AT91F_PIO_B_RegisterSelection
|
896 |
|
|
//* \brief PIO B Register Selection
|
897 |
|
|
//*----------------------------------------------------------------------------
|
898 |
|
|
__inline void AT91F_PIO_B_RegisterSelection(
|
899 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
900 |
|
|
unsigned int flag) // \arg pio B register selection
|
901 |
|
|
{
|
902 |
|
|
pPio->PIO_BSR = flag;
|
903 |
|
|
}
|
904 |
|
|
|
905 |
|
|
//*----------------------------------------------------------------------------
|
906 |
|
|
//* \fn AT91F_PIO_Get_AB_RegisterStatus
|
907 |
|
|
//* \brief Return PIO Interrupt Status
|
908 |
|
|
//*----------------------------------------------------------------------------
|
909 |
|
|
__inline unsigned int AT91F_PIO_Get_AB_RegisterStatus( // \return PIO AB Register Status
|
910 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
911 |
|
|
{
|
912 |
|
|
return pPio->PIO_ABSR;
|
913 |
|
|
}
|
914 |
|
|
|
915 |
|
|
//*----------------------------------------------------------------------------
|
916 |
|
|
//* \fn AT91F_PIO_IsAB_RegisterSet
|
917 |
|
|
//* \brief Test if PIO AB Register is Set
|
918 |
|
|
//*----------------------------------------------------------------------------
|
919 |
|
|
__inline int AT91F_PIO_IsAB_RegisterSet(
|
920 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
921 |
|
|
unsigned int flag) // \arg flag to be tested
|
922 |
|
|
{
|
923 |
|
|
return (AT91F_PIO_Get_AB_RegisterStatus(pPio) & flag);
|
924 |
|
|
}
|
925 |
|
|
|
926 |
|
|
//*----------------------------------------------------------------------------
|
927 |
|
|
//* \fn AT91F_PIO_OutputWriteEnable
|
928 |
|
|
//* \brief Output Write Enable PIO
|
929 |
|
|
//*----------------------------------------------------------------------------
|
930 |
|
|
__inline void AT91F_PIO_OutputWriteEnable(
|
931 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
932 |
|
|
unsigned int flag) // \arg pio output write to be enabled
|
933 |
|
|
{
|
934 |
|
|
pPio->PIO_OWER = flag;
|
935 |
|
|
}
|
936 |
|
|
|
937 |
|
|
//*----------------------------------------------------------------------------
|
938 |
|
|
//* \fn AT91F_PIO_OutputWriteDisable
|
939 |
|
|
//* \brief Output Write Disable PIO
|
940 |
|
|
//*----------------------------------------------------------------------------
|
941 |
|
|
__inline void AT91F_PIO_OutputWriteDisable(
|
942 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
943 |
|
|
unsigned int flag) // \arg pio output write to be disabled
|
944 |
|
|
{
|
945 |
|
|
pPio->PIO_OWDR = flag;
|
946 |
|
|
}
|
947 |
|
|
|
948 |
|
|
//*----------------------------------------------------------------------------
|
949 |
|
|
//* \fn AT91F_PIO_GetOutputWriteStatus
|
950 |
|
|
//* \brief Return PIO Output Write Status
|
951 |
|
|
//*----------------------------------------------------------------------------
|
952 |
|
|
__inline unsigned int AT91F_PIO_GetOutputWriteStatus( // \return PIO Output Write Status
|
953 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
954 |
|
|
{
|
955 |
|
|
return pPio->PIO_OWSR;
|
956 |
|
|
}
|
957 |
|
|
|
958 |
|
|
//*----------------------------------------------------------------------------
|
959 |
|
|
//* \fn AT91F_PIO_IsOutputWriteSet
|
960 |
|
|
//* \brief Test if PIO OutputWrite is Set
|
961 |
|
|
//*----------------------------------------------------------------------------
|
962 |
|
|
__inline int AT91F_PIO_IsOutputWriteSet(
|
963 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
964 |
|
|
unsigned int flag) // \arg flag to be tested
|
965 |
|
|
{
|
966 |
|
|
return (AT91F_PIO_GetOutputWriteStatus(pPio) & flag);
|
967 |
|
|
}
|
968 |
|
|
|
969 |
|
|
//*----------------------------------------------------------------------------
|
970 |
|
|
//* \fn AT91F_PIO_GetCfgPullup
|
971 |
|
|
//* \brief Return PIO Configuration Pullup
|
972 |
|
|
//*----------------------------------------------------------------------------
|
973 |
|
|
__inline unsigned int AT91F_PIO_GetCfgPullup( // \return PIO Configuration Pullup
|
974 |
|
|
AT91PS_PIO pPio) // \arg pointer to a PIO controller
|
975 |
|
|
{
|
976 |
|
|
return pPio->PIO_PPUSR;
|
977 |
|
|
}
|
978 |
|
|
|
979 |
|
|
//*----------------------------------------------------------------------------
|
980 |
|
|
//* \fn AT91F_PIO_IsOutputDataStatusSet
|
981 |
|
|
//* \brief Test if PIO Output Data Status is Set
|
982 |
|
|
//*----------------------------------------------------------------------------
|
983 |
|
|
__inline int AT91F_PIO_IsOutputDataStatusSet(
|
984 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
985 |
|
|
unsigned int flag) // \arg flag to be tested
|
986 |
|
|
{
|
987 |
|
|
return (AT91F_PIO_GetOutputDataStatus(pPio) & flag);
|
988 |
|
|
}
|
989 |
|
|
|
990 |
|
|
//*----------------------------------------------------------------------------
|
991 |
|
|
//* \fn AT91F_PIO_IsCfgPullupStatusSet
|
992 |
|
|
//* \brief Test if PIO Configuration Pullup Status is Set
|
993 |
|
|
//*----------------------------------------------------------------------------
|
994 |
|
|
__inline int AT91F_PIO_IsCfgPullupStatusSet(
|
995 |
|
|
AT91PS_PIO pPio, // \arg pointer to a PIO controller
|
996 |
|
|
unsigned int flag) // \arg flag to be tested
|
997 |
|
|
{
|
998 |
|
|
return (~AT91F_PIO_GetCfgPullup(pPio) & flag);
|
999 |
|
|
}
|
1000 |
|
|
|
1001 |
|
|
/* *****************************************************************************
|
1002 |
|
|
SOFTWARE API FOR PMC
|
1003 |
|
|
***************************************************************************** */
|
1004 |
|
|
//*----------------------------------------------------------------------------
|
1005 |
|
|
//* \fn AT91F_PMC_CfgSysClkEnableReg
|
1006 |
|
|
//* \brief Configure the System Clock Enable Register of the PMC controller
|
1007 |
|
|
//*----------------------------------------------------------------------------
|
1008 |
|
|
__inline void AT91F_PMC_CfgSysClkEnableReg (
|
1009 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1010 |
|
|
unsigned int mode)
|
1011 |
|
|
{
|
1012 |
|
|
//* Write to the SCER register
|
1013 |
|
|
pPMC->PMC_SCER = mode;
|
1014 |
|
|
}
|
1015 |
|
|
|
1016 |
|
|
//*----------------------------------------------------------------------------
|
1017 |
|
|
//* \fn AT91F_PMC_CfgSysClkDisableReg
|
1018 |
|
|
//* \brief Configure the System Clock Disable Register of the PMC controller
|
1019 |
|
|
//*----------------------------------------------------------------------------
|
1020 |
|
|
__inline void AT91F_PMC_CfgSysClkDisableReg (
|
1021 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1022 |
|
|
unsigned int mode)
|
1023 |
|
|
{
|
1024 |
|
|
//* Write to the SCDR register
|
1025 |
|
|
pPMC->PMC_SCDR = mode;
|
1026 |
|
|
}
|
1027 |
|
|
|
1028 |
|
|
//*----------------------------------------------------------------------------
|
1029 |
|
|
//* \fn AT91F_PMC_GetSysClkStatusReg
|
1030 |
|
|
//* \brief Return the System Clock Status Register of the PMC controller
|
1031 |
|
|
//*----------------------------------------------------------------------------
|
1032 |
|
|
__inline unsigned int AT91F_PMC_GetSysClkStatusReg (
|
1033 |
|
|
AT91PS_PMC pPMC // pointer to a CAN controller
|
1034 |
|
|
)
|
1035 |
|
|
{
|
1036 |
|
|
return pPMC->PMC_SCSR;
|
1037 |
|
|
}
|
1038 |
|
|
|
1039 |
|
|
//*----------------------------------------------------------------------------
|
1040 |
|
|
//* \fn AT91F_PMC_EnablePeriphClock
|
1041 |
|
|
//* \brief Enable peripheral clock
|
1042 |
|
|
//*----------------------------------------------------------------------------
|
1043 |
|
|
__inline void AT91F_PMC_EnablePeriphClock (
|
1044 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1045 |
|
|
unsigned int periphIds) // \arg IDs of peripherals to enable
|
1046 |
|
|
{
|
1047 |
|
|
pPMC->PMC_PCER = periphIds;
|
1048 |
|
|
}
|
1049 |
|
|
|
1050 |
|
|
//*----------------------------------------------------------------------------
|
1051 |
|
|
//* \fn AT91F_PMC_DisablePeriphClock
|
1052 |
|
|
//* \brief Disable peripheral clock
|
1053 |
|
|
//*----------------------------------------------------------------------------
|
1054 |
|
|
__inline void AT91F_PMC_DisablePeriphClock (
|
1055 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1056 |
|
|
unsigned int periphIds) // \arg IDs of peripherals to enable
|
1057 |
|
|
{
|
1058 |
|
|
pPMC->PMC_PCDR = periphIds;
|
1059 |
|
|
}
|
1060 |
|
|
|
1061 |
|
|
//*----------------------------------------------------------------------------
|
1062 |
|
|
//* \fn AT91F_PMC_GetPeriphClock
|
1063 |
|
|
//* \brief Get peripheral clock status
|
1064 |
|
|
//*----------------------------------------------------------------------------
|
1065 |
|
|
__inline unsigned int AT91F_PMC_GetPeriphClock (
|
1066 |
|
|
AT91PS_PMC pPMC) // \arg pointer to PMC controller
|
1067 |
|
|
{
|
1068 |
|
|
return pPMC->PMC_PCSR;
|
1069 |
|
|
}
|
1070 |
|
|
|
1071 |
|
|
//*----------------------------------------------------------------------------
|
1072 |
|
|
//* \fn AT91F_CKGR_CfgMainOscillatorReg
|
1073 |
|
|
//* \brief Cfg the main oscillator
|
1074 |
|
|
//*----------------------------------------------------------------------------
|
1075 |
|
|
__inline void AT91F_CKGR_CfgMainOscillatorReg (
|
1076 |
|
|
AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
|
1077 |
|
|
unsigned int mode)
|
1078 |
|
|
{
|
1079 |
|
|
pCKGR->CKGR_MOR = mode;
|
1080 |
|
|
}
|
1081 |
|
|
|
1082 |
|
|
//*----------------------------------------------------------------------------
|
1083 |
|
|
//* \fn AT91F_CKGR_GetMainOscillatorReg
|
1084 |
|
|
//* \brief Cfg the main oscillator
|
1085 |
|
|
//*----------------------------------------------------------------------------
|
1086 |
|
|
__inline unsigned int AT91F_CKGR_GetMainOscillatorReg (
|
1087 |
|
|
AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
|
1088 |
|
|
{
|
1089 |
|
|
return pCKGR->CKGR_MOR;
|
1090 |
|
|
}
|
1091 |
|
|
|
1092 |
|
|
//*----------------------------------------------------------------------------
|
1093 |
|
|
//* \fn AT91F_CKGR_EnableMainOscillator
|
1094 |
|
|
//* \brief Enable the main oscillator
|
1095 |
|
|
//*----------------------------------------------------------------------------
|
1096 |
|
|
__inline void AT91F_CKGR_EnableMainOscillator(
|
1097 |
|
|
AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
|
1098 |
|
|
{
|
1099 |
|
|
pCKGR->CKGR_MOR |= AT91C_CKGR_MOSCEN;
|
1100 |
|
|
}
|
1101 |
|
|
|
1102 |
|
|
//*----------------------------------------------------------------------------
|
1103 |
|
|
//* \fn AT91F_CKGR_DisableMainOscillator
|
1104 |
|
|
//* \brief Disable the main oscillator
|
1105 |
|
|
//*----------------------------------------------------------------------------
|
1106 |
|
|
__inline void AT91F_CKGR_DisableMainOscillator (
|
1107 |
|
|
AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
|
1108 |
|
|
{
|
1109 |
|
|
pCKGR->CKGR_MOR &= ~AT91C_CKGR_MOSCEN;
|
1110 |
|
|
}
|
1111 |
|
|
|
1112 |
|
|
//*----------------------------------------------------------------------------
|
1113 |
|
|
//* \fn AT91F_CKGR_CfgMainOscStartUpTime
|
1114 |
|
|
//* \brief Cfg MOR Register according to the main osc startup time
|
1115 |
|
|
//*----------------------------------------------------------------------------
|
1116 |
|
|
__inline void AT91F_CKGR_CfgMainOscStartUpTime (
|
1117 |
|
|
AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
|
1118 |
|
|
unsigned int startup_time, // \arg main osc startup time in microsecond (us)
|
1119 |
|
|
unsigned int slowClock) // \arg slowClock in Hz
|
1120 |
|
|
{
|
1121 |
|
|
pCKGR->CKGR_MOR &= ~AT91C_CKGR_OSCOUNT;
|
1122 |
|
|
pCKGR->CKGR_MOR |= ((slowClock * startup_time)/(8*1000000)) << 8;
|
1123 |
|
|
}
|
1124 |
|
|
|
1125 |
|
|
//*----------------------------------------------------------------------------
|
1126 |
|
|
//* \fn AT91F_CKGR_GetMainClockFreqReg
|
1127 |
|
|
//* \brief Cfg the main oscillator
|
1128 |
|
|
//*----------------------------------------------------------------------------
|
1129 |
|
|
__inline unsigned int AT91F_CKGR_GetMainClockFreqReg (
|
1130 |
|
|
AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
|
1131 |
|
|
{
|
1132 |
|
|
return pCKGR->CKGR_MCFR;
|
1133 |
|
|
}
|
1134 |
|
|
|
1135 |
|
|
//*----------------------------------------------------------------------------
|
1136 |
|
|
//* \fn AT91F_CKGR_GetMainClock
|
1137 |
|
|
//* \brief Return Main clock in Hz
|
1138 |
|
|
//*----------------------------------------------------------------------------
|
1139 |
|
|
__inline unsigned int AT91F_CKGR_GetMainClock (
|
1140 |
|
|
AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
|
1141 |
|
|
unsigned int slowClock) // \arg slowClock in Hz
|
1142 |
|
|
{
|
1143 |
|
|
return ((pCKGR->CKGR_MCFR & AT91C_CKGR_MAINF) * slowClock) >> 4;
|
1144 |
|
|
}
|
1145 |
|
|
|
1146 |
|
|
//*----------------------------------------------------------------------------
|
1147 |
|
|
//* \fn AT91F_PMC_CfgMCKReg
|
1148 |
|
|
//* \brief Cfg Master Clock Register
|
1149 |
|
|
//*----------------------------------------------------------------------------
|
1150 |
|
|
__inline void AT91F_PMC_CfgMCKReg (
|
1151 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1152 |
|
|
unsigned int mode)
|
1153 |
|
|
{
|
1154 |
|
|
pPMC->PMC_MCKR = mode;
|
1155 |
|
|
}
|
1156 |
|
|
|
1157 |
|
|
//*----------------------------------------------------------------------------
|
1158 |
|
|
//* \fn AT91F_PMC_GetMCKReg
|
1159 |
|
|
//* \brief Return Master Clock Register
|
1160 |
|
|
//*----------------------------------------------------------------------------
|
1161 |
|
|
__inline unsigned int AT91F_PMC_GetMCKReg(
|
1162 |
|
|
AT91PS_PMC pPMC) // \arg pointer to PMC controller
|
1163 |
|
|
{
|
1164 |
|
|
return pPMC->PMC_MCKR;
|
1165 |
|
|
}
|
1166 |
|
|
|
1167 |
|
|
//*------------------------------------------------------------------------------
|
1168 |
|
|
//* \fn AT91F_PMC_GetMasterClock
|
1169 |
|
|
//* \brief Return master clock in Hz which correponds to processor clock for ARM7
|
1170 |
|
|
//*------------------------------------------------------------------------------
|
1171 |
|
|
__inline unsigned int AT91F_PMC_GetMasterClock (
|
1172 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1173 |
|
|
AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
|
1174 |
|
|
unsigned int slowClock) // \arg slowClock in Hz
|
1175 |
|
|
{
|
1176 |
|
|
unsigned int reg = pPMC->PMC_MCKR;
|
1177 |
|
|
unsigned int prescaler = (1 << ((reg & AT91C_PMC_PRES) >> 2));
|
1178 |
|
|
unsigned int pllDivider, pllMultiplier;
|
1179 |
|
|
|
1180 |
|
|
switch (reg & AT91C_PMC_CSS) {
|
1181 |
|
|
case AT91C_PMC_CSS_SLOW_CLK: // Slow clock selected
|
1182 |
|
|
return slowClock / prescaler;
|
1183 |
|
|
case AT91C_PMC_CSS_MAIN_CLK: // Main clock is selected
|
1184 |
|
|
return AT91F_CKGR_GetMainClock(pCKGR, slowClock) / prescaler;
|
1185 |
|
|
case AT91C_PMC_CSS_PLL_CLK: // PLLB clock is selected
|
1186 |
|
|
reg = pCKGR->CKGR_PLLR;
|
1187 |
|
|
pllDivider = (reg & AT91C_CKGR_DIV);
|
1188 |
|
|
pllMultiplier = ((reg & AT91C_CKGR_MUL) >> 16) + 1;
|
1189 |
|
|
return AT91F_CKGR_GetMainClock(pCKGR, slowClock) / pllDivider * pllMultiplier / prescaler;
|
1190 |
|
|
}
|
1191 |
|
|
return 0;
|
1192 |
|
|
}
|
1193 |
|
|
|
1194 |
|
|
//*----------------------------------------------------------------------------
|
1195 |
|
|
//* \fn AT91F_PMC_EnablePCK
|
1196 |
|
|
//* \brief Enable peripheral clock
|
1197 |
|
|
//*----------------------------------------------------------------------------
|
1198 |
|
|
__inline void AT91F_PMC_EnablePCK (
|
1199 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1200 |
|
|
unsigned int pck, // \arg Peripheral clock identifier 0 .. 7
|
1201 |
|
|
unsigned int mode)
|
1202 |
|
|
{
|
1203 |
|
|
pPMC->PMC_PCKR[pck] = mode;
|
1204 |
|
|
pPMC->PMC_SCER = (1 << pck) << 8;
|
1205 |
|
|
}
|
1206 |
|
|
|
1207 |
|
|
//*----------------------------------------------------------------------------
|
1208 |
|
|
//* \fn AT91F_PMC_DisablePCK
|
1209 |
|
|
//* \brief Enable peripheral clock
|
1210 |
|
|
//*----------------------------------------------------------------------------
|
1211 |
|
|
__inline void AT91F_PMC_DisablePCK (
|
1212 |
|
|
AT91PS_PMC pPMC, // \arg pointer to PMC controller
|
1213 |
|
|
unsigned int pck) // \arg Peripheral clock identifier 0 .. 7
|
1214 |
|
|
{
|
1215 |
|
|
pPMC->PMC_SCDR = (1 << pck) << 8;
|
1216 |
|
|
}
|
1217 |
|
|
|
1218 |
|
|
//*----------------------------------------------------------------------------
|
1219 |
|
|
//* \fn AT91F_PMC_EnableIt
|
1220 |
|
|
//* \brief Enable PMC interrupt
|
1221 |
|
|
//*----------------------------------------------------------------------------
|
1222 |
|
|
__inline void AT91F_PMC_EnableIt (
|
1223 |
|
|
AT91PS_PMC pPMC, // pointer to a PMC controller
|
1224 |
|
|
unsigned int flag) // IT to be enabled
|
1225 |
|
|
{
|
1226 |
|
|
//* Write to the IER register
|
1227 |
|
|
pPMC->PMC_IER = flag;
|
1228 |
|
|
}
|
1229 |
|
|
|
1230 |
|
|
//*----------------------------------------------------------------------------
|
1231 |
|
|
//* \fn AT91F_PMC_DisableIt
|
1232 |
|
|
//* \brief Disable PMC interrupt
|
1233 |
|
|
//*----------------------------------------------------------------------------
|
1234 |
|
|
__inline void AT91F_PMC_DisableIt (
|
1235 |
|
|
AT91PS_PMC pPMC, // pointer to a PMC controller
|
1236 |
|
|
unsigned int flag) // IT to be disabled
|
1237 |
|
|
{
|
1238 |
|
|
//* Write to the IDR register
|
1239 |
|
|
pPMC->PMC_IDR = flag;
|
1240 |
|
|
}
|
1241 |
|
|
|
1242 |
|
|
//*----------------------------------------------------------------------------
|
1243 |
|
|
//* \fn AT91F_PMC_GetStatus
|
1244 |
|
|
//* \brief Return PMC Interrupt Status
|
1245 |
|
|
//*----------------------------------------------------------------------------
|
1246 |
|
|
__inline unsigned int AT91F_PMC_GetStatus( // \return PMC Interrupt Status
|
1247 |
|
|
AT91PS_PMC pPMC) // pointer to a PMC controller
|
1248 |
|
|
{
|
1249 |
|
|
return pPMC->PMC_SR;
|
1250 |
|
|
}
|
1251 |
|
|
|
1252 |
|
|
//*----------------------------------------------------------------------------
|
1253 |
|
|
//* \fn AT91F_PMC_GetInterruptMaskStatus
|
1254 |
|
|
//* \brief Return PMC Interrupt Mask Status
|
1255 |
|
|
//*----------------------------------------------------------------------------
|
1256 |
|
|
__inline unsigned int AT91F_PMC_GetInterruptMaskStatus( // \return PMC Interrupt Mask Status
|
1257 |
|
|
AT91PS_PMC pPMC) // pointer to a PMC controller
|
1258 |
|
|
{
|
1259 |
|
|
return pPMC->PMC_IMR;
|
1260 |
|
|
}
|
1261 |
|
|
|
1262 |
|
|
//*----------------------------------------------------------------------------
|
1263 |
|
|
//* \fn AT91F_PMC_IsInterruptMasked
|
1264 |
|
|
//* \brief Test if PMC Interrupt is Masked
|
1265 |
|
|
//*----------------------------------------------------------------------------
|
1266 |
|
|
__inline unsigned int AT91F_PMC_IsInterruptMasked(
|
1267 |
|
|
AT91PS_PMC pPMC, // \arg pointer to a PMC controller
|
1268 |
|
|
unsigned int flag) // \arg flag to be tested
|
1269 |
|
|
{
|
1270 |
|
|
return (AT91F_PMC_GetInterruptMaskStatus(pPMC) & flag);
|
1271 |
|
|
}
|
1272 |
|
|
|
1273 |
|
|
//*----------------------------------------------------------------------------
|
1274 |
|
|
//* \fn AT91F_PMC_IsStatusSet
|
1275 |
|
|
//* \brief Test if PMC Status is Set
|
1276 |
|
|
//*----------------------------------------------------------------------------
|
1277 |
|
|
__inline unsigned int AT91F_PMC_IsStatusSet(
|
1278 |
|
|
AT91PS_PMC pPMC, // \arg pointer to a PMC controller
|
1279 |
|
|
unsigned int flag) // \arg flag to be tested
|
1280 |
|
|
{
|
1281 |
|
|
return (AT91F_PMC_GetStatus(pPMC) & flag);
|
1282 |
|
|
}/* *****************************************************************************
|
1283 |
|
|
SOFTWARE API FOR RSTC
|
1284 |
|
|
***************************************************************************** */
|
1285 |
|
|
//*----------------------------------------------------------------------------
|
1286 |
|
|
//* \fn AT91F_RSTSoftReset
|
1287 |
|
|
//* \brief Start Software Reset
|
1288 |
|
|
//*----------------------------------------------------------------------------
|
1289 |
|
|
__inline void AT91F_RSTSoftReset(
|
1290 |
|
|
AT91PS_RSTC pRSTC,
|
1291 |
|
|
unsigned int reset)
|
1292 |
|
|
{
|
1293 |
|
|
pRSTC->RSTC_RCR = (0xA5000000 | reset);
|
1294 |
|
|
}
|
1295 |
|
|
|
1296 |
|
|
//*----------------------------------------------------------------------------
|
1297 |
|
|
//* \fn AT91F_RSTSetMode
|
1298 |
|
|
//* \brief Set Reset Mode
|
1299 |
|
|
//*----------------------------------------------------------------------------
|
1300 |
|
|
__inline void AT91F_RSTSetMode(
|
1301 |
|
|
AT91PS_RSTC pRSTC,
|
1302 |
|
|
unsigned int mode)
|
1303 |
|
|
{
|
1304 |
|
|
pRSTC->RSTC_RMR = (0xA5000000 | mode);
|
1305 |
|
|
}
|
1306 |
|
|
|
1307 |
|
|
//*----------------------------------------------------------------------------
|
1308 |
|
|
//* \fn AT91F_RSTGetMode
|
1309 |
|
|
//* \brief Get Reset Mode
|
1310 |
|
|
//*----------------------------------------------------------------------------
|
1311 |
|
|
__inline unsigned int AT91F_RSTGetMode(
|
1312 |
|
|
AT91PS_RSTC pRSTC)
|
1313 |
|
|
{
|
1314 |
|
|
return (pRSTC->RSTC_RMR);
|
1315 |
|
|
}
|
1316 |
|
|
|
1317 |
|
|
//*----------------------------------------------------------------------------
|
1318 |
|
|
//* \fn AT91F_RSTGetStatus
|
1319 |
|
|
//* \brief Get Reset Status
|
1320 |
|
|
//*----------------------------------------------------------------------------
|
1321 |
|
|
__inline unsigned int AT91F_RSTGetStatus(
|
1322 |
|
|
AT91PS_RSTC pRSTC)
|
1323 |
|
|
{
|
1324 |
|
|
return (pRSTC->RSTC_RSR);
|
1325 |
|
|
}
|
1326 |
|
|
|
1327 |
|
|
//*----------------------------------------------------------------------------
|
1328 |
|
|
//* \fn AT91F_RSTIsSoftRstActive
|
1329 |
|
|
//* \brief Return !=0 if software reset is still not completed
|
1330 |
|
|
//*----------------------------------------------------------------------------
|
1331 |
|
|
__inline unsigned int AT91F_RSTIsSoftRstActive(
|
1332 |
|
|
AT91PS_RSTC pRSTC)
|
1333 |
|
|
{
|
1334 |
|
|
return ((pRSTC->RSTC_RSR) & AT91C_RSTC_SRCMP);
|
1335 |
|
|
}
|
1336 |
|
|
/* *****************************************************************************
|
1337 |
|
|
SOFTWARE API FOR RTTC
|
1338 |
|
|
***************************************************************************** */
|
1339 |
|
|
//*--------------------------------------------------------------------------------------
|
1340 |
|
|
//* \fn AT91F_SetRTT_TimeBase()
|
1341 |
|
|
//* \brief Set the RTT prescaler according to the TimeBase in ms
|
1342 |
|
|
//*--------------------------------------------------------------------------------------
|
1343 |
|
|
__inline unsigned int AT91F_RTTSetTimeBase(
|
1344 |
|
|
AT91PS_RTTC pRTTC,
|
1345 |
|
|
unsigned int ms)
|
1346 |
|
|
{
|
1347 |
|
|
if (ms > 2000)
|
1348 |
|
|
return 1; // AT91C_TIME_OUT_OF_RANGE
|
1349 |
|
|
pRTTC->RTTC_RTMR &= ~0xFFFF;
|
1350 |
|
|
pRTTC->RTTC_RTMR |= (((ms << 15) /1000) & 0xFFFF);
|
1351 |
|
|
return 0;
|
1352 |
|
|
}
|
1353 |
|
|
|
1354 |
|
|
//*--------------------------------------------------------------------------------------
|
1355 |
|
|
//* \fn AT91F_RTTSetPrescaler()
|
1356 |
|
|
//* \brief Set the new prescaler value
|
1357 |
|
|
//*--------------------------------------------------------------------------------------
|
1358 |
|
|
__inline unsigned int AT91F_RTTSetPrescaler(
|
1359 |
|
|
AT91PS_RTTC pRTTC,
|
1360 |
|
|
unsigned int rtpres)
|
1361 |
|
|
{
|
1362 |
|
|
pRTTC->RTTC_RTMR &= ~0xFFFF;
|
1363 |
|
|
pRTTC->RTTC_RTMR |= (rtpres & 0xFFFF);
|
1364 |
|
|
return (pRTTC->RTTC_RTMR);
|
1365 |
|
|
}
|
1366 |
|
|
|
1367 |
|
|
//*--------------------------------------------------------------------------------------
|
1368 |
|
|
//* \fn AT91F_RTTRestart()
|
1369 |
|
|
//* \brief Restart the RTT prescaler
|
1370 |
|
|
//*--------------------------------------------------------------------------------------
|
1371 |
|
|
__inline void AT91F_RTTRestart(
|
1372 |
|
|
AT91PS_RTTC pRTTC)
|
1373 |
|
|
{
|
1374 |
|
|
pRTTC->RTTC_RTMR |= AT91C_RTTC_RTTRST;
|
1375 |
|
|
}
|
1376 |
|
|
|
1377 |
|
|
|
1378 |
|
|
//*--------------------------------------------------------------------------------------
|
1379 |
|
|
//* \fn AT91F_RTT_SetAlarmINT()
|
1380 |
|
|
//* \brief Enable RTT Alarm Interrupt
|
1381 |
|
|
//*--------------------------------------------------------------------------------------
|
1382 |
|
|
__inline void AT91F_RTTSetAlarmINT(
|
1383 |
|
|
AT91PS_RTTC pRTTC)
|
1384 |
|
|
{
|
1385 |
|
|
pRTTC->RTTC_RTMR |= AT91C_RTTC_ALMIEN;
|
1386 |
|
|
}
|
1387 |
|
|
|
1388 |
|
|
//*--------------------------------------------------------------------------------------
|
1389 |
|
|
//* \fn AT91F_RTT_ClearAlarmINT()
|
1390 |
|
|
//* \brief Disable RTT Alarm Interrupt
|
1391 |
|
|
//*--------------------------------------------------------------------------------------
|
1392 |
|
|
__inline void AT91F_RTTClearAlarmINT(
|
1393 |
|
|
AT91PS_RTTC pRTTC)
|
1394 |
|
|
{
|
1395 |
|
|
pRTTC->RTTC_RTMR &= ~AT91C_RTTC_ALMIEN;
|
1396 |
|
|
}
|
1397 |
|
|
|
1398 |
|
|
//*--------------------------------------------------------------------------------------
|
1399 |
|
|
//* \fn AT91F_RTT_SetRttIncINT()
|
1400 |
|
|
//* \brief Enable RTT INC Interrupt
|
1401 |
|
|
//*--------------------------------------------------------------------------------------
|
1402 |
|
|
__inline void AT91F_RTTSetRttIncINT(
|
1403 |
|
|
AT91PS_RTTC pRTTC)
|
1404 |
|
|
{
|
1405 |
|
|
pRTTC->RTTC_RTMR |= AT91C_RTTC_RTTINCIEN;
|
1406 |
|
|
}
|
1407 |
|
|
|
1408 |
|
|
//*--------------------------------------------------------------------------------------
|
1409 |
|
|
//* \fn AT91F_RTT_ClearRttIncINT()
|
1410 |
|
|
//* \brief Disable RTT INC Interrupt
|
1411 |
|
|
//*--------------------------------------------------------------------------------------
|
1412 |
|
|
__inline void AT91F_RTTClearRttIncINT(
|
1413 |
|
|
AT91PS_RTTC pRTTC)
|
1414 |
|
|
{
|
1415 |
|
|
pRTTC->RTTC_RTMR &= ~AT91C_RTTC_RTTINCIEN;
|
1416 |
|
|
}
|
1417 |
|
|
|
1418 |
|
|
//*--------------------------------------------------------------------------------------
|
1419 |
|
|
//* \fn AT91F_RTT_SetAlarmValue()
|
1420 |
|
|
//* \brief Set RTT Alarm Value
|
1421 |
|
|
//*--------------------------------------------------------------------------------------
|
1422 |
|
|
__inline void AT91F_RTTSetAlarmValue(
|
1423 |
|
|
AT91PS_RTTC pRTTC, unsigned int alarm)
|
1424 |
|
|
{
|
1425 |
|
|
pRTTC->RTTC_RTAR = alarm;
|
1426 |
|
|
}
|
1427 |
|
|
|
1428 |
|
|
//*--------------------------------------------------------------------------------------
|
1429 |
|
|
//* \fn AT91F_RTT_GetAlarmValue()
|
1430 |
|
|
//* \brief Get RTT Alarm Value
|
1431 |
|
|
//*--------------------------------------------------------------------------------------
|
1432 |
|
|
__inline unsigned int AT91F_RTTGetAlarmValue(
|
1433 |
|
|
AT91PS_RTTC pRTTC)
|
1434 |
|
|
{
|
1435 |
|
|
return(pRTTC->RTTC_RTAR);
|
1436 |
|
|
}
|
1437 |
|
|
|
1438 |
|
|
//*--------------------------------------------------------------------------------------
|
1439 |
|
|
//* \fn AT91F_RTTGetStatus()
|
1440 |
|
|
//* \brief Read the RTT status
|
1441 |
|
|
//*--------------------------------------------------------------------------------------
|
1442 |
|
|
__inline unsigned int AT91F_RTTGetStatus(
|
1443 |
|
|
AT91PS_RTTC pRTTC)
|
1444 |
|
|
{
|
1445 |
|
|
return(pRTTC->RTTC_RTSR);
|
1446 |
|
|
}
|
1447 |
|
|
|
1448 |
|
|
//*--------------------------------------------------------------------------------------
|
1449 |
|
|
//* \fn AT91F_RTT_ReadValue()
|
1450 |
|
|
//* \brief Read the RTT value
|
1451 |
|
|
//*--------------------------------------------------------------------------------------
|
1452 |
|
|
__inline unsigned int AT91F_RTTReadValue(
|
1453 |
|
|
AT91PS_RTTC pRTTC)
|
1454 |
|
|
{
|
1455 |
|
|
register volatile unsigned int val1,val2;
|
1456 |
|
|
do
|
1457 |
|
|
{
|
1458 |
|
|
val1 = pRTTC->RTTC_RTVR;
|
1459 |
|
|
val2 = pRTTC->RTTC_RTVR;
|
1460 |
|
|
}
|
1461 |
|
|
while(val1 != val2);
|
1462 |
|
|
return(val1);
|
1463 |
|
|
}
|
1464 |
|
|
/* *****************************************************************************
|
1465 |
|
|
SOFTWARE API FOR PITC
|
1466 |
|
|
***************************************************************************** */
|
1467 |
|
|
//*----------------------------------------------------------------------------
|
1468 |
|
|
//* \fn AT91F_PITInit
|
1469 |
|
|
//* \brief System timer init : period in µsecond, system clock freq in MHz
|
1470 |
|
|
//*----------------------------------------------------------------------------
|
1471 |
|
|
__inline void AT91F_PITInit(
|
1472 |
|
|
AT91PS_PITC pPITC,
|
1473 |
|
|
unsigned int period,
|
1474 |
|
|
unsigned int pit_frequency)
|
1475 |
|
|
{
|
1476 |
|
|
pPITC->PITC_PIMR = period? (period * pit_frequency + 8) >> 4 : 0; // +8 to avoid %10 and /10
|
1477 |
|
|
pPITC->PITC_PIMR |= AT91C_PITC_PITEN;
|
1478 |
|
|
}
|
1479 |
|
|
|
1480 |
|
|
//*----------------------------------------------------------------------------
|
1481 |
|
|
//* \fn AT91F_PITSetPIV
|
1482 |
|
|
//* \brief Set the PIT Periodic Interval Value
|
1483 |
|
|
//*----------------------------------------------------------------------------
|
1484 |
|
|
__inline void AT91F_PITSetPIV(
|
1485 |
|
|
AT91PS_PITC pPITC,
|
1486 |
|
|
unsigned int piv)
|
1487 |
|
|
{
|
1488 |
|
|
pPITC->PITC_PIMR = piv | (pPITC->PITC_PIMR & (AT91C_PITC_PITEN | AT91C_PITC_PITIEN));
|
1489 |
|
|
}
|
1490 |
|
|
|
1491 |
|
|
//*----------------------------------------------------------------------------
|
1492 |
|
|
//* \fn AT91F_PITEnableInt
|
1493 |
|
|
//* \brief Enable PIT periodic interrupt
|
1494 |
|
|
//*----------------------------------------------------------------------------
|
1495 |
|
|
__inline void AT91F_PITEnableInt(
|
1496 |
|
|
AT91PS_PITC pPITC)
|
1497 |
|
|
{
|
1498 |
|
|
pPITC->PITC_PIMR |= AT91C_PITC_PITIEN;
|
1499 |
|
|
}
|
1500 |
|
|
|
1501 |
|
|
//*----------------------------------------------------------------------------
|
1502 |
|
|
//* \fn AT91F_PITDisableInt
|
1503 |
|
|
//* \brief Disable PIT periodic interrupt
|
1504 |
|
|
//*----------------------------------------------------------------------------
|
1505 |
|
|
__inline void AT91F_PITDisableInt(
|
1506 |
|
|
AT91PS_PITC pPITC)
|
1507 |
|
|
{
|
1508 |
|
|
pPITC->PITC_PIMR &= ~AT91C_PITC_PITIEN;
|
1509 |
|
|
}
|
1510 |
|
|
|
1511 |
|
|
//*----------------------------------------------------------------------------
|
1512 |
|
|
//* \fn AT91F_PITGetMode
|
1513 |
|
|
//* \brief Read PIT mode register
|
1514 |
|
|
//*----------------------------------------------------------------------------
|
1515 |
|
|
__inline unsigned int AT91F_PITGetMode(
|
1516 |
|
|
AT91PS_PITC pPITC)
|
1517 |
|
|
{
|
1518 |
|
|
return(pPITC->PITC_PIMR);
|
1519 |
|
|
}
|
1520 |
|
|
|
1521 |
|
|
//*----------------------------------------------------------------------------
|
1522 |
|
|
//* \fn AT91F_PITGetStatus
|
1523 |
|
|
//* \brief Read PIT status register
|
1524 |
|
|
//*----------------------------------------------------------------------------
|
1525 |
|
|
__inline unsigned int AT91F_PITGetStatus(
|
1526 |
|
|
AT91PS_PITC pPITC)
|
1527 |
|
|
{
|
1528 |
|
|
return(pPITC->PITC_PISR);
|
1529 |
|
|
}
|
1530 |
|
|
|
1531 |
|
|
//*----------------------------------------------------------------------------
|
1532 |
|
|
//* \fn AT91F_PITGetPIIR
|
1533 |
|
|
//* \brief Read PIT CPIV and PICNT without ressetting the counters
|
1534 |
|
|
//*----------------------------------------------------------------------------
|
1535 |
|
|
__inline unsigned int AT91F_PITGetPIIR(
|
1536 |
|
|
AT91PS_PITC pPITC)
|
1537 |
|
|
{
|
1538 |
|
|
return(pPITC->PITC_PIIR);
|
1539 |
|
|
}
|
1540 |
|
|
|
1541 |
|
|
//*----------------------------------------------------------------------------
|
1542 |
|
|
//* \fn AT91F_PITGetPIVR
|
1543 |
|
|
//* \brief Read System timer CPIV and PICNT without ressetting the counters
|
1544 |
|
|
//*----------------------------------------------------------------------------
|
1545 |
|
|
__inline unsigned int AT91F_PITGetPIVR(
|
1546 |
|
|
AT91PS_PITC pPITC)
|
1547 |
|
|
{
|
1548 |
|
|
return(pPITC->PITC_PIVR);
|
1549 |
|
|
}
|
1550 |
|
|
/* *****************************************************************************
|
1551 |
|
|
SOFTWARE API FOR WDTC
|
1552 |
|
|
***************************************************************************** */
|
1553 |
|
|
//*----------------------------------------------------------------------------
|
1554 |
|
|
//* \fn AT91F_WDTSetMode
|
1555 |
|
|
//* \brief Set Watchdog Mode Register
|
1556 |
|
|
//*----------------------------------------------------------------------------
|
1557 |
|
|
__inline void AT91F_WDTSetMode(
|
1558 |
|
|
AT91PS_WDTC pWDTC,
|
1559 |
|
|
unsigned int Mode)
|
1560 |
|
|
{
|
1561 |
|
|
pWDTC->WDTC_WDMR = Mode;
|
1562 |
|
|
}
|
1563 |
|
|
|
1564 |
|
|
//*----------------------------------------------------------------------------
|
1565 |
|
|
//* \fn AT91F_WDTRestart
|
1566 |
|
|
//* \brief Restart Watchdog
|
1567 |
|
|
//*----------------------------------------------------------------------------
|
1568 |
|
|
__inline void AT91F_WDTRestart(
|
1569 |
|
|
AT91PS_WDTC pWDTC)
|
1570 |
|
|
{
|
1571 |
|
|
pWDTC->WDTC_WDCR = 0xA5000001;
|
1572 |
|
|
}
|
1573 |
|
|
|
1574 |
|
|
//*----------------------------------------------------------------------------
|
1575 |
|
|
//* \fn AT91F_WDTSGettatus
|
1576 |
|
|
//* \brief Get Watchdog Status
|
1577 |
|
|
//*----------------------------------------------------------------------------
|
1578 |
|
|
__inline unsigned int AT91F_WDTSGettatus(
|
1579 |
|
|
AT91PS_WDTC pWDTC)
|
1580 |
|
|
{
|
1581 |
|
|
return(pWDTC->WDTC_WDSR & 0x3);
|
1582 |
|
|
}
|
1583 |
|
|
|
1584 |
|
|
//*----------------------------------------------------------------------------
|
1585 |
|
|
//* \fn AT91F_WDTGetPeriod
|
1586 |
|
|
//* \brief Translate ms into Watchdog Compatible value
|
1587 |
|
|
//*----------------------------------------------------------------------------
|
1588 |
|
|
__inline unsigned int AT91F_WDTGetPeriod(unsigned int ms)
|
1589 |
|
|
{
|
1590 |
|
|
if ((ms < 4) || (ms > 16000))
|
1591 |
|
|
return 0;
|
1592 |
|
|
return((ms << 8) / 1000);
|
1593 |
|
|
}
|
1594 |
|
|
/* *****************************************************************************
|
1595 |
|
|
SOFTWARE API FOR VREG
|
1596 |
|
|
***************************************************************************** */
|
1597 |
|
|
//*----------------------------------------------------------------------------
|
1598 |
|
|
//* \fn AT91F_VREG_Enable_LowPowerMode
|
1599 |
|
|
//* \brief Enable VREG Low Power Mode
|
1600 |
|
|
//*----------------------------------------------------------------------------
|
1601 |
|
|
__inline void AT91F_VREG_Enable_LowPowerMode(
|
1602 |
|
|
AT91PS_VREG pVREG)
|
1603 |
|
|
{
|
1604 |
|
|
pVREG->VREG_MR |= AT91C_VREG_PSTDBY;
|
1605 |
|
|
}
|
1606 |
|
|
|
1607 |
|
|
//*----------------------------------------------------------------------------
|
1608 |
|
|
//* \fn AT91F_VREG_Disable_LowPowerMode
|
1609 |
|
|
//* \brief Disable VREG Low Power Mode
|
1610 |
|
|
//*----------------------------------------------------------------------------
|
1611 |
|
|
__inline void AT91F_VREG_Disable_LowPowerMode(
|
1612 |
|
|
AT91PS_VREG pVREG)
|
1613 |
|
|
{
|
1614 |
|
|
pVREG->VREG_MR &= ~AT91C_VREG_PSTDBY;
|
1615 |
|
|
}/* *****************************************************************************
|
1616 |
|
|
SOFTWARE API FOR MC
|
1617 |
|
|
***************************************************************************** */
|
1618 |
|
|
|
1619 |
|
|
#define AT91C_MC_CORRECT_KEY ((unsigned int) 0x5A << 24) // (MC) Correct Protect Key
|
1620 |
|
|
|
1621 |
|
|
//*----------------------------------------------------------------------------
|
1622 |
|
|
//* \fn AT91F_MC_Remap
|
1623 |
|
|
//* \brief Make Remap
|
1624 |
|
|
//*----------------------------------------------------------------------------
|
1625 |
|
|
__inline void AT91F_MC_Remap (void) //
|
1626 |
|
|
{
|
1627 |
|
|
AT91PS_MC pMC = (AT91PS_MC) AT91C_BASE_MC;
|
1628 |
|
|
|
1629 |
|
|
pMC->MC_RCR = AT91C_MC_RCB;
|
1630 |
|
|
}
|
1631 |
|
|
|
1632 |
|
|
//*----------------------------------------------------------------------------
|
1633 |
|
|
//* \fn AT91F_MC_EFC_CfgModeReg
|
1634 |
|
|
//* \brief Configure the EFC Mode Register of the MC controller
|
1635 |
|
|
//*----------------------------------------------------------------------------
|
1636 |
|
|
__inline void AT91F_MC_EFC_CfgModeReg (
|
1637 |
|
|
AT91PS_MC pMC, // pointer to a MC controller
|
1638 |
|
|
unsigned int mode) // mode register
|
1639 |
|
|
{
|
1640 |
|
|
// Write to the FMR register
|
1641 |
|
|
pMC->MC_FMR = mode;
|
1642 |
|
|
}
|
1643 |
|
|
|
1644 |
|
|
//*----------------------------------------------------------------------------
|
1645 |
|
|
//* \fn AT91F_MC_EFC_GetModeReg
|
1646 |
|
|
//* \brief Return MC EFC Mode Regsiter
|
1647 |
|
|
//*----------------------------------------------------------------------------
|
1648 |
|
|
__inline unsigned int AT91F_MC_EFC_GetModeReg(
|
1649 |
|
|
AT91PS_MC pMC) // pointer to a MC controller
|
1650 |
|
|
{
|
1651 |
|
|
return pMC->MC_FMR;
|
1652 |
|
|
}
|
1653 |
|
|
|
1654 |
|
|
//*----------------------------------------------------------------------------
|
1655 |
|
|
//* \fn AT91F_MC_EFC_ComputeFMCN
|
1656 |
|
|
//* \brief Return MC EFC Mode Regsiter
|
1657 |
|
|
//*----------------------------------------------------------------------------
|
1658 |
|
|
__inline unsigned int AT91F_MC_EFC_ComputeFMCN(
|
1659 |
|
|
int master_clock) // master clock in Hz
|
1660 |
|
|
{
|
1661 |
|
|
return (master_clock/1000000 +2);
|
1662 |
|
|
}
|
1663 |
|
|
|
1664 |
|
|
//*----------------------------------------------------------------------------
|
1665 |
|
|
//* \fn AT91F_MC_EFC_PerformCmd
|
1666 |
|
|
//* \brief Perform EFC Command
|
1667 |
|
|
//*----------------------------------------------------------------------------
|
1668 |
|
|
__inline void AT91F_MC_EFC_PerformCmd (
|
1669 |
|
|
AT91PS_MC pMC, // pointer to a MC controller
|
1670 |
|
|
unsigned int transfer_cmd)
|
1671 |
|
|
{
|
1672 |
|
|
pMC->MC_FCR = transfer_cmd;
|
1673 |
|
|
}
|
1674 |
|
|
|
1675 |
|
|
//*----------------------------------------------------------------------------
|
1676 |
|
|
//* \fn AT91F_MC_EFC_GetStatus
|
1677 |
|
|
//* \brief Return MC EFC Status
|
1678 |
|
|
//*----------------------------------------------------------------------------
|
1679 |
|
|
__inline unsigned int AT91F_MC_EFC_GetStatus(
|
1680 |
|
|
AT91PS_MC pMC) // pointer to a MC controller
|
1681 |
|
|
{
|
1682 |
|
|
return pMC->MC_FSR;
|
1683 |
|
|
}
|
1684 |
|
|
|
1685 |
|
|
//*----------------------------------------------------------------------------
|
1686 |
|
|
//* \fn AT91F_MC_EFC_IsInterruptMasked
|
1687 |
|
|
//* \brief Test if EFC MC Interrupt is Masked
|
1688 |
|
|
//*----------------------------------------------------------------------------
|
1689 |
|
|
__inline unsigned int AT91F_MC_EFC_IsInterruptMasked(
|
1690 |
|
|
AT91PS_MC pMC, // \arg pointer to a MC controller
|
1691 |
|
|
unsigned int flag) // \arg flag to be tested
|
1692 |
|
|
{
|
1693 |
|
|
return (AT91F_MC_EFC_GetModeReg(pMC) & flag);
|
1694 |
|
|
}
|
1695 |
|
|
|
1696 |
|
|
//*----------------------------------------------------------------------------
|
1697 |
|
|
//* \fn AT91F_MC_EFC_IsInterruptSet
|
1698 |
|
|
//* \brief Test if EFC MC Interrupt is Set
|
1699 |
|
|
//*----------------------------------------------------------------------------
|
1700 |
|
|
__inline unsigned int AT91F_MC_EFC_IsInterruptSet(
|
1701 |
|
|
AT91PS_MC pMC, // \arg pointer to a MC controller
|
1702 |
|
|
unsigned int flag) // \arg flag to be tested
|
1703 |
|
|
{
|
1704 |
|
|
return (AT91F_MC_EFC_GetStatus(pMC) & flag);
|
1705 |
|
|
}
|
1706 |
|
|
|
1707 |
|
|
/* *****************************************************************************
|
1708 |
|
|
SOFTWARE API FOR SPI
|
1709 |
|
|
***************************************************************************** */
|
1710 |
|
|
//*----------------------------------------------------------------------------
|
1711 |
|
|
//* \fn AT91F_SPI_Open
|
1712 |
|
|
//* \brief Open a SPI Port
|
1713 |
|
|
//*----------------------------------------------------------------------------
|
1714 |
|
|
__inline unsigned int AT91F_SPI_Open (
|
1715 |
|
|
const unsigned int null) // \arg
|
1716 |
|
|
{
|
1717 |
|
|
/* NOT DEFINED AT THIS MOMENT */
|
1718 |
|
|
return ( 0 );
|
1719 |
|
|
}
|
1720 |
|
|
|
1721 |
|
|
//*----------------------------------------------------------------------------
|
1722 |
|
|
//* \fn AT91F_SPI_CfgCs
|
1723 |
|
|
//* \brief Configure SPI chip select register
|
1724 |
|
|
//*----------------------------------------------------------------------------
|
1725 |
|
|
__inline void AT91F_SPI_CfgCs (
|
1726 |
|
|
AT91PS_SPI pSPI, // pointer to a SPI controller
|
1727 |
|
|
int cs, // SPI cs number (0 to 3)
|
1728 |
|
|
int val) // chip select register
|
1729 |
|
|
{
|
1730 |
|
|
//* Write to the CSR register
|
1731 |
|
|
*(pSPI->SPI_CSR + cs) = val;
|
1732 |
|
|
}
|
1733 |
|
|
|
1734 |
|
|
//*----------------------------------------------------------------------------
|
1735 |
|
|
//* \fn AT91F_SPI_EnableIt
|
1736 |
|
|
//* \brief Enable SPI interrupt
|
1737 |
|
|
//*----------------------------------------------------------------------------
|
1738 |
|
|
__inline void AT91F_SPI_EnableIt (
|
1739 |
|
|
AT91PS_SPI pSPI, // pointer to a SPI controller
|
1740 |
|
|
unsigned int flag) // IT to be enabled
|
1741 |
|
|
{
|
1742 |
|
|
//* Write to the IER register
|
1743 |
|
|
pSPI->SPI_IER = flag;
|
1744 |
|
|
}
|
1745 |
|
|
|
1746 |
|
|
//*----------------------------------------------------------------------------
|
1747 |
|
|
//* \fn AT91F_SPI_DisableIt
|
1748 |
|
|
//* \brief Disable SPI interrupt
|
1749 |
|
|
//*----------------------------------------------------------------------------
|
1750 |
|
|
__inline void AT91F_SPI_DisableIt (
|
1751 |
|
|
AT91PS_SPI pSPI, // pointer to a SPI controller
|
1752 |
|
|
unsigned int flag) // IT to be disabled
|
1753 |
|
|
{
|
1754 |
|
|
//* Write to the IDR register
|
1755 |
|
|
pSPI->SPI_IDR = flag;
|
1756 |
|
|
}
|
1757 |
|
|
|
1758 |
|
|
//*----------------------------------------------------------------------------
|
1759 |
|
|
//* \fn AT91F_SPI_Reset
|
1760 |
|
|
//* \brief Reset the SPI controller
|
1761 |
|
|
//*----------------------------------------------------------------------------
|
1762 |
|
|
__inline void AT91F_SPI_Reset (
|
1763 |
|
|
AT91PS_SPI pSPI // pointer to a SPI controller
|
1764 |
|
|
)
|
1765 |
|
|
{
|
1766 |
|
|
//* Write to the CR register
|
1767 |
|
|
pSPI->SPI_CR = AT91C_SPI_SWRST;
|
1768 |
|
|
}
|
1769 |
|
|
|
1770 |
|
|
//*----------------------------------------------------------------------------
|
1771 |
|
|
//* \fn AT91F_SPI_Enable
|
1772 |
|
|
//* \brief Enable the SPI controller
|
1773 |
|
|
//*----------------------------------------------------------------------------
|
1774 |
|
|
__inline void AT91F_SPI_Enable (
|
1775 |
|
|
AT91PS_SPI pSPI // pointer to a SPI controller
|
1776 |
|
|
)
|
1777 |
|
|
{
|
1778 |
|
|
//* Write to the CR register
|
1779 |
|
|
pSPI->SPI_CR = AT91C_SPI_SPIEN;
|
1780 |
|
|
}
|
1781 |
|
|
|
1782 |
|
|
//*----------------------------------------------------------------------------
|
1783 |
|
|
//* \fn AT91F_SPI_Disable
|
1784 |
|
|
//* \brief Disable the SPI controller
|
1785 |
|
|
//*----------------------------------------------------------------------------
|
1786 |
|
|
__inline void AT91F_SPI_Disable (
|
1787 |
|
|
AT91PS_SPI pSPI // pointer to a SPI controller
|
1788 |
|
|
)
|
1789 |
|
|
{
|
1790 |
|
|
//* Write to the CR register
|
1791 |
|
|
pSPI->SPI_CR = AT91C_SPI_SPIDIS;
|
1792 |
|
|
}
|
1793 |
|
|
|
1794 |
|
|
//*----------------------------------------------------------------------------
|
1795 |
|
|
//* \fn AT91F_SPI_CfgMode
|
1796 |
|
|
//* \brief Enable the SPI controller
|
1797 |
|
|
//*----------------------------------------------------------------------------
|
1798 |
|
|
__inline void AT91F_SPI_CfgMode (
|
1799 |
|
|
AT91PS_SPI pSPI, // pointer to a SPI controller
|
1800 |
|
|
int mode) // mode register
|
1801 |
|
|
{
|
1802 |
|
|
//* Write to the MR register
|
1803 |
|
|
pSPI->SPI_MR = mode;
|
1804 |
|
|
}
|
1805 |
|
|
|
1806 |
|
|
//*----------------------------------------------------------------------------
|
1807 |
|
|
//* \fn AT91F_SPI_CfgPCS
|
1808 |
|
|
//* \brief Switch to the correct PCS of SPI Mode Register : Fixed Peripheral Selected
|
1809 |
|
|
//*----------------------------------------------------------------------------
|
1810 |
|
|
__inline void AT91F_SPI_CfgPCS (
|
1811 |
|
|
AT91PS_SPI pSPI, // pointer to a SPI controller
|
1812 |
|
|
char PCS_Device) // PCS of the Device
|
1813 |
|
|
{
|
1814 |
|
|
//* Write to the MR register
|
1815 |
|
|
pSPI->SPI_MR &= 0xFFF0FFFF;
|
1816 |
|
|
pSPI->SPI_MR |= ( (PCS_Device<<16) & AT91C_SPI_PCS );
|
1817 |
|
|
}
|
1818 |
|
|
|
1819 |
|
|
//*----------------------------------------------------------------------------
|
1820 |
|
|
//* \fn AT91F_SPI_ReceiveFrame
|
1821 |
|
|
//* \brief Return 2 if PDC has been initialized with Buffer and Next Buffer, 1 if PDC has been initializaed with Next Buffer, 0 if PDC is busy
|
1822 |
|
|
//*----------------------------------------------------------------------------
|
1823 |
|
|
__inline unsigned int AT91F_SPI_ReceiveFrame (
|
1824 |
|
|
AT91PS_SPI pSPI,
|
1825 |
|
|
char *pBuffer,
|
1826 |
|
|
unsigned int szBuffer,
|
1827 |
|
|
char *pNextBuffer,
|
1828 |
|
|
unsigned int szNextBuffer )
|
1829 |
|
|
{
|
1830 |
|
|
return AT91F_PDC_ReceiveFrame(
|
1831 |
|
|
(AT91PS_PDC) &(pSPI->SPI_RPR),
|
1832 |
|
|
pBuffer,
|
1833 |
|
|
szBuffer,
|
1834 |
|
|
pNextBuffer,
|
1835 |
|
|
szNextBuffer);
|
1836 |
|
|
}
|
1837 |
|
|
|
1838 |
|
|
//*----------------------------------------------------------------------------
|
1839 |
|
|
//* \fn AT91F_SPI_SendFrame
|
1840 |
|
|
//* \brief Return 2 if PDC has been initialized with Buffer and Next Buffer, 1 if PDC has been initializaed with Next Buffer, 0 if PDC is bSPIy
|
1841 |
|
|
//*----------------------------------------------------------------------------
|
1842 |
|
|
__inline unsigned int AT91F_SPI_SendFrame(
|
1843 |
|
|
AT91PS_SPI pSPI,
|
1844 |
|
|
char *pBuffer,
|
1845 |
|
|
unsigned int szBuffer,
|
1846 |
|
|
char *pNextBuffer,
|
1847 |
|
|
unsigned int szNextBuffer )
|
1848 |
|
|
{
|
1849 |
|
|
return AT91F_PDC_SendFrame(
|
1850 |
|
|
(AT91PS_PDC) &(pSPI->SPI_RPR),
|
1851 |
|
|
pBuffer,
|
1852 |
|
|
szBuffer,
|
1853 |
|
|
pNextBuffer,
|
1854 |
|
|
szNextBuffer);
|
1855 |
|
|
}
|
1856 |
|
|
|
1857 |
|
|
//*----------------------------------------------------------------------------
|
1858 |
|
|
//* \fn AT91F_SPI_Close
|
1859 |
|
|
//* \brief Close SPI: disable IT disable transfert, close PDC
|
1860 |
|
|
//*----------------------------------------------------------------------------
|
1861 |
|
|
__inline void AT91F_SPI_Close (
|
1862 |
|
|
AT91PS_SPI pSPI) // \arg pointer to a SPI controller
|
1863 |
|
|
{
|
1864 |
|
|
//* Reset all the Chip Select register
|
1865 |
|
|
pSPI->SPI_CSR[0] = 0 ;
|
1866 |
|
|
pSPI->SPI_CSR[1] = 0 ;
|
1867 |
|
|
pSPI->SPI_CSR[2] = 0 ;
|
1868 |
|
|
pSPI->SPI_CSR[3] = 0 ;
|
1869 |
|
|
|
1870 |
|
|
//* Reset the SPI mode
|
1871 |
|
|
pSPI->SPI_MR = 0 ;
|
1872 |
|
|
|
1873 |
|
|
//* Disable all interrupts
|
1874 |
|
|
pSPI->SPI_IDR = 0xFFFFFFFF ;
|
1875 |
|
|
|
1876 |
|
|
//* Abort the Peripheral Data Transfers
|
1877 |
|
|
AT91F_PDC_Close((AT91PS_PDC) &(pSPI->SPI_RPR));
|
1878 |
|
|
|
1879 |
|
|
//* Disable receiver and transmitter and stop any activity immediately
|
1880 |
|
|
pSPI->SPI_CR = AT91C_SPI_SPIDIS;
|
1881 |
|
|
}
|
1882 |
|
|
|
1883 |
|
|
//*----------------------------------------------------------------------------
|
1884 |
|
|
//* \fn AT91F_SPI_PutChar
|
1885 |
|
|
//* \brief Send a character,does not check if ready to send
|
1886 |
|
|
//*----------------------------------------------------------------------------
|
1887 |
|
|
__inline void AT91F_SPI_PutChar (
|
1888 |
|
|
AT91PS_SPI pSPI,
|
1889 |
|
|
unsigned int character,
|
1890 |
|
|
unsigned int cs_number )
|
1891 |
|
|
{
|
1892 |
|
|
unsigned int value_for_cs;
|
1893 |
|
|
value_for_cs = (~(1 << cs_number)) & 0xF; //Place a zero among a 4 ONEs number
|
1894 |
|
|
pSPI->SPI_TDR = (character & 0xFFFF) | (value_for_cs << 16);
|
1895 |
|
|
}
|
1896 |
|
|
|
1897 |
|
|
//*----------------------------------------------------------------------------
|
1898 |
|
|
//* \fn AT91F_SPI_GetChar
|
1899 |
|
|
//* \brief Receive a character,does not check if a character is available
|
1900 |
|
|
//*----------------------------------------------------------------------------
|
1901 |
|
|
__inline int AT91F_SPI_GetChar (
|
1902 |
|
|
const AT91PS_SPI pSPI)
|
1903 |
|
|
{
|
1904 |
|
|
return((pSPI->SPI_RDR) & 0xFFFF);
|
1905 |
|
|
}
|
1906 |
|
|
|
1907 |
|
|
//*----------------------------------------------------------------------------
|
1908 |
|
|
//* \fn AT91F_SPI_GetInterruptMaskStatus
|
1909 |
|
|
//* \brief Return SPI Interrupt Mask Status
|
1910 |
|
|
//*----------------------------------------------------------------------------
|
1911 |
|
|
__inline unsigned int AT91F_SPI_GetInterruptMaskStatus( // \return SPI Interrupt Mask Status
|
1912 |
|
|
AT91PS_SPI pSpi) // \arg pointer to a SPI controller
|
1913 |
|
|
{
|
1914 |
|
|
return pSpi->SPI_IMR;
|
1915 |
|
|
}
|
1916 |
|
|
|
1917 |
|
|
//*----------------------------------------------------------------------------
|
1918 |
|
|
//* \fn AT91F_SPI_IsInterruptMasked
|
1919 |
|
|
//* \brief Test if SPI Interrupt is Masked
|
1920 |
|
|
//*----------------------------------------------------------------------------
|
1921 |
|
|
__inline int AT91F_SPI_IsInterruptMasked(
|
1922 |
|
|
AT91PS_SPI pSpi, // \arg pointer to a SPI controller
|
1923 |
|
|
unsigned int flag) // \arg flag to be tested
|
1924 |
|
|
{
|
1925 |
|
|
return (AT91F_SPI_GetInterruptMaskStatus(pSpi) & flag);
|
1926 |
|
|
}
|
1927 |
|
|
|
1928 |
|
|
/* *****************************************************************************
|
1929 |
|
|
SOFTWARE API FOR USART
|
1930 |
|
|
***************************************************************************** */
|
1931 |
|
|
//*----------------------------------------------------------------------------
|
1932 |
|
|
//* \fn AT91F_US_Baudrate
|
1933 |
|
|
//* \brief Calculate the baudrate
|
1934 |
|
|
//* Standard Asynchronous Mode : 8 bits , 1 stop , no parity
|
1935 |
|
|
#define AT91C_US_ASYNC_MODE ( AT91C_US_USMODE_NORMAL + \
|
1936 |
|
|
AT91C_US_NBSTOP_1_BIT + \
|
1937 |
|
|
AT91C_US_PAR_NONE + \
|
1938 |
|
|
AT91C_US_CHRL_8_BITS + \
|
1939 |
|
|
AT91C_US_CLKS_CLOCK )
|
1940 |
|
|
|
1941 |
|
|
//* Standard External Asynchronous Mode : 8 bits , 1 stop , no parity
|
1942 |
|
|
#define AT91C_US_ASYNC_SCK_MODE ( AT91C_US_USMODE_NORMAL + \
|
1943 |
|
|
AT91C_US_NBSTOP_1_BIT + \
|
1944 |
|
|
AT91C_US_PAR_NONE + \
|
1945 |
|
|
AT91C_US_CHRL_8_BITS + \
|
1946 |
|
|
AT91C_US_CLKS_EXT )
|
1947 |
|
|
|
1948 |
|
|
//* Standard Synchronous Mode : 8 bits , 1 stop , no parity
|
1949 |
|
|
#define AT91C_US_SYNC_MODE ( AT91C_US_SYNC + \
|
1950 |
|
|
AT91C_US_USMODE_NORMAL + \
|
1951 |
|
|
AT91C_US_NBSTOP_1_BIT + \
|
1952 |
|
|
AT91C_US_PAR_NONE + \
|
1953 |
|
|
AT91C_US_CHRL_8_BITS + \
|
1954 |
|
|
AT91C_US_CLKS_CLOCK )
|
1955 |
|
|
|
1956 |
|
|
//* SCK used Label
|
1957 |
|
|
#define AT91C_US_SCK_USED (AT91C_US_CKLO | AT91C_US_CLKS_EXT)
|
1958 |
|
|
|
1959 |
|
|
//* Standard ISO T=0 Mode : 8 bits , 1 stop , parity
|
1960 |
|
|
#define AT91C_US_ISO_READER_MODE ( AT91C_US_USMODE_ISO7816_0 + \
|
1961 |
|
|
AT91C_US_CLKS_CLOCK +\
|
1962 |
|
|
AT91C_US_NBSTOP_1_BIT + \
|
1963 |
|
|
AT91C_US_PAR_EVEN + \
|
1964 |
|
|
AT91C_US_CHRL_8_BITS + \
|
1965 |
|
|
AT91C_US_CKLO +\
|
1966 |
|
|
AT91C_US_OVER)
|
1967 |
|
|
|
1968 |
|
|
//* Standard IRDA mode
|
1969 |
|
|
#define AT91C_US_ASYNC_IRDA_MODE ( AT91C_US_USMODE_IRDA + \
|
1970 |
|
|
AT91C_US_NBSTOP_1_BIT + \
|
1971 |
|
|
AT91C_US_PAR_NONE + \
|
1972 |
|
|
AT91C_US_CHRL_8_BITS + \
|
1973 |
|
|
AT91C_US_CLKS_CLOCK )
|
1974 |
|
|
|
1975 |
|
|
//*----------------------------------------------------------------------------
|
1976 |
|
|
//* \fn AT91F_US_Baudrate
|
1977 |
|
|
//* \brief Caluculate baud_value according to the main clock and the baud rate
|
1978 |
|
|
//*----------------------------------------------------------------------------
|
1979 |
|
|
__inline unsigned int AT91F_US_Baudrate (
|
1980 |
|
|
const unsigned int main_clock, // \arg peripheral clock
|
1981 |
|
|
const unsigned int baud_rate) // \arg UART baudrate
|
1982 |
|
|
{
|
1983 |
|
|
unsigned int baud_value = ((main_clock*10)/(baud_rate * 16));
|
1984 |
|
|
if ((baud_value % 10) >= 5)
|
1985 |
|
|
baud_value = (baud_value / 10) + 1;
|
1986 |
|
|
else
|
1987 |
|
|
baud_value /= 10;
|
1988 |
|
|
return baud_value;
|
1989 |
|
|
}
|
1990 |
|
|
|
1991 |
|
|
//*----------------------------------------------------------------------------
|
1992 |
|
|
//* \fn AT91F_US_SetBaudrate
|
1993 |
|
|
//* \brief Set the baudrate according to the CPU clock
|
1994 |
|
|
//*----------------------------------------------------------------------------
|
1995 |
|
|
__inline void AT91F_US_SetBaudrate (
|
1996 |
|
|
AT91PS_USART pUSART, // \arg pointer to a USART controller
|
1997 |
|
|
unsigned int mainClock, // \arg peripheral clock
|
1998 |
|
|
unsigned int speed) // \arg UART baudrate
|
1999 |
|
|
{
|
2000 |
|
|
//* Define the baud rate divisor register
|
2001 |
|
|
pUSART->US_BRGR = AT91F_US_Baudrate(mainClock, speed);
|
2002 |
|
|
}
|
2003 |
|
|
|
2004 |
|
|
//*----------------------------------------------------------------------------
|
2005 |
|
|
//* \fn AT91F_US_SetTimeguard
|
2006 |
|
|
//* \brief Set USART timeguard
|
2007 |
|
|
//*----------------------------------------------------------------------------
|
2008 |
|
|
__inline void AT91F_US_SetTimeguard (
|
2009 |
|
|
AT91PS_USART pUSART, // \arg pointer to a USART controller
|
2010 |
|
|
unsigned int timeguard) // \arg timeguard value
|
2011 |
|
|
{
|
2012 |
|
|
//* Write the Timeguard Register
|
2013 |
|
|
pUSART->US_TTGR = timeguard ;
|
2014 |
|
|
}
|
2015 |
|
|
|
2016 |
|
|
//*----------------------------------------------------------------------------
|
2017 |
|
|
//* \fn AT91F_US_EnableIt
|
2018 |
|
|
//* \brief Enable USART IT
|
2019 |
|
|
//*----------------------------------------------------------------------------
|
2020 |
|
|
__inline void AT91F_US_EnableIt (
|
2021 |
|
|
AT91PS_USART pUSART, // \arg pointer to a USART controller
|
2022 |
|
|
unsigned int flag) // \arg IT to be enabled
|
2023 |
|
|
{
|
2024 |
|
|
//* Write to the IER register
|
2025 |
|
|
pUSART->US_IER = flag;
|
2026 |
|
|
}
|
2027 |
|
|
|
2028 |
|
|
//*----------------------------------------------------------------------------
|
2029 |
|
|
//* \fn AT91F_US_DisableIt
|
2030 |
|
|
//* \brief Disable USART IT
|
2031 |
|
|
//*----------------------------------------------------------------------------
|
2032 |
|
|
__inline void AT91F_US_DisableIt (
|
2033 |
|
|
AT91PS_USART pUSART, // \arg pointer to a USART controller
|
2034 |
|
|
unsigned int flag) // \arg IT to be disabled
|
2035 |
|
|
{
|
2036 |
|
|
//* Write to the IER register
|
2037 |
|
|
pUSART->US_IDR = flag;
|
2038 |
|
|
}
|
2039 |
|
|
|
2040 |
|
|
//*----------------------------------------------------------------------------
|
2041 |
|
|
//* \fn AT91F_US_Configure
|
2042 |
|
|
//* \brief Configure USART
|
2043 |
|
|
//*----------------------------------------------------------------------------
|
2044 |
|
|
__inline void AT91F_US_Configure (
|
2045 |
|
|
AT91PS_USART pUSART, // \arg pointer to a USART controller
|
2046 |
|
|
unsigned int mainClock, // \arg peripheral clock
|
2047 |
|
|
unsigned int mode , // \arg mode Register to be programmed
|
2048 |
|
|
unsigned int baudRate , // \arg baudrate to be programmed
|
2049 |
|
|
unsigned int timeguard ) // \arg timeguard to be programmed
|
2050 |
|
|
{
|
2051 |
|
|
//* Disable interrupts
|
2052 |
|
|
pUSART->US_IDR = (unsigned int) -1;
|
2053 |
|
|
|
2054 |
|
|
//* Reset receiver and transmitter
|
2055 |
|
|
pUSART->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS ;
|
2056 |
|
|
|
2057 |
|
|
//* Define the baud rate divisor register
|
2058 |
|
|
AT91F_US_SetBaudrate(pUSART, mainClock, baudRate);
|
2059 |
|
|
|
2060 |
|
|
//* Write the Timeguard Register
|
2061 |
|
|
AT91F_US_SetTimeguard(pUSART, timeguard);
|
2062 |
|
|
|
2063 |
|
|
//* Clear Transmit and Receive Counters
|
2064 |
|
|
AT91F_PDC_Open((AT91PS_PDC) &(pUSART->US_RPR));
|
2065 |
|
|
|
2066 |
|
|
//* Define the USART mode
|
2067 |
|
|
pUSART->US_MR = mode ;
|
2068 |
|
|
|
2069 |
|
|
}
|
2070 |
|
|
|
2071 |
|
|
//*----------------------------------------------------------------------------
|
2072 |
|
|
//* \fn AT91F_US_EnableRx
|
2073 |
|
|
//* \brief Enable receiving characters
|
2074 |
|
|
//*----------------------------------------------------------------------------
|
2075 |
|
|
__inline void AT91F_US_EnableRx (
|
2076 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2077 |
|
|
{
|
2078 |
|
|
//* Enable receiver
|
2079 |
|
|
pUSART->US_CR = AT91C_US_RXEN;
|
2080 |
|
|
}
|
2081 |
|
|
|
2082 |
|
|
//*----------------------------------------------------------------------------
|
2083 |
|
|
//* \fn AT91F_US_EnableTx
|
2084 |
|
|
//* \brief Enable sending characters
|
2085 |
|
|
//*----------------------------------------------------------------------------
|
2086 |
|
|
__inline void AT91F_US_EnableTx (
|
2087 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2088 |
|
|
{
|
2089 |
|
|
//* Enable transmitter
|
2090 |
|
|
pUSART->US_CR = AT91C_US_TXEN;
|
2091 |
|
|
}
|
2092 |
|
|
|
2093 |
|
|
//*----------------------------------------------------------------------------
|
2094 |
|
|
//* \fn AT91F_US_ResetRx
|
2095 |
|
|
//* \brief Reset Receiver and re-enable it
|
2096 |
|
|
//*----------------------------------------------------------------------------
|
2097 |
|
|
__inline void AT91F_US_ResetRx (
|
2098 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2099 |
|
|
{
|
2100 |
|
|
//* Reset receiver
|
2101 |
|
|
pUSART->US_CR = AT91C_US_RSTRX;
|
2102 |
|
|
//* Re-Enable receiver
|
2103 |
|
|
pUSART->US_CR = AT91C_US_RXEN;
|
2104 |
|
|
}
|
2105 |
|
|
|
2106 |
|
|
//*----------------------------------------------------------------------------
|
2107 |
|
|
//* \fn AT91F_US_ResetTx
|
2108 |
|
|
//* \brief Reset Transmitter and re-enable it
|
2109 |
|
|
//*----------------------------------------------------------------------------
|
2110 |
|
|
__inline void AT91F_US_ResetTx (
|
2111 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2112 |
|
|
{
|
2113 |
|
|
//* Reset transmitter
|
2114 |
|
|
pUSART->US_CR = AT91C_US_RSTTX;
|
2115 |
|
|
//* Enable transmitter
|
2116 |
|
|
pUSART->US_CR = AT91C_US_TXEN;
|
2117 |
|
|
}
|
2118 |
|
|
|
2119 |
|
|
//*----------------------------------------------------------------------------
|
2120 |
|
|
//* \fn AT91F_US_DisableRx
|
2121 |
|
|
//* \brief Disable Receiver
|
2122 |
|
|
//*----------------------------------------------------------------------------
|
2123 |
|
|
__inline void AT91F_US_DisableRx (
|
2124 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2125 |
|
|
{
|
2126 |
|
|
//* Disable receiver
|
2127 |
|
|
pUSART->US_CR = AT91C_US_RXDIS;
|
2128 |
|
|
}
|
2129 |
|
|
|
2130 |
|
|
//*----------------------------------------------------------------------------
|
2131 |
|
|
//* \fn AT91F_US_DisableTx
|
2132 |
|
|
//* \brief Disable Transmitter
|
2133 |
|
|
//*----------------------------------------------------------------------------
|
2134 |
|
|
__inline void AT91F_US_DisableTx (
|
2135 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2136 |
|
|
{
|
2137 |
|
|
//* Disable transmitter
|
2138 |
|
|
pUSART->US_CR = AT91C_US_TXDIS;
|
2139 |
|
|
}
|
2140 |
|
|
|
2141 |
|
|
//*----------------------------------------------------------------------------
|
2142 |
|
|
//* \fn AT91F_US_Close
|
2143 |
|
|
//* \brief Close USART: disable IT disable receiver and transmitter, close PDC
|
2144 |
|
|
//*----------------------------------------------------------------------------
|
2145 |
|
|
__inline void AT91F_US_Close (
|
2146 |
|
|
AT91PS_USART pUSART) // \arg pointer to a USART controller
|
2147 |
|
|
{
|
2148 |
|
|
//* Reset the baud rate divisor register
|
2149 |
|
|
pUSART->US_BRGR = 0 ;
|
2150 |
|
|
|
2151 |
|
|
//* Reset the USART mode
|
2152 |
|
|
pUSART->US_MR = 0 ;
|
2153 |
|
|
|
2154 |
|
|
//* Reset the Timeguard Register
|
2155 |
|
|
pUSART->US_TTGR = 0;
|
2156 |
|
|
|
2157 |
|
|
//* Disable all interrupts
|
2158 |
|
|
pUSART->US_IDR = 0xFFFFFFFF ;
|
2159 |
|
|
|
2160 |
|
|
//* Abort the Peripheral Data Transfers
|
2161 |
|
|
AT91F_PDC_Close((AT91PS_PDC) &(pUSART->US_RPR));
|
2162 |
|
|
|
2163 |
|
|
//* Disable receiver and transmitter and stop any activity immediately
|
2164 |
|
|
pUSART->US_CR = AT91C_US_TXDIS | AT91C_US_RXDIS | AT91C_US_RSTTX | AT91C_US_RSTRX ;
|
2165 |
|
|
}
|
2166 |
|
|
|
2167 |
|
|
//*----------------------------------------------------------------------------
|
2168 |
|
|
//* \fn AT91F_US_TxReady
|
2169 |
|
|
//* \brief Return 1 if a character can be written in US_THR
|
2170 |
|
|
//*----------------------------------------------------------------------------
|
2171 |
|
|
__inline unsigned int AT91F_US_TxReady (
|
2172 |
|
|
AT91PS_USART pUSART ) // \arg pointer to a USART controller
|
2173 |
|
|
{
|
2174 |
|
|
return (pUSART->US_CSR & AT91C_US_TXRDY);
|
2175 |
|
|
}
|
2176 |
|
|
|
2177 |
|
|
//*----------------------------------------------------------------------------
|
2178 |
|
|
//* \fn AT91F_US_RxReady
|
2179 |
|
|
//* \brief Return 1 if a character can be read in US_RHR
|
2180 |
|
|
//*----------------------------------------------------------------------------
|
2181 |
|
|
__inline unsigned int AT91F_US_RxReady (
|
2182 |
|
|
AT91PS_USART pUSART ) // \arg pointer to a USART controller
|
2183 |
|
|
{
|
2184 |
|
|
return (pUSART->US_CSR & AT91C_US_RXRDY);
|
2185 |
|
|
}
|
2186 |
|
|
|
2187 |
|
|
//*----------------------------------------------------------------------------
|
2188 |
|
|
//* \fn AT91F_US_Error
|
2189 |
|
|
//* \brief Return the error flag
|
2190 |
|
|
//*----------------------------------------------------------------------------
|
2191 |
|
|
__inline unsigned int AT91F_US_Error (
|
2192 |
|
|
AT91PS_USART pUSART ) // \arg pointer to a USART controller
|
2193 |
|
|
{
|
2194 |
|
|
return (pUSART->US_CSR &
|
2195 |
|
|
(AT91C_US_OVRE | // Overrun error
|
2196 |
|
|
AT91C_US_FRAME | // Framing error
|
2197 |
|
|
AT91C_US_PARE)); // Parity error
|
2198 |
|
|
}
|
2199 |
|
|
|
2200 |
|
|
//*----------------------------------------------------------------------------
|
2201 |
|
|
//* \fn AT91F_US_PutChar
|
2202 |
|
|
//* \brief Send a character,does not check if ready to send
|
2203 |
|
|
//*----------------------------------------------------------------------------
|
2204 |
|
|
__inline void AT91F_US_PutChar (
|
2205 |
|
|
AT91PS_USART pUSART,
|
2206 |
|
|
int character )
|
2207 |
|
|
{
|
2208 |
|
|
pUSART->US_THR = (character & 0x1FF);
|
2209 |
|
|
}
|
2210 |
|
|
|
2211 |
|
|
//*----------------------------------------------------------------------------
|
2212 |
|
|
//* \fn AT91F_US_GetChar
|
2213 |
|
|
//* \brief Receive a character,does not check if a character is available
|
2214 |
|
|
//*----------------------------------------------------------------------------
|
2215 |
|
|
__inline int AT91F_US_GetChar (
|
2216 |
|
|
const AT91PS_USART pUSART)
|
2217 |
|
|
{
|
2218 |
|
|
return((pUSART->US_RHR) & 0x1FF);
|
2219 |
|
|
}
|
2220 |
|
|
|
2221 |
|
|
//*----------------------------------------------------------------------------
|
2222 |
|
|
//* \fn AT91F_US_SendFrame
|
2223 |
|
|
//* \brief Return 2 if PDC has been initialized with Buffer and Next Buffer, 1 if PDC has been initializaed with Next Buffer, 0 if PDC is busy
|
2224 |
|
|
//*----------------------------------------------------------------------------
|
2225 |
|
|
__inline unsigned int AT91F_US_SendFrame(
|
2226 |
|
|
AT91PS_USART pUSART,
|
2227 |
|
|
char *pBuffer,
|
2228 |
|
|
unsigned int szBuffer,
|
2229 |
|
|
char *pNextBuffer,
|
2230 |
|
|
unsigned int szNextBuffer )
|
2231 |
|
|
{
|
2232 |
|
|
return AT91F_PDC_SendFrame(
|
2233 |
|
|
(AT91PS_PDC) &(pUSART->US_RPR),
|
2234 |
|
|
pBuffer,
|
2235 |
|
|
szBuffer,
|
2236 |
|
|
pNextBuffer,
|
2237 |
|
|
szNextBuffer);
|
2238 |
|
|
}
|
2239 |
|
|
|
2240 |
|
|
//*----------------------------------------------------------------------------
|
2241 |
|
|
//* \fn AT91F_US_ReceiveFrame
|
2242 |
|
|
//* \brief Return 2 if PDC has been initialized with Buffer and Next Buffer, 1 if PDC has been initializaed with Next Buffer, 0 if PDC is busy
|
2243 |
|
|
//*----------------------------------------------------------------------------
|
2244 |
|
|
__inline unsigned int AT91F_US_ReceiveFrame (
|
2245 |
|
|
AT91PS_USART pUSART,
|
2246 |
|
|
char *pBuffer,
|
2247 |
|
|
unsigned int szBuffer,
|
2248 |
|
|
char *pNextBuffer,
|
2249 |
|
|
unsigned int szNextBuffer )
|
2250 |
|
|
{
|
2251 |
|
|
return AT91F_PDC_ReceiveFrame(
|
2252 |
|
|
(AT91PS_PDC) &(pUSART->US_RPR),
|
2253 |
|
|
pBuffer,
|
2254 |
|
|
szBuffer,
|
2255 |
|
|
pNextBuffer,
|
2256 |
|
|
szNextBuffer);
|
2257 |
|
|
}
|
2258 |
|
|
|
2259 |
|
|
//*----------------------------------------------------------------------------
|
2260 |
|
|
//* \fn AT91F_US_SetIrdaFilter
|
2261 |
|
|
//* \brief Set the value of IrDa filter tregister
|
2262 |
|
|
//*----------------------------------------------------------------------------
|
2263 |
|
|
__inline void AT91F_US_SetIrdaFilter (
|
2264 |
|
|
AT91PS_USART pUSART,
|
2265 |
|
|
unsigned char value
|
2266 |
|
|
)
|
2267 |
|
|
{
|
2268 |
|
|
pUSART->US_IF = value;
|
2269 |
|
|
}
|
2270 |
|
|
|
2271 |
|
|
/* *****************************************************************************
|
2272 |
|
|
SOFTWARE API FOR SSC
|
2273 |
|
|
***************************************************************************** */
|
2274 |
|
|
//* Define the standard I2S mode configuration
|
2275 |
|
|
|
2276 |
|
|
//* Configuration to set in the SSC Transmit Clock Mode Register
|
2277 |
|
|
//* Parameters : nb_bit_by_slot : 8, 16 or 32 bits
|
2278 |
|
|
//* nb_slot_by_frame : number of channels
|
2279 |
|
|
#define AT91C_I2S_ASY_MASTER_TX_SETTING(nb_bit_by_slot, nb_slot_by_frame)( +\
|
2280 |
|
|
AT91C_SSC_CKS_DIV +\
|
2281 |
|
|
AT91C_SSC_CKO_CONTINOUS +\
|
2282 |
|
|
AT91C_SSC_CKG_NONE +\
|
2283 |
|
|
AT91C_SSC_START_FALL_RF +\
|
2284 |
|
|
AT91C_SSC_STTOUT +\
|
2285 |
|
|
((1<<16) & AT91C_SSC_STTDLY) +\
|
2286 |
|
|
((((nb_bit_by_slot*nb_slot_by_frame)/2)-1) <<24))
|
2287 |
|
|
|
2288 |
|
|
|
2289 |
|
|
//* Configuration to set in the SSC Transmit Frame Mode Register
|
2290 |
|
|
//* Parameters : nb_bit_by_slot : 8, 16 or 32 bits
|
2291 |
|
|
//* nb_slot_by_frame : number of channels
|
2292 |
|
|
#define AT91C_I2S_ASY_TX_FRAME_SETTING(nb_bit_by_slot, nb_slot_by_frame)( +\
|
2293 |
|
|
(nb_bit_by_slot-1) +\
|
2294 |
|
|
AT91C_SSC_MSBF +\
|
2295 |
|
|
(((nb_slot_by_frame-1)<<8) & AT91C_SSC_DATNB) +\
|
2296 |
|
|
(((nb_bit_by_slot-1)<<16) & AT91C_SSC_FSLEN) +\
|
2297 |
|
|
AT91C_SSC_FSOS_NEGATIVE)
|
2298 |
|
|
|
2299 |
|
|
|
2300 |
|
|
//*----------------------------------------------------------------------------
|
2301 |
|
|
//* \fn AT91F_SSC_SetBaudrate
|
2302 |
|
|
//* \brief Set the baudrate according to the CPU clock
|
2303 |
|
|
//*----------------------------------------------------------------------------
|
2304 |
|
|
__inline void AT91F_SSC_SetBaudrate (
|
2305 |
|
|
AT91PS_SSC pSSC, // \arg pointer to a SSC controller
|
2306 |
|
|
unsigned int mainClock, // \arg peripheral clock
|
2307 |
|
|
unsigned int speed) // \arg SSC baudrate
|
2308 |
|
|
{
|
2309 |
|
|
unsigned int baud_value;
|
2310 |
|
|
//* Define the baud rate divisor register
|
2311 |
|
|
if (speed == 0)
|
2312 |
|
|
baud_value = 0;
|
2313 |
|
|
else
|
2314 |
|
|
{
|
2315 |
|
|
baud_value = (unsigned int) (mainClock * 10)/(2*speed);
|
2316 |
|
|
if ((baud_value % 10) >= 5)
|
2317 |
|
|
baud_value = (baud_value / 10) + 1;
|
2318 |
|
|
else
|
2319 |
|
|
baud_value /= 10;
|
2320 |
|
|
}
|
2321 |
|
|
|
2322 |
|
|
pSSC->SSC_CMR = baud_value;
|
2323 |
|
|
}
|
2324 |
|
|
|
2325 |
|
|
//*----------------------------------------------------------------------------
|
2326 |
|
|
//* \fn AT91F_SSC_Configure
|
2327 |
|
|
//* \brief Configure SSC
|
2328 |
|
|
//*----------------------------------------------------------------------------
|
2329 |
|
|
__inline void AT91F_SSC_Configure (
|
2330 |
|
|
AT91PS_SSC pSSC, // \arg pointer to a SSC controller
|
2331 |
|
|
unsigned int syst_clock, // \arg System Clock Frequency
|
2332 |
|
|
unsigned int baud_rate, // \arg Expected Baud Rate Frequency
|
2333 |
|
|
unsigned int clock_rx, // \arg Receiver Clock Parameters
|
2334 |
|
|
unsigned int mode_rx, // \arg mode Register to be programmed
|
2335 |
|
|
unsigned int clock_tx, // \arg Transmitter Clock Parameters
|
2336 |
|
|
unsigned int mode_tx) // \arg mode Register to be programmed
|
2337 |
|
|
{
|
2338 |
|
|
//* Disable interrupts
|
2339 |
|
|
pSSC->SSC_IDR = (unsigned int) -1;
|
2340 |
|
|
|
2341 |
|
|
//* Reset receiver and transmitter
|
2342 |
|
|
pSSC->SSC_CR = AT91C_SSC_SWRST | AT91C_SSC_RXDIS | AT91C_SSC_TXDIS ;
|
2343 |
|
|
|
2344 |
|
|
//* Define the Clock Mode Register
|
2345 |
|
|
AT91F_SSC_SetBaudrate(pSSC, syst_clock, baud_rate);
|
2346 |
|
|
|
2347 |
|
|
//* Write the Receive Clock Mode Register
|
2348 |
|
|
pSSC->SSC_RCMR = clock_rx;
|
2349 |
|
|
|
2350 |
|
|
//* Write the Transmit Clock Mode Register
|
2351 |
|
|
pSSC->SSC_TCMR = clock_tx;
|
2352 |
|
|
|
2353 |
|
|
//* Write the Receive Frame Mode Register
|
2354 |
|
|
pSSC->SSC_RFMR = mode_rx;
|
2355 |
|
|
|
2356 |
|
|
//* Write the Transmit Frame Mode Register
|
2357 |
|
|
pSSC->SSC_TFMR = mode_tx;
|
2358 |
|
|
|
2359 |
|
|
//* Clear Transmit and Receive Counters
|
2360 |
|
|
AT91F_PDC_Open((AT91PS_PDC) &(pSSC->SSC_RPR));
|
2361 |
|
|
|
2362 |
|
|
|
2363 |
|
|
}
|
2364 |
|
|
|
2365 |
|
|
//*----------------------------------------------------------------------------
|
2366 |
|
|
//* \fn AT91F_SSC_EnableRx
|
2367 |
|
|
//* \brief Enable receiving datas
|
2368 |
|
|
//*----------------------------------------------------------------------------
|
2369 |
|
|
__inline void AT91F_SSC_EnableRx (
|
2370 |
|
|
AT91PS_SSC pSSC) // \arg pointer to a SSC controller
|
2371 |
|
|
{
|
2372 |
|
|
//* Enable receiver
|
2373 |
|
|
pSSC->SSC_CR = AT91C_SSC_RXEN;
|
2374 |
|
|
}
|
2375 |
|
|
|
2376 |
|
|
//*----------------------------------------------------------------------------
|
2377 |
|
|
//* \fn AT91F_SSC_DisableRx
|
2378 |
|
|
//* \brief Disable receiving datas
|
2379 |
|
|
//*----------------------------------------------------------------------------
|
2380 |
|
|
__inline void AT91F_SSC_DisableRx (
|
2381 |
|
|
AT91PS_SSC pSSC) // \arg pointer to a SSC controller
|
2382 |
|
|
{
|
2383 |
|
|
//* Disable receiver
|
2384 |
|
|
pSSC->SSC_CR = AT91C_SSC_RXDIS;
|
2385 |
|
|
}
|
2386 |
|
|
|
2387 |
|
|
//*----------------------------------------------------------------------------
|
2388 |
|
|
//* \fn AT91F_SSC_EnableTx
|
2389 |
|
|
//* \brief Enable sending datas
|
2390 |
|
|
//*----------------------------------------------------------------------------
|
2391 |
|
|
__inline void AT91F_SSC_EnableTx (
|
2392 |
|
|
AT91PS_SSC pSSC) // \arg pointer to a SSC controller
|
2393 |
|
|
{
|
2394 |
|
|
//* Enable transmitter
|
2395 |
|
|
pSSC->SSC_CR = AT91C_SSC_TXEN;
|
2396 |
|
|
}
|
2397 |
|
|
|
2398 |
|
|
//*----------------------------------------------------------------------------
|
2399 |
|
|
//* \fn AT91F_SSC_DisableTx
|
2400 |
|
|
//* \brief Disable sending datas
|
2401 |
|
|
//*----------------------------------------------------------------------------
|
2402 |
|
|
__inline void AT91F_SSC_DisableTx (
|
2403 |
|
|
AT91PS_SSC pSSC) // \arg pointer to a SSC controller
|
2404 |
|
|
{
|
2405 |
|
|
//* Disable transmitter
|
2406 |
|
|
pSSC->SSC_CR = AT91C_SSC_TXDIS;
|
2407 |
|
|
}
|
2408 |
|
|
|
2409 |
|
|
//*----------------------------------------------------------------------------
|
2410 |
|
|
//* \fn AT91F_SSC_EnableIt
|
2411 |
|
|
//* \brief Enable SSC IT
|
2412 |
|
|
//*----------------------------------------------------------------------------
|
2413 |
|
|
__inline void AT91F_SSC_EnableIt (
|
2414 |
|
|
AT91PS_SSC pSSC, // \arg pointer to a SSC controller
|
2415 |
|
|
unsigned int flag) // \arg IT to be enabled
|
2416 |
|
|
{
|
2417 |
|
|
//* Write to the IER register
|
2418 |
|
|
pSSC->SSC_IER = flag;
|
2419 |
|
|
}
|
2420 |
|
|
|
2421 |
|
|
//*----------------------------------------------------------------------------
|
2422 |
|
|
//* \fn AT91F_SSC_DisableIt
|
2423 |
|
|
//* \brief Disable SSC IT
|
2424 |
|
|
//*----------------------------------------------------------------------------
|
2425 |
|
|
__inline void AT91F_SSC_DisableIt (
|
2426 |
|
|
AT91PS_SSC pSSC, // \arg pointer to a SSC controller
|
2427 |
|
|
unsigned int flag) // \arg IT to be disabled
|
2428 |
|
|
{
|
2429 |
|
|
//* Write to the IDR register
|
2430 |
|
|
pSSC->SSC_IDR = flag;
|
2431 |
|
|
}
|
2432 |
|
|
|
2433 |
|
|
//*----------------------------------------------------------------------------
|
2434 |
|
|
//* \fn AT91F_SSC_ReceiveFrame
|
2435 |
|
|
//* \brief Return 2 if PDC has been initialized with Buffer and Next Buffer, 1 if PDC has been initialized with Next Buffer, 0 if PDC is busy
|
2436 |
|
|
//*----------------------------------------------------------------------------
|
2437 |
|
|
__inline unsigned int AT91F_SSC_ReceiveFrame (
|
2438 |
|
|
AT91PS_SSC pSSC,
|
2439 |
|
|
char *pBuffer,
|
2440 |
|
|
unsigned int szBuffer,
|
2441 |
|
|
char *pNextBuffer,
|
2442 |
|
|
unsigned int szNextBuffer )
|
2443 |
|
|
{
|
2444 |
|
|
return AT91F_PDC_ReceiveFrame(
|
2445 |
|
|
(AT91PS_PDC) &(pSSC->SSC_RPR),
|
2446 |
|
|
pBuffer,
|
2447 |
|
|
szBuffer,
|
2448 |
|
|
pNextBuffer,
|
2449 |
|
|
szNextBuffer);
|
2450 |
|
|
}
|
2451 |
|
|
|
2452 |
|
|
//*----------------------------------------------------------------------------
|
2453 |
|
|
//* \fn AT91F_SSC_SendFrame
|
2454 |
|
|
//* \brief Return 2 if PDC has been initialized with Buffer and Next Buffer, 1 if PDC has been initialized with Next Buffer, 0 if PDC is busy
|
2455 |
|
|
//*----------------------------------------------------------------------------
|
2456 |
|
|
__inline unsigned int AT91F_SSC_SendFrame(
|
2457 |
|
|
AT91PS_SSC pSSC,
|
2458 |
|
|
char *pBuffer,
|
2459 |
|
|
unsigned int szBuffer,
|
2460 |
|
|
char *pNextBuffer,
|
2461 |
|
|
unsigned int szNextBuffer )
|
2462 |
|
|
{
|
2463 |
|
|
return AT91F_PDC_SendFrame(
|
2464 |
|
|
(AT91PS_PDC) &(pSSC->SSC_RPR),
|
2465 |
|
|
pBuffer,
|
2466 |
|
|
szBuffer,
|
2467 |
|
|
pNextBuffer,
|
2468 |
|
|
szNextBuffer);
|
2469 |
|
|
}
|
2470 |
|
|
|
2471 |
|
|
//*----------------------------------------------------------------------------
|
2472 |
|
|
//* \fn AT91F_SSC_GetInterruptMaskStatus
|
2473 |
|
|
//* \brief Return SSC Interrupt Mask Status
|
2474 |
|
|
//*----------------------------------------------------------------------------
|
2475 |
|
|
__inline unsigned int AT91F_SSC_GetInterruptMaskStatus( // \return SSC Interrupt Mask Status
|
2476 |
|
|
AT91PS_SSC pSsc) // \arg pointer to a SSC controller
|
2477 |
|
|
{
|
2478 |
|
|
return pSsc->SSC_IMR;
|
2479 |
|
|
}
|
2480 |
|
|
|
2481 |
|
|
//*----------------------------------------------------------------------------
|
2482 |
|
|
//* \fn AT91F_SSC_IsInterruptMasked
|
2483 |
|
|
//* \brief Test if SSC Interrupt is Masked
|
2484 |
|
|
//*----------------------------------------------------------------------------
|
2485 |
|
|
__inline int AT91F_SSC_IsInterruptMasked(
|
2486 |
|
|
AT91PS_SSC pSsc, // \arg pointer to a SSC controller
|
2487 |
|
|
unsigned int flag) // \arg flag to be tested
|
2488 |
|
|
{
|
2489 |
|
|
return (AT91F_SSC_GetInterruptMaskStatus(pSsc) & flag);
|
2490 |
|
|
}
|
2491 |
|
|
|
2492 |
|
|
/* *****************************************************************************
|
2493 |
|
|
SOFTWARE API FOR TWI
|
2494 |
|
|
***************************************************************************** */
|
2495 |
|
|
//*----------------------------------------------------------------------------
|
2496 |
|
|
//* \fn AT91F_TWI_EnableIt
|
2497 |
|
|
//* \brief Enable TWI IT
|
2498 |
|
|
//*----------------------------------------------------------------------------
|
2499 |
|
|
__inline void AT91F_TWI_EnableIt (
|
2500 |
|
|
AT91PS_TWI pTWI, // \arg pointer to a TWI controller
|
2501 |
|
|
unsigned int flag) // \arg IT to be enabled
|
2502 |
|
|
{
|
2503 |
|
|
//* Write to the IER register
|
2504 |
|
|
pTWI->TWI_IER = flag;
|
2505 |
|
|
}
|
2506 |
|
|
|
2507 |
|
|
//*----------------------------------------------------------------------------
|
2508 |
|
|
//* \fn AT91F_TWI_DisableIt
|
2509 |
|
|
//* \brief Disable TWI IT
|
2510 |
|
|
//*----------------------------------------------------------------------------
|
2511 |
|
|
__inline void AT91F_TWI_DisableIt (
|
2512 |
|
|
AT91PS_TWI pTWI, // \arg pointer to a TWI controller
|
2513 |
|
|
unsigned int flag) // \arg IT to be disabled
|
2514 |
|
|
{
|
2515 |
|
|
//* Write to the IDR register
|
2516 |
|
|
pTWI->TWI_IDR = flag;
|
2517 |
|
|
}
|
2518 |
|
|
|
2519 |
|
|
//*----------------------------------------------------------------------------
|
2520 |
|
|
//* \fn AT91F_TWI_Configure
|
2521 |
|
|
//* \brief Configure TWI in master mode
|
2522 |
|
|
//*----------------------------------------------------------------------------
|
2523 |
|
|
__inline void AT91F_TWI_Configure ( AT91PS_TWI pTWI ) // \arg pointer to a TWI controller
|
2524 |
|
|
{
|
2525 |
|
|
//* Disable interrupts
|
2526 |
|
|
pTWI->TWI_IDR = (unsigned int) -1;
|
2527 |
|
|
|
2528 |
|
|
//* Reset peripheral
|
2529 |
|
|
pTWI->TWI_CR = AT91C_TWI_SWRST;
|
2530 |
|
|
|
2531 |
|
|
//* Set Master mode
|
2532 |
|
|
pTWI->TWI_CR = AT91C_TWI_MSEN;
|
2533 |
|
|
|
2534 |
|
|
}
|
2535 |
|
|
|
2536 |
|
|
//*----------------------------------------------------------------------------
|
2537 |
|
|
//* \fn AT91F_TWI_GetInterruptMaskStatus
|
2538 |
|
|
//* \brief Return TWI Interrupt Mask Status
|
2539 |
|
|
//*----------------------------------------------------------------------------
|
2540 |
|
|
__inline unsigned int AT91F_TWI_GetInterruptMaskStatus( // \return TWI Interrupt Mask Status
|
2541 |
|
|
AT91PS_TWI pTwi) // \arg pointer to a TWI controller
|
2542 |
|
|
{
|
2543 |
|
|
return pTwi->TWI_IMR;
|
2544 |
|
|
}
|
2545 |
|
|
|
2546 |
|
|
//*----------------------------------------------------------------------------
|
2547 |
|
|
//* \fn AT91F_TWI_IsInterruptMasked
|
2548 |
|
|
//* \brief Test if TWI Interrupt is Masked
|
2549 |
|
|
//*----------------------------------------------------------------------------
|
2550 |
|
|
__inline int AT91F_TWI_IsInterruptMasked(
|
2551 |
|
|
AT91PS_TWI pTwi, // \arg pointer to a TWI controller
|
2552 |
|
|
unsigned int flag) // \arg flag to be tested
|
2553 |
|
|
{
|
2554 |
|
|
return (AT91F_TWI_GetInterruptMaskStatus(pTwi) & flag);
|
2555 |
|
|
}
|
2556 |
|
|
|
2557 |
|
|
/* *****************************************************************************
|
2558 |
|
|
SOFTWARE API FOR PWMC
|
2559 |
|
|
***************************************************************************** */
|
2560 |
|
|
//*----------------------------------------------------------------------------
|
2561 |
|
|
//* \fn AT91F_PWM_GetStatus
|
2562 |
|
|
//* \brief Return PWM Interrupt Status
|
2563 |
|
|
//*----------------------------------------------------------------------------
|
2564 |
|
|
__inline unsigned int AT91F_PWMC_GetStatus( // \return PWM Interrupt Status
|
2565 |
|
|
AT91PS_PWMC pPWM) // pointer to a PWM controller
|
2566 |
|
|
{
|
2567 |
|
|
return pPWM->PWMC_SR;
|
2568 |
|
|
}
|
2569 |
|
|
|
2570 |
|
|
//*----------------------------------------------------------------------------
|
2571 |
|
|
//* \fn AT91F_PWM_InterruptEnable
|
2572 |
|
|
//* \brief Enable PWM Interrupt
|
2573 |
|
|
//*----------------------------------------------------------------------------
|
2574 |
|
|
__inline void AT91F_PWMC_InterruptEnable(
|
2575 |
|
|
AT91PS_PWMC pPwm, // \arg pointer to a PWM controller
|
2576 |
|
|
unsigned int flag) // \arg PWM interrupt to be enabled
|
2577 |
|
|
{
|
2578 |
|
|
pPwm->PWMC_IER = flag;
|
2579 |
|
|
}
|
2580 |
|
|
|
2581 |
|
|
//*----------------------------------------------------------------------------
|
2582 |
|
|
//* \fn AT91F_PWM_InterruptDisable
|
2583 |
|
|
//* \brief Disable PWM Interrupt
|
2584 |
|
|
//*----------------------------------------------------------------------------
|
2585 |
|
|
__inline void AT91F_PWMC_InterruptDisable(
|
2586 |
|
|
AT91PS_PWMC pPwm, // \arg pointer to a PWM controller
|
2587 |
|
|
unsigned int flag) // \arg PWM interrupt to be disabled
|
2588 |
|
|
{
|
2589 |
|
|
pPwm->PWMC_IDR = flag;
|
2590 |
|
|
}
|
2591 |
|
|
|
2592 |
|
|
//*----------------------------------------------------------------------------
|
2593 |
|
|
//* \fn AT91F_PWM_GetInterruptMaskStatus
|
2594 |
|
|
//* \brief Return PWM Interrupt Mask Status
|
2595 |
|
|
//*----------------------------------------------------------------------------
|
2596 |
|
|
__inline unsigned int AT91F_PWMC_GetInterruptMaskStatus( // \return PWM Interrupt Mask Status
|
2597 |
|
|
AT91PS_PWMC pPwm) // \arg pointer to a PWM controller
|
2598 |
|
|
{
|
2599 |
|
|
return pPwm->PWMC_IMR;
|
2600 |
|
|
}
|
2601 |
|
|
|
2602 |
|
|
//*----------------------------------------------------------------------------
|
2603 |
|
|
//* \fn AT91F_PWM_IsInterruptMasked
|
2604 |
|
|
//* \brief Test if PWM Interrupt is Masked
|
2605 |
|
|
//*----------------------------------------------------------------------------
|
2606 |
|
|
__inline unsigned int AT91F_PWMC_IsInterruptMasked(
|
2607 |
|
|
AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
|
2608 |
|
|
unsigned int flag) // \arg flag to be tested
|
2609 |
|
|
{
|
2610 |
|
|
return (AT91F_PWMC_GetInterruptMaskStatus(pPWM) & flag);
|
2611 |
|
|
}
|
2612 |
|
|
|
2613 |
|
|
//*----------------------------------------------------------------------------
|
2614 |
|
|
//* \fn AT91F_PWM_IsStatusSet
|
2615 |
|
|
//* \brief Test if PWM Interrupt is Set
|
2616 |
|
|
//*----------------------------------------------------------------------------
|
2617 |
|
|
__inline unsigned int AT91F_PWMC_IsStatusSet(
|
2618 |
|
|
AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
|
2619 |
|
|
unsigned int flag) // \arg flag to be tested
|
2620 |
|
|
{
|
2621 |
|
|
return (AT91F_PWMC_GetStatus(pPWM) & flag);
|
2622 |
|
|
}
|
2623 |
|
|
|
2624 |
|
|
//*----------------------------------------------------------------------------
|
2625 |
|
|
//* \fn AT91F_PWM_CfgChannel
|
2626 |
|
|
//* \brief Test if PWM Interrupt is Set
|
2627 |
|
|
//*----------------------------------------------------------------------------
|
2628 |
|
|
__inline void AT91F_PWMC_CfgChannel(
|
2629 |
|
|
AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
|
2630 |
|
|
unsigned int channelId, // \arg PWM channel ID
|
2631 |
|
|
unsigned int mode, // \arg PWM mode
|
2632 |
|
|
unsigned int period, // \arg PWM period
|
2633 |
|
|
unsigned int duty) // \arg PWM duty cycle
|
2634 |
|
|
{
|
2635 |
|
|
pPWM->PWMC_CH[channelId].PWMC_CMR = mode;
|
2636 |
|
|
pPWM->PWMC_CH[channelId].PWMC_CDTYR = duty;
|
2637 |
|
|
pPWM->PWMC_CH[channelId].PWMC_CPRDR = period;
|
2638 |
|
|
}
|
2639 |
|
|
|
2640 |
|
|
//*----------------------------------------------------------------------------
|
2641 |
|
|
//* \fn AT91F_PWM_StartChannel
|
2642 |
|
|
//* \brief Enable channel
|
2643 |
|
|
//*----------------------------------------------------------------------------
|
2644 |
|
|
__inline void AT91F_PWMC_StartChannel(
|
2645 |
|
|
AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
|
2646 |
|
|
unsigned int flag) // \arg Channels IDs to be enabled
|
2647 |
|
|
{
|
2648 |
|
|
pPWM->PWMC_ENA = flag;
|
2649 |
|
|
}
|
2650 |
|
|
|
2651 |
|
|
//*----------------------------------------------------------------------------
|
2652 |
|
|
//* \fn AT91F_PWM_StopChannel
|
2653 |
|
|
//* \brief Disable channel
|
2654 |
|
|
//*----------------------------------------------------------------------------
|
2655 |
|
|
__inline void AT91F_PWMC_StopChannel(
|
2656 |
|
|
AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
|
2657 |
|
|
unsigned int flag) // \arg Channels IDs to be enabled
|
2658 |
|
|
{
|
2659 |
|
|
pPWM->PWMC_DIS = flag;
|
2660 |
|
|
}
|
2661 |
|
|
|
2662 |
|
|
//*----------------------------------------------------------------------------
|
2663 |
|
|
//* \fn AT91F_PWM_UpdateChannel
|
2664 |
|
|
//* \brief Update Period or Duty Cycle
|
2665 |
|
|
//*----------------------------------------------------------------------------
|
2666 |
|
|
__inline void AT91F_PWMC_UpdateChannel(
|
2667 |
|
|
AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
|
2668 |
|
|
unsigned int channelId, // \arg PWM channel ID
|
2669 |
|
|
unsigned int update) // \arg Channels IDs to be enabled
|
2670 |
|
|
{
|
2671 |
|
|
pPWM->PWMC_CH[channelId].PWMC_CUPDR = update;
|
2672 |
|
|
}
|
2673 |
|
|
|
2674 |
|
|
/* *****************************************************************************
|
2675 |
|
|
SOFTWARE API FOR UDP
|
2676 |
|
|
***************************************************************************** */
|
2677 |
|
|
//*----------------------------------------------------------------------------
|
2678 |
|
|
//* \fn AT91F_UDP_EnableIt
|
2679 |
|
|
//* \brief Enable UDP IT
|
2680 |
|
|
//*----------------------------------------------------------------------------
|
2681 |
|
|
__inline void AT91F_UDP_EnableIt (
|
2682 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2683 |
|
|
unsigned int flag) // \arg IT to be enabled
|
2684 |
|
|
{
|
2685 |
|
|
//* Write to the IER register
|
2686 |
|
|
pUDP->UDP_IER = flag;
|
2687 |
|
|
}
|
2688 |
|
|
|
2689 |
|
|
//*----------------------------------------------------------------------------
|
2690 |
|
|
//* \fn AT91F_UDP_DisableIt
|
2691 |
|
|
//* \brief Disable UDP IT
|
2692 |
|
|
//*----------------------------------------------------------------------------
|
2693 |
|
|
__inline void AT91F_UDP_DisableIt (
|
2694 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2695 |
|
|
unsigned int flag) // \arg IT to be disabled
|
2696 |
|
|
{
|
2697 |
|
|
//* Write to the IDR register
|
2698 |
|
|
pUDP->UDP_IDR = flag;
|
2699 |
|
|
}
|
2700 |
|
|
|
2701 |
|
|
//*----------------------------------------------------------------------------
|
2702 |
|
|
//* \fn AT91F_UDP_SetAddress
|
2703 |
|
|
//* \brief Set UDP functional address
|
2704 |
|
|
//*----------------------------------------------------------------------------
|
2705 |
|
|
__inline void AT91F_UDP_SetAddress (
|
2706 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2707 |
|
|
unsigned char address) // \arg new UDP address
|
2708 |
|
|
{
|
2709 |
|
|
pUDP->UDP_FADDR = (AT91C_UDP_FEN | address);
|
2710 |
|
|
}
|
2711 |
|
|
|
2712 |
|
|
//*----------------------------------------------------------------------------
|
2713 |
|
|
//* \fn AT91F_UDP_EnableEp
|
2714 |
|
|
//* \brief Enable Endpoint
|
2715 |
|
|
//*----------------------------------------------------------------------------
|
2716 |
|
|
__inline void AT91F_UDP_EnableEp (
|
2717 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2718 |
|
|
unsigned char endpoint) // \arg endpoint number
|
2719 |
|
|
{
|
2720 |
|
|
pUDP->UDP_CSR[endpoint] |= AT91C_UDP_EPEDS;
|
2721 |
|
|
}
|
2722 |
|
|
|
2723 |
|
|
//*----------------------------------------------------------------------------
|
2724 |
|
|
//* \fn AT91F_UDP_DisableEp
|
2725 |
|
|
//* \brief Enable Endpoint
|
2726 |
|
|
//*----------------------------------------------------------------------------
|
2727 |
|
|
__inline void AT91F_UDP_DisableEp (
|
2728 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2729 |
|
|
unsigned char endpoint) // \arg endpoint number
|
2730 |
|
|
{
|
2731 |
|
|
pUDP->UDP_CSR[endpoint] &= ~AT91C_UDP_EPEDS;
|
2732 |
|
|
}
|
2733 |
|
|
|
2734 |
|
|
//*----------------------------------------------------------------------------
|
2735 |
|
|
//* \fn AT91F_UDP_SetState
|
2736 |
|
|
//* \brief Set UDP Device state
|
2737 |
|
|
//*----------------------------------------------------------------------------
|
2738 |
|
|
__inline void AT91F_UDP_SetState (
|
2739 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2740 |
|
|
unsigned int flag) // \arg new UDP address
|
2741 |
|
|
{
|
2742 |
|
|
pUDP->UDP_GLBSTATE &= ~(AT91C_UDP_FADDEN | AT91C_UDP_CONFG);
|
2743 |
|
|
pUDP->UDP_GLBSTATE |= flag;
|
2744 |
|
|
}
|
2745 |
|
|
|
2746 |
|
|
//*----------------------------------------------------------------------------
|
2747 |
|
|
//* \fn AT91F_UDP_GetState
|
2748 |
|
|
//* \brief return UDP Device state
|
2749 |
|
|
//*----------------------------------------------------------------------------
|
2750 |
|
|
__inline unsigned int AT91F_UDP_GetState ( // \return the UDP device state
|
2751 |
|
|
AT91PS_UDP pUDP) // \arg pointer to a UDP controller
|
2752 |
|
|
{
|
2753 |
|
|
return (pUDP->UDP_GLBSTATE & (AT91C_UDP_FADDEN | AT91C_UDP_CONFG));
|
2754 |
|
|
}
|
2755 |
|
|
|
2756 |
|
|
//*----------------------------------------------------------------------------
|
2757 |
|
|
//* \fn AT91F_UDP_ResetEp
|
2758 |
|
|
//* \brief Reset UDP endpoint
|
2759 |
|
|
//*----------------------------------------------------------------------------
|
2760 |
|
|
__inline void AT91F_UDP_ResetEp ( // \return the UDP device state
|
2761 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2762 |
|
|
unsigned int flag) // \arg Endpoints to be reset
|
2763 |
|
|
{
|
2764 |
|
|
pUDP->UDP_RSTEP = flag;
|
2765 |
|
|
pUDP->UDP_RSTEP = 0;
|
2766 |
|
|
}
|
2767 |
|
|
|
2768 |
|
|
//*----------------------------------------------------------------------------
|
2769 |
|
|
//* \fn AT91F_UDP_EpStall
|
2770 |
|
|
//* \brief Endpoint will STALL requests
|
2771 |
|
|
//*----------------------------------------------------------------------------
|
2772 |
|
|
__inline void AT91F_UDP_EpStall(
|
2773 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2774 |
|
|
unsigned char endpoint) // \arg endpoint number
|
2775 |
|
|
{
|
2776 |
|
|
pUDP->UDP_CSR[endpoint] |= AT91C_UDP_FORCESTALL;
|
2777 |
|
|
}
|
2778 |
|
|
|
2779 |
|
|
//*----------------------------------------------------------------------------
|
2780 |
|
|
//* \fn AT91F_UDP_EpWrite
|
2781 |
|
|
//* \brief Write value in the DPR
|
2782 |
|
|
//*----------------------------------------------------------------------------
|
2783 |
|
|
__inline void AT91F_UDP_EpWrite(
|
2784 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2785 |
|
|
unsigned char endpoint, // \arg endpoint number
|
2786 |
|
|
unsigned char value) // \arg value to be written in the DPR
|
2787 |
|
|
{
|
2788 |
|
|
pUDP->UDP_FDR[endpoint] = value;
|
2789 |
|
|
}
|
2790 |
|
|
|
2791 |
|
|
//*----------------------------------------------------------------------------
|
2792 |
|
|
//* \fn AT91F_UDP_EpRead
|
2793 |
|
|
//* \brief Return value from the DPR
|
2794 |
|
|
//*----------------------------------------------------------------------------
|
2795 |
|
|
__inline unsigned int AT91F_UDP_EpRead(
|
2796 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2797 |
|
|
unsigned char endpoint) // \arg endpoint number
|
2798 |
|
|
{
|
2799 |
|
|
return pUDP->UDP_FDR[endpoint];
|
2800 |
|
|
}
|
2801 |
|
|
|
2802 |
|
|
//*----------------------------------------------------------------------------
|
2803 |
|
|
//* \fn AT91F_UDP_EpEndOfWr
|
2804 |
|
|
//* \brief Notify the UDP that values in DPR are ready to be sent
|
2805 |
|
|
//*----------------------------------------------------------------------------
|
2806 |
|
|
__inline void AT91F_UDP_EpEndOfWr(
|
2807 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2808 |
|
|
unsigned char endpoint) // \arg endpoint number
|
2809 |
|
|
{
|
2810 |
|
|
pUDP->UDP_CSR[endpoint] |= AT91C_UDP_TXPKTRDY;
|
2811 |
|
|
}
|
2812 |
|
|
|
2813 |
|
|
//*----------------------------------------------------------------------------
|
2814 |
|
|
//* \fn AT91F_UDP_EpClear
|
2815 |
|
|
//* \brief Clear flag in the endpoint CSR register
|
2816 |
|
|
//*----------------------------------------------------------------------------
|
2817 |
|
|
__inline void AT91F_UDP_EpClear(
|
2818 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2819 |
|
|
unsigned char endpoint, // \arg endpoint number
|
2820 |
|
|
unsigned int flag) // \arg flag to be cleared
|
2821 |
|
|
{
|
2822 |
|
|
pUDP->UDP_CSR[endpoint] &= ~(flag);
|
2823 |
|
|
}
|
2824 |
|
|
|
2825 |
|
|
//*----------------------------------------------------------------------------
|
2826 |
|
|
//* \fn AT91F_UDP_EpSet
|
2827 |
|
|
//* \brief Set flag in the endpoint CSR register
|
2828 |
|
|
//*----------------------------------------------------------------------------
|
2829 |
|
|
__inline void AT91F_UDP_EpSet(
|
2830 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2831 |
|
|
unsigned char endpoint, // \arg endpoint number
|
2832 |
|
|
unsigned int flag) // \arg flag to be cleared
|
2833 |
|
|
{
|
2834 |
|
|
pUDP->UDP_CSR[endpoint] |= flag;
|
2835 |
|
|
}
|
2836 |
|
|
|
2837 |
|
|
//*----------------------------------------------------------------------------
|
2838 |
|
|
//* \fn AT91F_UDP_EpStatus
|
2839 |
|
|
//* \brief Return the endpoint CSR register
|
2840 |
|
|
//*----------------------------------------------------------------------------
|
2841 |
|
|
__inline unsigned int AT91F_UDP_EpStatus(
|
2842 |
|
|
AT91PS_UDP pUDP, // \arg pointer to a UDP controller
|
2843 |
|
|
unsigned char endpoint) // \arg endpoint number
|
2844 |
|
|
{
|
2845 |
|
|
return pUDP->UDP_CSR[endpoint];
|
2846 |
|
|
}
|
2847 |
|
|
|
2848 |
|
|
//*----------------------------------------------------------------------------
|
2849 |
|
|
//* \fn AT91F_UDP_GetInterruptMaskStatus
|
2850 |
|
|
//* \brief Return UDP Interrupt Mask Status
|
2851 |
|
|
//*----------------------------------------------------------------------------
|
2852 |
|
|
__inline unsigned int AT91F_UDP_GetInterruptMaskStatus( // \return UDP Interrupt Mask Status
|
2853 |
|
|
AT91PS_UDP pUdp) // \arg pointer to a UDP controller
|
2854 |
|
|
{
|
2855 |
|
|
return pUdp->UDP_IMR;
|
2856 |
|
|
}
|
2857 |
|
|
|
2858 |
|
|
//*----------------------------------------------------------------------------
|
2859 |
|
|
//* \fn AT91F_UDP_IsInterruptMasked
|
2860 |
|
|
//* \brief Test if UDP Interrupt is Masked
|
2861 |
|
|
//*----------------------------------------------------------------------------
|
2862 |
|
|
__inline int AT91F_UDP_IsInterruptMasked(
|
2863 |
|
|
AT91PS_UDP pUdp, // \arg pointer to a UDP controller
|
2864 |
|
|
unsigned int flag) // \arg flag to be tested
|
2865 |
|
|
{
|
2866 |
|
|
return (AT91F_UDP_GetInterruptMaskStatus(pUdp) & flag);
|
2867 |
|
|
}
|
2868 |
|
|
|
2869 |
|
|
/* *****************************************************************************
|
2870 |
|
|
SOFTWARE API FOR TC
|
2871 |
|
|
***************************************************************************** */
|
2872 |
|
|
//*----------------------------------------------------------------------------
|
2873 |
|
|
//* \fn AT91F_TC_InterruptEnable
|
2874 |
|
|
//* \brief Enable TC Interrupt
|
2875 |
|
|
//*----------------------------------------------------------------------------
|
2876 |
|
|
__inline void AT91F_TC_InterruptEnable(
|
2877 |
|
|
AT91PS_TC pTc, // \arg pointer to a TC controller
|
2878 |
|
|
unsigned int flag) // \arg TC interrupt to be enabled
|
2879 |
|
|
{
|
2880 |
|
|
pTc->TC_IER = flag;
|
2881 |
|
|
}
|
2882 |
|
|
|
2883 |
|
|
//*----------------------------------------------------------------------------
|
2884 |
|
|
//* \fn AT91F_TC_InterruptDisable
|
2885 |
|
|
//* \brief Disable TC Interrupt
|
2886 |
|
|
//*----------------------------------------------------------------------------
|
2887 |
|
|
__inline void AT91F_TC_InterruptDisable(
|
2888 |
|
|
AT91PS_TC pTc, // \arg pointer to a TC controller
|
2889 |
|
|
unsigned int flag) // \arg TC interrupt to be disabled
|
2890 |
|
|
{
|
2891 |
|
|
pTc->TC_IDR = flag;
|
2892 |
|
|
}
|
2893 |
|
|
|
2894 |
|
|
//*----------------------------------------------------------------------------
|
2895 |
|
|
//* \fn AT91F_TC_GetInterruptMaskStatus
|
2896 |
|
|
//* \brief Return TC Interrupt Mask Status
|
2897 |
|
|
//*----------------------------------------------------------------------------
|
2898 |
|
|
__inline unsigned int AT91F_TC_GetInterruptMaskStatus( // \return TC Interrupt Mask Status
|
2899 |
|
|
AT91PS_TC pTc) // \arg pointer to a TC controller
|
2900 |
|
|
{
|
2901 |
|
|
return pTc->TC_IMR;
|
2902 |
|
|
}
|
2903 |
|
|
|
2904 |
|
|
//*----------------------------------------------------------------------------
|
2905 |
|
|
//* \fn AT91F_TC_IsInterruptMasked
|
2906 |
|
|
//* \brief Test if TC Interrupt is Masked
|
2907 |
|
|
//*----------------------------------------------------------------------------
|
2908 |
|
|
__inline int AT91F_TC_IsInterruptMasked(
|
2909 |
|
|
AT91PS_TC pTc, // \arg pointer to a TC controller
|
2910 |
|
|
unsigned int flag) // \arg flag to be tested
|
2911 |
|
|
{
|
2912 |
|
|
return (AT91F_TC_GetInterruptMaskStatus(pTc) & flag);
|
2913 |
|
|
}
|
2914 |
|
|
|
2915 |
|
|
/* *****************************************************************************
|
2916 |
|
|
SOFTWARE API FOR CAN
|
2917 |
|
|
***************************************************************************** */
|
2918 |
|
|
#define STANDARD_FORMAT 0
|
2919 |
|
|
#define EXTENDED_FORMAT 1
|
2920 |
|
|
|
2921 |
|
|
//*----------------------------------------------------------------------------
|
2922 |
|
|
//* \fn AT91F_InitMailboxRegisters()
|
2923 |
|
|
//* \brief Configure the corresponding mailbox
|
2924 |
|
|
//*----------------------------------------------------------------------------
|
2925 |
|
|
__inline void AT91F_InitMailboxRegisters(AT91PS_CAN_MB CAN_Mailbox,
|
2926 |
|
|
int mode_reg,
|
2927 |
|
|
int acceptance_mask_reg,
|
2928 |
|
|
int id_reg,
|
2929 |
|
|
int data_low_reg,
|
2930 |
|
|
int data_high_reg,
|
2931 |
|
|
int control_reg)
|
2932 |
|
|
{
|
2933 |
|
|
CAN_Mailbox->CAN_MB_MCR = 0x0;
|
2934 |
|
|
CAN_Mailbox->CAN_MB_MMR = mode_reg;
|
2935 |
|
|
CAN_Mailbox->CAN_MB_MAM = acceptance_mask_reg;
|
2936 |
|
|
CAN_Mailbox->CAN_MB_MID = id_reg;
|
2937 |
|
|
CAN_Mailbox->CAN_MB_MDL = data_low_reg;
|
2938 |
|
|
CAN_Mailbox->CAN_MB_MDH = data_high_reg;
|
2939 |
|
|
CAN_Mailbox->CAN_MB_MCR = control_reg;
|
2940 |
|
|
}
|
2941 |
|
|
|
2942 |
|
|
//*----------------------------------------------------------------------------
|
2943 |
|
|
//* \fn AT91F_EnableCAN()
|
2944 |
|
|
//* \brief
|
2945 |
|
|
//*----------------------------------------------------------------------------
|
2946 |
|
|
__inline void AT91F_EnableCAN(
|
2947 |
|
|
AT91PS_CAN pCAN) // pointer to a CAN controller
|
2948 |
|
|
{
|
2949 |
|
|
pCAN->CAN_MR |= AT91C_CAN_CANEN;
|
2950 |
|
|
|
2951 |
|
|
// Wait for WAKEUP flag raising <=> 11-recessive-bit were scanned by the transceiver
|
2952 |
|
|
while( (pCAN->CAN_SR & AT91C_CAN_WAKEUP) != AT91C_CAN_WAKEUP );
|
2953 |
|
|
}
|
2954 |
|
|
|
2955 |
|
|
//*----------------------------------------------------------------------------
|
2956 |
|
|
//* \fn AT91F_DisableCAN()
|
2957 |
|
|
//* \brief
|
2958 |
|
|
//*----------------------------------------------------------------------------
|
2959 |
|
|
__inline void AT91F_DisableCAN(
|
2960 |
|
|
AT91PS_CAN pCAN) // pointer to a CAN controller
|
2961 |
|
|
{
|
2962 |
|
|
pCAN->CAN_MR &= ~AT91C_CAN_CANEN;
|
2963 |
|
|
}
|
2964 |
|
|
|
2965 |
|
|
//*----------------------------------------------------------------------------
|
2966 |
|
|
//* \fn AT91F_CAN_EnableIt
|
2967 |
|
|
//* \brief Enable CAN interrupt
|
2968 |
|
|
//*----------------------------------------------------------------------------
|
2969 |
|
|
__inline void AT91F_CAN_EnableIt (
|
2970 |
|
|
AT91PS_CAN pCAN, // pointer to a CAN controller
|
2971 |
|
|
unsigned int flag) // IT to be enabled
|
2972 |
|
|
{
|
2973 |
|
|
//* Write to the IER register
|
2974 |
|
|
pCAN->CAN_IER = flag;
|
2975 |
|
|
}
|
2976 |
|
|
|
2977 |
|
|
//*----------------------------------------------------------------------------
|
2978 |
|
|
//* \fn AT91F_CAN_DisableIt
|
2979 |
|
|
//* \brief Disable CAN interrupt
|
2980 |
|
|
//*----------------------------------------------------------------------------
|
2981 |
|
|
__inline void AT91F_CAN_DisableIt (
|
2982 |
|
|
AT91PS_CAN pCAN, // pointer to a CAN controller
|
2983 |
|
|
unsigned int flag) // IT to be disabled
|
2984 |
|
|
{
|
2985 |
|
|
//* Write to the IDR register
|
2986 |
|
|
pCAN->CAN_IDR = flag;
|
2987 |
|
|
}
|
2988 |
|
|
|
2989 |
|
|
//*----------------------------------------------------------------------------
|
2990 |
|
|
//* \fn AT91F_CAN_GetStatus
|
2991 |
|
|
//* \brief Return CAN Interrupt Status
|
2992 |
|
|
//*----------------------------------------------------------------------------
|
2993 |
|
|
__inline unsigned int AT91F_CAN_GetStatus( // \return CAN Interrupt Status
|
2994 |
|
|
AT91PS_CAN pCAN) // pointer to a CAN controller
|
2995 |
|
|
{
|
2996 |
|
|
return pCAN->CAN_SR;
|
2997 |
|
|
}
|
2998 |
|
|
|
2999 |
|
|
//*----------------------------------------------------------------------------
|
3000 |
|
|
//* \fn AT91F_CAN_GetInterruptMaskStatus
|
3001 |
|
|
//* \brief Return CAN Interrupt Mask Status
|
3002 |
|
|
//*----------------------------------------------------------------------------
|
3003 |
|
|
__inline unsigned int AT91F_CAN_GetInterruptMaskStatus( // \return CAN Interrupt Mask Status
|
3004 |
|
|
AT91PS_CAN pCAN) // pointer to a CAN controller
|
3005 |
|
|
{
|
3006 |
|
|
return pCAN->CAN_IMR;
|
3007 |
|
|
}
|
3008 |
|
|
|
3009 |
|
|
//*----------------------------------------------------------------------------
|
3010 |
|
|
//* \fn AT91F_CAN_IsInterruptMasked
|
3011 |
|
|
//* \brief Test if CAN Interrupt is Masked
|
3012 |
|
|
//*----------------------------------------------------------------------------
|
3013 |
|
|
__inline unsigned int AT91F_CAN_IsInterruptMasked(
|
3014 |
|
|
AT91PS_CAN pCAN, // \arg pointer to a CAN controller
|
3015 |
|
|
unsigned int flag) // \arg flag to be tested
|
3016 |
|
|
{
|
3017 |
|
|
return (AT91F_CAN_GetInterruptMaskStatus(pCAN) & flag);
|
3018 |
|
|
}
|
3019 |
|
|
|
3020 |
|
|
//*----------------------------------------------------------------------------
|
3021 |
|
|
//* \fn AT91F_CAN_IsStatusSet
|
3022 |
|
|
//* \brief Test if CAN Interrupt is Set
|
3023 |
|
|
//*----------------------------------------------------------------------------
|
3024 |
|
|
__inline unsigned int AT91F_CAN_IsStatusSet(
|
3025 |
|
|
AT91PS_CAN pCAN, // \arg pointer to a CAN controller
|
3026 |
|
|
unsigned int flag) // \arg flag to be tested
|
3027 |
|
|
{
|
3028 |
|
|
return (AT91F_CAN_GetStatus(pCAN) & flag);
|
3029 |
|
|
}
|
3030 |
|
|
|
3031 |
|
|
//*----------------------------------------------------------------------------
|
3032 |
|
|
//* \fn AT91F_CAN_CfgModeReg
|
3033 |
|
|
//* \brief Configure the Mode Register of the CAN controller
|
3034 |
|
|
//*----------------------------------------------------------------------------
|
3035 |
|
|
__inline void AT91F_CAN_CfgModeReg (
|
3036 |
|
|
AT91PS_CAN pCAN, // pointer to a CAN controller
|
3037 |
|
|
unsigned int mode) // mode register
|
3038 |
|
|
{
|
3039 |
|
|
//* Write to the MR register
|
3040 |
|
|
pCAN->CAN_MR = mode;
|
3041 |
|
|
}
|
3042 |
|
|
|
3043 |
|
|
//*----------------------------------------------------------------------------
|
3044 |
|
|
//* \fn AT91F_CAN_GetModeReg
|
3045 |
|
|
//* \brief Return the Mode Register of the CAN controller value
|
3046 |
|
|
//*----------------------------------------------------------------------------
|
3047 |
|
|
__inline unsigned int AT91F_CAN_GetModeReg (
|
3048 |
|
|
AT91PS_CAN pCAN // pointer to a CAN controller
|
3049 |
|
|
)
|
3050 |
|
|
{
|
3051 |
|
|
return pCAN->CAN_MR;
|
3052 |
|
|
}
|
3053 |
|
|
|
3054 |
|
|
//*----------------------------------------------------------------------------
|
3055 |
|
|
//* \fn AT91F_CAN_CfgBaudrateReg
|
3056 |
|
|
//* \brief Configure the Baudrate of the CAN controller for the network
|
3057 |
|
|
//*----------------------------------------------------------------------------
|
3058 |
|
|
__inline void AT91F_CAN_CfgBaudrateReg (
|
3059 |
|
|
AT91PS_CAN pCAN, // pointer to a CAN controller
|
3060 |
|
|
unsigned int baudrate_cfg)
|
3061 |
|
|
{
|
3062 |
|
|
//* Write to the BR register
|
3063 |
|
|
pCAN->CAN_BR = baudrate_cfg;
|
3064 |
|
|
}
|
3065 |
|
|
|
3066 |
|
|
//*----------------------------------------------------------------------------
|
3067 |
|
|
//* \fn AT91F_CAN_GetBaudrate
|
3068 |
|
|
//* \brief Return the Baudrate of the CAN controller for the network value
|
3069 |
|
|
//*----------------------------------------------------------------------------
|
3070 |
|
|
__inline unsigned int AT91F_CAN_GetBaudrate (
|
3071 |
|
|
AT91PS_CAN pCAN // pointer to a CAN controller
|
3072 |
|
|
)
|
3073 |
|
|
{
|
3074 |
|
|
return pCAN->CAN_BR;
|
3075 |
|
|
}
|
3076 |
|
|
|
3077 |
|
|
//*----------------------------------------------------------------------------
|
3078 |
|
|
//* \fn AT91F_CAN_GetInternalCounter
|
3079 |
|
|
//* \brief Return CAN Timer Regsiter Value
|
3080 |
|
|
//*----------------------------------------------------------------------------
|
3081 |
|
|
__inline unsigned int AT91F_CAN_GetInternalCounter (
|
3082 |
|
|
AT91PS_CAN pCAN // pointer to a CAN controller
|
3083 |
|
|
)
|
3084 |
|
|
{
|
3085 |
|
|
return pCAN->CAN_TIM;
|
3086 |
|
|
}
|
3087 |
|
|
|
3088 |
|
|
//*----------------------------------------------------------------------------
|
3089 |
|
|
//* \fn AT91F_CAN_GetTimestamp
|
3090 |
|
|
//* \brief Return CAN Timestamp Register Value
|
3091 |
|
|
//*----------------------------------------------------------------------------
|
3092 |
|
|
__inline unsigned int AT91F_CAN_GetTimestamp (
|
3093 |
|
|
AT91PS_CAN pCAN // pointer to a CAN controller
|
3094 |
|
|
)
|
3095 |
|
|
{
|
3096 |
|
|
return pCAN->CAN_TIMESTP;
|
3097 |
|
|
}
|
3098 |
|
|
|
3099 |
|
|
//*----------------------------------------------------------------------------
|
3100 |
|
|
//* \fn AT91F_CAN_GetErrorCounter
|
3101 |
|
|
//* \brief Return CAN Error Counter Register Value
|
3102 |
|
|
//*----------------------------------------------------------------------------
|
3103 |
|
|
__inline unsigned int AT91F_CAN_GetErrorCounter (
|
3104 |
|
|
AT91PS_CAN pCAN // pointer to a CAN controller
|
3105 |
|
|
)
|
3106 |
|
|
{
|
3107 |
|
|
return pCAN->CAN_ECR;
|
3108 |
|
|
}
|
3109 |
|
|
|
3110 |
|
|
//*----------------------------------------------------------------------------
|
3111 |
|
|
//* \fn AT91F_CAN_InitTransferRequest
|
3112 |
|
|
//* \brief Request for a transfer on the corresponding mailboxes
|
3113 |
|
|
//*----------------------------------------------------------------------------
|
3114 |
|
|
__inline void AT91F_CAN_InitTransferRequest (
|
3115 |
|
|
AT91PS_CAN pCAN, // pointer to a CAN controller
|
3116 |
|
|
unsigned int transfer_cmd)
|
3117 |
|
|
{
|
3118 |
|
|
pCAN->CAN_TCR = transfer_cmd;
|
3119 |
|
|
}
|
3120 |
|
|
|
3121 |
|
|
//*----------------------------------------------------------------------------
|
3122 |
|
|
//* \fn AT91F_CAN_InitAbortRequest
|
3123 |
|
|
//* \brief Abort the corresponding mailboxes
|
3124 |
|
|
//*----------------------------------------------------------------------------
|
3125 |
|
|
__inline void AT91F_CAN_InitAbortRequest (
|
3126 |
|
|
AT91PS_CAN pCAN, // pointer to a CAN controller
|
3127 |
|
|
unsigned int abort_cmd)
|
3128 |
|
|
{
|
3129 |
|
|
pCAN->CAN_ACR = abort_cmd;
|
3130 |
|
|
}
|
3131 |
|
|
|
3132 |
|
|
//*----------------------------------------------------------------------------
|
3133 |
|
|
//* \fn AT91F_CAN_CfgMessageModeReg
|
3134 |
|
|
//* \brief Program the Message Mode Register
|
3135 |
|
|
//*----------------------------------------------------------------------------
|
3136 |
|
|
__inline void AT91F_CAN_CfgMessageModeReg (
|
3137 |
|
|
AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
|
3138 |
|
|
unsigned int mode)
|
3139 |
|
|
{
|
3140 |
|
|
CAN_Mailbox->CAN_MB_MMR = mode;
|
3141 |
|
|
}
|
3142 |
|
|
|
3143 |
|
|
//*----------------------------------------------------------------------------
|
3144 |
|
|
//* \fn AT91F_CAN_GetMessageModeReg
|
3145 |
|
|
//* \brief Return the Message Mode Register
|
3146 |
|
|
//*----------------------------------------------------------------------------
|
3147 |
|
|
__inline unsigned int AT91F_CAN_GetMessageModeReg (
|
3148 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3149 |
|
|
{
|
3150 |
|
|
return CAN_Mailbox->CAN_MB_MMR;
|
3151 |
|
|
}
|
3152 |
|
|
|
3153 |
|
|
//*----------------------------------------------------------------------------
|
3154 |
|
|
//* \fn AT91F_CAN_CfgMessageIDReg
|
3155 |
|
|
//* \brief Program the Message ID Register
|
3156 |
|
|
//* \brief Version == 0 for Standard messsage, Version == 1 for Extended
|
3157 |
|
|
//*----------------------------------------------------------------------------
|
3158 |
|
|
__inline void AT91F_CAN_CfgMessageIDReg (
|
3159 |
|
|
AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
|
3160 |
|
|
unsigned int id,
|
3161 |
|
|
unsigned char version)
|
3162 |
|
|
{
|
3163 |
|
|
if(version==0) // IDvA Standard Format
|
3164 |
|
|
CAN_Mailbox->CAN_MB_MID = id<<18;
|
3165 |
|
|
else // IDvB Extended Format
|
3166 |
|
|
CAN_Mailbox->CAN_MB_MID = id | (1<<29); // set MIDE bit
|
3167 |
|
|
}
|
3168 |
|
|
|
3169 |
|
|
//*----------------------------------------------------------------------------
|
3170 |
|
|
//* \fn AT91F_CAN_GetMessageIDReg
|
3171 |
|
|
//* \brief Return the Message ID Register
|
3172 |
|
|
//*----------------------------------------------------------------------------
|
3173 |
|
|
__inline unsigned int AT91F_CAN_GetMessageIDReg (
|
3174 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3175 |
|
|
{
|
3176 |
|
|
return CAN_Mailbox->CAN_MB_MID;
|
3177 |
|
|
}
|
3178 |
|
|
|
3179 |
|
|
//*----------------------------------------------------------------------------
|
3180 |
|
|
//* \fn AT91F_CAN_CfgMessageAcceptanceMaskReg
|
3181 |
|
|
//* \brief Program the Message Acceptance Mask Register
|
3182 |
|
|
//*----------------------------------------------------------------------------
|
3183 |
|
|
__inline void AT91F_CAN_CfgMessageAcceptanceMaskReg (
|
3184 |
|
|
AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
|
3185 |
|
|
unsigned int mask)
|
3186 |
|
|
{
|
3187 |
|
|
CAN_Mailbox->CAN_MB_MAM = mask;
|
3188 |
|
|
}
|
3189 |
|
|
|
3190 |
|
|
//*----------------------------------------------------------------------------
|
3191 |
|
|
//* \fn AT91F_CAN_GetMessageAcceptanceMaskReg
|
3192 |
|
|
//* \brief Return the Message Acceptance Mask Register
|
3193 |
|
|
//*----------------------------------------------------------------------------
|
3194 |
|
|
__inline unsigned int AT91F_CAN_GetMessageAcceptanceMaskReg (
|
3195 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3196 |
|
|
{
|
3197 |
|
|
return CAN_Mailbox->CAN_MB_MAM;
|
3198 |
|
|
}
|
3199 |
|
|
|
3200 |
|
|
//*----------------------------------------------------------------------------
|
3201 |
|
|
//* \fn AT91F_CAN_GetFamilyID
|
3202 |
|
|
//* \brief Return the Message ID Register
|
3203 |
|
|
//*----------------------------------------------------------------------------
|
3204 |
|
|
__inline unsigned int AT91F_CAN_GetFamilyID (
|
3205 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3206 |
|
|
{
|
3207 |
|
|
return CAN_Mailbox->CAN_MB_MFID;
|
3208 |
|
|
}
|
3209 |
|
|
|
3210 |
|
|
//*----------------------------------------------------------------------------
|
3211 |
|
|
//* \fn AT91F_CAN_CfgMessageCtrl
|
3212 |
|
|
//* \brief Request and config for a transfer on the corresponding mailbox
|
3213 |
|
|
//*----------------------------------------------------------------------------
|
3214 |
|
|
__inline void AT91F_CAN_CfgMessageCtrlReg (
|
3215 |
|
|
AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
|
3216 |
|
|
unsigned int message_ctrl_cmd)
|
3217 |
|
|
{
|
3218 |
|
|
CAN_Mailbox->CAN_MB_MCR = message_ctrl_cmd;
|
3219 |
|
|
}
|
3220 |
|
|
|
3221 |
|
|
//*----------------------------------------------------------------------------
|
3222 |
|
|
//* \fn AT91F_CAN_GetMessageStatus
|
3223 |
|
|
//* \brief Return CAN Mailbox Status
|
3224 |
|
|
//*----------------------------------------------------------------------------
|
3225 |
|
|
__inline unsigned int AT91F_CAN_GetMessageStatus (
|
3226 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3227 |
|
|
{
|
3228 |
|
|
return CAN_Mailbox->CAN_MB_MSR;
|
3229 |
|
|
}
|
3230 |
|
|
|
3231 |
|
|
//*----------------------------------------------------------------------------
|
3232 |
|
|
//* \fn AT91F_CAN_CfgMessageDataLow
|
3233 |
|
|
//* \brief Program data low value
|
3234 |
|
|
//*----------------------------------------------------------------------------
|
3235 |
|
|
__inline void AT91F_CAN_CfgMessageDataLow (
|
3236 |
|
|
AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
|
3237 |
|
|
unsigned int data)
|
3238 |
|
|
{
|
3239 |
|
|
CAN_Mailbox->CAN_MB_MDL = data;
|
3240 |
|
|
}
|
3241 |
|
|
|
3242 |
|
|
//*----------------------------------------------------------------------------
|
3243 |
|
|
//* \fn AT91F_CAN_GetMessageDataLow
|
3244 |
|
|
//* \brief Return data low value
|
3245 |
|
|
//*----------------------------------------------------------------------------
|
3246 |
|
|
__inline unsigned int AT91F_CAN_GetMessageDataLow (
|
3247 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3248 |
|
|
{
|
3249 |
|
|
return CAN_Mailbox->CAN_MB_MDL;
|
3250 |
|
|
}
|
3251 |
|
|
|
3252 |
|
|
//*----------------------------------------------------------------------------
|
3253 |
|
|
//* \fn AT91F_CAN_CfgMessageDataHigh
|
3254 |
|
|
//* \brief Program data high value
|
3255 |
|
|
//*----------------------------------------------------------------------------
|
3256 |
|
|
__inline void AT91F_CAN_CfgMessageDataHigh (
|
3257 |
|
|
AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
|
3258 |
|
|
unsigned int data)
|
3259 |
|
|
{
|
3260 |
|
|
CAN_Mailbox->CAN_MB_MDH = data;
|
3261 |
|
|
}
|
3262 |
|
|
|
3263 |
|
|
//*----------------------------------------------------------------------------
|
3264 |
|
|
//* \fn AT91F_CAN_GetMessageDataHigh
|
3265 |
|
|
//* \brief Return data high value
|
3266 |
|
|
//*----------------------------------------------------------------------------
|
3267 |
|
|
__inline unsigned int AT91F_CAN_GetMessageDataHigh (
|
3268 |
|
|
AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
|
3269 |
|
|
{
|
3270 |
|
|
return CAN_Mailbox->CAN_MB_MDH;
|
3271 |
|
|
}
|
3272 |
|
|
|
3273 |
|
|
//*----------------------------------------------------------------------------
|
3274 |
|
|
//* \fn AT91F_CAN_Open
|
3275 |
|
|
//* \brief Open a CAN Port
|
3276 |
|
|
//*----------------------------------------------------------------------------
|
3277 |
|
|
__inline unsigned int AT91F_CAN_Open (
|
3278 |
|
|
const unsigned int null) // \arg
|
3279 |
|
|
{
|
3280 |
|
|
/* NOT DEFINED AT THIS MOMENT */
|
3281 |
|
|
return ( 0 );
|
3282 |
|
|
}
|
3283 |
|
|
/* *****************************************************************************
|
3284 |
|
|
SOFTWARE API FOR ADC
|
3285 |
|
|
***************************************************************************** */
|
3286 |
|
|
//*----------------------------------------------------------------------------
|
3287 |
|
|
//* \fn AT91F_ADC_EnableIt
|
3288 |
|
|
//* \brief Enable ADC interrupt
|
3289 |
|
|
//*----------------------------------------------------------------------------
|
3290 |
|
|
__inline void AT91F_ADC_EnableIt (
|
3291 |
|
|
AT91PS_ADC pADC, // pointer to a ADC controller
|
3292 |
|
|
unsigned int flag) // IT to be enabled
|
3293 |
|
|
{
|
3294 |
|
|
//* Write to the IER register
|
3295 |
|
|
pADC->ADC_IER = flag;
|
3296 |
|
|
}
|
3297 |
|
|
|
3298 |
|
|
//*----------------------------------------------------------------------------
|
3299 |
|
|
//* \fn AT91F_ADC_DisableIt
|
3300 |
|
|
//* \brief Disable ADC interrupt
|
3301 |
|
|
//*----------------------------------------------------------------------------
|
3302 |
|
|
__inline void AT91F_ADC_DisableIt (
|
3303 |
|
|
AT91PS_ADC pADC, // pointer to a ADC controller
|
3304 |
|
|
unsigned int flag) // IT to be disabled
|
3305 |
|
|
{
|
3306 |
|
|
//* Write to the IDR register
|
3307 |
|
|
pADC->ADC_IDR = flag;
|
3308 |
|
|
}
|
3309 |
|
|
|
3310 |
|
|
//*----------------------------------------------------------------------------
|
3311 |
|
|
//* \fn AT91F_ADC_GetStatus
|
3312 |
|
|
//* \brief Return ADC Interrupt Status
|
3313 |
|
|
//*----------------------------------------------------------------------------
|
3314 |
|
|
__inline unsigned int AT91F_ADC_GetStatus( // \return ADC Interrupt Status
|
3315 |
|
|
AT91PS_ADC pADC) // pointer to a ADC controller
|
3316 |
|
|
{
|
3317 |
|
|
return pADC->ADC_SR;
|
3318 |
|
|
}
|
3319 |
|
|
|
3320 |
|
|
//*----------------------------------------------------------------------------
|
3321 |
|
|
//* \fn AT91F_ADC_GetInterruptMaskStatus
|
3322 |
|
|
//* \brief Return ADC Interrupt Mask Status
|
3323 |
|
|
//*----------------------------------------------------------------------------
|
3324 |
|
|
__inline unsigned int AT91F_ADC_GetInterruptMaskStatus( // \return ADC Interrupt Mask Status
|
3325 |
|
|
AT91PS_ADC pADC) // pointer to a ADC controller
|
3326 |
|
|
{
|
3327 |
|
|
return pADC->ADC_IMR;
|
3328 |
|
|
}
|
3329 |
|
|
|
3330 |
|
|
//*----------------------------------------------------------------------------
|
3331 |
|
|
//* \fn AT91F_ADC_IsInterruptMasked
|
3332 |
|
|
//* \brief Test if ADC Interrupt is Masked
|
3333 |
|
|
//*----------------------------------------------------------------------------
|
3334 |
|
|
__inline unsigned int AT91F_ADC_IsInterruptMasked(
|
3335 |
|
|
AT91PS_ADC pADC, // \arg pointer to a ADC controller
|
3336 |
|
|
unsigned int flag) // \arg flag to be tested
|
3337 |
|
|
{
|
3338 |
|
|
return (AT91F_ADC_GetInterruptMaskStatus(pADC) & flag);
|
3339 |
|
|
}
|
3340 |
|
|
|
3341 |
|
|
//*----------------------------------------------------------------------------
|
3342 |
|
|
//* \fn AT91F_ADC_IsStatusSet
|
3343 |
|
|
//* \brief Test if ADC Status is Set
|
3344 |
|
|
//*----------------------------------------------------------------------------
|
3345 |
|
|
__inline unsigned int AT91F_ADC_IsStatusSet(
|
3346 |
|
|
AT91PS_ADC pADC, // \arg pointer to a ADC controller
|
3347 |
|
|
unsigned int flag) // \arg flag to be tested
|
3348 |
|
|
{
|
3349 |
|
|
return (AT91F_ADC_GetStatus(pADC) & flag);
|
3350 |
|
|
}
|
3351 |
|
|
|
3352 |
|
|
//*----------------------------------------------------------------------------
|
3353 |
|
|
//* \fn AT91F_ADC_CfgModeReg
|
3354 |
|
|
//* \brief Configure the Mode Register of the ADC controller
|
3355 |
|
|
//*----------------------------------------------------------------------------
|
3356 |
|
|
__inline void AT91F_ADC_CfgModeReg (
|
3357 |
|
|
AT91PS_ADC pADC, // pointer to a ADC controller
|
3358 |
|
|
unsigned int mode) // mode register
|
3359 |
|
|
{
|
3360 |
|
|
//* Write to the MR register
|
3361 |
|
|
pADC->ADC_MR = mode;
|
3362 |
|
|
}
|
3363 |
|
|
|
3364 |
|
|
//*----------------------------------------------------------------------------
|
3365 |
|
|
//* \fn AT91F_ADC_GetModeReg
|
3366 |
|
|
//* \brief Return the Mode Register of the ADC controller value
|
3367 |
|
|
//*----------------------------------------------------------------------------
|
3368 |
|
|
__inline unsigned int AT91F_ADC_GetModeReg (
|
3369 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3370 |
|
|
)
|
3371 |
|
|
{
|
3372 |
|
|
return pADC->ADC_MR;
|
3373 |
|
|
}
|
3374 |
|
|
|
3375 |
|
|
//*----------------------------------------------------------------------------
|
3376 |
|
|
//* \fn AT91F_ADC_CfgTimings
|
3377 |
|
|
//* \brief Configure the different necessary timings of the ADC controller
|
3378 |
|
|
//*----------------------------------------------------------------------------
|
3379 |
|
|
__inline void AT91F_ADC_CfgTimings (
|
3380 |
|
|
AT91PS_ADC pADC, // pointer to a ADC controller
|
3381 |
|
|
unsigned int mck_clock, // in MHz
|
3382 |
|
|
unsigned int adc_clock, // in MHz
|
3383 |
|
|
unsigned int startup_time, // in us
|
3384 |
|
|
unsigned int sample_and_hold_time) // in ns
|
3385 |
|
|
{
|
3386 |
|
|
unsigned int prescal,startup,shtim;
|
3387 |
|
|
|
3388 |
|
|
prescal = mck_clock/(2*adc_clock) - 1;
|
3389 |
|
|
startup = adc_clock*startup_time/8 - 1;
|
3390 |
|
|
shtim = adc_clock*sample_and_hold_time/1000 - 1;
|
3391 |
|
|
|
3392 |
|
|
//* Write to the MR register
|
3393 |
|
|
pADC->ADC_MR = ( (prescal<<8) & AT91C_ADC_PRESCAL) | ( (startup<<16) & AT91C_ADC_STARTUP) | ( (shtim<<24) & AT91C_ADC_SHTIM);
|
3394 |
|
|
}
|
3395 |
|
|
|
3396 |
|
|
//*----------------------------------------------------------------------------
|
3397 |
|
|
//* \fn AT91F_ADC_EnableChannel
|
3398 |
|
|
//* \brief Return ADC Timer Register Value
|
3399 |
|
|
//*----------------------------------------------------------------------------
|
3400 |
|
|
__inline void AT91F_ADC_EnableChannel (
|
3401 |
|
|
AT91PS_ADC pADC, // pointer to a ADC controller
|
3402 |
|
|
unsigned int channel) // mode register
|
3403 |
|
|
{
|
3404 |
|
|
//* Write to the CHER register
|
3405 |
|
|
pADC->ADC_CHER = channel;
|
3406 |
|
|
}
|
3407 |
|
|
|
3408 |
|
|
//*----------------------------------------------------------------------------
|
3409 |
|
|
//* \fn AT91F_ADC_DisableChannel
|
3410 |
|
|
//* \brief Return ADC Timer Register Value
|
3411 |
|
|
//*----------------------------------------------------------------------------
|
3412 |
|
|
__inline void AT91F_ADC_DisableChannel (
|
3413 |
|
|
AT91PS_ADC pADC, // pointer to a ADC controller
|
3414 |
|
|
unsigned int channel) // mode register
|
3415 |
|
|
{
|
3416 |
|
|
//* Write to the CHDR register
|
3417 |
|
|
pADC->ADC_CHDR = channel;
|
3418 |
|
|
}
|
3419 |
|
|
|
3420 |
|
|
//*----------------------------------------------------------------------------
|
3421 |
|
|
//* \fn AT91F_ADC_GetChannelStatus
|
3422 |
|
|
//* \brief Return ADC Timer Register Value
|
3423 |
|
|
//*----------------------------------------------------------------------------
|
3424 |
|
|
__inline unsigned int AT91F_ADC_GetChannelStatus (
|
3425 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3426 |
|
|
)
|
3427 |
|
|
{
|
3428 |
|
|
return pADC->ADC_CHSR;
|
3429 |
|
|
}
|
3430 |
|
|
|
3431 |
|
|
//*----------------------------------------------------------------------------
|
3432 |
|
|
//* \fn AT91F_ADC_StartConversion
|
3433 |
|
|
//* \brief Software request for a analog to digital conversion
|
3434 |
|
|
//*----------------------------------------------------------------------------
|
3435 |
|
|
__inline void AT91F_ADC_StartConversion (
|
3436 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3437 |
|
|
)
|
3438 |
|
|
{
|
3439 |
|
|
pADC->ADC_CR = AT91C_ADC_START;
|
3440 |
|
|
}
|
3441 |
|
|
|
3442 |
|
|
//*----------------------------------------------------------------------------
|
3443 |
|
|
//* \fn AT91F_ADC_SoftReset
|
3444 |
|
|
//* \brief Software reset
|
3445 |
|
|
//*----------------------------------------------------------------------------
|
3446 |
|
|
__inline void AT91F_ADC_SoftReset (
|
3447 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3448 |
|
|
)
|
3449 |
|
|
{
|
3450 |
|
|
pADC->ADC_CR = AT91C_ADC_SWRST;
|
3451 |
|
|
}
|
3452 |
|
|
|
3453 |
|
|
//*----------------------------------------------------------------------------
|
3454 |
|
|
//* \fn AT91F_ADC_GetLastConvertedData
|
3455 |
|
|
//* \brief Return the Last Converted Data
|
3456 |
|
|
//*----------------------------------------------------------------------------
|
3457 |
|
|
__inline unsigned int AT91F_ADC_GetLastConvertedData (
|
3458 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3459 |
|
|
)
|
3460 |
|
|
{
|
3461 |
|
|
return pADC->ADC_LCDR;
|
3462 |
|
|
}
|
3463 |
|
|
|
3464 |
|
|
//*----------------------------------------------------------------------------
|
3465 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH0
|
3466 |
|
|
//* \brief Return the Channel 0 Converted Data
|
3467 |
|
|
//*----------------------------------------------------------------------------
|
3468 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH0 (
|
3469 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3470 |
|
|
)
|
3471 |
|
|
{
|
3472 |
|
|
return pADC->ADC_CDR0;
|
3473 |
|
|
}
|
3474 |
|
|
|
3475 |
|
|
//*----------------------------------------------------------------------------
|
3476 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH1
|
3477 |
|
|
//* \brief Return the Channel 1 Converted Data
|
3478 |
|
|
//*----------------------------------------------------------------------------
|
3479 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH1 (
|
3480 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3481 |
|
|
)
|
3482 |
|
|
{
|
3483 |
|
|
return pADC->ADC_CDR1;
|
3484 |
|
|
}
|
3485 |
|
|
|
3486 |
|
|
//*----------------------------------------------------------------------------
|
3487 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH2
|
3488 |
|
|
//* \brief Return the Channel 2 Converted Data
|
3489 |
|
|
//*----------------------------------------------------------------------------
|
3490 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH2 (
|
3491 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3492 |
|
|
)
|
3493 |
|
|
{
|
3494 |
|
|
return pADC->ADC_CDR2;
|
3495 |
|
|
}
|
3496 |
|
|
|
3497 |
|
|
//*----------------------------------------------------------------------------
|
3498 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH3
|
3499 |
|
|
//* \brief Return the Channel 3 Converted Data
|
3500 |
|
|
//*----------------------------------------------------------------------------
|
3501 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH3 (
|
3502 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3503 |
|
|
)
|
3504 |
|
|
{
|
3505 |
|
|
return pADC->ADC_CDR3;
|
3506 |
|
|
}
|
3507 |
|
|
|
3508 |
|
|
//*----------------------------------------------------------------------------
|
3509 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH4
|
3510 |
|
|
//* \brief Return the Channel 4 Converted Data
|
3511 |
|
|
//*----------------------------------------------------------------------------
|
3512 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH4 (
|
3513 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3514 |
|
|
)
|
3515 |
|
|
{
|
3516 |
|
|
return pADC->ADC_CDR4;
|
3517 |
|
|
}
|
3518 |
|
|
|
3519 |
|
|
//*----------------------------------------------------------------------------
|
3520 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH5
|
3521 |
|
|
//* \brief Return the Channel 5 Converted Data
|
3522 |
|
|
//*----------------------------------------------------------------------------
|
3523 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH5 (
|
3524 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3525 |
|
|
)
|
3526 |
|
|
{
|
3527 |
|
|
return pADC->ADC_CDR5;
|
3528 |
|
|
}
|
3529 |
|
|
|
3530 |
|
|
//*----------------------------------------------------------------------------
|
3531 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH6
|
3532 |
|
|
//* \brief Return the Channel 6 Converted Data
|
3533 |
|
|
//*----------------------------------------------------------------------------
|
3534 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH6 (
|
3535 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3536 |
|
|
)
|
3537 |
|
|
{
|
3538 |
|
|
return pADC->ADC_CDR6;
|
3539 |
|
|
}
|
3540 |
|
|
|
3541 |
|
|
//*----------------------------------------------------------------------------
|
3542 |
|
|
//* \fn AT91F_ADC_GetConvertedDataCH7
|
3543 |
|
|
//* \brief Return the Channel 7 Converted Data
|
3544 |
|
|
//*----------------------------------------------------------------------------
|
3545 |
|
|
__inline unsigned int AT91F_ADC_GetConvertedDataCH7 (
|
3546 |
|
|
AT91PS_ADC pADC // pointer to a ADC controller
|
3547 |
|
|
)
|
3548 |
|
|
{
|
3549 |
|
|
return pADC->ADC_CDR7;
|
3550 |
|
|
}
|
3551 |
|
|
|
3552 |
|
|
/* *****************************************************************************
|
3553 |
|
|
SOFTWARE API FOR AES
|
3554 |
|
|
***************************************************************************** */
|
3555 |
|
|
//*----------------------------------------------------------------------------
|
3556 |
|
|
//* \fn AT91F_AES_EnableIt
|
3557 |
|
|
//* \brief Enable AES interrupt
|
3558 |
|
|
//*----------------------------------------------------------------------------
|
3559 |
|
|
__inline void AT91F_AES_EnableIt (
|
3560 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3561 |
|
|
unsigned int flag) // IT to be enabled
|
3562 |
|
|
{
|
3563 |
|
|
//* Write to the IER register
|
3564 |
|
|
pAES->AES_IER = flag;
|
3565 |
|
|
}
|
3566 |
|
|
|
3567 |
|
|
//*----------------------------------------------------------------------------
|
3568 |
|
|
//* \fn AT91F_AES_DisableIt
|
3569 |
|
|
//* \brief Disable AES interrupt
|
3570 |
|
|
//*----------------------------------------------------------------------------
|
3571 |
|
|
__inline void AT91F_AES_DisableIt (
|
3572 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3573 |
|
|
unsigned int flag) // IT to be disabled
|
3574 |
|
|
{
|
3575 |
|
|
//* Write to the IDR register
|
3576 |
|
|
pAES->AES_IDR = flag;
|
3577 |
|
|
}
|
3578 |
|
|
|
3579 |
|
|
//*----------------------------------------------------------------------------
|
3580 |
|
|
//* \fn AT91F_AES_GetStatus
|
3581 |
|
|
//* \brief Return AES Interrupt Status
|
3582 |
|
|
//*----------------------------------------------------------------------------
|
3583 |
|
|
__inline unsigned int AT91F_AES_GetStatus( // \return AES Interrupt Status
|
3584 |
|
|
AT91PS_AES pAES) // pointer to a AES controller
|
3585 |
|
|
{
|
3586 |
|
|
return pAES->AES_ISR;
|
3587 |
|
|
}
|
3588 |
|
|
|
3589 |
|
|
//*----------------------------------------------------------------------------
|
3590 |
|
|
//* \fn AT91F_AES_GetInterruptMaskStatus
|
3591 |
|
|
//* \brief Return AES Interrupt Mask Status
|
3592 |
|
|
//*----------------------------------------------------------------------------
|
3593 |
|
|
__inline unsigned int AT91F_AES_GetInterruptMaskStatus( // \return AES Interrupt Mask Status
|
3594 |
|
|
AT91PS_AES pAES) // pointer to a AES controller
|
3595 |
|
|
{
|
3596 |
|
|
return pAES->AES_IMR;
|
3597 |
|
|
}
|
3598 |
|
|
|
3599 |
|
|
//*----------------------------------------------------------------------------
|
3600 |
|
|
//* \fn AT91F_AES_IsInterruptMasked
|
3601 |
|
|
//* \brief Test if AES Interrupt is Masked
|
3602 |
|
|
//*----------------------------------------------------------------------------
|
3603 |
|
|
__inline unsigned int AT91F_AES_IsInterruptMasked(
|
3604 |
|
|
AT91PS_AES pAES, // \arg pointer to a AES controller
|
3605 |
|
|
unsigned int flag) // \arg flag to be tested
|
3606 |
|
|
{
|
3607 |
|
|
return (AT91F_AES_GetInterruptMaskStatus(pAES) & flag);
|
3608 |
|
|
}
|
3609 |
|
|
|
3610 |
|
|
//*----------------------------------------------------------------------------
|
3611 |
|
|
//* \fn AT91F_AES_IsStatusSet
|
3612 |
|
|
//* \brief Test if AES Status is Set
|
3613 |
|
|
//*----------------------------------------------------------------------------
|
3614 |
|
|
__inline unsigned int AT91F_AES_IsStatusSet(
|
3615 |
|
|
AT91PS_AES pAES, // \arg pointer to a AES controller
|
3616 |
|
|
unsigned int flag) // \arg flag to be tested
|
3617 |
|
|
{
|
3618 |
|
|
return (AT91F_AES_GetStatus(pAES) & flag);
|
3619 |
|
|
}
|
3620 |
|
|
|
3621 |
|
|
//*----------------------------------------------------------------------------
|
3622 |
|
|
//* \fn AT91F_AES_CfgModeReg
|
3623 |
|
|
//* \brief Configure the Mode Register of the AES controller
|
3624 |
|
|
//*----------------------------------------------------------------------------
|
3625 |
|
|
__inline void AT91F_AES_CfgModeReg (
|
3626 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3627 |
|
|
unsigned int mode) // mode register
|
3628 |
|
|
{
|
3629 |
|
|
//* Write to the MR register
|
3630 |
|
|
pAES->AES_MR = mode;
|
3631 |
|
|
}
|
3632 |
|
|
|
3633 |
|
|
//*----------------------------------------------------------------------------
|
3634 |
|
|
//* \fn AT91F_AES_GetModeReg
|
3635 |
|
|
//* \brief Return the Mode Register of the AES controller value
|
3636 |
|
|
//*----------------------------------------------------------------------------
|
3637 |
|
|
__inline unsigned int AT91F_AES_GetModeReg (
|
3638 |
|
|
AT91PS_AES pAES // pointer to a AES controller
|
3639 |
|
|
)
|
3640 |
|
|
{
|
3641 |
|
|
return pAES->AES_MR;
|
3642 |
|
|
}
|
3643 |
|
|
|
3644 |
|
|
//*----------------------------------------------------------------------------
|
3645 |
|
|
//* \fn AT91F_AES_StartProcessing
|
3646 |
|
|
//* \brief Start Encryption or Decryption
|
3647 |
|
|
//*----------------------------------------------------------------------------
|
3648 |
|
|
__inline void AT91F_AES_StartProcessing (
|
3649 |
|
|
AT91PS_AES pAES // pointer to a AES controller
|
3650 |
|
|
)
|
3651 |
|
|
{
|
3652 |
|
|
pAES->AES_CR = AT91C_AES_START;
|
3653 |
|
|
}
|
3654 |
|
|
|
3655 |
|
|
//*----------------------------------------------------------------------------
|
3656 |
|
|
//* \fn AT91F_AES_SoftReset
|
3657 |
|
|
//* \brief Reset AES
|
3658 |
|
|
//*----------------------------------------------------------------------------
|
3659 |
|
|
__inline void AT91F_AES_SoftReset (
|
3660 |
|
|
AT91PS_AES pAES // pointer to a AES controller
|
3661 |
|
|
)
|
3662 |
|
|
{
|
3663 |
|
|
pAES->AES_CR = AT91C_AES_SWRST;
|
3664 |
|
|
}
|
3665 |
|
|
|
3666 |
|
|
//*----------------------------------------------------------------------------
|
3667 |
|
|
//* \fn AT91F_AES_LoadNewSeed
|
3668 |
|
|
//* \brief Load New Seed in the random number generator
|
3669 |
|
|
//*----------------------------------------------------------------------------
|
3670 |
|
|
__inline void AT91F_AES_LoadNewSeed (
|
3671 |
|
|
AT91PS_AES pAES // pointer to a AES controller
|
3672 |
|
|
)
|
3673 |
|
|
{
|
3674 |
|
|
pAES->AES_CR = AT91C_AES_LOADSEED;
|
3675 |
|
|
}
|
3676 |
|
|
|
3677 |
|
|
//*----------------------------------------------------------------------------
|
3678 |
|
|
//* \fn AT91F_AES_SetCryptoKey
|
3679 |
|
|
//* \brief Set Cryptographic Key x
|
3680 |
|
|
//*----------------------------------------------------------------------------
|
3681 |
|
|
__inline void AT91F_AES_SetCryptoKey (
|
3682 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3683 |
|
|
unsigned char index,
|
3684 |
|
|
unsigned int keyword
|
3685 |
|
|
)
|
3686 |
|
|
{
|
3687 |
|
|
pAES->AES_KEYWxR[index] = keyword;
|
3688 |
|
|
}
|
3689 |
|
|
|
3690 |
|
|
//*----------------------------------------------------------------------------
|
3691 |
|
|
//* \fn AT91F_AES_InputData
|
3692 |
|
|
//* \brief Set Input Data x
|
3693 |
|
|
//*----------------------------------------------------------------------------
|
3694 |
|
|
__inline void AT91F_AES_InputData (
|
3695 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3696 |
|
|
unsigned char index,
|
3697 |
|
|
unsigned int indata
|
3698 |
|
|
)
|
3699 |
|
|
{
|
3700 |
|
|
pAES->AES_IDATAxR[index] = indata;
|
3701 |
|
|
}
|
3702 |
|
|
|
3703 |
|
|
//*----------------------------------------------------------------------------
|
3704 |
|
|
//* \fn AT91F_AES_GetOutputData
|
3705 |
|
|
//* \brief Get Output Data x
|
3706 |
|
|
//*----------------------------------------------------------------------------
|
3707 |
|
|
__inline unsigned int AT91F_AES_GetOutputData (
|
3708 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3709 |
|
|
unsigned char index
|
3710 |
|
|
)
|
3711 |
|
|
{
|
3712 |
|
|
return pAES->AES_ODATAxR[index];
|
3713 |
|
|
}
|
3714 |
|
|
|
3715 |
|
|
//*----------------------------------------------------------------------------
|
3716 |
|
|
//* \fn AT91F_AES_SetInitializationVector
|
3717 |
|
|
//* \brief Set Initialization Vector (or Counter) x
|
3718 |
|
|
//*----------------------------------------------------------------------------
|
3719 |
|
|
__inline void AT91F_AES_SetInitializationVector (
|
3720 |
|
|
AT91PS_AES pAES, // pointer to a AES controller
|
3721 |
|
|
unsigned char index,
|
3722 |
|
|
unsigned int initvector
|
3723 |
|
|
)
|
3724 |
|
|
{
|
3725 |
|
|
pAES->AES_IVxR[index] = initvector;
|
3726 |
|
|
}
|
3727 |
|
|
|
3728 |
|
|
/* *****************************************************************************
|
3729 |
|
|
SOFTWARE API FOR TDES
|
3730 |
|
|
***************************************************************************** */
|
3731 |
|
|
//*----------------------------------------------------------------------------
|
3732 |
|
|
//* \fn AT91F_TDES_EnableIt
|
3733 |
|
|
//* \brief Enable TDES interrupt
|
3734 |
|
|
//*----------------------------------------------------------------------------
|
3735 |
|
|
__inline void AT91F_TDES_EnableIt (
|
3736 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3737 |
|
|
unsigned int flag) // IT to be enabled
|
3738 |
|
|
{
|
3739 |
|
|
//* Write to the IER register
|
3740 |
|
|
pTDES->TDES_IER = flag;
|
3741 |
|
|
}
|
3742 |
|
|
|
3743 |
|
|
//*----------------------------------------------------------------------------
|
3744 |
|
|
//* \fn AT91F_TDES_DisableIt
|
3745 |
|
|
//* \brief Disable TDES interrupt
|
3746 |
|
|
//*----------------------------------------------------------------------------
|
3747 |
|
|
__inline void AT91F_TDES_DisableIt (
|
3748 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3749 |
|
|
unsigned int flag) // IT to be disabled
|
3750 |
|
|
{
|
3751 |
|
|
//* Write to the IDR register
|
3752 |
|
|
pTDES->TDES_IDR = flag;
|
3753 |
|
|
}
|
3754 |
|
|
|
3755 |
|
|
//*----------------------------------------------------------------------------
|
3756 |
|
|
//* \fn AT91F_TDES_GetStatus
|
3757 |
|
|
//* \brief Return TDES Interrupt Status
|
3758 |
|
|
//*----------------------------------------------------------------------------
|
3759 |
|
|
__inline unsigned int AT91F_TDES_GetStatus( // \return TDES Interrupt Status
|
3760 |
|
|
AT91PS_TDES pTDES) // pointer to a TDES controller
|
3761 |
|
|
{
|
3762 |
|
|
return pTDES->TDES_ISR;
|
3763 |
|
|
}
|
3764 |
|
|
|
3765 |
|
|
//*----------------------------------------------------------------------------
|
3766 |
|
|
//* \fn AT91F_TDES_GetInterruptMaskStatus
|
3767 |
|
|
//* \brief Return TDES Interrupt Mask Status
|
3768 |
|
|
//*----------------------------------------------------------------------------
|
3769 |
|
|
__inline unsigned int AT91F_TDES_GetInterruptMaskStatus( // \return TDES Interrupt Mask Status
|
3770 |
|
|
AT91PS_TDES pTDES) // pointer to a TDES controller
|
3771 |
|
|
{
|
3772 |
|
|
return pTDES->TDES_IMR;
|
3773 |
|
|
}
|
3774 |
|
|
|
3775 |
|
|
//*----------------------------------------------------------------------------
|
3776 |
|
|
//* \fn AT91F_TDES_IsInterruptMasked
|
3777 |
|
|
//* \brief Test if TDES Interrupt is Masked
|
3778 |
|
|
//*----------------------------------------------------------------------------
|
3779 |
|
|
__inline unsigned int AT91F_TDES_IsInterruptMasked(
|
3780 |
|
|
AT91PS_TDES pTDES, // \arg pointer to a TDES controller
|
3781 |
|
|
unsigned int flag) // \arg flag to be tested
|
3782 |
|
|
{
|
3783 |
|
|
return (AT91F_TDES_GetInterruptMaskStatus(pTDES) & flag);
|
3784 |
|
|
}
|
3785 |
|
|
|
3786 |
|
|
//*----------------------------------------------------------------------------
|
3787 |
|
|
//* \fn AT91F_TDES_IsStatusSet
|
3788 |
|
|
//* \brief Test if TDES Status is Set
|
3789 |
|
|
//*----------------------------------------------------------------------------
|
3790 |
|
|
__inline unsigned int AT91F_TDES_IsStatusSet(
|
3791 |
|
|
AT91PS_TDES pTDES, // \arg pointer to a TDES controller
|
3792 |
|
|
unsigned int flag) // \arg flag to be tested
|
3793 |
|
|
{
|
3794 |
|
|
return (AT91F_TDES_GetStatus(pTDES) & flag);
|
3795 |
|
|
}
|
3796 |
|
|
|
3797 |
|
|
//*----------------------------------------------------------------------------
|
3798 |
|
|
//* \fn AT91F_TDES_CfgModeReg
|
3799 |
|
|
//* \brief Configure the Mode Register of the TDES controller
|
3800 |
|
|
//*----------------------------------------------------------------------------
|
3801 |
|
|
__inline void AT91F_TDES_CfgModeReg (
|
3802 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3803 |
|
|
unsigned int mode) // mode register
|
3804 |
|
|
{
|
3805 |
|
|
//* Write to the MR register
|
3806 |
|
|
pTDES->TDES_MR = mode;
|
3807 |
|
|
}
|
3808 |
|
|
|
3809 |
|
|
//*----------------------------------------------------------------------------
|
3810 |
|
|
//* \fn AT91F_TDES_GetModeReg
|
3811 |
|
|
//* \brief Return the Mode Register of the TDES controller value
|
3812 |
|
|
//*----------------------------------------------------------------------------
|
3813 |
|
|
__inline unsigned int AT91F_TDES_GetModeReg (
|
3814 |
|
|
AT91PS_TDES pTDES // pointer to a TDES controller
|
3815 |
|
|
)
|
3816 |
|
|
{
|
3817 |
|
|
return pTDES->TDES_MR;
|
3818 |
|
|
}
|
3819 |
|
|
|
3820 |
|
|
//*----------------------------------------------------------------------------
|
3821 |
|
|
//* \fn AT91F_TDES_StartProcessing
|
3822 |
|
|
//* \brief Start Encryption or Decryption
|
3823 |
|
|
//*----------------------------------------------------------------------------
|
3824 |
|
|
__inline void AT91F_TDES_StartProcessing (
|
3825 |
|
|
AT91PS_TDES pTDES // pointer to a TDES controller
|
3826 |
|
|
)
|
3827 |
|
|
{
|
3828 |
|
|
pTDES->TDES_CR = AT91C_TDES_START;
|
3829 |
|
|
}
|
3830 |
|
|
|
3831 |
|
|
//*----------------------------------------------------------------------------
|
3832 |
|
|
//* \fn AT91F_TDES_SoftReset
|
3833 |
|
|
//* \brief Reset TDES
|
3834 |
|
|
//*----------------------------------------------------------------------------
|
3835 |
|
|
__inline void AT91F_TDES_SoftReset (
|
3836 |
|
|
AT91PS_TDES pTDES // pointer to a TDES controller
|
3837 |
|
|
)
|
3838 |
|
|
{
|
3839 |
|
|
pTDES->TDES_CR = AT91C_TDES_SWRST;
|
3840 |
|
|
}
|
3841 |
|
|
|
3842 |
|
|
//*----------------------------------------------------------------------------
|
3843 |
|
|
//* \fn AT91F_TDES_SetCryptoKey1
|
3844 |
|
|
//* \brief Set Cryptographic Key 1 Word x
|
3845 |
|
|
//*----------------------------------------------------------------------------
|
3846 |
|
|
__inline void AT91F_TDES_SetCryptoKey1 (
|
3847 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3848 |
|
|
unsigned char index,
|
3849 |
|
|
unsigned int keyword
|
3850 |
|
|
)
|
3851 |
|
|
{
|
3852 |
|
|
pTDES->TDES_KEY1WxR[index] = keyword;
|
3853 |
|
|
}
|
3854 |
|
|
|
3855 |
|
|
//*----------------------------------------------------------------------------
|
3856 |
|
|
//* \fn AT91F_TDES_SetCryptoKey2
|
3857 |
|
|
//* \brief Set Cryptographic Key 2 Word x
|
3858 |
|
|
//*----------------------------------------------------------------------------
|
3859 |
|
|
__inline void AT91F_TDES_SetCryptoKey2 (
|
3860 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3861 |
|
|
unsigned char index,
|
3862 |
|
|
unsigned int keyword
|
3863 |
|
|
)
|
3864 |
|
|
{
|
3865 |
|
|
pTDES->TDES_KEY2WxR[index] = keyword;
|
3866 |
|
|
}
|
3867 |
|
|
|
3868 |
|
|
//*----------------------------------------------------------------------------
|
3869 |
|
|
//* \fn AT91F_TDES_SetCryptoKey3
|
3870 |
|
|
//* \brief Set Cryptographic Key 3 Word x
|
3871 |
|
|
//*----------------------------------------------------------------------------
|
3872 |
|
|
__inline void AT91F_TDES_SetCryptoKey3 (
|
3873 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3874 |
|
|
unsigned char index,
|
3875 |
|
|
unsigned int keyword
|
3876 |
|
|
)
|
3877 |
|
|
{
|
3878 |
|
|
pTDES->TDES_KEY3WxR[index] = keyword;
|
3879 |
|
|
}
|
3880 |
|
|
|
3881 |
|
|
//*----------------------------------------------------------------------------
|
3882 |
|
|
//* \fn AT91F_TDES_InputData
|
3883 |
|
|
//* \brief Set Input Data x
|
3884 |
|
|
//*----------------------------------------------------------------------------
|
3885 |
|
|
__inline void AT91F_TDES_InputData (
|
3886 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3887 |
|
|
unsigned char index,
|
3888 |
|
|
unsigned int indata
|
3889 |
|
|
)
|
3890 |
|
|
{
|
3891 |
|
|
pTDES->TDES_IDATAxR[index] = indata;
|
3892 |
|
|
}
|
3893 |
|
|
|
3894 |
|
|
//*----------------------------------------------------------------------------
|
3895 |
|
|
//* \fn AT91F_TDES_GetOutputData
|
3896 |
|
|
//* \brief Get Output Data x
|
3897 |
|
|
//*----------------------------------------------------------------------------
|
3898 |
|
|
__inline unsigned int AT91F_TDES_GetOutputData (
|
3899 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3900 |
|
|
unsigned char index
|
3901 |
|
|
)
|
3902 |
|
|
{
|
3903 |
|
|
return pTDES->TDES_ODATAxR[index];
|
3904 |
|
|
}
|
3905 |
|
|
|
3906 |
|
|
//*----------------------------------------------------------------------------
|
3907 |
|
|
//* \fn AT91F_TDES_SetInitializationVector
|
3908 |
|
|
//* \brief Set Initialization Vector x
|
3909 |
|
|
//*----------------------------------------------------------------------------
|
3910 |
|
|
__inline void AT91F_TDES_SetInitializationVector (
|
3911 |
|
|
AT91PS_TDES pTDES, // pointer to a TDES controller
|
3912 |
|
|
unsigned char index,
|
3913 |
|
|
unsigned int initvector
|
3914 |
|
|
)
|
3915 |
|
|
{
|
3916 |
|
|
pTDES->TDES_IVxR[index] = initvector;
|
3917 |
|
|
}
|
3918 |
|
|
|
3919 |
|
|
//*----------------------------------------------------------------------------
|
3920 |
|
|
//* \fn AT91F_DBGU_CfgPMC
|
3921 |
|
|
//* \brief Enable Peripheral clock in PMC for DBGU
|
3922 |
|
|
//*----------------------------------------------------------------------------
|
3923 |
|
|
__inline void AT91F_DBGU_CfgPMC (void)
|
3924 |
|
|
{
|
3925 |
|
|
AT91F_PMC_EnablePeriphClock(
|
3926 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
3927 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
3928 |
|
|
}
|
3929 |
|
|
|
3930 |
|
|
//*----------------------------------------------------------------------------
|
3931 |
|
|
//* \fn AT91F_DBGU_CfgPIO
|
3932 |
|
|
//* \brief Configure PIO controllers to drive DBGU signals
|
3933 |
|
|
//*----------------------------------------------------------------------------
|
3934 |
|
|
__inline void AT91F_DBGU_CfgPIO (void)
|
3935 |
|
|
{
|
3936 |
|
|
// Configure PIO controllers to periph mode
|
3937 |
|
|
AT91F_PIO_CfgPeriph(
|
3938 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
3939 |
|
|
((unsigned int) AT91C_PA27_DRXD ) |
|
3940 |
|
|
((unsigned int) AT91C_PA28_DTXD ), // Peripheral A
|
3941 |
|
|
0); // Peripheral B
|
3942 |
|
|
}
|
3943 |
|
|
|
3944 |
|
|
//*----------------------------------------------------------------------------
|
3945 |
|
|
//* \fn AT91F_PMC_CfgPMC
|
3946 |
|
|
//* \brief Enable Peripheral clock in PMC for PMC
|
3947 |
|
|
//*----------------------------------------------------------------------------
|
3948 |
|
|
__inline void AT91F_PMC_CfgPMC (void)
|
3949 |
|
|
{
|
3950 |
|
|
AT91F_PMC_EnablePeriphClock(
|
3951 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
3952 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
3953 |
|
|
}
|
3954 |
|
|
|
3955 |
|
|
//*----------------------------------------------------------------------------
|
3956 |
|
|
//* \fn AT91F_PMC_CfgPIO
|
3957 |
|
|
//* \brief Configure PIO controllers to drive PMC signals
|
3958 |
|
|
//*----------------------------------------------------------------------------
|
3959 |
|
|
__inline void AT91F_PMC_CfgPIO (void)
|
3960 |
|
|
{
|
3961 |
|
|
// Configure PIO controllers to periph mode
|
3962 |
|
|
AT91F_PIO_CfgPeriph(
|
3963 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
3964 |
|
|
((unsigned int) AT91C_PB30_PCK2 ) |
|
3965 |
|
|
((unsigned int) AT91C_PB29_PCK1 ), // Peripheral A
|
3966 |
|
|
((unsigned int) AT91C_PB20_PCK0 ) |
|
3967 |
|
|
((unsigned int) AT91C_PB0_PCK0 ) |
|
3968 |
|
|
((unsigned int) AT91C_PB22_PCK2 ) |
|
3969 |
|
|
((unsigned int) AT91C_PB21_PCK1 )); // Peripheral B
|
3970 |
|
|
// Configure PIO controllers to periph mode
|
3971 |
|
|
AT91F_PIO_CfgPeriph(
|
3972 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
3973 |
|
|
0, // Peripheral A
|
3974 |
|
|
((unsigned int) AT91C_PA30_PCK2 ) |
|
3975 |
|
|
((unsigned int) AT91C_PA13_PCK1 ) |
|
3976 |
|
|
((unsigned int) AT91C_PA27_PCK3 )); // Peripheral B
|
3977 |
|
|
}
|
3978 |
|
|
|
3979 |
|
|
//*----------------------------------------------------------------------------
|
3980 |
|
|
//* \fn AT91F_VREG_CfgPMC
|
3981 |
|
|
//* \brief Enable Peripheral clock in PMC for VREG
|
3982 |
|
|
//*----------------------------------------------------------------------------
|
3983 |
|
|
__inline void AT91F_VREG_CfgPMC (void)
|
3984 |
|
|
{
|
3985 |
|
|
AT91F_PMC_EnablePeriphClock(
|
3986 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
3987 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
3988 |
|
|
}
|
3989 |
|
|
|
3990 |
|
|
//*----------------------------------------------------------------------------
|
3991 |
|
|
//* \fn AT91F_RSTC_CfgPMC
|
3992 |
|
|
//* \brief Enable Peripheral clock in PMC for RSTC
|
3993 |
|
|
//*----------------------------------------------------------------------------
|
3994 |
|
|
__inline void AT91F_RSTC_CfgPMC (void)
|
3995 |
|
|
{
|
3996 |
|
|
AT91F_PMC_EnablePeriphClock(
|
3997 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
3998 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
3999 |
|
|
}
|
4000 |
|
|
|
4001 |
|
|
//*----------------------------------------------------------------------------
|
4002 |
|
|
//* \fn AT91F_SSC_CfgPMC
|
4003 |
|
|
//* \brief Enable Peripheral clock in PMC for SSC
|
4004 |
|
|
//*----------------------------------------------------------------------------
|
4005 |
|
|
__inline void AT91F_SSC_CfgPMC (void)
|
4006 |
|
|
{
|
4007 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4008 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4009 |
|
|
((unsigned int) 1 << AT91C_ID_SSC));
|
4010 |
|
|
}
|
4011 |
|
|
|
4012 |
|
|
//*----------------------------------------------------------------------------
|
4013 |
|
|
//* \fn AT91F_SSC_CfgPIO
|
4014 |
|
|
//* \brief Configure PIO controllers to drive SSC signals
|
4015 |
|
|
//*----------------------------------------------------------------------------
|
4016 |
|
|
__inline void AT91F_SSC_CfgPIO (void)
|
4017 |
|
|
{
|
4018 |
|
|
// Configure PIO controllers to periph mode
|
4019 |
|
|
AT91F_PIO_CfgPeriph(
|
4020 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4021 |
|
|
((unsigned int) AT91C_PA25_RK ) |
|
4022 |
|
|
((unsigned int) AT91C_PA22_TK ) |
|
4023 |
|
|
((unsigned int) AT91C_PA21_TF ) |
|
4024 |
|
|
((unsigned int) AT91C_PA24_RD ) |
|
4025 |
|
|
((unsigned int) AT91C_PA26_RF ) |
|
4026 |
|
|
((unsigned int) AT91C_PA23_TD ), // Peripheral A
|
4027 |
|
|
0); // Peripheral B
|
4028 |
|
|
}
|
4029 |
|
|
|
4030 |
|
|
//*----------------------------------------------------------------------------
|
4031 |
|
|
//* \fn AT91F_WDTC_CfgPMC
|
4032 |
|
|
//* \brief Enable Peripheral clock in PMC for WDTC
|
4033 |
|
|
//*----------------------------------------------------------------------------
|
4034 |
|
|
__inline void AT91F_WDTC_CfgPMC (void)
|
4035 |
|
|
{
|
4036 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4037 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4038 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
4039 |
|
|
}
|
4040 |
|
|
|
4041 |
|
|
//*----------------------------------------------------------------------------
|
4042 |
|
|
//* \fn AT91F_US1_CfgPMC
|
4043 |
|
|
//* \brief Enable Peripheral clock in PMC for US1
|
4044 |
|
|
//*----------------------------------------------------------------------------
|
4045 |
|
|
__inline void AT91F_US1_CfgPMC (void)
|
4046 |
|
|
{
|
4047 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4048 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4049 |
|
|
((unsigned int) 1 << AT91C_ID_US1));
|
4050 |
|
|
}
|
4051 |
|
|
|
4052 |
|
|
//*----------------------------------------------------------------------------
|
4053 |
|
|
//* \fn AT91F_US1_CfgPIO
|
4054 |
|
|
//* \brief Configure PIO controllers to drive US1 signals
|
4055 |
|
|
//*----------------------------------------------------------------------------
|
4056 |
|
|
__inline void AT91F_US1_CfgPIO (void)
|
4057 |
|
|
{
|
4058 |
|
|
// Configure PIO controllers to periph mode
|
4059 |
|
|
AT91F_PIO_CfgPeriph(
|
4060 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4061 |
|
|
0, // Peripheral A
|
4062 |
|
|
((unsigned int) AT91C_PB26_RI1 ) |
|
4063 |
|
|
((unsigned int) AT91C_PB24_DSR1 ) |
|
4064 |
|
|
((unsigned int) AT91C_PB23_DCD1 ) |
|
4065 |
|
|
((unsigned int) AT91C_PB25_DTR1 )); // Peripheral B
|
4066 |
|
|
// Configure PIO controllers to periph mode
|
4067 |
|
|
AT91F_PIO_CfgPeriph(
|
4068 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4069 |
|
|
((unsigned int) AT91C_PA7_SCK1 ) |
|
4070 |
|
|
((unsigned int) AT91C_PA8_RTS1 ) |
|
4071 |
|
|
((unsigned int) AT91C_PA6_TXD1 ) |
|
4072 |
|
|
((unsigned int) AT91C_PA5_RXD1 ) |
|
4073 |
|
|
((unsigned int) AT91C_PA9_CTS1 ), // Peripheral A
|
4074 |
|
|
0); // Peripheral B
|
4075 |
|
|
}
|
4076 |
|
|
|
4077 |
|
|
//*----------------------------------------------------------------------------
|
4078 |
|
|
//* \fn AT91F_US0_CfgPMC
|
4079 |
|
|
//* \brief Enable Peripheral clock in PMC for US0
|
4080 |
|
|
//*----------------------------------------------------------------------------
|
4081 |
|
|
__inline void AT91F_US0_CfgPMC (void)
|
4082 |
|
|
{
|
4083 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4084 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4085 |
|
|
((unsigned int) 1 << AT91C_ID_US0));
|
4086 |
|
|
}
|
4087 |
|
|
|
4088 |
|
|
//*----------------------------------------------------------------------------
|
4089 |
|
|
//* \fn AT91F_US0_CfgPIO
|
4090 |
|
|
//* \brief Configure PIO controllers to drive US0 signals
|
4091 |
|
|
//*----------------------------------------------------------------------------
|
4092 |
|
|
__inline void AT91F_US0_CfgPIO (void)
|
4093 |
|
|
{
|
4094 |
|
|
// Configure PIO controllers to periph mode
|
4095 |
|
|
AT91F_PIO_CfgPeriph(
|
4096 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4097 |
|
|
((unsigned int) AT91C_PA0_RXD0 ) |
|
4098 |
|
|
((unsigned int) AT91C_PA4_CTS0 ) |
|
4099 |
|
|
((unsigned int) AT91C_PA3_RTS0 ) |
|
4100 |
|
|
((unsigned int) AT91C_PA2_SCK0 ) |
|
4101 |
|
|
((unsigned int) AT91C_PA1_TXD0 ), // Peripheral A
|
4102 |
|
|
0); // Peripheral B
|
4103 |
|
|
}
|
4104 |
|
|
|
4105 |
|
|
//*----------------------------------------------------------------------------
|
4106 |
|
|
//* \fn AT91F_SPI1_CfgPMC
|
4107 |
|
|
//* \brief Enable Peripheral clock in PMC for SPI1
|
4108 |
|
|
//*----------------------------------------------------------------------------
|
4109 |
|
|
__inline void AT91F_SPI1_CfgPMC (void)
|
4110 |
|
|
{
|
4111 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4112 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4113 |
|
|
((unsigned int) 1 << AT91C_ID_SPI1));
|
4114 |
|
|
}
|
4115 |
|
|
|
4116 |
|
|
//*----------------------------------------------------------------------------
|
4117 |
|
|
//* \fn AT91F_SPI1_CfgPIO
|
4118 |
|
|
//* \brief Configure PIO controllers to drive SPI1 signals
|
4119 |
|
|
//*----------------------------------------------------------------------------
|
4120 |
|
|
__inline void AT91F_SPI1_CfgPIO (void)
|
4121 |
|
|
{
|
4122 |
|
|
// Configure PIO controllers to periph mode
|
4123 |
|
|
AT91F_PIO_CfgPeriph(
|
4124 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4125 |
|
|
0, // Peripheral A
|
4126 |
|
|
((unsigned int) AT91C_PB16_NPCS13 ) |
|
4127 |
|
|
((unsigned int) AT91C_PB10_NPCS11 ) |
|
4128 |
|
|
((unsigned int) AT91C_PB11_NPCS12 )); // Peripheral B
|
4129 |
|
|
// Configure PIO controllers to periph mode
|
4130 |
|
|
AT91F_PIO_CfgPeriph(
|
4131 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4132 |
|
|
0, // Peripheral A
|
4133 |
|
|
((unsigned int) AT91C_PA4_NPCS13 ) |
|
4134 |
|
|
((unsigned int) AT91C_PA29_NPCS13 ) |
|
4135 |
|
|
((unsigned int) AT91C_PA21_NPCS10 ) |
|
4136 |
|
|
((unsigned int) AT91C_PA22_SPCK1 ) |
|
4137 |
|
|
((unsigned int) AT91C_PA25_NPCS11 ) |
|
4138 |
|
|
((unsigned int) AT91C_PA2_NPCS11 ) |
|
4139 |
|
|
((unsigned int) AT91C_PA24_MISO1 ) |
|
4140 |
|
|
((unsigned int) AT91C_PA3_NPCS12 ) |
|
4141 |
|
|
((unsigned int) AT91C_PA26_NPCS12 ) |
|
4142 |
|
|
((unsigned int) AT91C_PA23_MOSI1 )); // Peripheral B
|
4143 |
|
|
}
|
4144 |
|
|
|
4145 |
|
|
//*----------------------------------------------------------------------------
|
4146 |
|
|
//* \fn AT91F_SPI0_CfgPMC
|
4147 |
|
|
//* \brief Enable Peripheral clock in PMC for SPI0
|
4148 |
|
|
//*----------------------------------------------------------------------------
|
4149 |
|
|
__inline void AT91F_SPI0_CfgPMC (void)
|
4150 |
|
|
{
|
4151 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4152 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4153 |
|
|
((unsigned int) 1 << AT91C_ID_SPI0));
|
4154 |
|
|
}
|
4155 |
|
|
|
4156 |
|
|
//*----------------------------------------------------------------------------
|
4157 |
|
|
//* \fn AT91F_SPI0_CfgPIO
|
4158 |
|
|
//* \brief Configure PIO controllers to drive SPI0 signals
|
4159 |
|
|
//*----------------------------------------------------------------------------
|
4160 |
|
|
__inline void AT91F_SPI0_CfgPIO (void)
|
4161 |
|
|
{
|
4162 |
|
|
// Configure PIO controllers to periph mode
|
4163 |
|
|
AT91F_PIO_CfgPeriph(
|
4164 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4165 |
|
|
0, // Peripheral A
|
4166 |
|
|
((unsigned int) AT91C_PB13_NPCS01 ) |
|
4167 |
|
|
((unsigned int) AT91C_PB17_NPCS03 ) |
|
4168 |
|
|
((unsigned int) AT91C_PB14_NPCS02 )); // Peripheral B
|
4169 |
|
|
// Configure PIO controllers to periph mode
|
4170 |
|
|
AT91F_PIO_CfgPeriph(
|
4171 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4172 |
|
|
((unsigned int) AT91C_PA16_MISO0 ) |
|
4173 |
|
|
((unsigned int) AT91C_PA13_NPCS01 ) |
|
4174 |
|
|
((unsigned int) AT91C_PA15_NPCS03 ) |
|
4175 |
|
|
((unsigned int) AT91C_PA17_MOSI0 ) |
|
4176 |
|
|
((unsigned int) AT91C_PA18_SPCK0 ) |
|
4177 |
|
|
((unsigned int) AT91C_PA14_NPCS02 ) |
|
4178 |
|
|
((unsigned int) AT91C_PA12_NPCS00 ), // Peripheral A
|
4179 |
|
|
((unsigned int) AT91C_PA7_NPCS01 ) |
|
4180 |
|
|
((unsigned int) AT91C_PA9_NPCS03 ) |
|
4181 |
|
|
((unsigned int) AT91C_PA8_NPCS02 )); // Peripheral B
|
4182 |
|
|
}
|
4183 |
|
|
|
4184 |
|
|
//*----------------------------------------------------------------------------
|
4185 |
|
|
//* \fn AT91F_PITC_CfgPMC
|
4186 |
|
|
//* \brief Enable Peripheral clock in PMC for PITC
|
4187 |
|
|
//*----------------------------------------------------------------------------
|
4188 |
|
|
__inline void AT91F_PITC_CfgPMC (void)
|
4189 |
|
|
{
|
4190 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4191 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4192 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
4193 |
|
|
}
|
4194 |
|
|
|
4195 |
|
|
//*----------------------------------------------------------------------------
|
4196 |
|
|
//* \fn AT91F_AIC_CfgPMC
|
4197 |
|
|
//* \brief Enable Peripheral clock in PMC for AIC
|
4198 |
|
|
//*----------------------------------------------------------------------------
|
4199 |
|
|
__inline void AT91F_AIC_CfgPMC (void)
|
4200 |
|
|
{
|
4201 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4202 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4203 |
|
|
((unsigned int) 1 << AT91C_ID_FIQ) |
|
4204 |
|
|
((unsigned int) 1 << AT91C_ID_IRQ0) |
|
4205 |
|
|
((unsigned int) 1 << AT91C_ID_IRQ1));
|
4206 |
|
|
}
|
4207 |
|
|
|
4208 |
|
|
//*----------------------------------------------------------------------------
|
4209 |
|
|
//* \fn AT91F_AIC_CfgPIO
|
4210 |
|
|
//* \brief Configure PIO controllers to drive AIC signals
|
4211 |
|
|
//*----------------------------------------------------------------------------
|
4212 |
|
|
__inline void AT91F_AIC_CfgPIO (void)
|
4213 |
|
|
{
|
4214 |
|
|
// Configure PIO controllers to periph mode
|
4215 |
|
|
AT91F_PIO_CfgPeriph(
|
4216 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4217 |
|
|
((unsigned int) AT91C_PA30_IRQ0 ) |
|
4218 |
|
|
((unsigned int) AT91C_PA29_FIQ ), // Peripheral A
|
4219 |
|
|
((unsigned int) AT91C_PA14_IRQ1 )); // Peripheral B
|
4220 |
|
|
}
|
4221 |
|
|
|
4222 |
|
|
//*----------------------------------------------------------------------------
|
4223 |
|
|
//* \fn AT91F_AES_CfgPMC
|
4224 |
|
|
//* \brief Enable Peripheral clock in PMC for AES
|
4225 |
|
|
//*----------------------------------------------------------------------------
|
4226 |
|
|
__inline void AT91F_AES_CfgPMC (void)
|
4227 |
|
|
{
|
4228 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4229 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4230 |
|
|
((unsigned int) 1 << AT91C_ID_AES));
|
4231 |
|
|
}
|
4232 |
|
|
|
4233 |
|
|
//*----------------------------------------------------------------------------
|
4234 |
|
|
//* \fn AT91F_TWI_CfgPMC
|
4235 |
|
|
//* \brief Enable Peripheral clock in PMC for TWI
|
4236 |
|
|
//*----------------------------------------------------------------------------
|
4237 |
|
|
__inline void AT91F_TWI_CfgPMC (void)
|
4238 |
|
|
{
|
4239 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4240 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4241 |
|
|
((unsigned int) 1 << AT91C_ID_TWI));
|
4242 |
|
|
}
|
4243 |
|
|
|
4244 |
|
|
//*----------------------------------------------------------------------------
|
4245 |
|
|
//* \fn AT91F_TWI_CfgPIO
|
4246 |
|
|
//* \brief Configure PIO controllers to drive TWI signals
|
4247 |
|
|
//*----------------------------------------------------------------------------
|
4248 |
|
|
__inline void AT91F_TWI_CfgPIO (void)
|
4249 |
|
|
{
|
4250 |
|
|
// Configure PIO controllers to periph mode
|
4251 |
|
|
AT91F_PIO_CfgPeriph(
|
4252 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4253 |
|
|
((unsigned int) AT91C_PA11_TWCK ) |
|
4254 |
|
|
((unsigned int) AT91C_PA10_TWD ), // Peripheral A
|
4255 |
|
|
0); // Peripheral B
|
4256 |
|
|
}
|
4257 |
|
|
|
4258 |
|
|
//*----------------------------------------------------------------------------
|
4259 |
|
|
//* \fn AT91F_ADC_CfgPMC
|
4260 |
|
|
//* \brief Enable Peripheral clock in PMC for ADC
|
4261 |
|
|
//*----------------------------------------------------------------------------
|
4262 |
|
|
__inline void AT91F_ADC_CfgPMC (void)
|
4263 |
|
|
{
|
4264 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4265 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4266 |
|
|
((unsigned int) 1 << AT91C_ID_ADC));
|
4267 |
|
|
}
|
4268 |
|
|
|
4269 |
|
|
//*----------------------------------------------------------------------------
|
4270 |
|
|
//* \fn AT91F_ADC_CfgPIO
|
4271 |
|
|
//* \brief Configure PIO controllers to drive ADC signals
|
4272 |
|
|
//*----------------------------------------------------------------------------
|
4273 |
|
|
__inline void AT91F_ADC_CfgPIO (void)
|
4274 |
|
|
{
|
4275 |
|
|
// Configure PIO controllers to periph mode
|
4276 |
|
|
AT91F_PIO_CfgPeriph(
|
4277 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4278 |
|
|
0, // Peripheral A
|
4279 |
|
|
((unsigned int) AT91C_PB18_ADTRG )); // Peripheral B
|
4280 |
|
|
}
|
4281 |
|
|
|
4282 |
|
|
//*----------------------------------------------------------------------------
|
4283 |
|
|
//* \fn AT91F_PWMC_CH3_CfgPIO
|
4284 |
|
|
//* \brief Configure PIO controllers to drive PWMC_CH3 signals
|
4285 |
|
|
//*----------------------------------------------------------------------------
|
4286 |
|
|
__inline void AT91F_PWMC_CH3_CfgPIO (void)
|
4287 |
|
|
{
|
4288 |
|
|
// Configure PIO controllers to periph mode
|
4289 |
|
|
AT91F_PIO_CfgPeriph(
|
4290 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4291 |
|
|
((unsigned int) AT91C_PB22_PWM3 ), // Peripheral A
|
4292 |
|
|
((unsigned int) AT91C_PB30_PWM3 )); // Peripheral B
|
4293 |
|
|
}
|
4294 |
|
|
|
4295 |
|
|
//*----------------------------------------------------------------------------
|
4296 |
|
|
//* \fn AT91F_PWMC_CH2_CfgPIO
|
4297 |
|
|
//* \brief Configure PIO controllers to drive PWMC_CH2 signals
|
4298 |
|
|
//*----------------------------------------------------------------------------
|
4299 |
|
|
__inline void AT91F_PWMC_CH2_CfgPIO (void)
|
4300 |
|
|
{
|
4301 |
|
|
// Configure PIO controllers to periph mode
|
4302 |
|
|
AT91F_PIO_CfgPeriph(
|
4303 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4304 |
|
|
((unsigned int) AT91C_PB21_PWM2 ), // Peripheral A
|
4305 |
|
|
((unsigned int) AT91C_PB29_PWM2 )); // Peripheral B
|
4306 |
|
|
}
|
4307 |
|
|
|
4308 |
|
|
//*----------------------------------------------------------------------------
|
4309 |
|
|
//* \fn AT91F_PWMC_CH1_CfgPIO
|
4310 |
|
|
//* \brief Configure PIO controllers to drive PWMC_CH1 signals
|
4311 |
|
|
//*----------------------------------------------------------------------------
|
4312 |
|
|
__inline void AT91F_PWMC_CH1_CfgPIO (void)
|
4313 |
|
|
{
|
4314 |
|
|
// Configure PIO controllers to periph mode
|
4315 |
|
|
AT91F_PIO_CfgPeriph(
|
4316 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4317 |
|
|
((unsigned int) AT91C_PB20_PWM1 ), // Peripheral A
|
4318 |
|
|
((unsigned int) AT91C_PB28_PWM1 )); // Peripheral B
|
4319 |
|
|
}
|
4320 |
|
|
|
4321 |
|
|
//*----------------------------------------------------------------------------
|
4322 |
|
|
//* \fn AT91F_PWMC_CH0_CfgPIO
|
4323 |
|
|
//* \brief Configure PIO controllers to drive PWMC_CH0 signals
|
4324 |
|
|
//*----------------------------------------------------------------------------
|
4325 |
|
|
__inline void AT91F_PWMC_CH0_CfgPIO (void)
|
4326 |
|
|
{
|
4327 |
|
|
// Configure PIO controllers to periph mode
|
4328 |
|
|
AT91F_PIO_CfgPeriph(
|
4329 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4330 |
|
|
((unsigned int) AT91C_PB19_PWM0 ), // Peripheral A
|
4331 |
|
|
((unsigned int) AT91C_PB27_PWM0 )); // Peripheral B
|
4332 |
|
|
}
|
4333 |
|
|
|
4334 |
|
|
//*----------------------------------------------------------------------------
|
4335 |
|
|
//* \fn AT91F_RTTC_CfgPMC
|
4336 |
|
|
//* \brief Enable Peripheral clock in PMC for RTTC
|
4337 |
|
|
//*----------------------------------------------------------------------------
|
4338 |
|
|
__inline void AT91F_RTTC_CfgPMC (void)
|
4339 |
|
|
{
|
4340 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4341 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4342 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
4343 |
|
|
}
|
4344 |
|
|
|
4345 |
|
|
//*----------------------------------------------------------------------------
|
4346 |
|
|
//* \fn AT91F_UDP_CfgPMC
|
4347 |
|
|
//* \brief Enable Peripheral clock in PMC for UDP
|
4348 |
|
|
//*----------------------------------------------------------------------------
|
4349 |
|
|
__inline void AT91F_UDP_CfgPMC (void)
|
4350 |
|
|
{
|
4351 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4352 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4353 |
|
|
((unsigned int) 1 << AT91C_ID_UDP));
|
4354 |
|
|
}
|
4355 |
|
|
|
4356 |
|
|
//*----------------------------------------------------------------------------
|
4357 |
|
|
//* \fn AT91F_TDES_CfgPMC
|
4358 |
|
|
//* \brief Enable Peripheral clock in PMC for TDES
|
4359 |
|
|
//*----------------------------------------------------------------------------
|
4360 |
|
|
__inline void AT91F_TDES_CfgPMC (void)
|
4361 |
|
|
{
|
4362 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4363 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4364 |
|
|
((unsigned int) 1 << AT91C_ID_TDES));
|
4365 |
|
|
}
|
4366 |
|
|
|
4367 |
|
|
//*----------------------------------------------------------------------------
|
4368 |
|
|
//* \fn AT91F_EMAC_CfgPMC
|
4369 |
|
|
//* \brief Enable Peripheral clock in PMC for EMAC
|
4370 |
|
|
//*----------------------------------------------------------------------------
|
4371 |
|
|
__inline void AT91F_EMAC_CfgPMC (void)
|
4372 |
|
|
{
|
4373 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4374 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4375 |
|
|
((unsigned int) 1 << AT91C_ID_EMAC));
|
4376 |
|
|
}
|
4377 |
|
|
|
4378 |
|
|
//*----------------------------------------------------------------------------
|
4379 |
|
|
//* \fn AT91F_EMAC_CfgPIO
|
4380 |
|
|
//* \brief Configure PIO controllers to drive EMAC signals
|
4381 |
|
|
//*----------------------------------------------------------------------------
|
4382 |
|
|
__inline void AT91F_EMAC_CfgPIO (void)
|
4383 |
|
|
{
|
4384 |
|
|
// Configure PIO controllers to periph mode
|
4385 |
|
|
AT91F_PIO_CfgPeriph(
|
4386 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4387 |
|
|
((unsigned int) AT91C_PB2_ETX0 ) |
|
4388 |
|
|
((unsigned int) AT91C_PB12_ETXER ) |
|
4389 |
|
|
((unsigned int) AT91C_PB16_ECOL ) |
|
4390 |
|
|
((unsigned int) AT91C_PB11_ETX3 ) |
|
4391 |
|
|
((unsigned int) AT91C_PB6_ERX1 ) |
|
4392 |
|
|
((unsigned int) AT91C_PB15_ERXDV ) |
|
4393 |
|
|
((unsigned int) AT91C_PB13_ERX2 ) |
|
4394 |
|
|
((unsigned int) AT91C_PB3_ETX1 ) |
|
4395 |
|
|
((unsigned int) AT91C_PB8_EMDC ) |
|
4396 |
|
|
((unsigned int) AT91C_PB5_ERX0 ) |
|
4397 |
|
|
//((unsigned int) AT91C_PB18_EF100 ) |
|
4398 |
|
|
((unsigned int) AT91C_PB14_ERX3 ) |
|
4399 |
|
|
((unsigned int) AT91C_PB4_ECRS_ECRSDV) |
|
4400 |
|
|
((unsigned int) AT91C_PB1_ETXEN ) |
|
4401 |
|
|
((unsigned int) AT91C_PB10_ETX2 ) |
|
4402 |
|
|
((unsigned int) AT91C_PB0_ETXCK_EREFCK) |
|
4403 |
|
|
((unsigned int) AT91C_PB9_EMDIO ) |
|
4404 |
|
|
((unsigned int) AT91C_PB7_ERXER ) |
|
4405 |
|
|
((unsigned int) AT91C_PB17_ERXCK ), // Peripheral A
|
4406 |
|
|
0); // Peripheral B
|
4407 |
|
|
}
|
4408 |
|
|
|
4409 |
|
|
//*----------------------------------------------------------------------------
|
4410 |
|
|
//* \fn AT91F_TC0_CfgPMC
|
4411 |
|
|
//* \brief Enable Peripheral clock in PMC for TC0
|
4412 |
|
|
//*----------------------------------------------------------------------------
|
4413 |
|
|
__inline void AT91F_TC0_CfgPMC (void)
|
4414 |
|
|
{
|
4415 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4416 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4417 |
|
|
((unsigned int) 1 << AT91C_ID_TC0));
|
4418 |
|
|
}
|
4419 |
|
|
|
4420 |
|
|
//*----------------------------------------------------------------------------
|
4421 |
|
|
//* \fn AT91F_TC0_CfgPIO
|
4422 |
|
|
//* \brief Configure PIO controllers to drive TC0 signals
|
4423 |
|
|
//*----------------------------------------------------------------------------
|
4424 |
|
|
__inline void AT91F_TC0_CfgPIO (void)
|
4425 |
|
|
{
|
4426 |
|
|
// Configure PIO controllers to periph mode
|
4427 |
|
|
AT91F_PIO_CfgPeriph(
|
4428 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4429 |
|
|
((unsigned int) AT91C_PB23_TIOA0 ) |
|
4430 |
|
|
((unsigned int) AT91C_PB24_TIOB0 ), // Peripheral A
|
4431 |
|
|
((unsigned int) AT91C_PB12_TCLK0 )); // Peripheral B
|
4432 |
|
|
}
|
4433 |
|
|
|
4434 |
|
|
//*----------------------------------------------------------------------------
|
4435 |
|
|
//* \fn AT91F_TC1_CfgPMC
|
4436 |
|
|
//* \brief Enable Peripheral clock in PMC for TC1
|
4437 |
|
|
//*----------------------------------------------------------------------------
|
4438 |
|
|
__inline void AT91F_TC1_CfgPMC (void)
|
4439 |
|
|
{
|
4440 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4441 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4442 |
|
|
((unsigned int) 1 << AT91C_ID_TC1));
|
4443 |
|
|
}
|
4444 |
|
|
|
4445 |
|
|
//*----------------------------------------------------------------------------
|
4446 |
|
|
//* \fn AT91F_TC1_CfgPIO
|
4447 |
|
|
//* \brief Configure PIO controllers to drive TC1 signals
|
4448 |
|
|
//*----------------------------------------------------------------------------
|
4449 |
|
|
__inline void AT91F_TC1_CfgPIO (void)
|
4450 |
|
|
{
|
4451 |
|
|
// Configure PIO controllers to periph mode
|
4452 |
|
|
AT91F_PIO_CfgPeriph(
|
4453 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4454 |
|
|
((unsigned int) AT91C_PB25_TIOA1 ) |
|
4455 |
|
|
((unsigned int) AT91C_PB26_TIOB1 ), // Peripheral A
|
4456 |
|
|
((unsigned int) AT91C_PB19_TCLK1 )); // Peripheral B
|
4457 |
|
|
}
|
4458 |
|
|
|
4459 |
|
|
//*----------------------------------------------------------------------------
|
4460 |
|
|
//* \fn AT91F_TC2_CfgPMC
|
4461 |
|
|
//* \brief Enable Peripheral clock in PMC for TC2
|
4462 |
|
|
//*----------------------------------------------------------------------------
|
4463 |
|
|
__inline void AT91F_TC2_CfgPMC (void)
|
4464 |
|
|
{
|
4465 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4466 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4467 |
|
|
((unsigned int) 1 << AT91C_ID_TC2));
|
4468 |
|
|
}
|
4469 |
|
|
|
4470 |
|
|
//*----------------------------------------------------------------------------
|
4471 |
|
|
//* \fn AT91F_TC2_CfgPIO
|
4472 |
|
|
//* \brief Configure PIO controllers to drive TC2 signals
|
4473 |
|
|
//*----------------------------------------------------------------------------
|
4474 |
|
|
__inline void AT91F_TC2_CfgPIO (void)
|
4475 |
|
|
{
|
4476 |
|
|
// Configure PIO controllers to periph mode
|
4477 |
|
|
AT91F_PIO_CfgPeriph(
|
4478 |
|
|
AT91C_BASE_PIOB, // PIO controller base address
|
4479 |
|
|
((unsigned int) AT91C_PB28_TIOB2 ) |
|
4480 |
|
|
((unsigned int) AT91C_PB27_TIOA2 ), // Peripheral A
|
4481 |
|
|
0); // Peripheral B
|
4482 |
|
|
// Configure PIO controllers to periph mode
|
4483 |
|
|
AT91F_PIO_CfgPeriph(
|
4484 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4485 |
|
|
0, // Peripheral A
|
4486 |
|
|
((unsigned int) AT91C_PA15_TCLK2 )); // Peripheral B
|
4487 |
|
|
}
|
4488 |
|
|
|
4489 |
|
|
//*----------------------------------------------------------------------------
|
4490 |
|
|
//* \fn AT91F_MC_CfgPMC
|
4491 |
|
|
//* \brief Enable Peripheral clock in PMC for MC
|
4492 |
|
|
//*----------------------------------------------------------------------------
|
4493 |
|
|
__inline void AT91F_MC_CfgPMC (void)
|
4494 |
|
|
{
|
4495 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4496 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4497 |
|
|
((unsigned int) 1 << AT91C_ID_SYS));
|
4498 |
|
|
}
|
4499 |
|
|
|
4500 |
|
|
//*----------------------------------------------------------------------------
|
4501 |
|
|
//* \fn AT91F_PIOA_CfgPMC
|
4502 |
|
|
//* \brief Enable Peripheral clock in PMC for PIOA
|
4503 |
|
|
//*----------------------------------------------------------------------------
|
4504 |
|
|
__inline void AT91F_PIOA_CfgPMC (void)
|
4505 |
|
|
{
|
4506 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4507 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4508 |
|
|
((unsigned int) 1 << AT91C_ID_PIOA));
|
4509 |
|
|
}
|
4510 |
|
|
|
4511 |
|
|
//*----------------------------------------------------------------------------
|
4512 |
|
|
//* \fn AT91F_PIOB_CfgPMC
|
4513 |
|
|
//* \brief Enable Peripheral clock in PMC for PIOB
|
4514 |
|
|
//*----------------------------------------------------------------------------
|
4515 |
|
|
__inline void AT91F_PIOB_CfgPMC (void)
|
4516 |
|
|
{
|
4517 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4518 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4519 |
|
|
((unsigned int) 1 << AT91C_ID_PIOB));
|
4520 |
|
|
}
|
4521 |
|
|
|
4522 |
|
|
//*----------------------------------------------------------------------------
|
4523 |
|
|
//* \fn AT91F_CAN_CfgPMC
|
4524 |
|
|
//* \brief Enable Peripheral clock in PMC for CAN
|
4525 |
|
|
//*----------------------------------------------------------------------------
|
4526 |
|
|
__inline void AT91F_CAN_CfgPMC (void)
|
4527 |
|
|
{
|
4528 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4529 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4530 |
|
|
((unsigned int) 1 << AT91C_ID_CAN));
|
4531 |
|
|
}
|
4532 |
|
|
|
4533 |
|
|
//*----------------------------------------------------------------------------
|
4534 |
|
|
//* \fn AT91F_CAN_CfgPIO
|
4535 |
|
|
//* \brief Configure PIO controllers to drive CAN signals
|
4536 |
|
|
//*----------------------------------------------------------------------------
|
4537 |
|
|
__inline void AT91F_CAN_CfgPIO (void)
|
4538 |
|
|
{
|
4539 |
|
|
// Configure PIO controllers to periph mode
|
4540 |
|
|
AT91F_PIO_CfgPeriph(
|
4541 |
|
|
AT91C_BASE_PIOA, // PIO controller base address
|
4542 |
|
|
((unsigned int) AT91C_PA20_CANTX ) |
|
4543 |
|
|
((unsigned int) AT91C_PA19_CANRX ), // Peripheral A
|
4544 |
|
|
0); // Peripheral B
|
4545 |
|
|
}
|
4546 |
|
|
|
4547 |
|
|
//*----------------------------------------------------------------------------
|
4548 |
|
|
//* \fn AT91F_PWMC_CfgPMC
|
4549 |
|
|
//* \brief Enable Peripheral clock in PMC for PWMC
|
4550 |
|
|
//*----------------------------------------------------------------------------
|
4551 |
|
|
__inline void AT91F_PWMC_CfgPMC (void)
|
4552 |
|
|
{
|
4553 |
|
|
AT91F_PMC_EnablePeriphClock(
|
4554 |
|
|
AT91C_BASE_PMC, // PIO controller base address
|
4555 |
|
|
((unsigned int) 1 << AT91C_ID_PWMC));
|
4556 |
|
|
}
|
4557 |
|
|
|
4558 |
|
|
#endif // lib_AT91SAM7X256_H
|