1 //* ----------------------------------------------------------------------------
\r
2 //* ATMEL Microcontroller Software Support - ROUSSET -
\r
3 //* ----------------------------------------------------------------------------
\r
4 //* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
5 //* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
6 //* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
7 //* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
8 //* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
9 //* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
10 //* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
11 //* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
12 //* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
13 //* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
14 //* ----------------------------------------------------------------------------
\r
15 //* File Name : lib_AT91SAM7X256.h
\r
16 //* Object : AT91SAM7X256 inlined functions
\r
17 //* Generated : AT91 SW Application Group 05/20/2005 (16:22:29)
\r
19 //* CVS Reference : /lib_dbgu.h/1.1/Fri Jan 31 12:18:40 2003//
\r
20 //* CVS Reference : /lib_pmc_SAM7X.h/1.1/Tue Feb 1 08:32:10 2005//
\r
21 //* CVS Reference : /lib_VREG_6085B.h/1.1/Tue Feb 1 16:20:47 2005//
\r
22 //* CVS Reference : /lib_rstc_6098A.h/1.1/Wed Oct 6 10:39:20 2004//
\r
23 //* CVS Reference : /lib_ssc.h/1.4/Fri Jan 31 12:19:20 2003//
\r
24 //* CVS Reference : /lib_wdtc_6080A.h/1.1/Wed Oct 6 10:38:30 2004//
\r
25 //* CVS Reference : /lib_usart.h/1.5/Thu Nov 21 16:01:54 2002//
\r
26 //* CVS Reference : /lib_spi2.h/1.1/Mon Aug 25 14:23:52 2003//
\r
27 //* CVS Reference : /lib_pitc_6079A.h/1.2/Tue Nov 9 14:43:56 2004//
\r
28 //* CVS Reference : /lib_aic_6075b.h/1.1/Fri May 20 14:01:19 2005//
\r
29 //* CVS Reference : /lib_aes_6149a.h/1.1/Mon Jan 17 07:43:09 2005//
\r
30 //* CVS Reference : /lib_twi.h/1.3/Mon Jul 19 14:27:58 2004//
\r
31 //* CVS Reference : /lib_adc.h/1.6/Fri Oct 17 09:12:38 2003//
\r
32 //* CVS Reference : /lib_rttc_6081A.h/1.1/Wed Oct 6 10:39:38 2004//
\r
33 //* CVS Reference : /lib_udp.h/1.4/Wed Feb 16 08:39:34 2005//
\r
34 //* CVS Reference : /lib_des3_6150a.h/1.1/Mon Jan 17 09:19:19 2005//
\r
35 //* CVS Reference : /lib_tc_1753b.h/1.1/Fri Jan 31 12:20:02 2003//
\r
36 //* CVS Reference : /lib_MC_SAM7X.h/1.1/Thu Mar 25 15:19:14 2004//
\r
37 //* CVS Reference : /lib_pio.h/1.3/Fri Jan 31 12:18:56 2003//
\r
38 //* CVS Reference : /lib_can_AT91.h/1.4/Fri Oct 17 09:12:50 2003//
\r
39 //* CVS Reference : /lib_PWM_SAM.h/1.3/Thu Jan 22 10:10:50 2004//
\r
40 //* CVS Reference : /lib_pdc.h/1.2/Tue Jul 2 13:29:40 2002//
\r
41 //* ----------------------------------------------------------------------------
\r
43 #ifndef lib_AT91SAM7X256_H
\r
44 #define lib_AT91SAM7X256_H
\r
46 /* *****************************************************************************
\r
47 SOFTWARE API FOR AIC
\r
48 ***************************************************************************** */
\r
49 #define AT91C_AIC_BRANCH_OPCODE ((void (*) ()) 0xE51FFF20) // ldr, pc, [pc, #-&F20]
\r
51 //*----------------------------------------------------------------------------
\r
52 //* \fn AT91F_AIC_ConfigureIt
\r
53 //* \brief Interrupt Handler Initialization
\r
54 //*----------------------------------------------------------------------------
\r
55 __inline unsigned int AT91F_AIC_ConfigureIt (
\r
56 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
57 unsigned int irq_id, // \arg interrupt number to initialize
\r
58 unsigned int priority, // \arg priority to give to the interrupt
\r
59 unsigned int src_type, // \arg activation and sense of activation
\r
60 void (*newHandler) (void) ) // \arg address of the interrupt handler
\r
62 unsigned int oldHandler;
\r
65 oldHandler = pAic->AIC_SVR[irq_id];
\r
67 mask = 0x1 << irq_id ;
\r
68 //* Disable the interrupt on the interrupt controller
\r
69 pAic->AIC_IDCR = mask ;
\r
70 //* Save the interrupt handler routine pointer and the interrupt priority
\r
71 pAic->AIC_SVR[irq_id] = (unsigned int) newHandler ;
\r
72 //* Store the Source Mode Register
\r
73 pAic->AIC_SMR[irq_id] = src_type | priority ;
\r
74 //* Clear the interrupt on the interrupt controller
\r
75 pAic->AIC_ICCR = mask ;
\r
80 //*----------------------------------------------------------------------------
\r
81 //* \fn AT91F_AIC_EnableIt
\r
82 //* \brief Enable corresponding IT number
\r
83 //*----------------------------------------------------------------------------
\r
84 __inline void AT91F_AIC_EnableIt (
\r
85 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
86 unsigned int irq_id ) // \arg interrupt number to initialize
\r
88 //* Enable the interrupt on the interrupt controller
\r
89 pAic->AIC_IECR = 0x1 << irq_id ;
\r
92 //*----------------------------------------------------------------------------
\r
93 //* \fn AT91F_AIC_DisableIt
\r
94 //* \brief Disable corresponding IT number
\r
95 //*----------------------------------------------------------------------------
\r
96 __inline void AT91F_AIC_DisableIt (
\r
97 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
98 unsigned int irq_id ) // \arg interrupt number to initialize
\r
100 unsigned int mask = 0x1 << irq_id;
\r
101 //* Disable the interrupt on the interrupt controller
\r
102 pAic->AIC_IDCR = mask ;
\r
103 //* Clear the interrupt on the Interrupt Controller ( if one is pending )
\r
104 pAic->AIC_ICCR = mask ;
\r
107 //*----------------------------------------------------------------------------
\r
108 //* \fn AT91F_AIC_ClearIt
\r
109 //* \brief Clear corresponding IT number
\r
110 //*----------------------------------------------------------------------------
\r
111 __inline void AT91F_AIC_ClearIt (
\r
112 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
113 unsigned int irq_id) // \arg interrupt number to initialize
\r
115 //* Clear the interrupt on the Interrupt Controller ( if one is pending )
\r
116 pAic->AIC_ICCR = (0x1 << irq_id);
\r
119 //*----------------------------------------------------------------------------
\r
120 //* \fn AT91F_AIC_AcknowledgeIt
\r
121 //* \brief Acknowledge corresponding IT number
\r
122 //*----------------------------------------------------------------------------
\r
123 __inline void AT91F_AIC_AcknowledgeIt (
\r
124 AT91PS_AIC pAic) // \arg pointer to the AIC registers
\r
126 pAic->AIC_EOICR = pAic->AIC_EOICR;
\r
129 //*----------------------------------------------------------------------------
\r
130 //* \fn AT91F_AIC_SetExceptionVector
\r
131 //* \brief Configure vector handler
\r
132 //*----------------------------------------------------------------------------
\r
133 __inline unsigned int AT91F_AIC_SetExceptionVector (
\r
134 unsigned int *pVector, // \arg pointer to the AIC registers
\r
135 void (*Handler) () ) // \arg Interrupt Handler
\r
137 unsigned int oldVector = *pVector;
\r
139 if ((unsigned int) Handler == (unsigned int) AT91C_AIC_BRANCH_OPCODE)
\r
140 *pVector = (unsigned int) AT91C_AIC_BRANCH_OPCODE;
\r
142 *pVector = (((((unsigned int) Handler) - ((unsigned int) pVector) - 0x8) >> 2) & 0x00FFFFFF) | 0xEA000000;
\r
147 //*----------------------------------------------------------------------------
\r
148 //* \fn AT91F_AIC_Trig
\r
149 //* \brief Trig an IT
\r
150 //*----------------------------------------------------------------------------
\r
151 __inline void AT91F_AIC_Trig (
\r
152 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
153 unsigned int irq_id) // \arg interrupt number
\r
155 pAic->AIC_ISCR = (0x1 << irq_id) ;
\r
158 //*----------------------------------------------------------------------------
\r
159 //* \fn AT91F_AIC_IsActive
\r
160 //* \brief Test if an IT is active
\r
161 //*----------------------------------------------------------------------------
\r
162 __inline unsigned int AT91F_AIC_IsActive (
\r
163 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
164 unsigned int irq_id) // \arg Interrupt Number
\r
166 return (pAic->AIC_ISR & (0x1 << irq_id));
\r
169 //*----------------------------------------------------------------------------
\r
170 //* \fn AT91F_AIC_IsPending
\r
171 //* \brief Test if an IT is pending
\r
172 //*----------------------------------------------------------------------------
\r
173 __inline unsigned int AT91F_AIC_IsPending (
\r
174 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
175 unsigned int irq_id) // \arg Interrupt Number
\r
177 return (pAic->AIC_IPR & (0x1 << irq_id));
\r
180 //*----------------------------------------------------------------------------
\r
181 //* \fn AT91F_AIC_Open
\r
182 //* \brief Set exception vectors and AIC registers to default values
\r
183 //*----------------------------------------------------------------------------
\r
184 __inline void AT91F_AIC_Open(
\r
185 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
186 void (*IrqHandler) (), // \arg Default IRQ vector exception
\r
187 void (*FiqHandler) (), // \arg Default FIQ vector exception
\r
188 void (*DefaultHandler) (), // \arg Default Handler set in ISR
\r
189 void (*SpuriousHandler) (), // \arg Default Spurious Handler
\r
190 unsigned int protectMode) // \arg Debug Control Register
\r
194 // Disable all interrupts and set IVR to the default handler
\r
195 for (i = 0; i < 32; ++i) {
\r
196 AT91F_AIC_DisableIt(pAic, i);
\r
197 AT91F_AIC_ConfigureIt(pAic, i, AT91C_AIC_PRIOR_LOWEST, AT91C_AIC_SRCTYPE_HIGH_LEVEL, DefaultHandler);
\r
200 // Set the IRQ exception vector
\r
201 AT91F_AIC_SetExceptionVector((unsigned int *) 0x18, IrqHandler);
\r
202 // Set the Fast Interrupt exception vector
\r
203 AT91F_AIC_SetExceptionVector((unsigned int *) 0x1C, FiqHandler);
\r
205 pAic->AIC_SPU = (unsigned int) SpuriousHandler;
\r
206 pAic->AIC_DCR = protectMode;
\r
208 /* *****************************************************************************
\r
209 SOFTWARE API FOR PDC
\r
210 ***************************************************************************** */
\r
211 //*----------------------------------------------------------------------------
\r
212 //* \fn AT91F_PDC_SetNextRx
\r
213 //* \brief Set the next receive transfer descriptor
\r
214 //*----------------------------------------------------------------------------
\r
215 __inline void AT91F_PDC_SetNextRx (
\r
216 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
217 char *address, // \arg address to the next bloc to be received
\r
218 unsigned int bytes) // \arg number of bytes to be received
\r
220 pPDC->PDC_RNPR = (unsigned int) address;
\r
221 pPDC->PDC_RNCR = bytes;
\r
224 //*----------------------------------------------------------------------------
\r
225 //* \fn AT91F_PDC_SetNextTx
\r
226 //* \brief Set the next transmit transfer descriptor
\r
227 //*----------------------------------------------------------------------------
\r
228 __inline void AT91F_PDC_SetNextTx (
\r
229 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
230 char *address, // \arg address to the next bloc to be transmitted
\r
231 unsigned int bytes) // \arg number of bytes to be transmitted
\r
233 pPDC->PDC_TNPR = (unsigned int) address;
\r
234 pPDC->PDC_TNCR = bytes;
\r
237 //*----------------------------------------------------------------------------
\r
238 //* \fn AT91F_PDC_SetRx
\r
239 //* \brief Set the receive transfer descriptor
\r
240 //*----------------------------------------------------------------------------
\r
241 __inline void AT91F_PDC_SetRx (
\r
242 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
243 char *address, // \arg address to the next bloc to be received
\r
244 unsigned int bytes) // \arg number of bytes to be received
\r
246 pPDC->PDC_RPR = (unsigned int) address;
\r
247 pPDC->PDC_RCR = bytes;
\r
250 //*----------------------------------------------------------------------------
\r
251 //* \fn AT91F_PDC_SetTx
\r
252 //* \brief Set the transmit transfer descriptor
\r
253 //*----------------------------------------------------------------------------
\r
254 __inline void AT91F_PDC_SetTx (
\r
255 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
256 char *address, // \arg address to the next bloc to be transmitted
\r
257 unsigned int bytes) // \arg number of bytes to be transmitted
\r
259 pPDC->PDC_TPR = (unsigned int) address;
\r
260 pPDC->PDC_TCR = bytes;
\r
263 //*----------------------------------------------------------------------------
\r
264 //* \fn AT91F_PDC_EnableTx
\r
265 //* \brief Enable transmit
\r
266 //*----------------------------------------------------------------------------
\r
267 __inline void AT91F_PDC_EnableTx (
\r
268 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
270 pPDC->PDC_PTCR = AT91C_PDC_TXTEN;
\r
273 //*----------------------------------------------------------------------------
\r
274 //* \fn AT91F_PDC_EnableRx
\r
275 //* \brief Enable receive
\r
276 //*----------------------------------------------------------------------------
\r
277 __inline void AT91F_PDC_EnableRx (
\r
278 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
280 pPDC->PDC_PTCR = AT91C_PDC_RXTEN;
\r
283 //*----------------------------------------------------------------------------
\r
284 //* \fn AT91F_PDC_DisableTx
\r
285 //* \brief Disable transmit
\r
286 //*----------------------------------------------------------------------------
\r
287 __inline void AT91F_PDC_DisableTx (
\r
288 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
290 pPDC->PDC_PTCR = AT91C_PDC_TXTDIS;
\r
293 //*----------------------------------------------------------------------------
\r
294 //* \fn AT91F_PDC_DisableRx
\r
295 //* \brief Disable receive
\r
296 //*----------------------------------------------------------------------------
\r
297 __inline void AT91F_PDC_DisableRx (
\r
298 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
300 pPDC->PDC_PTCR = AT91C_PDC_RXTDIS;
\r
303 //*----------------------------------------------------------------------------
\r
304 //* \fn AT91F_PDC_IsTxEmpty
\r
305 //* \brief Test if the current transfer descriptor has been sent
\r
306 //*----------------------------------------------------------------------------
\r
307 __inline int AT91F_PDC_IsTxEmpty ( // \return return 1 if transfer is complete
\r
308 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
310 return !(pPDC->PDC_TCR);
\r
313 //*----------------------------------------------------------------------------
\r
314 //* \fn AT91F_PDC_IsNextTxEmpty
\r
315 //* \brief Test if the next transfer descriptor has been moved to the current td
\r
316 //*----------------------------------------------------------------------------
\r
317 __inline int AT91F_PDC_IsNextTxEmpty ( // \return return 1 if transfer is complete
\r
318 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
320 return !(pPDC->PDC_TNCR);
\r
323 //*----------------------------------------------------------------------------
\r
324 //* \fn AT91F_PDC_IsRxEmpty
\r
325 //* \brief Test if the current transfer descriptor has been filled
\r
326 //*----------------------------------------------------------------------------
\r
327 __inline int AT91F_PDC_IsRxEmpty ( // \return return 1 if transfer is complete
\r
328 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
330 return !(pPDC->PDC_RCR);
\r
333 //*----------------------------------------------------------------------------
\r
334 //* \fn AT91F_PDC_IsNextRxEmpty
\r
335 //* \brief Test if the next transfer descriptor has been moved to the current td
\r
336 //*----------------------------------------------------------------------------
\r
337 __inline int AT91F_PDC_IsNextRxEmpty ( // \return return 1 if transfer is complete
\r
338 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
340 return !(pPDC->PDC_RNCR);
\r
343 //*----------------------------------------------------------------------------
\r
344 //* \fn AT91F_PDC_Open
\r
345 //* \brief Open PDC: disable TX and RX reset transfer descriptors, re-enable RX and TX
\r
346 //*----------------------------------------------------------------------------
\r
347 __inline void AT91F_PDC_Open (
\r
348 AT91PS_PDC pPDC) // \arg pointer to a PDC controller
\r
350 //* Disable the RX and TX PDC transfer requests
\r
351 AT91F_PDC_DisableRx(pPDC);
\r
352 AT91F_PDC_DisableTx(pPDC);
\r
354 //* Reset all Counter register Next buffer first
\r
355 AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);
\r
356 AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);
\r
357 AT91F_PDC_SetTx(pPDC, (char *) 0, 0);
\r
358 AT91F_PDC_SetRx(pPDC, (char *) 0, 0);
\r
360 //* Enable the RX and TX PDC transfer requests
\r
361 AT91F_PDC_EnableRx(pPDC);
\r
362 AT91F_PDC_EnableTx(pPDC);
\r
365 //*----------------------------------------------------------------------------
\r
366 //* \fn AT91F_PDC_Close
\r
367 //* \brief Close PDC: disable TX and RX reset transfer descriptors
\r
368 //*----------------------------------------------------------------------------
\r
369 __inline void AT91F_PDC_Close (
\r
370 AT91PS_PDC pPDC) // \arg pointer to a PDC controller
\r
372 //* Disable the RX and TX PDC transfer requests
\r
373 AT91F_PDC_DisableRx(pPDC);
\r
374 AT91F_PDC_DisableTx(pPDC);
\r
376 //* Reset all Counter register Next buffer first
\r
377 AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);
\r
378 AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);
\r
379 AT91F_PDC_SetTx(pPDC, (char *) 0, 0);
\r
380 AT91F_PDC_SetRx(pPDC, (char *) 0, 0);
\r
384 //*----------------------------------------------------------------------------
\r
385 //* \fn AT91F_PDC_SendFrame
\r
386 //* \brief Close PDC: disable TX and RX reset transfer descriptors
\r
387 //*----------------------------------------------------------------------------
\r
388 __inline unsigned int AT91F_PDC_SendFrame(
\r
391 unsigned int szBuffer,
\r
393 unsigned int szNextBuffer )
\r
395 if (AT91F_PDC_IsTxEmpty(pPDC)) {
\r
396 //* Buffer and next buffer can be initialized
\r
397 AT91F_PDC_SetTx(pPDC, pBuffer, szBuffer);
\r
398 AT91F_PDC_SetNextTx(pPDC, pNextBuffer, szNextBuffer);
\r
401 else if (AT91F_PDC_IsNextTxEmpty(pPDC)) {
\r
402 //* Only one buffer can be initialized
\r
403 AT91F_PDC_SetNextTx(pPDC, pBuffer, szBuffer);
\r
407 //* All buffer are in use...
\r
412 //*----------------------------------------------------------------------------
\r
413 //* \fn AT91F_PDC_ReceiveFrame
\r
414 //* \brief Close PDC: disable TX and RX reset transfer descriptors
\r
415 //*----------------------------------------------------------------------------
\r
416 __inline unsigned int AT91F_PDC_ReceiveFrame (
\r
419 unsigned int szBuffer,
\r
421 unsigned int szNextBuffer )
\r
423 if (AT91F_PDC_IsRxEmpty(pPDC)) {
\r
424 //* Buffer and next buffer can be initialized
\r
425 AT91F_PDC_SetRx(pPDC, pBuffer, szBuffer);
\r
426 AT91F_PDC_SetNextRx(pPDC, pNextBuffer, szNextBuffer);
\r
429 else if (AT91F_PDC_IsNextRxEmpty(pPDC)) {
\r
430 //* Only one buffer can be initialized
\r
431 AT91F_PDC_SetNextRx(pPDC, pBuffer, szBuffer);
\r
435 //* All buffer are in use...
\r
439 /* *****************************************************************************
\r
440 SOFTWARE API FOR DBGU
\r
441 ***************************************************************************** */
\r
442 //*----------------------------------------------------------------------------
\r
443 //* \fn AT91F_DBGU_InterruptEnable
\r
444 //* \brief Enable DBGU Interrupt
\r
445 //*----------------------------------------------------------------------------
\r
446 __inline void AT91F_DBGU_InterruptEnable(
\r
447 AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
\r
448 unsigned int flag) // \arg dbgu interrupt to be enabled
\r
450 pDbgu->DBGU_IER = flag;
\r
453 //*----------------------------------------------------------------------------
\r
454 //* \fn AT91F_DBGU_InterruptDisable
\r
455 //* \brief Disable DBGU Interrupt
\r
456 //*----------------------------------------------------------------------------
\r
457 __inline void AT91F_DBGU_InterruptDisable(
\r
458 AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
\r
459 unsigned int flag) // \arg dbgu interrupt to be disabled
\r
461 pDbgu->DBGU_IDR = flag;
\r
464 //*----------------------------------------------------------------------------
\r
465 //* \fn AT91F_DBGU_GetInterruptMaskStatus
\r
466 //* \brief Return DBGU Interrupt Mask Status
\r
467 //*----------------------------------------------------------------------------
\r
468 __inline unsigned int AT91F_DBGU_GetInterruptMaskStatus( // \return DBGU Interrupt Mask Status
\r
469 AT91PS_DBGU pDbgu) // \arg pointer to a DBGU controller
\r
471 return pDbgu->DBGU_IMR;
\r
474 //*----------------------------------------------------------------------------
\r
475 //* \fn AT91F_DBGU_IsInterruptMasked
\r
476 //* \brief Test if DBGU Interrupt is Masked
\r
477 //*----------------------------------------------------------------------------
\r
478 __inline int AT91F_DBGU_IsInterruptMasked(
\r
479 AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
\r
480 unsigned int flag) // \arg flag to be tested
\r
482 return (AT91F_DBGU_GetInterruptMaskStatus(pDbgu) & flag);
\r
485 /* *****************************************************************************
\r
486 SOFTWARE API FOR PIO
\r
487 ***************************************************************************** */
\r
488 //*----------------------------------------------------------------------------
\r
489 //* \fn AT91F_PIO_CfgPeriph
\r
490 //* \brief Enable pins to be drived by peripheral
\r
491 //*----------------------------------------------------------------------------
\r
492 __inline void AT91F_PIO_CfgPeriph(
\r
493 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
494 unsigned int periphAEnable, // \arg PERIPH A to enable
\r
495 unsigned int periphBEnable) // \arg PERIPH B to enable
\r
498 pPio->PIO_ASR = periphAEnable;
\r
499 pPio->PIO_BSR = periphBEnable;
\r
500 pPio->PIO_PDR = (periphAEnable | periphBEnable); // Set in Periph mode
\r
503 //*----------------------------------------------------------------------------
\r
504 //* \fn AT91F_PIO_CfgOutput
\r
505 //* \brief Enable PIO in output mode
\r
506 //*----------------------------------------------------------------------------
\r
507 __inline void AT91F_PIO_CfgOutput(
\r
508 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
509 unsigned int pioEnable) // \arg PIO to be enabled
\r
511 pPio->PIO_PER = pioEnable; // Set in PIO mode
\r
512 pPio->PIO_OER = pioEnable; // Configure in Output
\r
515 //*----------------------------------------------------------------------------
\r
516 //* \fn AT91F_PIO_CfgInput
\r
517 //* \brief Enable PIO in input mode
\r
518 //*----------------------------------------------------------------------------
\r
519 __inline void AT91F_PIO_CfgInput(
\r
520 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
521 unsigned int inputEnable) // \arg PIO to be enabled
\r
524 pPio->PIO_ODR = inputEnable;
\r
525 pPio->PIO_PER = inputEnable;
\r
528 //*----------------------------------------------------------------------------
\r
529 //* \fn AT91F_PIO_CfgOpendrain
\r
530 //* \brief Configure PIO in open drain
\r
531 //*----------------------------------------------------------------------------
\r
532 __inline void AT91F_PIO_CfgOpendrain(
\r
533 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
534 unsigned int multiDrvEnable) // \arg pio to be configured in open drain
\r
536 // Configure the multi-drive option
\r
537 pPio->PIO_MDDR = ~multiDrvEnable;
\r
538 pPio->PIO_MDER = multiDrvEnable;
\r
541 //*----------------------------------------------------------------------------
\r
542 //* \fn AT91F_PIO_CfgPullup
\r
543 //* \brief Enable pullup on PIO
\r
544 //*----------------------------------------------------------------------------
\r
545 __inline void AT91F_PIO_CfgPullup(
\r
546 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
547 unsigned int pullupEnable) // \arg enable pullup on PIO
\r
549 // Connect or not Pullup
\r
550 pPio->PIO_PPUDR = ~pullupEnable;
\r
551 pPio->PIO_PPUER = pullupEnable;
\r
554 //*----------------------------------------------------------------------------
\r
555 //* \fn AT91F_PIO_CfgDirectDrive
\r
556 //* \brief Enable direct drive on PIO
\r
557 //*----------------------------------------------------------------------------
\r
558 __inline void AT91F_PIO_CfgDirectDrive(
\r
559 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
560 unsigned int directDrive) // \arg PIO to be configured with direct drive
\r
563 // Configure the Direct Drive
\r
564 pPio->PIO_OWDR = ~directDrive;
\r
565 pPio->PIO_OWER = directDrive;
\r
568 //*----------------------------------------------------------------------------
\r
569 //* \fn AT91F_PIO_CfgInputFilter
\r
570 //* \brief Enable input filter on input PIO
\r
571 //*----------------------------------------------------------------------------
\r
572 __inline void AT91F_PIO_CfgInputFilter(
\r
573 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
574 unsigned int inputFilter) // \arg PIO to be configured with input filter
\r
577 // Configure the Direct Drive
\r
578 pPio->PIO_IFDR = ~inputFilter;
\r
579 pPio->PIO_IFER = inputFilter;
\r
582 //*----------------------------------------------------------------------------
\r
583 //* \fn AT91F_PIO_GetInput
\r
584 //* \brief Return PIO input value
\r
585 //*----------------------------------------------------------------------------
\r
586 __inline unsigned int AT91F_PIO_GetInput( // \return PIO input
\r
587 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
589 return pPio->PIO_PDSR;
\r
592 //*----------------------------------------------------------------------------
\r
593 //* \fn AT91F_PIO_IsInputSet
\r
594 //* \brief Test if PIO is input flag is active
\r
595 //*----------------------------------------------------------------------------
\r
596 __inline int AT91F_PIO_IsInputSet(
\r
597 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
598 unsigned int flag) // \arg flag to be tested
\r
600 return (AT91F_PIO_GetInput(pPio) & flag);
\r
604 //*----------------------------------------------------------------------------
\r
605 //* \fn AT91F_PIO_SetOutput
\r
606 //* \brief Set to 1 output PIO
\r
607 //*----------------------------------------------------------------------------
\r
608 __inline void AT91F_PIO_SetOutput(
\r
609 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
610 unsigned int flag) // \arg output to be set
\r
612 pPio->PIO_SODR = flag;
\r
615 //*----------------------------------------------------------------------------
\r
616 //* \fn AT91F_PIO_ClearOutput
\r
617 //* \brief Set to 0 output PIO
\r
618 //*----------------------------------------------------------------------------
\r
619 __inline void AT91F_PIO_ClearOutput(
\r
620 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
621 unsigned int flag) // \arg output to be cleared
\r
623 pPio->PIO_CODR = flag;
\r
626 //*----------------------------------------------------------------------------
\r
627 //* \fn AT91F_PIO_ForceOutput
\r
628 //* \brief Force output when Direct drive option is enabled
\r
629 //*----------------------------------------------------------------------------
\r
630 __inline void AT91F_PIO_ForceOutput(
\r
631 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
632 unsigned int flag) // \arg output to be forced
\r
634 pPio->PIO_ODSR = flag;
\r
637 //*----------------------------------------------------------------------------
\r
638 //* \fn AT91F_PIO_Enable
\r
639 //* \brief Enable PIO
\r
640 //*----------------------------------------------------------------------------
\r
641 __inline void AT91F_PIO_Enable(
\r
642 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
643 unsigned int flag) // \arg pio to be enabled
\r
645 pPio->PIO_PER = flag;
\r
648 //*----------------------------------------------------------------------------
\r
649 //* \fn AT91F_PIO_Disable
\r
650 //* \brief Disable PIO
\r
651 //*----------------------------------------------------------------------------
\r
652 __inline void AT91F_PIO_Disable(
\r
653 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
654 unsigned int flag) // \arg pio to be disabled
\r
656 pPio->PIO_PDR = flag;
\r
659 //*----------------------------------------------------------------------------
\r
660 //* \fn AT91F_PIO_GetStatus
\r
661 //* \brief Return PIO Status
\r
662 //*----------------------------------------------------------------------------
\r
663 __inline unsigned int AT91F_PIO_GetStatus( // \return PIO Status
\r
664 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
666 return pPio->PIO_PSR;
\r
669 //*----------------------------------------------------------------------------
\r
670 //* \fn AT91F_PIO_IsSet
\r
671 //* \brief Test if PIO is Set
\r
672 //*----------------------------------------------------------------------------
\r
673 __inline int AT91F_PIO_IsSet(
\r
674 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
675 unsigned int flag) // \arg flag to be tested
\r
677 return (AT91F_PIO_GetStatus(pPio) & flag);
\r
680 //*----------------------------------------------------------------------------
\r
681 //* \fn AT91F_PIO_OutputEnable
\r
682 //* \brief Output Enable PIO
\r
683 //*----------------------------------------------------------------------------
\r
684 __inline void AT91F_PIO_OutputEnable(
\r
685 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
686 unsigned int flag) // \arg pio output to be enabled
\r
688 pPio->PIO_OER = flag;
\r
691 //*----------------------------------------------------------------------------
\r
692 //* \fn AT91F_PIO_OutputDisable
\r
693 //* \brief Output Enable PIO
\r
694 //*----------------------------------------------------------------------------
\r
695 __inline void AT91F_PIO_OutputDisable(
\r
696 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
697 unsigned int flag) // \arg pio output to be disabled
\r
699 pPio->PIO_ODR = flag;
\r
702 //*----------------------------------------------------------------------------
\r
703 //* \fn AT91F_PIO_GetOutputStatus
\r
704 //* \brief Return PIO Output Status
\r
705 //*----------------------------------------------------------------------------
\r
706 __inline unsigned int AT91F_PIO_GetOutputStatus( // \return PIO Output Status
\r
707 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
709 return pPio->PIO_OSR;
\r
712 //*----------------------------------------------------------------------------
\r
713 //* \fn AT91F_PIO_IsOuputSet
\r
714 //* \brief Test if PIO Output is Set
\r
715 //*----------------------------------------------------------------------------
\r
716 __inline int AT91F_PIO_IsOutputSet(
\r
717 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
718 unsigned int flag) // \arg flag to be tested
\r
720 return (AT91F_PIO_GetOutputStatus(pPio) & flag);
\r
723 //*----------------------------------------------------------------------------
\r
724 //* \fn AT91F_PIO_InputFilterEnable
\r
725 //* \brief Input Filter Enable PIO
\r
726 //*----------------------------------------------------------------------------
\r
727 __inline void AT91F_PIO_InputFilterEnable(
\r
728 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
729 unsigned int flag) // \arg pio input filter to be enabled
\r
731 pPio->PIO_IFER = flag;
\r
734 //*----------------------------------------------------------------------------
\r
735 //* \fn AT91F_PIO_InputFilterDisable
\r
736 //* \brief Input Filter Disable PIO
\r
737 //*----------------------------------------------------------------------------
\r
738 __inline void AT91F_PIO_InputFilterDisable(
\r
739 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
740 unsigned int flag) // \arg pio input filter to be disabled
\r
742 pPio->PIO_IFDR = flag;
\r
745 //*----------------------------------------------------------------------------
\r
746 //* \fn AT91F_PIO_GetInputFilterStatus
\r
747 //* \brief Return PIO Input Filter Status
\r
748 //*----------------------------------------------------------------------------
\r
749 __inline unsigned int AT91F_PIO_GetInputFilterStatus( // \return PIO Input Filter Status
\r
750 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
752 return pPio->PIO_IFSR;
\r
755 //*----------------------------------------------------------------------------
\r
756 //* \fn AT91F_PIO_IsInputFilterSet
\r
757 //* \brief Test if PIO Input filter is Set
\r
758 //*----------------------------------------------------------------------------
\r
759 __inline int AT91F_PIO_IsInputFilterSet(
\r
760 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
761 unsigned int flag) // \arg flag to be tested
\r
763 return (AT91F_PIO_GetInputFilterStatus(pPio) & flag);
\r
766 //*----------------------------------------------------------------------------
\r
767 //* \fn AT91F_PIO_GetOutputDataStatus
\r
768 //* \brief Return PIO Output Data Status
\r
769 //*----------------------------------------------------------------------------
\r
770 __inline unsigned int AT91F_PIO_GetOutputDataStatus( // \return PIO Output Data Status
\r
771 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
773 return pPio->PIO_ODSR;
\r
776 //*----------------------------------------------------------------------------
\r
777 //* \fn AT91F_PIO_InterruptEnable
\r
778 //* \brief Enable PIO Interrupt
\r
779 //*----------------------------------------------------------------------------
\r
780 __inline void AT91F_PIO_InterruptEnable(
\r
781 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
782 unsigned int flag) // \arg pio interrupt to be enabled
\r
784 pPio->PIO_IER = flag;
\r
787 //*----------------------------------------------------------------------------
\r
788 //* \fn AT91F_PIO_InterruptDisable
\r
789 //* \brief Disable PIO Interrupt
\r
790 //*----------------------------------------------------------------------------
\r
791 __inline void AT91F_PIO_InterruptDisable(
\r
792 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
793 unsigned int flag) // \arg pio interrupt to be disabled
\r
795 pPio->PIO_IDR = flag;
\r
798 //*----------------------------------------------------------------------------
\r
799 //* \fn AT91F_PIO_GetInterruptMaskStatus
\r
800 //* \brief Return PIO Interrupt Mask Status
\r
801 //*----------------------------------------------------------------------------
\r
802 __inline unsigned int AT91F_PIO_GetInterruptMaskStatus( // \return PIO Interrupt Mask Status
\r
803 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
805 return pPio->PIO_IMR;
\r
808 //*----------------------------------------------------------------------------
\r
809 //* \fn AT91F_PIO_GetInterruptStatus
\r
810 //* \brief Return PIO Interrupt Status
\r
811 //*----------------------------------------------------------------------------
\r
812 __inline unsigned int AT91F_PIO_GetInterruptStatus( // \return PIO Interrupt Status
\r
813 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
815 return pPio->PIO_ISR;
\r
818 //*----------------------------------------------------------------------------
\r
819 //* \fn AT91F_PIO_IsInterruptMasked
\r
820 //* \brief Test if PIO Interrupt is Masked
\r
821 //*----------------------------------------------------------------------------
\r
822 __inline int AT91F_PIO_IsInterruptMasked(
\r
823 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
824 unsigned int flag) // \arg flag to be tested
\r
826 return (AT91F_PIO_GetInterruptMaskStatus(pPio) & flag);
\r
829 //*----------------------------------------------------------------------------
\r
830 //* \fn AT91F_PIO_IsInterruptSet
\r
831 //* \brief Test if PIO Interrupt is Set
\r
832 //*----------------------------------------------------------------------------
\r
833 __inline int AT91F_PIO_IsInterruptSet(
\r
834 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
835 unsigned int flag) // \arg flag to be tested
\r
837 return (AT91F_PIO_GetInterruptStatus(pPio) & flag);
\r
840 //*----------------------------------------------------------------------------
\r
841 //* \fn AT91F_PIO_MultiDriverEnable
\r
842 //* \brief Multi Driver Enable PIO
\r
843 //*----------------------------------------------------------------------------
\r
844 __inline void AT91F_PIO_MultiDriverEnable(
\r
845 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
846 unsigned int flag) // \arg pio to be enabled
\r
848 pPio->PIO_MDER = flag;
\r
851 //*----------------------------------------------------------------------------
\r
852 //* \fn AT91F_PIO_MultiDriverDisable
\r
853 //* \brief Multi Driver Disable PIO
\r
854 //*----------------------------------------------------------------------------
\r
855 __inline void AT91F_PIO_MultiDriverDisable(
\r
856 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
857 unsigned int flag) // \arg pio to be disabled
\r
859 pPio->PIO_MDDR = flag;
\r
862 //*----------------------------------------------------------------------------
\r
863 //* \fn AT91F_PIO_GetMultiDriverStatus
\r
864 //* \brief Return PIO Multi Driver Status
\r
865 //*----------------------------------------------------------------------------
\r
866 __inline unsigned int AT91F_PIO_GetMultiDriverStatus( // \return PIO Multi Driver Status
\r
867 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
869 return pPio->PIO_MDSR;
\r
872 //*----------------------------------------------------------------------------
\r
873 //* \fn AT91F_PIO_IsMultiDriverSet
\r
874 //* \brief Test if PIO MultiDriver is Set
\r
875 //*----------------------------------------------------------------------------
\r
876 __inline int AT91F_PIO_IsMultiDriverSet(
\r
877 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
878 unsigned int flag) // \arg flag to be tested
\r
880 return (AT91F_PIO_GetMultiDriverStatus(pPio) & flag);
\r
883 //*----------------------------------------------------------------------------
\r
884 //* \fn AT91F_PIO_A_RegisterSelection
\r
885 //* \brief PIO A Register Selection
\r
886 //*----------------------------------------------------------------------------
\r
887 __inline void AT91F_PIO_A_RegisterSelection(
\r
888 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
889 unsigned int flag) // \arg pio A register selection
\r
891 pPio->PIO_ASR = flag;
\r
894 //*----------------------------------------------------------------------------
\r
895 //* \fn AT91F_PIO_B_RegisterSelection
\r
896 //* \brief PIO B Register Selection
\r
897 //*----------------------------------------------------------------------------
\r
898 __inline void AT91F_PIO_B_RegisterSelection(
\r
899 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
900 unsigned int flag) // \arg pio B register selection
\r
902 pPio->PIO_BSR = flag;
\r
905 //*----------------------------------------------------------------------------
\r
906 //* \fn AT91F_PIO_Get_AB_RegisterStatus
\r
907 //* \brief Return PIO Interrupt Status
\r
908 //*----------------------------------------------------------------------------
\r
909 __inline unsigned int AT91F_PIO_Get_AB_RegisterStatus( // \return PIO AB Register Status
\r
910 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
912 return pPio->PIO_ABSR;
\r
915 //*----------------------------------------------------------------------------
\r
916 //* \fn AT91F_PIO_IsAB_RegisterSet
\r
917 //* \brief Test if PIO AB Register is Set
\r
918 //*----------------------------------------------------------------------------
\r
919 __inline int AT91F_PIO_IsAB_RegisterSet(
\r
920 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
921 unsigned int flag) // \arg flag to be tested
\r
923 return (AT91F_PIO_Get_AB_RegisterStatus(pPio) & flag);
\r
926 //*----------------------------------------------------------------------------
\r
927 //* \fn AT91F_PIO_OutputWriteEnable
\r
928 //* \brief Output Write Enable PIO
\r
929 //*----------------------------------------------------------------------------
\r
930 __inline void AT91F_PIO_OutputWriteEnable(
\r
931 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
932 unsigned int flag) // \arg pio output write to be enabled
\r
934 pPio->PIO_OWER = flag;
\r
937 //*----------------------------------------------------------------------------
\r
938 //* \fn AT91F_PIO_OutputWriteDisable
\r
939 //* \brief Output Write Disable PIO
\r
940 //*----------------------------------------------------------------------------
\r
941 __inline void AT91F_PIO_OutputWriteDisable(
\r
942 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
943 unsigned int flag) // \arg pio output write to be disabled
\r
945 pPio->PIO_OWDR = flag;
\r
948 //*----------------------------------------------------------------------------
\r
949 //* \fn AT91F_PIO_GetOutputWriteStatus
\r
950 //* \brief Return PIO Output Write Status
\r
951 //*----------------------------------------------------------------------------
\r
952 __inline unsigned int AT91F_PIO_GetOutputWriteStatus( // \return PIO Output Write Status
\r
953 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
955 return pPio->PIO_OWSR;
\r
958 //*----------------------------------------------------------------------------
\r
959 //* \fn AT91F_PIO_IsOutputWriteSet
\r
960 //* \brief Test if PIO OutputWrite is Set
\r
961 //*----------------------------------------------------------------------------
\r
962 __inline int AT91F_PIO_IsOutputWriteSet(
\r
963 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
964 unsigned int flag) // \arg flag to be tested
\r
966 return (AT91F_PIO_GetOutputWriteStatus(pPio) & flag);
\r
969 //*----------------------------------------------------------------------------
\r
970 //* \fn AT91F_PIO_GetCfgPullup
\r
971 //* \brief Return PIO Configuration Pullup
\r
972 //*----------------------------------------------------------------------------
\r
973 __inline unsigned int AT91F_PIO_GetCfgPullup( // \return PIO Configuration Pullup
\r
974 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
976 return pPio->PIO_PPUSR;
\r
979 //*----------------------------------------------------------------------------
\r
980 //* \fn AT91F_PIO_IsOutputDataStatusSet
\r
981 //* \brief Test if PIO Output Data Status is Set
\r
982 //*----------------------------------------------------------------------------
\r
983 __inline int AT91F_PIO_IsOutputDataStatusSet(
\r
984 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
985 unsigned int flag) // \arg flag to be tested
\r
987 return (AT91F_PIO_GetOutputDataStatus(pPio) & flag);
\r
990 //*----------------------------------------------------------------------------
\r
991 //* \fn AT91F_PIO_IsCfgPullupStatusSet
\r
992 //* \brief Test if PIO Configuration Pullup Status is Set
\r
993 //*----------------------------------------------------------------------------
\r
994 __inline int AT91F_PIO_IsCfgPullupStatusSet(
\r
995 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
996 unsigned int flag) // \arg flag to be tested
\r
998 return (~AT91F_PIO_GetCfgPullup(pPio) & flag);
\r
1001 /* *****************************************************************************
\r
1002 SOFTWARE API FOR PMC
\r
1003 ***************************************************************************** */
\r
1004 //*----------------------------------------------------------------------------
\r
1005 //* \fn AT91F_PMC_CfgSysClkEnableReg
\r
1006 //* \brief Configure the System Clock Enable Register of the PMC controller
\r
1007 //*----------------------------------------------------------------------------
\r
1008 __inline void AT91F_PMC_CfgSysClkEnableReg (
\r
1009 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1010 unsigned int mode)
\r
1012 //* Write to the SCER register
\r
1013 pPMC->PMC_SCER = mode;
\r
1016 //*----------------------------------------------------------------------------
\r
1017 //* \fn AT91F_PMC_CfgSysClkDisableReg
\r
1018 //* \brief Configure the System Clock Disable Register of the PMC controller
\r
1019 //*----------------------------------------------------------------------------
\r
1020 __inline void AT91F_PMC_CfgSysClkDisableReg (
\r
1021 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1022 unsigned int mode)
\r
1024 //* Write to the SCDR register
\r
1025 pPMC->PMC_SCDR = mode;
\r
1028 //*----------------------------------------------------------------------------
\r
1029 //* \fn AT91F_PMC_GetSysClkStatusReg
\r
1030 //* \brief Return the System Clock Status Register of the PMC controller
\r
1031 //*----------------------------------------------------------------------------
\r
1032 __inline unsigned int AT91F_PMC_GetSysClkStatusReg (
\r
1033 AT91PS_PMC pPMC // pointer to a CAN controller
\r
1036 return pPMC->PMC_SCSR;
\r
1039 //*----------------------------------------------------------------------------
\r
1040 //* \fn AT91F_PMC_EnablePeriphClock
\r
1041 //* \brief Enable peripheral clock
\r
1042 //*----------------------------------------------------------------------------
\r
1043 __inline void AT91F_PMC_EnablePeriphClock (
\r
1044 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1045 unsigned int periphIds) // \arg IDs of peripherals to enable
\r
1047 pPMC->PMC_PCER = periphIds;
\r
1050 //*----------------------------------------------------------------------------
\r
1051 //* \fn AT91F_PMC_DisablePeriphClock
\r
1052 //* \brief Disable peripheral clock
\r
1053 //*----------------------------------------------------------------------------
\r
1054 __inline void AT91F_PMC_DisablePeriphClock (
\r
1055 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1056 unsigned int periphIds) // \arg IDs of peripherals to enable
\r
1058 pPMC->PMC_PCDR = periphIds;
\r
1061 //*----------------------------------------------------------------------------
\r
1062 //* \fn AT91F_PMC_GetPeriphClock
\r
1063 //* \brief Get peripheral clock status
\r
1064 //*----------------------------------------------------------------------------
\r
1065 __inline unsigned int AT91F_PMC_GetPeriphClock (
\r
1066 AT91PS_PMC pPMC) // \arg pointer to PMC controller
\r
1068 return pPMC->PMC_PCSR;
\r
1071 //*----------------------------------------------------------------------------
\r
1072 //* \fn AT91F_CKGR_CfgMainOscillatorReg
\r
1073 //* \brief Cfg the main oscillator
\r
1074 //*----------------------------------------------------------------------------
\r
1075 __inline void AT91F_CKGR_CfgMainOscillatorReg (
\r
1076 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1077 unsigned int mode)
\r
1079 pCKGR->CKGR_MOR = mode;
\r
1082 //*----------------------------------------------------------------------------
\r
1083 //* \fn AT91F_CKGR_GetMainOscillatorReg
\r
1084 //* \brief Cfg the main oscillator
\r
1085 //*----------------------------------------------------------------------------
\r
1086 __inline unsigned int AT91F_CKGR_GetMainOscillatorReg (
\r
1087 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1089 return pCKGR->CKGR_MOR;
\r
1092 //*----------------------------------------------------------------------------
\r
1093 //* \fn AT91F_CKGR_EnableMainOscillator
\r
1094 //* \brief Enable the main oscillator
\r
1095 //*----------------------------------------------------------------------------
\r
1096 __inline void AT91F_CKGR_EnableMainOscillator(
\r
1097 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1099 pCKGR->CKGR_MOR |= AT91C_CKGR_MOSCEN;
\r
1102 //*----------------------------------------------------------------------------
\r
1103 //* \fn AT91F_CKGR_DisableMainOscillator
\r
1104 //* \brief Disable the main oscillator
\r
1105 //*----------------------------------------------------------------------------
\r
1106 __inline void AT91F_CKGR_DisableMainOscillator (
\r
1107 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1109 pCKGR->CKGR_MOR &= ~AT91C_CKGR_MOSCEN;
\r
1112 //*----------------------------------------------------------------------------
\r
1113 //* \fn AT91F_CKGR_CfgMainOscStartUpTime
\r
1114 //* \brief Cfg MOR Register according to the main osc startup time
\r
1115 //*----------------------------------------------------------------------------
\r
1116 __inline void AT91F_CKGR_CfgMainOscStartUpTime (
\r
1117 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1118 unsigned int startup_time, // \arg main osc startup time in microsecond (us)
\r
1119 unsigned int slowClock) // \arg slowClock in Hz
\r
1121 pCKGR->CKGR_MOR &= ~AT91C_CKGR_OSCOUNT;
\r
1122 pCKGR->CKGR_MOR |= ((slowClock * startup_time)/(8*1000000)) << 8;
\r
1125 //*----------------------------------------------------------------------------
\r
1126 //* \fn AT91F_CKGR_GetMainClockFreqReg
\r
1127 //* \brief Cfg the main oscillator
\r
1128 //*----------------------------------------------------------------------------
\r
1129 __inline unsigned int AT91F_CKGR_GetMainClockFreqReg (
\r
1130 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1132 return pCKGR->CKGR_MCFR;
\r
1135 //*----------------------------------------------------------------------------
\r
1136 //* \fn AT91F_CKGR_GetMainClock
\r
1137 //* \brief Return Main clock in Hz
\r
1138 //*----------------------------------------------------------------------------
\r
1139 __inline unsigned int AT91F_CKGR_GetMainClock (
\r
1140 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1141 unsigned int slowClock) // \arg slowClock in Hz
\r
1143 return ((pCKGR->CKGR_MCFR & AT91C_CKGR_MAINF) * slowClock) >> 4;
\r
1146 //*----------------------------------------------------------------------------
\r
1147 //* \fn AT91F_PMC_CfgMCKReg
\r
1148 //* \brief Cfg Master Clock Register
\r
1149 //*----------------------------------------------------------------------------
\r
1150 __inline void AT91F_PMC_CfgMCKReg (
\r
1151 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1152 unsigned int mode)
\r
1154 pPMC->PMC_MCKR = mode;
\r
1157 //*----------------------------------------------------------------------------
\r
1158 //* \fn AT91F_PMC_GetMCKReg
\r
1159 //* \brief Return Master Clock Register
\r
1160 //*----------------------------------------------------------------------------
\r
1161 __inline unsigned int AT91F_PMC_GetMCKReg(
\r
1162 AT91PS_PMC pPMC) // \arg pointer to PMC controller
\r
1164 return pPMC->PMC_MCKR;
\r
1167 //*------------------------------------------------------------------------------
\r
1168 //* \fn AT91F_PMC_GetMasterClock
\r
1169 //* \brief Return master clock in Hz which correponds to processor clock for ARM7
\r
1170 //*------------------------------------------------------------------------------
\r
1171 __inline unsigned int AT91F_PMC_GetMasterClock (
\r
1172 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1173 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1174 unsigned int slowClock) // \arg slowClock in Hz
\r
1176 unsigned int reg = pPMC->PMC_MCKR;
\r
1177 unsigned int prescaler = (1 << ((reg & AT91C_PMC_PRES) >> 2));
\r
1178 unsigned int pllDivider, pllMultiplier;
\r
1180 switch (reg & AT91C_PMC_CSS) {
\r
1181 case AT91C_PMC_CSS_SLOW_CLK: // Slow clock selected
\r
1182 return slowClock / prescaler;
\r
1183 case AT91C_PMC_CSS_MAIN_CLK: // Main clock is selected
\r
1184 return AT91F_CKGR_GetMainClock(pCKGR, slowClock) / prescaler;
\r
1185 case AT91C_PMC_CSS_PLL_CLK: // PLLB clock is selected
\r
1186 reg = pCKGR->CKGR_PLLR;
\r
1187 pllDivider = (reg & AT91C_CKGR_DIV);
\r
1188 pllMultiplier = ((reg & AT91C_CKGR_MUL) >> 16) + 1;
\r
1189 return AT91F_CKGR_GetMainClock(pCKGR, slowClock) / pllDivider * pllMultiplier / prescaler;
\r
1194 //*----------------------------------------------------------------------------
\r
1195 //* \fn AT91F_PMC_EnablePCK
\r
1196 //* \brief Enable peripheral clock
\r
1197 //*----------------------------------------------------------------------------
\r
1198 __inline void AT91F_PMC_EnablePCK (
\r
1199 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1200 unsigned int pck, // \arg Peripheral clock identifier 0 .. 7
\r
1201 unsigned int mode)
\r
1203 pPMC->PMC_PCKR[pck] = mode;
\r
1204 pPMC->PMC_SCER = (1 << pck) << 8;
\r
1207 //*----------------------------------------------------------------------------
\r
1208 //* \fn AT91F_PMC_DisablePCK
\r
1209 //* \brief Enable peripheral clock
\r
1210 //*----------------------------------------------------------------------------
\r
1211 __inline void AT91F_PMC_DisablePCK (
\r
1212 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1213 unsigned int pck) // \arg Peripheral clock identifier 0 .. 7
\r
1215 pPMC->PMC_SCDR = (1 << pck) << 8;
\r
1218 //*----------------------------------------------------------------------------
\r
1219 //* \fn AT91F_PMC_EnableIt
\r
1220 //* \brief Enable PMC interrupt
\r
1221 //*----------------------------------------------------------------------------
\r
1222 __inline void AT91F_PMC_EnableIt (
\r
1223 AT91PS_PMC pPMC, // pointer to a PMC controller
\r
1224 unsigned int flag) // IT to be enabled
\r
1226 //* Write to the IER register
\r
1227 pPMC->PMC_IER = flag;
\r
1230 //*----------------------------------------------------------------------------
\r
1231 //* \fn AT91F_PMC_DisableIt
\r
1232 //* \brief Disable PMC interrupt
\r
1233 //*----------------------------------------------------------------------------
\r
1234 __inline void AT91F_PMC_DisableIt (
\r
1235 AT91PS_PMC pPMC, // pointer to a PMC controller
\r
1236 unsigned int flag) // IT to be disabled
\r
1238 //* Write to the IDR register
\r
1239 pPMC->PMC_IDR = flag;
\r
1242 //*----------------------------------------------------------------------------
\r
1243 //* \fn AT91F_PMC_GetStatus
\r
1244 //* \brief Return PMC Interrupt Status
\r
1245 //*----------------------------------------------------------------------------
\r
1246 __inline unsigned int AT91F_PMC_GetStatus( // \return PMC Interrupt Status
\r
1247 AT91PS_PMC pPMC) // pointer to a PMC controller
\r
1249 return pPMC->PMC_SR;
\r
1252 //*----------------------------------------------------------------------------
\r
1253 //* \fn AT91F_PMC_GetInterruptMaskStatus
\r
1254 //* \brief Return PMC Interrupt Mask Status
\r
1255 //*----------------------------------------------------------------------------
\r
1256 __inline unsigned int AT91F_PMC_GetInterruptMaskStatus( // \return PMC Interrupt Mask Status
\r
1257 AT91PS_PMC pPMC) // pointer to a PMC controller
\r
1259 return pPMC->PMC_IMR;
\r
1262 //*----------------------------------------------------------------------------
\r
1263 //* \fn AT91F_PMC_IsInterruptMasked
\r
1264 //* \brief Test if PMC Interrupt is Masked
\r
1265 //*----------------------------------------------------------------------------
\r
1266 __inline unsigned int AT91F_PMC_IsInterruptMasked(
\r
1267 AT91PS_PMC pPMC, // \arg pointer to a PMC controller
\r
1268 unsigned int flag) // \arg flag to be tested
\r
1270 return (AT91F_PMC_GetInterruptMaskStatus(pPMC) & flag);
\r
1273 //*----------------------------------------------------------------------------
\r
1274 //* \fn AT91F_PMC_IsStatusSet
\r
1275 //* \brief Test if PMC Status is Set
\r
1276 //*----------------------------------------------------------------------------
\r
1277 __inline unsigned int AT91F_PMC_IsStatusSet(
\r
1278 AT91PS_PMC pPMC, // \arg pointer to a PMC controller
\r
1279 unsigned int flag) // \arg flag to be tested
\r
1281 return (AT91F_PMC_GetStatus(pPMC) & flag);
\r
1282 }/* *****************************************************************************
\r
1283 SOFTWARE API FOR RSTC
\r
1284 ***************************************************************************** */
\r
1285 //*----------------------------------------------------------------------------
\r
1286 //* \fn AT91F_RSTSoftReset
\r
1287 //* \brief Start Software Reset
\r
1288 //*----------------------------------------------------------------------------
\r
1289 __inline void AT91F_RSTSoftReset(
\r
1290 AT91PS_RSTC pRSTC,
\r
1291 unsigned int reset)
\r
1293 pRSTC->RSTC_RCR = (0xA5000000 | reset);
\r
1296 //*----------------------------------------------------------------------------
\r
1297 //* \fn AT91F_RSTSetMode
\r
1298 //* \brief Set Reset Mode
\r
1299 //*----------------------------------------------------------------------------
\r
1300 __inline void AT91F_RSTSetMode(
\r
1301 AT91PS_RSTC pRSTC,
\r
1302 unsigned int mode)
\r
1304 pRSTC->RSTC_RMR = (0xA5000000 | mode);
\r
1307 //*----------------------------------------------------------------------------
\r
1308 //* \fn AT91F_RSTGetMode
\r
1309 //* \brief Get Reset Mode
\r
1310 //*----------------------------------------------------------------------------
\r
1311 __inline unsigned int AT91F_RSTGetMode(
\r
1312 AT91PS_RSTC pRSTC)
\r
1314 return (pRSTC->RSTC_RMR);
\r
1317 //*----------------------------------------------------------------------------
\r
1318 //* \fn AT91F_RSTGetStatus
\r
1319 //* \brief Get Reset Status
\r
1320 //*----------------------------------------------------------------------------
\r
1321 __inline unsigned int AT91F_RSTGetStatus(
\r
1322 AT91PS_RSTC pRSTC)
\r
1324 return (pRSTC->RSTC_RSR);
\r
1327 //*----------------------------------------------------------------------------
\r
1328 //* \fn AT91F_RSTIsSoftRstActive
\r
1329 //* \brief Return !=0 if software reset is still not completed
\r
1330 //*----------------------------------------------------------------------------
\r
1331 __inline unsigned int AT91F_RSTIsSoftRstActive(
\r
1332 AT91PS_RSTC pRSTC)
\r
1334 return ((pRSTC->RSTC_RSR) & AT91C_RSTC_SRCMP);
\r
1336 /* *****************************************************************************
\r
1337 SOFTWARE API FOR RTTC
\r
1338 ***************************************************************************** */
\r
1339 //*--------------------------------------------------------------------------------------
\r
1340 //* \fn AT91F_SetRTT_TimeBase()
\r
1341 //* \brief Set the RTT prescaler according to the TimeBase in ms
\r
1342 //*--------------------------------------------------------------------------------------
\r
1343 __inline unsigned int AT91F_RTTSetTimeBase(
\r
1344 AT91PS_RTTC pRTTC,
\r
1348 return 1; // AT91C_TIME_OUT_OF_RANGE
\r
1349 pRTTC->RTTC_RTMR &= ~0xFFFF;
\r
1350 pRTTC->RTTC_RTMR |= (((ms << 15) /1000) & 0xFFFF);
\r
1354 //*--------------------------------------------------------------------------------------
\r
1355 //* \fn AT91F_RTTSetPrescaler()
\r
1356 //* \brief Set the new prescaler value
\r
1357 //*--------------------------------------------------------------------------------------
\r
1358 __inline unsigned int AT91F_RTTSetPrescaler(
\r
1359 AT91PS_RTTC pRTTC,
\r
1360 unsigned int rtpres)
\r
1362 pRTTC->RTTC_RTMR &= ~0xFFFF;
\r
1363 pRTTC->RTTC_RTMR |= (rtpres & 0xFFFF);
\r
1364 return (pRTTC->RTTC_RTMR);
\r
1367 //*--------------------------------------------------------------------------------------
\r
1368 //* \fn AT91F_RTTRestart()
\r
1369 //* \brief Restart the RTT prescaler
\r
1370 //*--------------------------------------------------------------------------------------
\r
1371 __inline void AT91F_RTTRestart(
\r
1372 AT91PS_RTTC pRTTC)
\r
1374 pRTTC->RTTC_RTMR |= AT91C_RTTC_RTTRST;
\r
1378 //*--------------------------------------------------------------------------------------
\r
1379 //* \fn AT91F_RTT_SetAlarmINT()
\r
1380 //* \brief Enable RTT Alarm Interrupt
\r
1381 //*--------------------------------------------------------------------------------------
\r
1382 __inline void AT91F_RTTSetAlarmINT(
\r
1383 AT91PS_RTTC pRTTC)
\r
1385 pRTTC->RTTC_RTMR |= AT91C_RTTC_ALMIEN;
\r
1388 //*--------------------------------------------------------------------------------------
\r
1389 //* \fn AT91F_RTT_ClearAlarmINT()
\r
1390 //* \brief Disable RTT Alarm Interrupt
\r
1391 //*--------------------------------------------------------------------------------------
\r
1392 __inline void AT91F_RTTClearAlarmINT(
\r
1393 AT91PS_RTTC pRTTC)
\r
1395 pRTTC->RTTC_RTMR &= ~AT91C_RTTC_ALMIEN;
\r
1398 //*--------------------------------------------------------------------------------------
\r
1399 //* \fn AT91F_RTT_SetRttIncINT()
\r
1400 //* \brief Enable RTT INC Interrupt
\r
1401 //*--------------------------------------------------------------------------------------
\r
1402 __inline void AT91F_RTTSetRttIncINT(
\r
1403 AT91PS_RTTC pRTTC)
\r
1405 pRTTC->RTTC_RTMR |= AT91C_RTTC_RTTINCIEN;
\r
1408 //*--------------------------------------------------------------------------------------
\r
1409 //* \fn AT91F_RTT_ClearRttIncINT()
\r
1410 //* \brief Disable RTT INC Interrupt
\r
1411 //*--------------------------------------------------------------------------------------
\r
1412 __inline void AT91F_RTTClearRttIncINT(
\r
1413 AT91PS_RTTC pRTTC)
\r
1415 pRTTC->RTTC_RTMR &= ~AT91C_RTTC_RTTINCIEN;
\r
1418 //*--------------------------------------------------------------------------------------
\r
1419 //* \fn AT91F_RTT_SetAlarmValue()
\r
1420 //* \brief Set RTT Alarm Value
\r
1421 //*--------------------------------------------------------------------------------------
\r
1422 __inline void AT91F_RTTSetAlarmValue(
\r
1423 AT91PS_RTTC pRTTC, unsigned int alarm)
\r
1425 pRTTC->RTTC_RTAR = alarm;
\r
1428 //*--------------------------------------------------------------------------------------
\r
1429 //* \fn AT91F_RTT_GetAlarmValue()
\r
1430 //* \brief Get RTT Alarm Value
\r
1431 //*--------------------------------------------------------------------------------------
\r
1432 __inline unsigned int AT91F_RTTGetAlarmValue(
\r
1433 AT91PS_RTTC pRTTC)
\r
1435 return(pRTTC->RTTC_RTAR);
\r
1438 //*--------------------------------------------------------------------------------------
\r
1439 //* \fn AT91F_RTTGetStatus()
\r
1440 //* \brief Read the RTT status
\r
1441 //*--------------------------------------------------------------------------------------
\r
1442 __inline unsigned int AT91F_RTTGetStatus(
\r
1443 AT91PS_RTTC pRTTC)
\r
1445 return(pRTTC->RTTC_RTSR);
\r
1448 //*--------------------------------------------------------------------------------------
\r
1449 //* \fn AT91F_RTT_ReadValue()
\r
1450 //* \brief Read the RTT value
\r
1451 //*--------------------------------------------------------------------------------------
\r
1452 __inline unsigned int AT91F_RTTReadValue(
\r
1453 AT91PS_RTTC pRTTC)
\r
1455 register volatile unsigned int val1,val2;
\r
1458 val1 = pRTTC->RTTC_RTVR;
\r
1459 val2 = pRTTC->RTTC_RTVR;
\r
1461 while(val1 != val2);
\r
1464 /* *****************************************************************************
\r
1465 SOFTWARE API FOR PITC
\r
1466 ***************************************************************************** */
\r
1467 //*----------------------------------------------------------------------------
\r
1468 //* \fn AT91F_PITInit
\r
1469 //* \brief System timer init : period in µsecond, system clock freq in MHz
\r
1470 //*----------------------------------------------------------------------------
\r
1471 __inline void AT91F_PITInit(
\r
1472 AT91PS_PITC pPITC,
\r
1473 unsigned int period,
\r
1474 unsigned int pit_frequency)
\r
1476 pPITC->PITC_PIMR = period? (period * pit_frequency + 8) >> 4 : 0; // +8 to avoid %10 and /10
\r
1477 pPITC->PITC_PIMR |= AT91C_PITC_PITEN;
\r
1480 //*----------------------------------------------------------------------------
\r
1481 //* \fn AT91F_PITSetPIV
\r
1482 //* \brief Set the PIT Periodic Interval Value
\r
1483 //*----------------------------------------------------------------------------
\r
1484 __inline void AT91F_PITSetPIV(
\r
1485 AT91PS_PITC pPITC,
\r
1488 pPITC->PITC_PIMR = piv | (pPITC->PITC_PIMR & (AT91C_PITC_PITEN | AT91C_PITC_PITIEN));
\r
1491 //*----------------------------------------------------------------------------
\r
1492 //* \fn AT91F_PITEnableInt
\r
1493 //* \brief Enable PIT periodic interrupt
\r
1494 //*----------------------------------------------------------------------------
\r
1495 __inline void AT91F_PITEnableInt(
\r
1496 AT91PS_PITC pPITC)
\r
1498 pPITC->PITC_PIMR |= AT91C_PITC_PITIEN;
\r
1501 //*----------------------------------------------------------------------------
\r
1502 //* \fn AT91F_PITDisableInt
\r
1503 //* \brief Disable PIT periodic interrupt
\r
1504 //*----------------------------------------------------------------------------
\r
1505 __inline void AT91F_PITDisableInt(
\r
1506 AT91PS_PITC pPITC)
\r
1508 pPITC->PITC_PIMR &= ~AT91C_PITC_PITIEN;
\r
1511 //*----------------------------------------------------------------------------
\r
1512 //* \fn AT91F_PITGetMode
\r
1513 //* \brief Read PIT mode register
\r
1514 //*----------------------------------------------------------------------------
\r
1515 __inline unsigned int AT91F_PITGetMode(
\r
1516 AT91PS_PITC pPITC)
\r
1518 return(pPITC->PITC_PIMR);
\r
1521 //*----------------------------------------------------------------------------
\r
1522 //* \fn AT91F_PITGetStatus
\r
1523 //* \brief Read PIT status register
\r
1524 //*----------------------------------------------------------------------------
\r
1525 __inline unsigned int AT91F_PITGetStatus(
\r
1526 AT91PS_PITC pPITC)
\r
1528 return(pPITC->PITC_PISR);
\r
1531 //*----------------------------------------------------------------------------
\r
1532 //* \fn AT91F_PITGetPIIR
\r
1533 //* \brief Read PIT CPIV and PICNT without ressetting the counters
\r
1534 //*----------------------------------------------------------------------------
\r
1535 __inline unsigned int AT91F_PITGetPIIR(
\r
1536 AT91PS_PITC pPITC)
\r
1538 return(pPITC->PITC_PIIR);
\r
1541 //*----------------------------------------------------------------------------
\r
1542 //* \fn AT91F_PITGetPIVR
\r
1543 //* \brief Read System timer CPIV and PICNT without ressetting the counters
\r
1544 //*----------------------------------------------------------------------------
\r
1545 __inline unsigned int AT91F_PITGetPIVR(
\r
1546 AT91PS_PITC pPITC)
\r
1548 return(pPITC->PITC_PIVR);
\r
1550 /* *****************************************************************************
\r
1551 SOFTWARE API FOR WDTC
\r
1552 ***************************************************************************** */
\r
1553 //*----------------------------------------------------------------------------
\r
1554 //* \fn AT91F_WDTSetMode
\r
1555 //* \brief Set Watchdog Mode Register
\r
1556 //*----------------------------------------------------------------------------
\r
1557 __inline void AT91F_WDTSetMode(
\r
1558 AT91PS_WDTC pWDTC,
\r
1559 unsigned int Mode)
\r
1561 pWDTC->WDTC_WDMR = Mode;
\r
1564 //*----------------------------------------------------------------------------
\r
1565 //* \fn AT91F_WDTRestart
\r
1566 //* \brief Restart Watchdog
\r
1567 //*----------------------------------------------------------------------------
\r
1568 __inline void AT91F_WDTRestart(
\r
1569 AT91PS_WDTC pWDTC)
\r
1571 pWDTC->WDTC_WDCR = 0xA5000001;
\r
1574 //*----------------------------------------------------------------------------
\r
1575 //* \fn AT91F_WDTSGettatus
\r
1576 //* \brief Get Watchdog Status
\r
1577 //*----------------------------------------------------------------------------
\r
1578 __inline unsigned int AT91F_WDTSGettatus(
\r
1579 AT91PS_WDTC pWDTC)
\r
1581 return(pWDTC->WDTC_WDSR & 0x3);
\r
1584 //*----------------------------------------------------------------------------
\r
1585 //* \fn AT91F_WDTGetPeriod
\r
1586 //* \brief Translate ms into Watchdog Compatible value
\r
1587 //*----------------------------------------------------------------------------
\r
1588 __inline unsigned int AT91F_WDTGetPeriod(unsigned int ms)
\r
1590 if ((ms < 4) || (ms > 16000))
\r
1592 return((ms << 8) / 1000);
\r
1594 /* *****************************************************************************
\r
1595 SOFTWARE API FOR VREG
\r
1596 ***************************************************************************** */
\r
1597 //*----------------------------------------------------------------------------
\r
1598 //* \fn AT91F_VREG_Enable_LowPowerMode
\r
1599 //* \brief Enable VREG Low Power Mode
\r
1600 //*----------------------------------------------------------------------------
\r
1601 __inline void AT91F_VREG_Enable_LowPowerMode(
\r
1602 AT91PS_VREG pVREG)
\r
1604 pVREG->VREG_MR |= AT91C_VREG_PSTDBY;
\r
1607 //*----------------------------------------------------------------------------
\r
1608 //* \fn AT91F_VREG_Disable_LowPowerMode
\r
1609 //* \brief Disable VREG Low Power Mode
\r
1610 //*----------------------------------------------------------------------------
\r
1611 __inline void AT91F_VREG_Disable_LowPowerMode(
\r
1612 AT91PS_VREG pVREG)
\r
1614 pVREG->VREG_MR &= ~AT91C_VREG_PSTDBY;
\r
1615 }/* *****************************************************************************
\r
1616 SOFTWARE API FOR MC
\r
1617 ***************************************************************************** */
\r
1619 #define AT91C_MC_CORRECT_KEY ((unsigned int) 0x5A << 24) // (MC) Correct Protect Key
\r
1621 //*----------------------------------------------------------------------------
\r
1622 //* \fn AT91F_MC_Remap
\r
1623 //* \brief Make Remap
\r
1624 //*----------------------------------------------------------------------------
\r
1625 __inline void AT91F_MC_Remap (void) //
\r
1627 AT91PS_MC pMC = (AT91PS_MC) AT91C_BASE_MC;
\r
1629 pMC->MC_RCR = AT91C_MC_RCB;
\r
1632 //*----------------------------------------------------------------------------
\r
1633 //* \fn AT91F_MC_EFC_CfgModeReg
\r
1634 //* \brief Configure the EFC Mode Register of the MC controller
\r
1635 //*----------------------------------------------------------------------------
\r
1636 __inline void AT91F_MC_EFC_CfgModeReg (
\r
1637 AT91PS_MC pMC, // pointer to a MC controller
\r
1638 unsigned int mode) // mode register
\r
1640 // Write to the FMR register
\r
1641 pMC->MC_FMR = mode;
\r
1644 //*----------------------------------------------------------------------------
\r
1645 //* \fn AT91F_MC_EFC_GetModeReg
\r
1646 //* \brief Return MC EFC Mode Regsiter
\r
1647 //*----------------------------------------------------------------------------
\r
1648 __inline unsigned int AT91F_MC_EFC_GetModeReg(
\r
1649 AT91PS_MC pMC) // pointer to a MC controller
\r
1651 return pMC->MC_FMR;
\r
1654 //*----------------------------------------------------------------------------
\r
1655 //* \fn AT91F_MC_EFC_ComputeFMCN
\r
1656 //* \brief Return MC EFC Mode Regsiter
\r
1657 //*----------------------------------------------------------------------------
\r
1658 __inline unsigned int AT91F_MC_EFC_ComputeFMCN(
\r
1659 int master_clock) // master clock in Hz
\r
1661 return (master_clock/1000000 +2);
\r
1664 //*----------------------------------------------------------------------------
\r
1665 //* \fn AT91F_MC_EFC_PerformCmd
\r
1666 //* \brief Perform EFC Command
\r
1667 //*----------------------------------------------------------------------------
\r
1668 __inline void AT91F_MC_EFC_PerformCmd (
\r
1669 AT91PS_MC pMC, // pointer to a MC controller
\r
1670 unsigned int transfer_cmd)
\r
1672 pMC->MC_FCR = transfer_cmd;
\r
1675 //*----------------------------------------------------------------------------
\r
1676 //* \fn AT91F_MC_EFC_GetStatus
\r
1677 //* \brief Return MC EFC Status
\r
1678 //*----------------------------------------------------------------------------
\r
1679 __inline unsigned int AT91F_MC_EFC_GetStatus(
\r
1680 AT91PS_MC pMC) // pointer to a MC controller
\r
1682 return pMC->MC_FSR;
\r
1685 //*----------------------------------------------------------------------------
\r
1686 //* \fn AT91F_MC_EFC_IsInterruptMasked
\r
1687 //* \brief Test if EFC MC Interrupt is Masked
\r
1688 //*----------------------------------------------------------------------------
\r
1689 __inline unsigned int AT91F_MC_EFC_IsInterruptMasked(
\r
1690 AT91PS_MC pMC, // \arg pointer to a MC controller
\r
1691 unsigned int flag) // \arg flag to be tested
\r
1693 return (AT91F_MC_EFC_GetModeReg(pMC) & flag);
\r
1696 //*----------------------------------------------------------------------------
\r
1697 //* \fn AT91F_MC_EFC_IsInterruptSet
\r
1698 //* \brief Test if EFC MC Interrupt is Set
\r
1699 //*----------------------------------------------------------------------------
\r
1700 __inline unsigned int AT91F_MC_EFC_IsInterruptSet(
\r
1701 AT91PS_MC pMC, // \arg pointer to a MC controller
\r
1702 unsigned int flag) // \arg flag to be tested
\r
1704 return (AT91F_MC_EFC_GetStatus(pMC) & flag);
\r
1707 /* *****************************************************************************
\r
1708 SOFTWARE API FOR SPI
\r
1709 ***************************************************************************** */
\r
1710 //*----------------------------------------------------------------------------
\r
1711 //* \fn AT91F_SPI_Open
\r
1712 //* \brief Open a SPI Port
\r
1713 //*----------------------------------------------------------------------------
\r
1714 __inline unsigned int AT91F_SPI_Open (
\r
1715 const unsigned int null) // \arg
\r
1717 /* NOT DEFINED AT THIS MOMENT */
\r
1721 //*----------------------------------------------------------------------------
\r
1722 //* \fn AT91F_SPI_CfgCs
\r
1723 //* \brief Configure SPI chip select register
\r
1724 //*----------------------------------------------------------------------------
\r
1725 __inline void AT91F_SPI_CfgCs (
\r
1726 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
1727 int cs, // SPI cs number (0 to 3)
\r
1728 int val) // chip select register
\r
1730 //* Write to the CSR register
\r
1731 *(pSPI->SPI_CSR + cs) = val;
\r
1734 //*----------------------------------------------------------------------------
\r
1735 //* \fn AT91F_SPI_EnableIt
\r
1736 //* \brief Enable SPI interrupt
\r
1737 //*----------------------------------------------------------------------------
\r
1738 __inline void AT91F_SPI_EnableIt (
\r
1739 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
1740 unsigned int flag) // IT to be enabled
\r
1742 //* Write to the IER register
\r
1743 pSPI->SPI_IER = flag;
\r
1746 //*----------------------------------------------------------------------------
\r
1747 //* \fn AT91F_SPI_DisableIt
\r
1748 //* \brief Disable SPI interrupt
\r
1749 //*----------------------------------------------------------------------------
\r
1750 __inline void AT91F_SPI_DisableIt (
\r
1751 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
1752 unsigned int flag) // IT to be disabled
\r
1754 //* Write to the IDR register
\r
1755 pSPI->SPI_IDR = flag;
\r
1758 //*----------------------------------------------------------------------------
\r
1759 //* \fn AT91F_SPI_Reset
\r
1760 //* \brief Reset the SPI controller
\r
1761 //*----------------------------------------------------------------------------
\r
1762 __inline void AT91F_SPI_Reset (
\r
1763 AT91PS_SPI pSPI // pointer to a SPI controller
\r
1766 //* Write to the CR register
\r
1767 pSPI->SPI_CR = AT91C_SPI_SWRST;
\r
1770 //*----------------------------------------------------------------------------
\r
1771 //* \fn AT91F_SPI_Enable
\r
1772 //* \brief Enable the SPI controller
\r
1773 //*----------------------------------------------------------------------------
\r
1774 __inline void AT91F_SPI_Enable (
\r
1775 AT91PS_SPI pSPI // pointer to a SPI controller
\r
1778 //* Write to the CR register
\r
1779 pSPI->SPI_CR = AT91C_SPI_SPIEN;
\r
1782 //*----------------------------------------------------------------------------
\r
1783 //* \fn AT91F_SPI_Disable
\r
1784 //* \brief Disable the SPI controller
\r
1785 //*----------------------------------------------------------------------------
\r
1786 __inline void AT91F_SPI_Disable (
\r
1787 AT91PS_SPI pSPI // pointer to a SPI controller
\r
1790 //* Write to the CR register
\r
1791 pSPI->SPI_CR = AT91C_SPI_SPIDIS;
\r
1794 //*----------------------------------------------------------------------------
\r
1795 //* \fn AT91F_SPI_CfgMode
\r
1796 //* \brief Enable the SPI controller
\r
1797 //*----------------------------------------------------------------------------
\r
1798 __inline void AT91F_SPI_CfgMode (
\r
1799 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
1800 int mode) // mode register
\r
1802 //* Write to the MR register
\r
1803 pSPI->SPI_MR = mode;
\r
1806 //*----------------------------------------------------------------------------
\r
1807 //* \fn AT91F_SPI_CfgPCS
\r
1808 //* \brief Switch to the correct PCS of SPI Mode Register : Fixed Peripheral Selected
\r
1809 //*----------------------------------------------------------------------------
\r
1810 __inline void AT91F_SPI_CfgPCS (
\r
1811 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
1812 char PCS_Device) // PCS of the Device
\r
1814 //* Write to the MR register
\r
1815 pSPI->SPI_MR &= 0xFFF0FFFF;
\r
1816 pSPI->SPI_MR |= ( (PCS_Device<<16) & AT91C_SPI_PCS );
\r
1819 //*----------------------------------------------------------------------------
\r
1820 //* \fn AT91F_SPI_ReceiveFrame
\r
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
\r
1822 //*----------------------------------------------------------------------------
\r
1823 __inline unsigned int AT91F_SPI_ReceiveFrame (
\r
1826 unsigned int szBuffer,
\r
1827 char *pNextBuffer,
\r
1828 unsigned int szNextBuffer )
\r
1830 return AT91F_PDC_ReceiveFrame(
\r
1831 (AT91PS_PDC) &(pSPI->SPI_RPR),
\r
1838 //*----------------------------------------------------------------------------
\r
1839 //* \fn AT91F_SPI_SendFrame
\r
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
\r
1841 //*----------------------------------------------------------------------------
\r
1842 __inline unsigned int AT91F_SPI_SendFrame(
\r
1845 unsigned int szBuffer,
\r
1846 char *pNextBuffer,
\r
1847 unsigned int szNextBuffer )
\r
1849 return AT91F_PDC_SendFrame(
\r
1850 (AT91PS_PDC) &(pSPI->SPI_RPR),
\r
1857 //*----------------------------------------------------------------------------
\r
1858 //* \fn AT91F_SPI_Close
\r
1859 //* \brief Close SPI: disable IT disable transfert, close PDC
\r
1860 //*----------------------------------------------------------------------------
\r
1861 __inline void AT91F_SPI_Close (
\r
1862 AT91PS_SPI pSPI) // \arg pointer to a SPI controller
\r
1864 //* Reset all the Chip Select register
\r
1865 pSPI->SPI_CSR[0] = 0 ;
\r
1866 pSPI->SPI_CSR[1] = 0 ;
\r
1867 pSPI->SPI_CSR[2] = 0 ;
\r
1868 pSPI->SPI_CSR[3] = 0 ;
\r
1870 //* Reset the SPI mode
\r
1871 pSPI->SPI_MR = 0 ;
\r
1873 //* Disable all interrupts
\r
1874 pSPI->SPI_IDR = 0xFFFFFFFF ;
\r
1876 //* Abort the Peripheral Data Transfers
\r
1877 AT91F_PDC_Close((AT91PS_PDC) &(pSPI->SPI_RPR));
\r
1879 //* Disable receiver and transmitter and stop any activity immediately
\r
1880 pSPI->SPI_CR = AT91C_SPI_SPIDIS;
\r
1883 //*----------------------------------------------------------------------------
\r
1884 //* \fn AT91F_SPI_PutChar
\r
1885 //* \brief Send a character,does not check if ready to send
\r
1886 //*----------------------------------------------------------------------------
\r
1887 __inline void AT91F_SPI_PutChar (
\r
1889 unsigned int character,
\r
1890 unsigned int cs_number )
\r
1892 unsigned int value_for_cs;
\r
1893 value_for_cs = (~(1 << cs_number)) & 0xF; //Place a zero among a 4 ONEs number
\r
1894 pSPI->SPI_TDR = (character & 0xFFFF) | (value_for_cs << 16);
\r
1897 //*----------------------------------------------------------------------------
\r
1898 //* \fn AT91F_SPI_GetChar
\r
1899 //* \brief Receive a character,does not check if a character is available
\r
1900 //*----------------------------------------------------------------------------
\r
1901 __inline int AT91F_SPI_GetChar (
\r
1902 const AT91PS_SPI pSPI)
\r
1904 return((pSPI->SPI_RDR) & 0xFFFF);
\r
1907 //*----------------------------------------------------------------------------
\r
1908 //* \fn AT91F_SPI_GetInterruptMaskStatus
\r
1909 //* \brief Return SPI Interrupt Mask Status
\r
1910 //*----------------------------------------------------------------------------
\r
1911 __inline unsigned int AT91F_SPI_GetInterruptMaskStatus( // \return SPI Interrupt Mask Status
\r
1912 AT91PS_SPI pSpi) // \arg pointer to a SPI controller
\r
1914 return pSpi->SPI_IMR;
\r
1917 //*----------------------------------------------------------------------------
\r
1918 //* \fn AT91F_SPI_IsInterruptMasked
\r
1919 //* \brief Test if SPI Interrupt is Masked
\r
1920 //*----------------------------------------------------------------------------
\r
1921 __inline int AT91F_SPI_IsInterruptMasked(
\r
1922 AT91PS_SPI pSpi, // \arg pointer to a SPI controller
\r
1923 unsigned int flag) // \arg flag to be tested
\r
1925 return (AT91F_SPI_GetInterruptMaskStatus(pSpi) & flag);
\r
1928 /* *****************************************************************************
\r
1929 SOFTWARE API FOR USART
\r
1930 ***************************************************************************** */
\r
1931 //*----------------------------------------------------------------------------
\r
1932 //* \fn AT91F_US_Baudrate
\r
1933 //* \brief Calculate the baudrate
\r
1934 //* Standard Asynchronous Mode : 8 bits , 1 stop , no parity
\r
1935 #define AT91C_US_ASYNC_MODE ( AT91C_US_USMODE_NORMAL + \
\r
1936 AT91C_US_NBSTOP_1_BIT + \
\r
1937 AT91C_US_PAR_NONE + \
\r
1938 AT91C_US_CHRL_8_BITS + \
\r
1939 AT91C_US_CLKS_CLOCK )
\r
1941 //* Standard External Asynchronous Mode : 8 bits , 1 stop , no parity
\r
1942 #define AT91C_US_ASYNC_SCK_MODE ( AT91C_US_USMODE_NORMAL + \
\r
1943 AT91C_US_NBSTOP_1_BIT + \
\r
1944 AT91C_US_PAR_NONE + \
\r
1945 AT91C_US_CHRL_8_BITS + \
\r
1946 AT91C_US_CLKS_EXT )
\r
1948 //* Standard Synchronous Mode : 8 bits , 1 stop , no parity
\r
1949 #define AT91C_US_SYNC_MODE ( AT91C_US_SYNC + \
\r
1950 AT91C_US_USMODE_NORMAL + \
\r
1951 AT91C_US_NBSTOP_1_BIT + \
\r
1952 AT91C_US_PAR_NONE + \
\r
1953 AT91C_US_CHRL_8_BITS + \
\r
1954 AT91C_US_CLKS_CLOCK )
\r
1956 //* SCK used Label
\r
1957 #define AT91C_US_SCK_USED (AT91C_US_CKLO | AT91C_US_CLKS_EXT)
\r
1959 //* Standard ISO T=0 Mode : 8 bits , 1 stop , parity
\r
1960 #define AT91C_US_ISO_READER_MODE ( AT91C_US_USMODE_ISO7816_0 + \
\r
1961 AT91C_US_CLKS_CLOCK +\
\r
1962 AT91C_US_NBSTOP_1_BIT + \
\r
1963 AT91C_US_PAR_EVEN + \
\r
1964 AT91C_US_CHRL_8_BITS + \
\r
1968 //* Standard IRDA mode
\r
1969 #define AT91C_US_ASYNC_IRDA_MODE ( AT91C_US_USMODE_IRDA + \
\r
1970 AT91C_US_NBSTOP_1_BIT + \
\r
1971 AT91C_US_PAR_NONE + \
\r
1972 AT91C_US_CHRL_8_BITS + \
\r
1973 AT91C_US_CLKS_CLOCK )
\r
1975 //*----------------------------------------------------------------------------
\r
1976 //* \fn AT91F_US_Baudrate
\r
1977 //* \brief Caluculate baud_value according to the main clock and the baud rate
\r
1978 //*----------------------------------------------------------------------------
\r
1979 __inline unsigned int AT91F_US_Baudrate (
\r
1980 const unsigned int main_clock, // \arg peripheral clock
\r
1981 const unsigned int baud_rate) // \arg UART baudrate
\r
1983 unsigned int baud_value = ((main_clock*10)/(baud_rate * 16));
\r
1984 if ((baud_value % 10) >= 5)
\r
1985 baud_value = (baud_value / 10) + 1;
\r
1988 return baud_value;
\r
1991 //*----------------------------------------------------------------------------
\r
1992 //* \fn AT91F_US_SetBaudrate
\r
1993 //* \brief Set the baudrate according to the CPU clock
\r
1994 //*----------------------------------------------------------------------------
\r
1995 __inline void AT91F_US_SetBaudrate (
\r
1996 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
1997 unsigned int mainClock, // \arg peripheral clock
\r
1998 unsigned int speed) // \arg UART baudrate
\r
2000 //* Define the baud rate divisor register
\r
2001 pUSART->US_BRGR = AT91F_US_Baudrate(mainClock, speed);
\r
2004 //*----------------------------------------------------------------------------
\r
2005 //* \fn AT91F_US_SetTimeguard
\r
2006 //* \brief Set USART timeguard
\r
2007 //*----------------------------------------------------------------------------
\r
2008 __inline void AT91F_US_SetTimeguard (
\r
2009 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2010 unsigned int timeguard) // \arg timeguard value
\r
2012 //* Write the Timeguard Register
\r
2013 pUSART->US_TTGR = timeguard ;
\r
2016 //*----------------------------------------------------------------------------
\r
2017 //* \fn AT91F_US_EnableIt
\r
2018 //* \brief Enable USART IT
\r
2019 //*----------------------------------------------------------------------------
\r
2020 __inline void AT91F_US_EnableIt (
\r
2021 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2022 unsigned int flag) // \arg IT to be enabled
\r
2024 //* Write to the IER register
\r
2025 pUSART->US_IER = flag;
\r
2028 //*----------------------------------------------------------------------------
\r
2029 //* \fn AT91F_US_DisableIt
\r
2030 //* \brief Disable USART IT
\r
2031 //*----------------------------------------------------------------------------
\r
2032 __inline void AT91F_US_DisableIt (
\r
2033 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2034 unsigned int flag) // \arg IT to be disabled
\r
2036 //* Write to the IER register
\r
2037 pUSART->US_IDR = flag;
\r
2040 //*----------------------------------------------------------------------------
\r
2041 //* \fn AT91F_US_Configure
\r
2042 //* \brief Configure USART
\r
2043 //*----------------------------------------------------------------------------
\r
2044 __inline void AT91F_US_Configure (
\r
2045 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2046 unsigned int mainClock, // \arg peripheral clock
\r
2047 unsigned int mode , // \arg mode Register to be programmed
\r
2048 unsigned int baudRate , // \arg baudrate to be programmed
\r
2049 unsigned int timeguard ) // \arg timeguard to be programmed
\r
2051 //* Disable interrupts
\r
2052 pUSART->US_IDR = (unsigned int) -1;
\r
2054 //* Reset receiver and transmitter
\r
2055 pUSART->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS ;
\r
2057 //* Define the baud rate divisor register
\r
2058 AT91F_US_SetBaudrate(pUSART, mainClock, baudRate);
\r
2060 //* Write the Timeguard Register
\r
2061 AT91F_US_SetTimeguard(pUSART, timeguard);
\r
2063 //* Clear Transmit and Receive Counters
\r
2064 AT91F_PDC_Open((AT91PS_PDC) &(pUSART->US_RPR));
\r
2066 //* Define the USART mode
\r
2067 pUSART->US_MR = mode ;
\r
2071 //*----------------------------------------------------------------------------
\r
2072 //* \fn AT91F_US_EnableRx
\r
2073 //* \brief Enable receiving characters
\r
2074 //*----------------------------------------------------------------------------
\r
2075 __inline void AT91F_US_EnableRx (
\r
2076 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2078 //* Enable receiver
\r
2079 pUSART->US_CR = AT91C_US_RXEN;
\r
2082 //*----------------------------------------------------------------------------
\r
2083 //* \fn AT91F_US_EnableTx
\r
2084 //* \brief Enable sending characters
\r
2085 //*----------------------------------------------------------------------------
\r
2086 __inline void AT91F_US_EnableTx (
\r
2087 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2089 //* Enable transmitter
\r
2090 pUSART->US_CR = AT91C_US_TXEN;
\r
2093 //*----------------------------------------------------------------------------
\r
2094 //* \fn AT91F_US_ResetRx
\r
2095 //* \brief Reset Receiver and re-enable it
\r
2096 //*----------------------------------------------------------------------------
\r
2097 __inline void AT91F_US_ResetRx (
\r
2098 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2100 //* Reset receiver
\r
2101 pUSART->US_CR = AT91C_US_RSTRX;
\r
2102 //* Re-Enable receiver
\r
2103 pUSART->US_CR = AT91C_US_RXEN;
\r
2106 //*----------------------------------------------------------------------------
\r
2107 //* \fn AT91F_US_ResetTx
\r
2108 //* \brief Reset Transmitter and re-enable it
\r
2109 //*----------------------------------------------------------------------------
\r
2110 __inline void AT91F_US_ResetTx (
\r
2111 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2113 //* Reset transmitter
\r
2114 pUSART->US_CR = AT91C_US_RSTTX;
\r
2115 //* Enable transmitter
\r
2116 pUSART->US_CR = AT91C_US_TXEN;
\r
2119 //*----------------------------------------------------------------------------
\r
2120 //* \fn AT91F_US_DisableRx
\r
2121 //* \brief Disable Receiver
\r
2122 //*----------------------------------------------------------------------------
\r
2123 __inline void AT91F_US_DisableRx (
\r
2124 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2126 //* Disable receiver
\r
2127 pUSART->US_CR = AT91C_US_RXDIS;
\r
2130 //*----------------------------------------------------------------------------
\r
2131 //* \fn AT91F_US_DisableTx
\r
2132 //* \brief Disable Transmitter
\r
2133 //*----------------------------------------------------------------------------
\r
2134 __inline void AT91F_US_DisableTx (
\r
2135 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2137 //* Disable transmitter
\r
2138 pUSART->US_CR = AT91C_US_TXDIS;
\r
2141 //*----------------------------------------------------------------------------
\r
2142 //* \fn AT91F_US_Close
\r
2143 //* \brief Close USART: disable IT disable receiver and transmitter, close PDC
\r
2144 //*----------------------------------------------------------------------------
\r
2145 __inline void AT91F_US_Close (
\r
2146 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2148 //* Reset the baud rate divisor register
\r
2149 pUSART->US_BRGR = 0 ;
\r
2151 //* Reset the USART mode
\r
2152 pUSART->US_MR = 0 ;
\r
2154 //* Reset the Timeguard Register
\r
2155 pUSART->US_TTGR = 0;
\r
2157 //* Disable all interrupts
\r
2158 pUSART->US_IDR = 0xFFFFFFFF ;
\r
2160 //* Abort the Peripheral Data Transfers
\r
2161 AT91F_PDC_Close((AT91PS_PDC) &(pUSART->US_RPR));
\r
2163 //* Disable receiver and transmitter and stop any activity immediately
\r
2164 pUSART->US_CR = AT91C_US_TXDIS | AT91C_US_RXDIS | AT91C_US_RSTTX | AT91C_US_RSTRX ;
\r
2167 //*----------------------------------------------------------------------------
\r
2168 //* \fn AT91F_US_TxReady
\r
2169 //* \brief Return 1 if a character can be written in US_THR
\r
2170 //*----------------------------------------------------------------------------
\r
2171 __inline unsigned int AT91F_US_TxReady (
\r
2172 AT91PS_USART pUSART ) // \arg pointer to a USART controller
\r
2174 return (pUSART->US_CSR & AT91C_US_TXRDY);
\r
2177 //*----------------------------------------------------------------------------
\r
2178 //* \fn AT91F_US_RxReady
\r
2179 //* \brief Return 1 if a character can be read in US_RHR
\r
2180 //*----------------------------------------------------------------------------
\r
2181 __inline unsigned int AT91F_US_RxReady (
\r
2182 AT91PS_USART pUSART ) // \arg pointer to a USART controller
\r
2184 return (pUSART->US_CSR & AT91C_US_RXRDY);
\r
2187 //*----------------------------------------------------------------------------
\r
2188 //* \fn AT91F_US_Error
\r
2189 //* \brief Return the error flag
\r
2190 //*----------------------------------------------------------------------------
\r
2191 __inline unsigned int AT91F_US_Error (
\r
2192 AT91PS_USART pUSART ) // \arg pointer to a USART controller
\r
2194 return (pUSART->US_CSR &
\r
2195 (AT91C_US_OVRE | // Overrun error
\r
2196 AT91C_US_FRAME | // Framing error
\r
2197 AT91C_US_PARE)); // Parity error
\r
2200 //*----------------------------------------------------------------------------
\r
2201 //* \fn AT91F_US_PutChar
\r
2202 //* \brief Send a character,does not check if ready to send
\r
2203 //*----------------------------------------------------------------------------
\r
2204 __inline void AT91F_US_PutChar (
\r
2205 AT91PS_USART pUSART,
\r
2208 pUSART->US_THR = (character & 0x1FF);
\r
2211 //*----------------------------------------------------------------------------
\r
2212 //* \fn AT91F_US_GetChar
\r
2213 //* \brief Receive a character,does not check if a character is available
\r
2214 //*----------------------------------------------------------------------------
\r
2215 __inline int AT91F_US_GetChar (
\r
2216 const AT91PS_USART pUSART)
\r
2218 return((pUSART->US_RHR) & 0x1FF);
\r
2221 //*----------------------------------------------------------------------------
\r
2222 //* \fn AT91F_US_SendFrame
\r
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
\r
2224 //*----------------------------------------------------------------------------
\r
2225 __inline unsigned int AT91F_US_SendFrame(
\r
2226 AT91PS_USART pUSART,
\r
2228 unsigned int szBuffer,
\r
2229 char *pNextBuffer,
\r
2230 unsigned int szNextBuffer )
\r
2232 return AT91F_PDC_SendFrame(
\r
2233 (AT91PS_PDC) &(pUSART->US_RPR),
\r
2240 //*----------------------------------------------------------------------------
\r
2241 //* \fn AT91F_US_ReceiveFrame
\r
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
\r
2243 //*----------------------------------------------------------------------------
\r
2244 __inline unsigned int AT91F_US_ReceiveFrame (
\r
2245 AT91PS_USART pUSART,
\r
2247 unsigned int szBuffer,
\r
2248 char *pNextBuffer,
\r
2249 unsigned int szNextBuffer )
\r
2251 return AT91F_PDC_ReceiveFrame(
\r
2252 (AT91PS_PDC) &(pUSART->US_RPR),
\r
2259 //*----------------------------------------------------------------------------
\r
2260 //* \fn AT91F_US_SetIrdaFilter
\r
2261 //* \brief Set the value of IrDa filter tregister
\r
2262 //*----------------------------------------------------------------------------
\r
2263 __inline void AT91F_US_SetIrdaFilter (
\r
2264 AT91PS_USART pUSART,
\r
2265 unsigned char value
\r
2268 pUSART->US_IF = value;
\r
2271 /* *****************************************************************************
\r
2272 SOFTWARE API FOR SSC
\r
2273 ***************************************************************************** */
\r
2274 //* Define the standard I2S mode configuration
\r
2276 //* Configuration to set in the SSC Transmit Clock Mode Register
\r
2277 //* Parameters : nb_bit_by_slot : 8, 16 or 32 bits
\r
2278 //* nb_slot_by_frame : number of channels
\r
2279 #define AT91C_I2S_ASY_MASTER_TX_SETTING(nb_bit_by_slot, nb_slot_by_frame)( +\
\r
2280 AT91C_SSC_CKS_DIV +\
\r
2281 AT91C_SSC_CKO_CONTINOUS +\
\r
2282 AT91C_SSC_CKG_NONE +\
\r
2283 AT91C_SSC_START_FALL_RF +\
\r
2284 AT91C_SSC_STTOUT +\
\r
2285 ((1<<16) & AT91C_SSC_STTDLY) +\
\r
2286 ((((nb_bit_by_slot*nb_slot_by_frame)/2)-1) <<24))
\r
2289 //* Configuration to set in the SSC Transmit Frame Mode Register
\r
2290 //* Parameters : nb_bit_by_slot : 8, 16 or 32 bits
\r
2291 //* nb_slot_by_frame : number of channels
\r
2292 #define AT91C_I2S_ASY_TX_FRAME_SETTING(nb_bit_by_slot, nb_slot_by_frame)( +\
\r
2293 (nb_bit_by_slot-1) +\
\r
2295 (((nb_slot_by_frame-1)<<8) & AT91C_SSC_DATNB) +\
\r
2296 (((nb_bit_by_slot-1)<<16) & AT91C_SSC_FSLEN) +\
\r
2297 AT91C_SSC_FSOS_NEGATIVE)
\r
2300 //*----------------------------------------------------------------------------
\r
2301 //* \fn AT91F_SSC_SetBaudrate
\r
2302 //* \brief Set the baudrate according to the CPU clock
\r
2303 //*----------------------------------------------------------------------------
\r
2304 __inline void AT91F_SSC_SetBaudrate (
\r
2305 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
2306 unsigned int mainClock, // \arg peripheral clock
\r
2307 unsigned int speed) // \arg SSC baudrate
\r
2309 unsigned int baud_value;
\r
2310 //* Define the baud rate divisor register
\r
2315 baud_value = (unsigned int) (mainClock * 10)/(2*speed);
\r
2316 if ((baud_value % 10) >= 5)
\r
2317 baud_value = (baud_value / 10) + 1;
\r
2322 pSSC->SSC_CMR = baud_value;
\r
2325 //*----------------------------------------------------------------------------
\r
2326 //* \fn AT91F_SSC_Configure
\r
2327 //* \brief Configure SSC
\r
2328 //*----------------------------------------------------------------------------
\r
2329 __inline void AT91F_SSC_Configure (
\r
2330 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
2331 unsigned int syst_clock, // \arg System Clock Frequency
\r
2332 unsigned int baud_rate, // \arg Expected Baud Rate Frequency
\r
2333 unsigned int clock_rx, // \arg Receiver Clock Parameters
\r
2334 unsigned int mode_rx, // \arg mode Register to be programmed
\r
2335 unsigned int clock_tx, // \arg Transmitter Clock Parameters
\r
2336 unsigned int mode_tx) // \arg mode Register to be programmed
\r
2338 //* Disable interrupts
\r
2339 pSSC->SSC_IDR = (unsigned int) -1;
\r
2341 //* Reset receiver and transmitter
\r
2342 pSSC->SSC_CR = AT91C_SSC_SWRST | AT91C_SSC_RXDIS | AT91C_SSC_TXDIS ;
\r
2344 //* Define the Clock Mode Register
\r
2345 AT91F_SSC_SetBaudrate(pSSC, syst_clock, baud_rate);
\r
2347 //* Write the Receive Clock Mode Register
\r
2348 pSSC->SSC_RCMR = clock_rx;
\r
2350 //* Write the Transmit Clock Mode Register
\r
2351 pSSC->SSC_TCMR = clock_tx;
\r
2353 //* Write the Receive Frame Mode Register
\r
2354 pSSC->SSC_RFMR = mode_rx;
\r
2356 //* Write the Transmit Frame Mode Register
\r
2357 pSSC->SSC_TFMR = mode_tx;
\r
2359 //* Clear Transmit and Receive Counters
\r
2360 AT91F_PDC_Open((AT91PS_PDC) &(pSSC->SSC_RPR));
\r
2365 //*----------------------------------------------------------------------------
\r
2366 //* \fn AT91F_SSC_EnableRx
\r
2367 //* \brief Enable receiving datas
\r
2368 //*----------------------------------------------------------------------------
\r
2369 __inline void AT91F_SSC_EnableRx (
\r
2370 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
2372 //* Enable receiver
\r
2373 pSSC->SSC_CR = AT91C_SSC_RXEN;
\r
2376 //*----------------------------------------------------------------------------
\r
2377 //* \fn AT91F_SSC_DisableRx
\r
2378 //* \brief Disable receiving datas
\r
2379 //*----------------------------------------------------------------------------
\r
2380 __inline void AT91F_SSC_DisableRx (
\r
2381 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
2383 //* Disable receiver
\r
2384 pSSC->SSC_CR = AT91C_SSC_RXDIS;
\r
2387 //*----------------------------------------------------------------------------
\r
2388 //* \fn AT91F_SSC_EnableTx
\r
2389 //* \brief Enable sending datas
\r
2390 //*----------------------------------------------------------------------------
\r
2391 __inline void AT91F_SSC_EnableTx (
\r
2392 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
2394 //* Enable transmitter
\r
2395 pSSC->SSC_CR = AT91C_SSC_TXEN;
\r
2398 //*----------------------------------------------------------------------------
\r
2399 //* \fn AT91F_SSC_DisableTx
\r
2400 //* \brief Disable sending datas
\r
2401 //*----------------------------------------------------------------------------
\r
2402 __inline void AT91F_SSC_DisableTx (
\r
2403 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
2405 //* Disable transmitter
\r
2406 pSSC->SSC_CR = AT91C_SSC_TXDIS;
\r
2409 //*----------------------------------------------------------------------------
\r
2410 //* \fn AT91F_SSC_EnableIt
\r
2411 //* \brief Enable SSC IT
\r
2412 //*----------------------------------------------------------------------------
\r
2413 __inline void AT91F_SSC_EnableIt (
\r
2414 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
2415 unsigned int flag) // \arg IT to be enabled
\r
2417 //* Write to the IER register
\r
2418 pSSC->SSC_IER = flag;
\r
2421 //*----------------------------------------------------------------------------
\r
2422 //* \fn AT91F_SSC_DisableIt
\r
2423 //* \brief Disable SSC IT
\r
2424 //*----------------------------------------------------------------------------
\r
2425 __inline void AT91F_SSC_DisableIt (
\r
2426 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
2427 unsigned int flag) // \arg IT to be disabled
\r
2429 //* Write to the IDR register
\r
2430 pSSC->SSC_IDR = flag;
\r
2433 //*----------------------------------------------------------------------------
\r
2434 //* \fn AT91F_SSC_ReceiveFrame
\r
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
\r
2436 //*----------------------------------------------------------------------------
\r
2437 __inline unsigned int AT91F_SSC_ReceiveFrame (
\r
2440 unsigned int szBuffer,
\r
2441 char *pNextBuffer,
\r
2442 unsigned int szNextBuffer )
\r
2444 return AT91F_PDC_ReceiveFrame(
\r
2445 (AT91PS_PDC) &(pSSC->SSC_RPR),
\r
2452 //*----------------------------------------------------------------------------
\r
2453 //* \fn AT91F_SSC_SendFrame
\r
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
\r
2455 //*----------------------------------------------------------------------------
\r
2456 __inline unsigned int AT91F_SSC_SendFrame(
\r
2459 unsigned int szBuffer,
\r
2460 char *pNextBuffer,
\r
2461 unsigned int szNextBuffer )
\r
2463 return AT91F_PDC_SendFrame(
\r
2464 (AT91PS_PDC) &(pSSC->SSC_RPR),
\r
2471 //*----------------------------------------------------------------------------
\r
2472 //* \fn AT91F_SSC_GetInterruptMaskStatus
\r
2473 //* \brief Return SSC Interrupt Mask Status
\r
2474 //*----------------------------------------------------------------------------
\r
2475 __inline unsigned int AT91F_SSC_GetInterruptMaskStatus( // \return SSC Interrupt Mask Status
\r
2476 AT91PS_SSC pSsc) // \arg pointer to a SSC controller
\r
2478 return pSsc->SSC_IMR;
\r
2481 //*----------------------------------------------------------------------------
\r
2482 //* \fn AT91F_SSC_IsInterruptMasked
\r
2483 //* \brief Test if SSC Interrupt is Masked
\r
2484 //*----------------------------------------------------------------------------
\r
2485 __inline int AT91F_SSC_IsInterruptMasked(
\r
2486 AT91PS_SSC pSsc, // \arg pointer to a SSC controller
\r
2487 unsigned int flag) // \arg flag to be tested
\r
2489 return (AT91F_SSC_GetInterruptMaskStatus(pSsc) & flag);
\r
2492 /* *****************************************************************************
\r
2493 SOFTWARE API FOR TWI
\r
2494 ***************************************************************************** */
\r
2495 //*----------------------------------------------------------------------------
\r
2496 //* \fn AT91F_TWI_EnableIt
\r
2497 //* \brief Enable TWI IT
\r
2498 //*----------------------------------------------------------------------------
\r
2499 __inline void AT91F_TWI_EnableIt (
\r
2500 AT91PS_TWI pTWI, // \arg pointer to a TWI controller
\r
2501 unsigned int flag) // \arg IT to be enabled
\r
2503 //* Write to the IER register
\r
2504 pTWI->TWI_IER = flag;
\r
2507 //*----------------------------------------------------------------------------
\r
2508 //* \fn AT91F_TWI_DisableIt
\r
2509 //* \brief Disable TWI IT
\r
2510 //*----------------------------------------------------------------------------
\r
2511 __inline void AT91F_TWI_DisableIt (
\r
2512 AT91PS_TWI pTWI, // \arg pointer to a TWI controller
\r
2513 unsigned int flag) // \arg IT to be disabled
\r
2515 //* Write to the IDR register
\r
2516 pTWI->TWI_IDR = flag;
\r
2519 //*----------------------------------------------------------------------------
\r
2520 //* \fn AT91F_TWI_Configure
\r
2521 //* \brief Configure TWI in master mode
\r
2522 //*----------------------------------------------------------------------------
\r
2523 __inline void AT91F_TWI_Configure ( AT91PS_TWI pTWI ) // \arg pointer to a TWI controller
\r
2525 //* Disable interrupts
\r
2526 pTWI->TWI_IDR = (unsigned int) -1;
\r
2528 //* Reset peripheral
\r
2529 pTWI->TWI_CR = AT91C_TWI_SWRST;
\r
2531 //* Set Master mode
\r
2532 pTWI->TWI_CR = AT91C_TWI_MSEN;
\r
2536 //*----------------------------------------------------------------------------
\r
2537 //* \fn AT91F_TWI_GetInterruptMaskStatus
\r
2538 //* \brief Return TWI Interrupt Mask Status
\r
2539 //*----------------------------------------------------------------------------
\r
2540 __inline unsigned int AT91F_TWI_GetInterruptMaskStatus( // \return TWI Interrupt Mask Status
\r
2541 AT91PS_TWI pTwi) // \arg pointer to a TWI controller
\r
2543 return pTwi->TWI_IMR;
\r
2546 //*----------------------------------------------------------------------------
\r
2547 //* \fn AT91F_TWI_IsInterruptMasked
\r
2548 //* \brief Test if TWI Interrupt is Masked
\r
2549 //*----------------------------------------------------------------------------
\r
2550 __inline int AT91F_TWI_IsInterruptMasked(
\r
2551 AT91PS_TWI pTwi, // \arg pointer to a TWI controller
\r
2552 unsigned int flag) // \arg flag to be tested
\r
2554 return (AT91F_TWI_GetInterruptMaskStatus(pTwi) & flag);
\r
2557 /* *****************************************************************************
\r
2558 SOFTWARE API FOR PWMC
\r
2559 ***************************************************************************** */
\r
2560 //*----------------------------------------------------------------------------
\r
2561 //* \fn AT91F_PWM_GetStatus
\r
2562 //* \brief Return PWM Interrupt Status
\r
2563 //*----------------------------------------------------------------------------
\r
2564 __inline unsigned int AT91F_PWMC_GetStatus( // \return PWM Interrupt Status
\r
2565 AT91PS_PWMC pPWM) // pointer to a PWM controller
\r
2567 return pPWM->PWMC_SR;
\r
2570 //*----------------------------------------------------------------------------
\r
2571 //* \fn AT91F_PWM_InterruptEnable
\r
2572 //* \brief Enable PWM Interrupt
\r
2573 //*----------------------------------------------------------------------------
\r
2574 __inline void AT91F_PWMC_InterruptEnable(
\r
2575 AT91PS_PWMC pPwm, // \arg pointer to a PWM controller
\r
2576 unsigned int flag) // \arg PWM interrupt to be enabled
\r
2578 pPwm->PWMC_IER = flag;
\r
2581 //*----------------------------------------------------------------------------
\r
2582 //* \fn AT91F_PWM_InterruptDisable
\r
2583 //* \brief Disable PWM Interrupt
\r
2584 //*----------------------------------------------------------------------------
\r
2585 __inline void AT91F_PWMC_InterruptDisable(
\r
2586 AT91PS_PWMC pPwm, // \arg pointer to a PWM controller
\r
2587 unsigned int flag) // \arg PWM interrupt to be disabled
\r
2589 pPwm->PWMC_IDR = flag;
\r
2592 //*----------------------------------------------------------------------------
\r
2593 //* \fn AT91F_PWM_GetInterruptMaskStatus
\r
2594 //* \brief Return PWM Interrupt Mask Status
\r
2595 //*----------------------------------------------------------------------------
\r
2596 __inline unsigned int AT91F_PWMC_GetInterruptMaskStatus( // \return PWM Interrupt Mask Status
\r
2597 AT91PS_PWMC pPwm) // \arg pointer to a PWM controller
\r
2599 return pPwm->PWMC_IMR;
\r
2602 //*----------------------------------------------------------------------------
\r
2603 //* \fn AT91F_PWM_IsInterruptMasked
\r
2604 //* \brief Test if PWM Interrupt is Masked
\r
2605 //*----------------------------------------------------------------------------
\r
2606 __inline unsigned int AT91F_PWMC_IsInterruptMasked(
\r
2607 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
2608 unsigned int flag) // \arg flag to be tested
\r
2610 return (AT91F_PWMC_GetInterruptMaskStatus(pPWM) & flag);
\r
2613 //*----------------------------------------------------------------------------
\r
2614 //* \fn AT91F_PWM_IsStatusSet
\r
2615 //* \brief Test if PWM Interrupt is Set
\r
2616 //*----------------------------------------------------------------------------
\r
2617 __inline unsigned int AT91F_PWMC_IsStatusSet(
\r
2618 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
2619 unsigned int flag) // \arg flag to be tested
\r
2621 return (AT91F_PWMC_GetStatus(pPWM) & flag);
\r
2624 //*----------------------------------------------------------------------------
\r
2625 //* \fn AT91F_PWM_CfgChannel
\r
2626 //* \brief Test if PWM Interrupt is Set
\r
2627 //*----------------------------------------------------------------------------
\r
2628 __inline void AT91F_PWMC_CfgChannel(
\r
2629 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
2630 unsigned int channelId, // \arg PWM channel ID
\r
2631 unsigned int mode, // \arg PWM mode
\r
2632 unsigned int period, // \arg PWM period
\r
2633 unsigned int duty) // \arg PWM duty cycle
\r
2635 pPWM->PWMC_CH[channelId].PWMC_CMR = mode;
\r
2636 pPWM->PWMC_CH[channelId].PWMC_CDTYR = duty;
\r
2637 pPWM->PWMC_CH[channelId].PWMC_CPRDR = period;
\r
2640 //*----------------------------------------------------------------------------
\r
2641 //* \fn AT91F_PWM_StartChannel
\r
2642 //* \brief Enable channel
\r
2643 //*----------------------------------------------------------------------------
\r
2644 __inline void AT91F_PWMC_StartChannel(
\r
2645 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
2646 unsigned int flag) // \arg Channels IDs to be enabled
\r
2648 pPWM->PWMC_ENA = flag;
\r
2651 //*----------------------------------------------------------------------------
\r
2652 //* \fn AT91F_PWM_StopChannel
\r
2653 //* \brief Disable channel
\r
2654 //*----------------------------------------------------------------------------
\r
2655 __inline void AT91F_PWMC_StopChannel(
\r
2656 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
2657 unsigned int flag) // \arg Channels IDs to be enabled
\r
2659 pPWM->PWMC_DIS = flag;
\r
2662 //*----------------------------------------------------------------------------
\r
2663 //* \fn AT91F_PWM_UpdateChannel
\r
2664 //* \brief Update Period or Duty Cycle
\r
2665 //*----------------------------------------------------------------------------
\r
2666 __inline void AT91F_PWMC_UpdateChannel(
\r
2667 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
2668 unsigned int channelId, // \arg PWM channel ID
\r
2669 unsigned int update) // \arg Channels IDs to be enabled
\r
2671 pPWM->PWMC_CH[channelId].PWMC_CUPDR = update;
\r
2674 /* *****************************************************************************
\r
2675 SOFTWARE API FOR UDP
\r
2676 ***************************************************************************** */
\r
2677 //*----------------------------------------------------------------------------
\r
2678 //* \fn AT91F_UDP_EnableIt
\r
2679 //* \brief Enable UDP IT
\r
2680 //*----------------------------------------------------------------------------
\r
2681 __inline void AT91F_UDP_EnableIt (
\r
2682 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2683 unsigned int flag) // \arg IT to be enabled
\r
2685 //* Write to the IER register
\r
2686 pUDP->UDP_IER = flag;
\r
2689 //*----------------------------------------------------------------------------
\r
2690 //* \fn AT91F_UDP_DisableIt
\r
2691 //* \brief Disable UDP IT
\r
2692 //*----------------------------------------------------------------------------
\r
2693 __inline void AT91F_UDP_DisableIt (
\r
2694 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2695 unsigned int flag) // \arg IT to be disabled
\r
2697 //* Write to the IDR register
\r
2698 pUDP->UDP_IDR = flag;
\r
2701 //*----------------------------------------------------------------------------
\r
2702 //* \fn AT91F_UDP_SetAddress
\r
2703 //* \brief Set UDP functional address
\r
2704 //*----------------------------------------------------------------------------
\r
2705 __inline void AT91F_UDP_SetAddress (
\r
2706 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2707 unsigned char address) // \arg new UDP address
\r
2709 pUDP->UDP_FADDR = (AT91C_UDP_FEN | address);
\r
2712 //*----------------------------------------------------------------------------
\r
2713 //* \fn AT91F_UDP_EnableEp
\r
2714 //* \brief Enable Endpoint
\r
2715 //*----------------------------------------------------------------------------
\r
2716 __inline void AT91F_UDP_EnableEp (
\r
2717 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2718 unsigned char endpoint) // \arg endpoint number
\r
2720 pUDP->UDP_CSR[endpoint] |= AT91C_UDP_EPEDS;
\r
2723 //*----------------------------------------------------------------------------
\r
2724 //* \fn AT91F_UDP_DisableEp
\r
2725 //* \brief Enable Endpoint
\r
2726 //*----------------------------------------------------------------------------
\r
2727 __inline void AT91F_UDP_DisableEp (
\r
2728 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2729 unsigned char endpoint) // \arg endpoint number
\r
2731 pUDP->UDP_CSR[endpoint] &= ~AT91C_UDP_EPEDS;
\r
2734 //*----------------------------------------------------------------------------
\r
2735 //* \fn AT91F_UDP_SetState
\r
2736 //* \brief Set UDP Device state
\r
2737 //*----------------------------------------------------------------------------
\r
2738 __inline void AT91F_UDP_SetState (
\r
2739 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2740 unsigned int flag) // \arg new UDP address
\r
2742 pUDP->UDP_GLBSTATE &= ~(AT91C_UDP_FADDEN | AT91C_UDP_CONFG);
\r
2743 pUDP->UDP_GLBSTATE |= flag;
\r
2746 //*----------------------------------------------------------------------------
\r
2747 //* \fn AT91F_UDP_GetState
\r
2748 //* \brief return UDP Device state
\r
2749 //*----------------------------------------------------------------------------
\r
2750 __inline unsigned int AT91F_UDP_GetState ( // \return the UDP device state
\r
2751 AT91PS_UDP pUDP) // \arg pointer to a UDP controller
\r
2753 return (pUDP->UDP_GLBSTATE & (AT91C_UDP_FADDEN | AT91C_UDP_CONFG));
\r
2756 //*----------------------------------------------------------------------------
\r
2757 //* \fn AT91F_UDP_ResetEp
\r
2758 //* \brief Reset UDP endpoint
\r
2759 //*----------------------------------------------------------------------------
\r
2760 __inline void AT91F_UDP_ResetEp ( // \return the UDP device state
\r
2761 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2762 unsigned int flag) // \arg Endpoints to be reset
\r
2764 pUDP->UDP_RSTEP = flag;
\r
2765 pUDP->UDP_RSTEP = 0;
\r
2768 //*----------------------------------------------------------------------------
\r
2769 //* \fn AT91F_UDP_EpStall
\r
2770 //* \brief Endpoint will STALL requests
\r
2771 //*----------------------------------------------------------------------------
\r
2772 __inline void AT91F_UDP_EpStall(
\r
2773 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2774 unsigned char endpoint) // \arg endpoint number
\r
2776 pUDP->UDP_CSR[endpoint] |= AT91C_UDP_FORCESTALL;
\r
2779 //*----------------------------------------------------------------------------
\r
2780 //* \fn AT91F_UDP_EpWrite
\r
2781 //* \brief Write value in the DPR
\r
2782 //*----------------------------------------------------------------------------
\r
2783 __inline void AT91F_UDP_EpWrite(
\r
2784 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2785 unsigned char endpoint, // \arg endpoint number
\r
2786 unsigned char value) // \arg value to be written in the DPR
\r
2788 pUDP->UDP_FDR[endpoint] = value;
\r
2791 //*----------------------------------------------------------------------------
\r
2792 //* \fn AT91F_UDP_EpRead
\r
2793 //* \brief Return value from the DPR
\r
2794 //*----------------------------------------------------------------------------
\r
2795 __inline unsigned int AT91F_UDP_EpRead(
\r
2796 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2797 unsigned char endpoint) // \arg endpoint number
\r
2799 return pUDP->UDP_FDR[endpoint];
\r
2802 //*----------------------------------------------------------------------------
\r
2803 //* \fn AT91F_UDP_EpEndOfWr
\r
2804 //* \brief Notify the UDP that values in DPR are ready to be sent
\r
2805 //*----------------------------------------------------------------------------
\r
2806 __inline void AT91F_UDP_EpEndOfWr(
\r
2807 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2808 unsigned char endpoint) // \arg endpoint number
\r
2810 pUDP->UDP_CSR[endpoint] |= AT91C_UDP_TXPKTRDY;
\r
2813 //*----------------------------------------------------------------------------
\r
2814 //* \fn AT91F_UDP_EpClear
\r
2815 //* \brief Clear flag in the endpoint CSR register
\r
2816 //*----------------------------------------------------------------------------
\r
2817 __inline void AT91F_UDP_EpClear(
\r
2818 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2819 unsigned char endpoint, // \arg endpoint number
\r
2820 unsigned int flag) // \arg flag to be cleared
\r
2822 pUDP->UDP_CSR[endpoint] &= ~(flag);
\r
2825 //*----------------------------------------------------------------------------
\r
2826 //* \fn AT91F_UDP_EpSet
\r
2827 //* \brief Set flag in the endpoint CSR register
\r
2828 //*----------------------------------------------------------------------------
\r
2829 __inline void AT91F_UDP_EpSet(
\r
2830 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2831 unsigned char endpoint, // \arg endpoint number
\r
2832 unsigned int flag) // \arg flag to be cleared
\r
2834 pUDP->UDP_CSR[endpoint] |= flag;
\r
2837 //*----------------------------------------------------------------------------
\r
2838 //* \fn AT91F_UDP_EpStatus
\r
2839 //* \brief Return the endpoint CSR register
\r
2840 //*----------------------------------------------------------------------------
\r
2841 __inline unsigned int AT91F_UDP_EpStatus(
\r
2842 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2843 unsigned char endpoint) // \arg endpoint number
\r
2845 return pUDP->UDP_CSR[endpoint];
\r
2848 //*----------------------------------------------------------------------------
\r
2849 //* \fn AT91F_UDP_GetInterruptMaskStatus
\r
2850 //* \brief Return UDP Interrupt Mask Status
\r
2851 //*----------------------------------------------------------------------------
\r
2852 __inline unsigned int AT91F_UDP_GetInterruptMaskStatus( // \return UDP Interrupt Mask Status
\r
2853 AT91PS_UDP pUdp) // \arg pointer to a UDP controller
\r
2855 return pUdp->UDP_IMR;
\r
2858 //*----------------------------------------------------------------------------
\r
2859 //* \fn AT91F_UDP_IsInterruptMasked
\r
2860 //* \brief Test if UDP Interrupt is Masked
\r
2861 //*----------------------------------------------------------------------------
\r
2862 __inline int AT91F_UDP_IsInterruptMasked(
\r
2863 AT91PS_UDP pUdp, // \arg pointer to a UDP controller
\r
2864 unsigned int flag) // \arg flag to be tested
\r
2866 return (AT91F_UDP_GetInterruptMaskStatus(pUdp) & flag);
\r
2869 /* *****************************************************************************
\r
2870 SOFTWARE API FOR TC
\r
2871 ***************************************************************************** */
\r
2872 //*----------------------------------------------------------------------------
\r
2873 //* \fn AT91F_TC_InterruptEnable
\r
2874 //* \brief Enable TC Interrupt
\r
2875 //*----------------------------------------------------------------------------
\r
2876 __inline void AT91F_TC_InterruptEnable(
\r
2877 AT91PS_TC pTc, // \arg pointer to a TC controller
\r
2878 unsigned int flag) // \arg TC interrupt to be enabled
\r
2880 pTc->TC_IER = flag;
\r
2883 //*----------------------------------------------------------------------------
\r
2884 //* \fn AT91F_TC_InterruptDisable
\r
2885 //* \brief Disable TC Interrupt
\r
2886 //*----------------------------------------------------------------------------
\r
2887 __inline void AT91F_TC_InterruptDisable(
\r
2888 AT91PS_TC pTc, // \arg pointer to a TC controller
\r
2889 unsigned int flag) // \arg TC interrupt to be disabled
\r
2891 pTc->TC_IDR = flag;
\r
2894 //*----------------------------------------------------------------------------
\r
2895 //* \fn AT91F_TC_GetInterruptMaskStatus
\r
2896 //* \brief Return TC Interrupt Mask Status
\r
2897 //*----------------------------------------------------------------------------
\r
2898 __inline unsigned int AT91F_TC_GetInterruptMaskStatus( // \return TC Interrupt Mask Status
\r
2899 AT91PS_TC pTc) // \arg pointer to a TC controller
\r
2901 return pTc->TC_IMR;
\r
2904 //*----------------------------------------------------------------------------
\r
2905 //* \fn AT91F_TC_IsInterruptMasked
\r
2906 //* \brief Test if TC Interrupt is Masked
\r
2907 //*----------------------------------------------------------------------------
\r
2908 __inline int AT91F_TC_IsInterruptMasked(
\r
2909 AT91PS_TC pTc, // \arg pointer to a TC controller
\r
2910 unsigned int flag) // \arg flag to be tested
\r
2912 return (AT91F_TC_GetInterruptMaskStatus(pTc) & flag);
\r
2915 /* *****************************************************************************
\r
2916 SOFTWARE API FOR CAN
\r
2917 ***************************************************************************** */
\r
2918 #define STANDARD_FORMAT 0
\r
2919 #define EXTENDED_FORMAT 1
\r
2921 //*----------------------------------------------------------------------------
\r
2922 //* \fn AT91F_InitMailboxRegisters()
\r
2923 //* \brief Configure the corresponding mailbox
\r
2924 //*----------------------------------------------------------------------------
\r
2925 __inline void AT91F_InitMailboxRegisters(AT91PS_CAN_MB CAN_Mailbox,
\r
2927 int acceptance_mask_reg,
\r
2930 int data_high_reg,
\r
2933 CAN_Mailbox->CAN_MB_MCR = 0x0;
\r
2934 CAN_Mailbox->CAN_MB_MMR = mode_reg;
\r
2935 CAN_Mailbox->CAN_MB_MAM = acceptance_mask_reg;
\r
2936 CAN_Mailbox->CAN_MB_MID = id_reg;
\r
2937 CAN_Mailbox->CAN_MB_MDL = data_low_reg;
\r
2938 CAN_Mailbox->CAN_MB_MDH = data_high_reg;
\r
2939 CAN_Mailbox->CAN_MB_MCR = control_reg;
\r
2942 //*----------------------------------------------------------------------------
\r
2943 //* \fn AT91F_EnableCAN()
\r
2945 //*----------------------------------------------------------------------------
\r
2946 __inline void AT91F_EnableCAN(
\r
2947 AT91PS_CAN pCAN) // pointer to a CAN controller
\r
2949 pCAN->CAN_MR |= AT91C_CAN_CANEN;
\r
2951 // Wait for WAKEUP flag raising <=> 11-recessive-bit were scanned by the transceiver
\r
2952 while( (pCAN->CAN_SR & AT91C_CAN_WAKEUP) != AT91C_CAN_WAKEUP );
\r
2955 //*----------------------------------------------------------------------------
\r
2956 //* \fn AT91F_DisableCAN()
\r
2958 //*----------------------------------------------------------------------------
\r
2959 __inline void AT91F_DisableCAN(
\r
2960 AT91PS_CAN pCAN) // pointer to a CAN controller
\r
2962 pCAN->CAN_MR &= ~AT91C_CAN_CANEN;
\r
2965 //*----------------------------------------------------------------------------
\r
2966 //* \fn AT91F_CAN_EnableIt
\r
2967 //* \brief Enable CAN interrupt
\r
2968 //*----------------------------------------------------------------------------
\r
2969 __inline void AT91F_CAN_EnableIt (
\r
2970 AT91PS_CAN pCAN, // pointer to a CAN controller
\r
2971 unsigned int flag) // IT to be enabled
\r
2973 //* Write to the IER register
\r
2974 pCAN->CAN_IER = flag;
\r
2977 //*----------------------------------------------------------------------------
\r
2978 //* \fn AT91F_CAN_DisableIt
\r
2979 //* \brief Disable CAN interrupt
\r
2980 //*----------------------------------------------------------------------------
\r
2981 __inline void AT91F_CAN_DisableIt (
\r
2982 AT91PS_CAN pCAN, // pointer to a CAN controller
\r
2983 unsigned int flag) // IT to be disabled
\r
2985 //* Write to the IDR register
\r
2986 pCAN->CAN_IDR = flag;
\r
2989 //*----------------------------------------------------------------------------
\r
2990 //* \fn AT91F_CAN_GetStatus
\r
2991 //* \brief Return CAN Interrupt Status
\r
2992 //*----------------------------------------------------------------------------
\r
2993 __inline unsigned int AT91F_CAN_GetStatus( // \return CAN Interrupt Status
\r
2994 AT91PS_CAN pCAN) // pointer to a CAN controller
\r
2996 return pCAN->CAN_SR;
\r
2999 //*----------------------------------------------------------------------------
\r
3000 //* \fn AT91F_CAN_GetInterruptMaskStatus
\r
3001 //* \brief Return CAN Interrupt Mask Status
\r
3002 //*----------------------------------------------------------------------------
\r
3003 __inline unsigned int AT91F_CAN_GetInterruptMaskStatus( // \return CAN Interrupt Mask Status
\r
3004 AT91PS_CAN pCAN) // pointer to a CAN controller
\r
3006 return pCAN->CAN_IMR;
\r
3009 //*----------------------------------------------------------------------------
\r
3010 //* \fn AT91F_CAN_IsInterruptMasked
\r
3011 //* \brief Test if CAN Interrupt is Masked
\r
3012 //*----------------------------------------------------------------------------
\r
3013 __inline unsigned int AT91F_CAN_IsInterruptMasked(
\r
3014 AT91PS_CAN pCAN, // \arg pointer to a CAN controller
\r
3015 unsigned int flag) // \arg flag to be tested
\r
3017 return (AT91F_CAN_GetInterruptMaskStatus(pCAN) & flag);
\r
3020 //*----------------------------------------------------------------------------
\r
3021 //* \fn AT91F_CAN_IsStatusSet
\r
3022 //* \brief Test if CAN Interrupt is Set
\r
3023 //*----------------------------------------------------------------------------
\r
3024 __inline unsigned int AT91F_CAN_IsStatusSet(
\r
3025 AT91PS_CAN pCAN, // \arg pointer to a CAN controller
\r
3026 unsigned int flag) // \arg flag to be tested
\r
3028 return (AT91F_CAN_GetStatus(pCAN) & flag);
\r
3031 //*----------------------------------------------------------------------------
\r
3032 //* \fn AT91F_CAN_CfgModeReg
\r
3033 //* \brief Configure the Mode Register of the CAN controller
\r
3034 //*----------------------------------------------------------------------------
\r
3035 __inline void AT91F_CAN_CfgModeReg (
\r
3036 AT91PS_CAN pCAN, // pointer to a CAN controller
\r
3037 unsigned int mode) // mode register
\r
3039 //* Write to the MR register
\r
3040 pCAN->CAN_MR = mode;
\r
3043 //*----------------------------------------------------------------------------
\r
3044 //* \fn AT91F_CAN_GetModeReg
\r
3045 //* \brief Return the Mode Register of the CAN controller value
\r
3046 //*----------------------------------------------------------------------------
\r
3047 __inline unsigned int AT91F_CAN_GetModeReg (
\r
3048 AT91PS_CAN pCAN // pointer to a CAN controller
\r
3051 return pCAN->CAN_MR;
\r
3054 //*----------------------------------------------------------------------------
\r
3055 //* \fn AT91F_CAN_CfgBaudrateReg
\r
3056 //* \brief Configure the Baudrate of the CAN controller for the network
\r
3057 //*----------------------------------------------------------------------------
\r
3058 __inline void AT91F_CAN_CfgBaudrateReg (
\r
3059 AT91PS_CAN pCAN, // pointer to a CAN controller
\r
3060 unsigned int baudrate_cfg)
\r
3062 //* Write to the BR register
\r
3063 pCAN->CAN_BR = baudrate_cfg;
\r
3066 //*----------------------------------------------------------------------------
\r
3067 //* \fn AT91F_CAN_GetBaudrate
\r
3068 //* \brief Return the Baudrate of the CAN controller for the network value
\r
3069 //*----------------------------------------------------------------------------
\r
3070 __inline unsigned int AT91F_CAN_GetBaudrate (
\r
3071 AT91PS_CAN pCAN // pointer to a CAN controller
\r
3074 return pCAN->CAN_BR;
\r
3077 //*----------------------------------------------------------------------------
\r
3078 //* \fn AT91F_CAN_GetInternalCounter
\r
3079 //* \brief Return CAN Timer Regsiter Value
\r
3080 //*----------------------------------------------------------------------------
\r
3081 __inline unsigned int AT91F_CAN_GetInternalCounter (
\r
3082 AT91PS_CAN pCAN // pointer to a CAN controller
\r
3085 return pCAN->CAN_TIM;
\r
3088 //*----------------------------------------------------------------------------
\r
3089 //* \fn AT91F_CAN_GetTimestamp
\r
3090 //* \brief Return CAN Timestamp Register Value
\r
3091 //*----------------------------------------------------------------------------
\r
3092 __inline unsigned int AT91F_CAN_GetTimestamp (
\r
3093 AT91PS_CAN pCAN // pointer to a CAN controller
\r
3096 return pCAN->CAN_TIMESTP;
\r
3099 //*----------------------------------------------------------------------------
\r
3100 //* \fn AT91F_CAN_GetErrorCounter
\r
3101 //* \brief Return CAN Error Counter Register Value
\r
3102 //*----------------------------------------------------------------------------
\r
3103 __inline unsigned int AT91F_CAN_GetErrorCounter (
\r
3104 AT91PS_CAN pCAN // pointer to a CAN controller
\r
3107 return pCAN->CAN_ECR;
\r
3110 //*----------------------------------------------------------------------------
\r
3111 //* \fn AT91F_CAN_InitTransferRequest
\r
3112 //* \brief Request for a transfer on the corresponding mailboxes
\r
3113 //*----------------------------------------------------------------------------
\r
3114 __inline void AT91F_CAN_InitTransferRequest (
\r
3115 AT91PS_CAN pCAN, // pointer to a CAN controller
\r
3116 unsigned int transfer_cmd)
\r
3118 pCAN->CAN_TCR = transfer_cmd;
\r
3121 //*----------------------------------------------------------------------------
\r
3122 //* \fn AT91F_CAN_InitAbortRequest
\r
3123 //* \brief Abort the corresponding mailboxes
\r
3124 //*----------------------------------------------------------------------------
\r
3125 __inline void AT91F_CAN_InitAbortRequest (
\r
3126 AT91PS_CAN pCAN, // pointer to a CAN controller
\r
3127 unsigned int abort_cmd)
\r
3129 pCAN->CAN_ACR = abort_cmd;
\r
3132 //*----------------------------------------------------------------------------
\r
3133 //* \fn AT91F_CAN_CfgMessageModeReg
\r
3134 //* \brief Program the Message Mode Register
\r
3135 //*----------------------------------------------------------------------------
\r
3136 __inline void AT91F_CAN_CfgMessageModeReg (
\r
3137 AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
\r
3138 unsigned int mode)
\r
3140 CAN_Mailbox->CAN_MB_MMR = mode;
\r
3143 //*----------------------------------------------------------------------------
\r
3144 //* \fn AT91F_CAN_GetMessageModeReg
\r
3145 //* \brief Return the Message Mode Register
\r
3146 //*----------------------------------------------------------------------------
\r
3147 __inline unsigned int AT91F_CAN_GetMessageModeReg (
\r
3148 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3150 return CAN_Mailbox->CAN_MB_MMR;
\r
3153 //*----------------------------------------------------------------------------
\r
3154 //* \fn AT91F_CAN_CfgMessageIDReg
\r
3155 //* \brief Program the Message ID Register
\r
3156 //* \brief Version == 0 for Standard messsage, Version == 1 for Extended
\r
3157 //*----------------------------------------------------------------------------
\r
3158 __inline void AT91F_CAN_CfgMessageIDReg (
\r
3159 AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
\r
3161 unsigned char version)
\r
3163 if(version==0) // IDvA Standard Format
\r
3164 CAN_Mailbox->CAN_MB_MID = id<<18;
\r
3165 else // IDvB Extended Format
\r
3166 CAN_Mailbox->CAN_MB_MID = id | (1<<29); // set MIDE bit
\r
3169 //*----------------------------------------------------------------------------
\r
3170 //* \fn AT91F_CAN_GetMessageIDReg
\r
3171 //* \brief Return the Message ID Register
\r
3172 //*----------------------------------------------------------------------------
\r
3173 __inline unsigned int AT91F_CAN_GetMessageIDReg (
\r
3174 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3176 return CAN_Mailbox->CAN_MB_MID;
\r
3179 //*----------------------------------------------------------------------------
\r
3180 //* \fn AT91F_CAN_CfgMessageAcceptanceMaskReg
\r
3181 //* \brief Program the Message Acceptance Mask Register
\r
3182 //*----------------------------------------------------------------------------
\r
3183 __inline void AT91F_CAN_CfgMessageAcceptanceMaskReg (
\r
3184 AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
\r
3185 unsigned int mask)
\r
3187 CAN_Mailbox->CAN_MB_MAM = mask;
\r
3190 //*----------------------------------------------------------------------------
\r
3191 //* \fn AT91F_CAN_GetMessageAcceptanceMaskReg
\r
3192 //* \brief Return the Message Acceptance Mask Register
\r
3193 //*----------------------------------------------------------------------------
\r
3194 __inline unsigned int AT91F_CAN_GetMessageAcceptanceMaskReg (
\r
3195 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3197 return CAN_Mailbox->CAN_MB_MAM;
\r
3200 //*----------------------------------------------------------------------------
\r
3201 //* \fn AT91F_CAN_GetFamilyID
\r
3202 //* \brief Return the Message ID Register
\r
3203 //*----------------------------------------------------------------------------
\r
3204 __inline unsigned int AT91F_CAN_GetFamilyID (
\r
3205 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3207 return CAN_Mailbox->CAN_MB_MFID;
\r
3210 //*----------------------------------------------------------------------------
\r
3211 //* \fn AT91F_CAN_CfgMessageCtrl
\r
3212 //* \brief Request and config for a transfer on the corresponding mailbox
\r
3213 //*----------------------------------------------------------------------------
\r
3214 __inline void AT91F_CAN_CfgMessageCtrlReg (
\r
3215 AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
\r
3216 unsigned int message_ctrl_cmd)
\r
3218 CAN_Mailbox->CAN_MB_MCR = message_ctrl_cmd;
\r
3221 //*----------------------------------------------------------------------------
\r
3222 //* \fn AT91F_CAN_GetMessageStatus
\r
3223 //* \brief Return CAN Mailbox Status
\r
3224 //*----------------------------------------------------------------------------
\r
3225 __inline unsigned int AT91F_CAN_GetMessageStatus (
\r
3226 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3228 return CAN_Mailbox->CAN_MB_MSR;
\r
3231 //*----------------------------------------------------------------------------
\r
3232 //* \fn AT91F_CAN_CfgMessageDataLow
\r
3233 //* \brief Program data low value
\r
3234 //*----------------------------------------------------------------------------
\r
3235 __inline void AT91F_CAN_CfgMessageDataLow (
\r
3236 AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
\r
3237 unsigned int data)
\r
3239 CAN_Mailbox->CAN_MB_MDL = data;
\r
3242 //*----------------------------------------------------------------------------
\r
3243 //* \fn AT91F_CAN_GetMessageDataLow
\r
3244 //* \brief Return data low value
\r
3245 //*----------------------------------------------------------------------------
\r
3246 __inline unsigned int AT91F_CAN_GetMessageDataLow (
\r
3247 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3249 return CAN_Mailbox->CAN_MB_MDL;
\r
3252 //*----------------------------------------------------------------------------
\r
3253 //* \fn AT91F_CAN_CfgMessageDataHigh
\r
3254 //* \brief Program data high value
\r
3255 //*----------------------------------------------------------------------------
\r
3256 __inline void AT91F_CAN_CfgMessageDataHigh (
\r
3257 AT91PS_CAN_MB CAN_Mailbox, // pointer to a CAN Mailbox
\r
3258 unsigned int data)
\r
3260 CAN_Mailbox->CAN_MB_MDH = data;
\r
3263 //*----------------------------------------------------------------------------
\r
3264 //* \fn AT91F_CAN_GetMessageDataHigh
\r
3265 //* \brief Return data high value
\r
3266 //*----------------------------------------------------------------------------
\r
3267 __inline unsigned int AT91F_CAN_GetMessageDataHigh (
\r
3268 AT91PS_CAN_MB CAN_Mailbox) // pointer to a CAN Mailbox
\r
3270 return CAN_Mailbox->CAN_MB_MDH;
\r
3273 //*----------------------------------------------------------------------------
\r
3274 //* \fn AT91F_CAN_Open
\r
3275 //* \brief Open a CAN Port
\r
3276 //*----------------------------------------------------------------------------
\r
3277 __inline unsigned int AT91F_CAN_Open (
\r
3278 const unsigned int null) // \arg
\r
3280 /* NOT DEFINED AT THIS MOMENT */
\r
3283 /* *****************************************************************************
\r
3284 SOFTWARE API FOR ADC
\r
3285 ***************************************************************************** */
\r
3286 //*----------------------------------------------------------------------------
\r
3287 //* \fn AT91F_ADC_EnableIt
\r
3288 //* \brief Enable ADC interrupt
\r
3289 //*----------------------------------------------------------------------------
\r
3290 __inline void AT91F_ADC_EnableIt (
\r
3291 AT91PS_ADC pADC, // pointer to a ADC controller
\r
3292 unsigned int flag) // IT to be enabled
\r
3294 //* Write to the IER register
\r
3295 pADC->ADC_IER = flag;
\r
3298 //*----------------------------------------------------------------------------
\r
3299 //* \fn AT91F_ADC_DisableIt
\r
3300 //* \brief Disable ADC interrupt
\r
3301 //*----------------------------------------------------------------------------
\r
3302 __inline void AT91F_ADC_DisableIt (
\r
3303 AT91PS_ADC pADC, // pointer to a ADC controller
\r
3304 unsigned int flag) // IT to be disabled
\r
3306 //* Write to the IDR register
\r
3307 pADC->ADC_IDR = flag;
\r
3310 //*----------------------------------------------------------------------------
\r
3311 //* \fn AT91F_ADC_GetStatus
\r
3312 //* \brief Return ADC Interrupt Status
\r
3313 //*----------------------------------------------------------------------------
\r
3314 __inline unsigned int AT91F_ADC_GetStatus( // \return ADC Interrupt Status
\r
3315 AT91PS_ADC pADC) // pointer to a ADC controller
\r
3317 return pADC->ADC_SR;
\r
3320 //*----------------------------------------------------------------------------
\r
3321 //* \fn AT91F_ADC_GetInterruptMaskStatus
\r
3322 //* \brief Return ADC Interrupt Mask Status
\r
3323 //*----------------------------------------------------------------------------
\r
3324 __inline unsigned int AT91F_ADC_GetInterruptMaskStatus( // \return ADC Interrupt Mask Status
\r
3325 AT91PS_ADC pADC) // pointer to a ADC controller
\r
3327 return pADC->ADC_IMR;
\r
3330 //*----------------------------------------------------------------------------
\r
3331 //* \fn AT91F_ADC_IsInterruptMasked
\r
3332 //* \brief Test if ADC Interrupt is Masked
\r
3333 //*----------------------------------------------------------------------------
\r
3334 __inline unsigned int AT91F_ADC_IsInterruptMasked(
\r
3335 AT91PS_ADC pADC, // \arg pointer to a ADC controller
\r
3336 unsigned int flag) // \arg flag to be tested
\r
3338 return (AT91F_ADC_GetInterruptMaskStatus(pADC) & flag);
\r
3341 //*----------------------------------------------------------------------------
\r
3342 //* \fn AT91F_ADC_IsStatusSet
\r
3343 //* \brief Test if ADC Status is Set
\r
3344 //*----------------------------------------------------------------------------
\r
3345 __inline unsigned int AT91F_ADC_IsStatusSet(
\r
3346 AT91PS_ADC pADC, // \arg pointer to a ADC controller
\r
3347 unsigned int flag) // \arg flag to be tested
\r
3349 return (AT91F_ADC_GetStatus(pADC) & flag);
\r
3352 //*----------------------------------------------------------------------------
\r
3353 //* \fn AT91F_ADC_CfgModeReg
\r
3354 //* \brief Configure the Mode Register of the ADC controller
\r
3355 //*----------------------------------------------------------------------------
\r
3356 __inline void AT91F_ADC_CfgModeReg (
\r
3357 AT91PS_ADC pADC, // pointer to a ADC controller
\r
3358 unsigned int mode) // mode register
\r
3360 //* Write to the MR register
\r
3361 pADC->ADC_MR = mode;
\r
3364 //*----------------------------------------------------------------------------
\r
3365 //* \fn AT91F_ADC_GetModeReg
\r
3366 //* \brief Return the Mode Register of the ADC controller value
\r
3367 //*----------------------------------------------------------------------------
\r
3368 __inline unsigned int AT91F_ADC_GetModeReg (
\r
3369 AT91PS_ADC pADC // pointer to a ADC controller
\r
3372 return pADC->ADC_MR;
\r
3375 //*----------------------------------------------------------------------------
\r
3376 //* \fn AT91F_ADC_CfgTimings
\r
3377 //* \brief Configure the different necessary timings of the ADC controller
\r
3378 //*----------------------------------------------------------------------------
\r
3379 __inline void AT91F_ADC_CfgTimings (
\r
3380 AT91PS_ADC pADC, // pointer to a ADC controller
\r
3381 unsigned int mck_clock, // in MHz
\r
3382 unsigned int adc_clock, // in MHz
\r
3383 unsigned int startup_time, // in us
\r
3384 unsigned int sample_and_hold_time) // in ns
\r
3386 unsigned int prescal,startup,shtim;
\r
3388 prescal = mck_clock/(2*adc_clock) - 1;
\r
3389 startup = adc_clock*startup_time/8 - 1;
\r
3390 shtim = adc_clock*sample_and_hold_time/1000 - 1;
\r
3392 //* Write to the MR register
\r
3393 pADC->ADC_MR = ( (prescal<<8) & AT91C_ADC_PRESCAL) | ( (startup<<16) & AT91C_ADC_STARTUP) | ( (shtim<<24) & AT91C_ADC_SHTIM);
\r
3396 //*----------------------------------------------------------------------------
\r
3397 //* \fn AT91F_ADC_EnableChannel
\r
3398 //* \brief Return ADC Timer Register Value
\r
3399 //*----------------------------------------------------------------------------
\r
3400 __inline void AT91F_ADC_EnableChannel (
\r
3401 AT91PS_ADC pADC, // pointer to a ADC controller
\r
3402 unsigned int channel) // mode register
\r
3404 //* Write to the CHER register
\r
3405 pADC->ADC_CHER = channel;
\r
3408 //*----------------------------------------------------------------------------
\r
3409 //* \fn AT91F_ADC_DisableChannel
\r
3410 //* \brief Return ADC Timer Register Value
\r
3411 //*----------------------------------------------------------------------------
\r
3412 __inline void AT91F_ADC_DisableChannel (
\r
3413 AT91PS_ADC pADC, // pointer to a ADC controller
\r
3414 unsigned int channel) // mode register
\r
3416 //* Write to the CHDR register
\r
3417 pADC->ADC_CHDR = channel;
\r
3420 //*----------------------------------------------------------------------------
\r
3421 //* \fn AT91F_ADC_GetChannelStatus
\r
3422 //* \brief Return ADC Timer Register Value
\r
3423 //*----------------------------------------------------------------------------
\r
3424 __inline unsigned int AT91F_ADC_GetChannelStatus (
\r
3425 AT91PS_ADC pADC // pointer to a ADC controller
\r
3428 return pADC->ADC_CHSR;
\r
3431 //*----------------------------------------------------------------------------
\r
3432 //* \fn AT91F_ADC_StartConversion
\r
3433 //* \brief Software request for a analog to digital conversion
\r
3434 //*----------------------------------------------------------------------------
\r
3435 __inline void AT91F_ADC_StartConversion (
\r
3436 AT91PS_ADC pADC // pointer to a ADC controller
\r
3439 pADC->ADC_CR = AT91C_ADC_START;
\r
3442 //*----------------------------------------------------------------------------
\r
3443 //* \fn AT91F_ADC_SoftReset
\r
3444 //* \brief Software reset
\r
3445 //*----------------------------------------------------------------------------
\r
3446 __inline void AT91F_ADC_SoftReset (
\r
3447 AT91PS_ADC pADC // pointer to a ADC controller
\r
3450 pADC->ADC_CR = AT91C_ADC_SWRST;
\r
3453 //*----------------------------------------------------------------------------
\r
3454 //* \fn AT91F_ADC_GetLastConvertedData
\r
3455 //* \brief Return the Last Converted Data
\r
3456 //*----------------------------------------------------------------------------
\r
3457 __inline unsigned int AT91F_ADC_GetLastConvertedData (
\r
3458 AT91PS_ADC pADC // pointer to a ADC controller
\r
3461 return pADC->ADC_LCDR;
\r
3464 //*----------------------------------------------------------------------------
\r
3465 //* \fn AT91F_ADC_GetConvertedDataCH0
\r
3466 //* \brief Return the Channel 0 Converted Data
\r
3467 //*----------------------------------------------------------------------------
\r
3468 __inline unsigned int AT91F_ADC_GetConvertedDataCH0 (
\r
3469 AT91PS_ADC pADC // pointer to a ADC controller
\r
3472 return pADC->ADC_CDR0;
\r
3475 //*----------------------------------------------------------------------------
\r
3476 //* \fn AT91F_ADC_GetConvertedDataCH1
\r
3477 //* \brief Return the Channel 1 Converted Data
\r
3478 //*----------------------------------------------------------------------------
\r
3479 __inline unsigned int AT91F_ADC_GetConvertedDataCH1 (
\r
3480 AT91PS_ADC pADC // pointer to a ADC controller
\r
3483 return pADC->ADC_CDR1;
\r
3486 //*----------------------------------------------------------------------------
\r
3487 //* \fn AT91F_ADC_GetConvertedDataCH2
\r
3488 //* \brief Return the Channel 2 Converted Data
\r
3489 //*----------------------------------------------------------------------------
\r
3490 __inline unsigned int AT91F_ADC_GetConvertedDataCH2 (
\r
3491 AT91PS_ADC pADC // pointer to a ADC controller
\r
3494 return pADC->ADC_CDR2;
\r
3497 //*----------------------------------------------------------------------------
\r
3498 //* \fn AT91F_ADC_GetConvertedDataCH3
\r
3499 //* \brief Return the Channel 3 Converted Data
\r
3500 //*----------------------------------------------------------------------------
\r
3501 __inline unsigned int AT91F_ADC_GetConvertedDataCH3 (
\r
3502 AT91PS_ADC pADC // pointer to a ADC controller
\r
3505 return pADC->ADC_CDR3;
\r
3508 //*----------------------------------------------------------------------------
\r
3509 //* \fn AT91F_ADC_GetConvertedDataCH4
\r
3510 //* \brief Return the Channel 4 Converted Data
\r
3511 //*----------------------------------------------------------------------------
\r
3512 __inline unsigned int AT91F_ADC_GetConvertedDataCH4 (
\r
3513 AT91PS_ADC pADC // pointer to a ADC controller
\r
3516 return pADC->ADC_CDR4;
\r
3519 //*----------------------------------------------------------------------------
\r
3520 //* \fn AT91F_ADC_GetConvertedDataCH5
\r
3521 //* \brief Return the Channel 5 Converted Data
\r
3522 //*----------------------------------------------------------------------------
\r
3523 __inline unsigned int AT91F_ADC_GetConvertedDataCH5 (
\r
3524 AT91PS_ADC pADC // pointer to a ADC controller
\r
3527 return pADC->ADC_CDR5;
\r
3530 //*----------------------------------------------------------------------------
\r
3531 //* \fn AT91F_ADC_GetConvertedDataCH6
\r
3532 //* \brief Return the Channel 6 Converted Data
\r
3533 //*----------------------------------------------------------------------------
\r
3534 __inline unsigned int AT91F_ADC_GetConvertedDataCH6 (
\r
3535 AT91PS_ADC pADC // pointer to a ADC controller
\r
3538 return pADC->ADC_CDR6;
\r
3541 //*----------------------------------------------------------------------------
\r
3542 //* \fn AT91F_ADC_GetConvertedDataCH7
\r
3543 //* \brief Return the Channel 7 Converted Data
\r
3544 //*----------------------------------------------------------------------------
\r
3545 __inline unsigned int AT91F_ADC_GetConvertedDataCH7 (
\r
3546 AT91PS_ADC pADC // pointer to a ADC controller
\r
3549 return pADC->ADC_CDR7;
\r
3552 /* *****************************************************************************
\r
3553 SOFTWARE API FOR AES
\r
3554 ***************************************************************************** */
\r
3555 //*----------------------------------------------------------------------------
\r
3556 //* \fn AT91F_AES_EnableIt
\r
3557 //* \brief Enable AES interrupt
\r
3558 //*----------------------------------------------------------------------------
\r
3559 __inline void AT91F_AES_EnableIt (
\r
3560 AT91PS_AES pAES, // pointer to a AES controller
\r
3561 unsigned int flag) // IT to be enabled
\r
3563 //* Write to the IER register
\r
3564 pAES->AES_IER = flag;
\r
3567 //*----------------------------------------------------------------------------
\r
3568 //* \fn AT91F_AES_DisableIt
\r
3569 //* \brief Disable AES interrupt
\r
3570 //*----------------------------------------------------------------------------
\r
3571 __inline void AT91F_AES_DisableIt (
\r
3572 AT91PS_AES pAES, // pointer to a AES controller
\r
3573 unsigned int flag) // IT to be disabled
\r
3575 //* Write to the IDR register
\r
3576 pAES->AES_IDR = flag;
\r
3579 //*----------------------------------------------------------------------------
\r
3580 //* \fn AT91F_AES_GetStatus
\r
3581 //* \brief Return AES Interrupt Status
\r
3582 //*----------------------------------------------------------------------------
\r
3583 __inline unsigned int AT91F_AES_GetStatus( // \return AES Interrupt Status
\r
3584 AT91PS_AES pAES) // pointer to a AES controller
\r
3586 return pAES->AES_ISR;
\r
3589 //*----------------------------------------------------------------------------
\r
3590 //* \fn AT91F_AES_GetInterruptMaskStatus
\r
3591 //* \brief Return AES Interrupt Mask Status
\r
3592 //*----------------------------------------------------------------------------
\r
3593 __inline unsigned int AT91F_AES_GetInterruptMaskStatus( // \return AES Interrupt Mask Status
\r
3594 AT91PS_AES pAES) // pointer to a AES controller
\r
3596 return pAES->AES_IMR;
\r
3599 //*----------------------------------------------------------------------------
\r
3600 //* \fn AT91F_AES_IsInterruptMasked
\r
3601 //* \brief Test if AES Interrupt is Masked
\r
3602 //*----------------------------------------------------------------------------
\r
3603 __inline unsigned int AT91F_AES_IsInterruptMasked(
\r
3604 AT91PS_AES pAES, // \arg pointer to a AES controller
\r
3605 unsigned int flag) // \arg flag to be tested
\r
3607 return (AT91F_AES_GetInterruptMaskStatus(pAES) & flag);
\r
3610 //*----------------------------------------------------------------------------
\r
3611 //* \fn AT91F_AES_IsStatusSet
\r
3612 //* \brief Test if AES Status is Set
\r
3613 //*----------------------------------------------------------------------------
\r
3614 __inline unsigned int AT91F_AES_IsStatusSet(
\r
3615 AT91PS_AES pAES, // \arg pointer to a AES controller
\r
3616 unsigned int flag) // \arg flag to be tested
\r
3618 return (AT91F_AES_GetStatus(pAES) & flag);
\r
3621 //*----------------------------------------------------------------------------
\r
3622 //* \fn AT91F_AES_CfgModeReg
\r
3623 //* \brief Configure the Mode Register of the AES controller
\r
3624 //*----------------------------------------------------------------------------
\r
3625 __inline void AT91F_AES_CfgModeReg (
\r
3626 AT91PS_AES pAES, // pointer to a AES controller
\r
3627 unsigned int mode) // mode register
\r
3629 //* Write to the MR register
\r
3630 pAES->AES_MR = mode;
\r
3633 //*----------------------------------------------------------------------------
\r
3634 //* \fn AT91F_AES_GetModeReg
\r
3635 //* \brief Return the Mode Register of the AES controller value
\r
3636 //*----------------------------------------------------------------------------
\r
3637 __inline unsigned int AT91F_AES_GetModeReg (
\r
3638 AT91PS_AES pAES // pointer to a AES controller
\r
3641 return pAES->AES_MR;
\r
3644 //*----------------------------------------------------------------------------
\r
3645 //* \fn AT91F_AES_StartProcessing
\r
3646 //* \brief Start Encryption or Decryption
\r
3647 //*----------------------------------------------------------------------------
\r
3648 __inline void AT91F_AES_StartProcessing (
\r
3649 AT91PS_AES pAES // pointer to a AES controller
\r
3652 pAES->AES_CR = AT91C_AES_START;
\r
3655 //*----------------------------------------------------------------------------
\r
3656 //* \fn AT91F_AES_SoftReset
\r
3657 //* \brief Reset AES
\r
3658 //*----------------------------------------------------------------------------
\r
3659 __inline void AT91F_AES_SoftReset (
\r
3660 AT91PS_AES pAES // pointer to a AES controller
\r
3663 pAES->AES_CR = AT91C_AES_SWRST;
\r
3666 //*----------------------------------------------------------------------------
\r
3667 //* \fn AT91F_AES_LoadNewSeed
\r
3668 //* \brief Load New Seed in the random number generator
\r
3669 //*----------------------------------------------------------------------------
\r
3670 __inline void AT91F_AES_LoadNewSeed (
\r
3671 AT91PS_AES pAES // pointer to a AES controller
\r
3674 pAES->AES_CR = AT91C_AES_LOADSEED;
\r
3677 //*----------------------------------------------------------------------------
\r
3678 //* \fn AT91F_AES_SetCryptoKey
\r
3679 //* \brief Set Cryptographic Key x
\r
3680 //*----------------------------------------------------------------------------
\r
3681 __inline void AT91F_AES_SetCryptoKey (
\r
3682 AT91PS_AES pAES, // pointer to a AES controller
\r
3683 unsigned char index,
\r
3684 unsigned int keyword
\r
3687 pAES->AES_KEYWxR[index] = keyword;
\r
3690 //*----------------------------------------------------------------------------
\r
3691 //* \fn AT91F_AES_InputData
\r
3692 //* \brief Set Input Data x
\r
3693 //*----------------------------------------------------------------------------
\r
3694 __inline void AT91F_AES_InputData (
\r
3695 AT91PS_AES pAES, // pointer to a AES controller
\r
3696 unsigned char index,
\r
3697 unsigned int indata
\r
3700 pAES->AES_IDATAxR[index] = indata;
\r
3703 //*----------------------------------------------------------------------------
\r
3704 //* \fn AT91F_AES_GetOutputData
\r
3705 //* \brief Get Output Data x
\r
3706 //*----------------------------------------------------------------------------
\r
3707 __inline unsigned int AT91F_AES_GetOutputData (
\r
3708 AT91PS_AES pAES, // pointer to a AES controller
\r
3709 unsigned char index
\r
3712 return pAES->AES_ODATAxR[index];
\r
3715 //*----------------------------------------------------------------------------
\r
3716 //* \fn AT91F_AES_SetInitializationVector
\r
3717 //* \brief Set Initialization Vector (or Counter) x
\r
3718 //*----------------------------------------------------------------------------
\r
3719 __inline void AT91F_AES_SetInitializationVector (
\r
3720 AT91PS_AES pAES, // pointer to a AES controller
\r
3721 unsigned char index,
\r
3722 unsigned int initvector
\r
3725 pAES->AES_IVxR[index] = initvector;
\r
3728 /* *****************************************************************************
\r
3729 SOFTWARE API FOR TDES
\r
3730 ***************************************************************************** */
\r
3731 //*----------------------------------------------------------------------------
\r
3732 //* \fn AT91F_TDES_EnableIt
\r
3733 //* \brief Enable TDES interrupt
\r
3734 //*----------------------------------------------------------------------------
\r
3735 __inline void AT91F_TDES_EnableIt (
\r
3736 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3737 unsigned int flag) // IT to be enabled
\r
3739 //* Write to the IER register
\r
3740 pTDES->TDES_IER = flag;
\r
3743 //*----------------------------------------------------------------------------
\r
3744 //* \fn AT91F_TDES_DisableIt
\r
3745 //* \brief Disable TDES interrupt
\r
3746 //*----------------------------------------------------------------------------
\r
3747 __inline void AT91F_TDES_DisableIt (
\r
3748 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3749 unsigned int flag) // IT to be disabled
\r
3751 //* Write to the IDR register
\r
3752 pTDES->TDES_IDR = flag;
\r
3755 //*----------------------------------------------------------------------------
\r
3756 //* \fn AT91F_TDES_GetStatus
\r
3757 //* \brief Return TDES Interrupt Status
\r
3758 //*----------------------------------------------------------------------------
\r
3759 __inline unsigned int AT91F_TDES_GetStatus( // \return TDES Interrupt Status
\r
3760 AT91PS_TDES pTDES) // pointer to a TDES controller
\r
3762 return pTDES->TDES_ISR;
\r
3765 //*----------------------------------------------------------------------------
\r
3766 //* \fn AT91F_TDES_GetInterruptMaskStatus
\r
3767 //* \brief Return TDES Interrupt Mask Status
\r
3768 //*----------------------------------------------------------------------------
\r
3769 __inline unsigned int AT91F_TDES_GetInterruptMaskStatus( // \return TDES Interrupt Mask Status
\r
3770 AT91PS_TDES pTDES) // pointer to a TDES controller
\r
3772 return pTDES->TDES_IMR;
\r
3775 //*----------------------------------------------------------------------------
\r
3776 //* \fn AT91F_TDES_IsInterruptMasked
\r
3777 //* \brief Test if TDES Interrupt is Masked
\r
3778 //*----------------------------------------------------------------------------
\r
3779 __inline unsigned int AT91F_TDES_IsInterruptMasked(
\r
3780 AT91PS_TDES pTDES, // \arg pointer to a TDES controller
\r
3781 unsigned int flag) // \arg flag to be tested
\r
3783 return (AT91F_TDES_GetInterruptMaskStatus(pTDES) & flag);
\r
3786 //*----------------------------------------------------------------------------
\r
3787 //* \fn AT91F_TDES_IsStatusSet
\r
3788 //* \brief Test if TDES Status is Set
\r
3789 //*----------------------------------------------------------------------------
\r
3790 __inline unsigned int AT91F_TDES_IsStatusSet(
\r
3791 AT91PS_TDES pTDES, // \arg pointer to a TDES controller
\r
3792 unsigned int flag) // \arg flag to be tested
\r
3794 return (AT91F_TDES_GetStatus(pTDES) & flag);
\r
3797 //*----------------------------------------------------------------------------
\r
3798 //* \fn AT91F_TDES_CfgModeReg
\r
3799 //* \brief Configure the Mode Register of the TDES controller
\r
3800 //*----------------------------------------------------------------------------
\r
3801 __inline void AT91F_TDES_CfgModeReg (
\r
3802 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3803 unsigned int mode) // mode register
\r
3805 //* Write to the MR register
\r
3806 pTDES->TDES_MR = mode;
\r
3809 //*----------------------------------------------------------------------------
\r
3810 //* \fn AT91F_TDES_GetModeReg
\r
3811 //* \brief Return the Mode Register of the TDES controller value
\r
3812 //*----------------------------------------------------------------------------
\r
3813 __inline unsigned int AT91F_TDES_GetModeReg (
\r
3814 AT91PS_TDES pTDES // pointer to a TDES controller
\r
3817 return pTDES->TDES_MR;
\r
3820 //*----------------------------------------------------------------------------
\r
3821 //* \fn AT91F_TDES_StartProcessing
\r
3822 //* \brief Start Encryption or Decryption
\r
3823 //*----------------------------------------------------------------------------
\r
3824 __inline void AT91F_TDES_StartProcessing (
\r
3825 AT91PS_TDES pTDES // pointer to a TDES controller
\r
3828 pTDES->TDES_CR = AT91C_TDES_START;
\r
3831 //*----------------------------------------------------------------------------
\r
3832 //* \fn AT91F_TDES_SoftReset
\r
3833 //* \brief Reset TDES
\r
3834 //*----------------------------------------------------------------------------
\r
3835 __inline void AT91F_TDES_SoftReset (
\r
3836 AT91PS_TDES pTDES // pointer to a TDES controller
\r
3839 pTDES->TDES_CR = AT91C_TDES_SWRST;
\r
3842 //*----------------------------------------------------------------------------
\r
3843 //* \fn AT91F_TDES_SetCryptoKey1
\r
3844 //* \brief Set Cryptographic Key 1 Word x
\r
3845 //*----------------------------------------------------------------------------
\r
3846 __inline void AT91F_TDES_SetCryptoKey1 (
\r
3847 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3848 unsigned char index,
\r
3849 unsigned int keyword
\r
3852 pTDES->TDES_KEY1WxR[index] = keyword;
\r
3855 //*----------------------------------------------------------------------------
\r
3856 //* \fn AT91F_TDES_SetCryptoKey2
\r
3857 //* \brief Set Cryptographic Key 2 Word x
\r
3858 //*----------------------------------------------------------------------------
\r
3859 __inline void AT91F_TDES_SetCryptoKey2 (
\r
3860 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3861 unsigned char index,
\r
3862 unsigned int keyword
\r
3865 pTDES->TDES_KEY2WxR[index] = keyword;
\r
3868 //*----------------------------------------------------------------------------
\r
3869 //* \fn AT91F_TDES_SetCryptoKey3
\r
3870 //* \brief Set Cryptographic Key 3 Word x
\r
3871 //*----------------------------------------------------------------------------
\r
3872 __inline void AT91F_TDES_SetCryptoKey3 (
\r
3873 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3874 unsigned char index,
\r
3875 unsigned int keyword
\r
3878 pTDES->TDES_KEY3WxR[index] = keyword;
\r
3881 //*----------------------------------------------------------------------------
\r
3882 //* \fn AT91F_TDES_InputData
\r
3883 //* \brief Set Input Data x
\r
3884 //*----------------------------------------------------------------------------
\r
3885 __inline void AT91F_TDES_InputData (
\r
3886 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3887 unsigned char index,
\r
3888 unsigned int indata
\r
3891 pTDES->TDES_IDATAxR[index] = indata;
\r
3894 //*----------------------------------------------------------------------------
\r
3895 //* \fn AT91F_TDES_GetOutputData
\r
3896 //* \brief Get Output Data x
\r
3897 //*----------------------------------------------------------------------------
\r
3898 __inline unsigned int AT91F_TDES_GetOutputData (
\r
3899 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3900 unsigned char index
\r
3903 return pTDES->TDES_ODATAxR[index];
\r
3906 //*----------------------------------------------------------------------------
\r
3907 //* \fn AT91F_TDES_SetInitializationVector
\r
3908 //* \brief Set Initialization Vector x
\r
3909 //*----------------------------------------------------------------------------
\r
3910 __inline void AT91F_TDES_SetInitializationVector (
\r
3911 AT91PS_TDES pTDES, // pointer to a TDES controller
\r
3912 unsigned char index,
\r
3913 unsigned int initvector
\r
3916 pTDES->TDES_IVxR[index] = initvector;
\r
3919 //*----------------------------------------------------------------------------
\r
3920 //* \fn AT91F_DBGU_CfgPMC
\r
3921 //* \brief Enable Peripheral clock in PMC for DBGU
\r
3922 //*----------------------------------------------------------------------------
\r
3923 __inline void AT91F_DBGU_CfgPMC (void)
\r
3925 AT91F_PMC_EnablePeriphClock(
\r
3926 AT91C_BASE_PMC, // PIO controller base address
\r
3927 ((unsigned int) 1 << AT91C_ID_SYS));
\r
3930 //*----------------------------------------------------------------------------
\r
3931 //* \fn AT91F_DBGU_CfgPIO
\r
3932 //* \brief Configure PIO controllers to drive DBGU signals
\r
3933 //*----------------------------------------------------------------------------
\r
3934 __inline void AT91F_DBGU_CfgPIO (void)
\r
3936 // Configure PIO controllers to periph mode
\r
3937 AT91F_PIO_CfgPeriph(
\r
3938 AT91C_BASE_PIOA, // PIO controller base address
\r
3939 ((unsigned int) AT91C_PA27_DRXD ) |
\r
3940 ((unsigned int) AT91C_PA28_DTXD ), // Peripheral A
\r
3941 0); // Peripheral B
\r
3944 //*----------------------------------------------------------------------------
\r
3945 //* \fn AT91F_PMC_CfgPMC
\r
3946 //* \brief Enable Peripheral clock in PMC for PMC
\r
3947 //*----------------------------------------------------------------------------
\r
3948 __inline void AT91F_PMC_CfgPMC (void)
\r
3950 AT91F_PMC_EnablePeriphClock(
\r
3951 AT91C_BASE_PMC, // PIO controller base address
\r
3952 ((unsigned int) 1 << AT91C_ID_SYS));
\r
3955 //*----------------------------------------------------------------------------
\r
3956 //* \fn AT91F_PMC_CfgPIO
\r
3957 //* \brief Configure PIO controllers to drive PMC signals
\r
3958 //*----------------------------------------------------------------------------
\r
3959 __inline void AT91F_PMC_CfgPIO (void)
\r
3961 // Configure PIO controllers to periph mode
\r
3962 AT91F_PIO_CfgPeriph(
\r
3963 AT91C_BASE_PIOB, // PIO controller base address
\r
3964 ((unsigned int) AT91C_PB30_PCK2 ) |
\r
3965 ((unsigned int) AT91C_PB29_PCK1 ), // Peripheral A
\r
3966 ((unsigned int) AT91C_PB20_PCK0 ) |
\r
3967 ((unsigned int) AT91C_PB0_PCK0 ) |
\r
3968 ((unsigned int) AT91C_PB22_PCK2 ) |
\r
3969 ((unsigned int) AT91C_PB21_PCK1 )); // Peripheral B
\r
3970 // Configure PIO controllers to periph mode
\r
3971 AT91F_PIO_CfgPeriph(
\r
3972 AT91C_BASE_PIOA, // PIO controller base address
\r
3973 0, // Peripheral A
\r
3974 ((unsigned int) AT91C_PA30_PCK2 ) |
\r
3975 ((unsigned int) AT91C_PA13_PCK1 ) |
\r
3976 ((unsigned int) AT91C_PA27_PCK3 )); // Peripheral B
\r
3979 //*----------------------------------------------------------------------------
\r
3980 //* \fn AT91F_VREG_CfgPMC
\r
3981 //* \brief Enable Peripheral clock in PMC for VREG
\r
3982 //*----------------------------------------------------------------------------
\r
3983 __inline void AT91F_VREG_CfgPMC (void)
\r
3985 AT91F_PMC_EnablePeriphClock(
\r
3986 AT91C_BASE_PMC, // PIO controller base address
\r
3987 ((unsigned int) 1 << AT91C_ID_SYS));
\r
3990 //*----------------------------------------------------------------------------
\r
3991 //* \fn AT91F_RSTC_CfgPMC
\r
3992 //* \brief Enable Peripheral clock in PMC for RSTC
\r
3993 //*----------------------------------------------------------------------------
\r
3994 __inline void AT91F_RSTC_CfgPMC (void)
\r
3996 AT91F_PMC_EnablePeriphClock(
\r
3997 AT91C_BASE_PMC, // PIO controller base address
\r
3998 ((unsigned int) 1 << AT91C_ID_SYS));
\r
4001 //*----------------------------------------------------------------------------
\r
4002 //* \fn AT91F_SSC_CfgPMC
\r
4003 //* \brief Enable Peripheral clock in PMC for SSC
\r
4004 //*----------------------------------------------------------------------------
\r
4005 __inline void AT91F_SSC_CfgPMC (void)
\r
4007 AT91F_PMC_EnablePeriphClock(
\r
4008 AT91C_BASE_PMC, // PIO controller base address
\r
4009 ((unsigned int) 1 << AT91C_ID_SSC));
\r
4012 //*----------------------------------------------------------------------------
\r
4013 //* \fn AT91F_SSC_CfgPIO
\r
4014 //* \brief Configure PIO controllers to drive SSC signals
\r
4015 //*----------------------------------------------------------------------------
\r
4016 __inline void AT91F_SSC_CfgPIO (void)
\r
4018 // Configure PIO controllers to periph mode
\r
4019 AT91F_PIO_CfgPeriph(
\r
4020 AT91C_BASE_PIOA, // PIO controller base address
\r
4021 ((unsigned int) AT91C_PA25_RK ) |
\r
4022 ((unsigned int) AT91C_PA22_TK ) |
\r
4023 ((unsigned int) AT91C_PA21_TF ) |
\r
4024 ((unsigned int) AT91C_PA24_RD ) |
\r
4025 ((unsigned int) AT91C_PA26_RF ) |
\r
4026 ((unsigned int) AT91C_PA23_TD ), // Peripheral A
\r
4027 0); // Peripheral B
\r
4030 //*----------------------------------------------------------------------------
\r
4031 //* \fn AT91F_WDTC_CfgPMC
\r
4032 //* \brief Enable Peripheral clock in PMC for WDTC
\r
4033 //*----------------------------------------------------------------------------
\r
4034 __inline void AT91F_WDTC_CfgPMC (void)
\r
4036 AT91F_PMC_EnablePeriphClock(
\r
4037 AT91C_BASE_PMC, // PIO controller base address
\r
4038 ((unsigned int) 1 << AT91C_ID_SYS));
\r
4041 //*----------------------------------------------------------------------------
\r
4042 //* \fn AT91F_US1_CfgPMC
\r
4043 //* \brief Enable Peripheral clock in PMC for US1
\r
4044 //*----------------------------------------------------------------------------
\r
4045 __inline void AT91F_US1_CfgPMC (void)
\r
4047 AT91F_PMC_EnablePeriphClock(
\r
4048 AT91C_BASE_PMC, // PIO controller base address
\r
4049 ((unsigned int) 1 << AT91C_ID_US1));
\r
4052 //*----------------------------------------------------------------------------
\r
4053 //* \fn AT91F_US1_CfgPIO
\r
4054 //* \brief Configure PIO controllers to drive US1 signals
\r
4055 //*----------------------------------------------------------------------------
\r
4056 __inline void AT91F_US1_CfgPIO (void)
\r
4058 // Configure PIO controllers to periph mode
\r
4059 AT91F_PIO_CfgPeriph(
\r
4060 AT91C_BASE_PIOB, // PIO controller base address
\r
4061 0, // Peripheral A
\r
4062 ((unsigned int) AT91C_PB26_RI1 ) |
\r
4063 ((unsigned int) AT91C_PB24_DSR1 ) |
\r
4064 ((unsigned int) AT91C_PB23_DCD1 ) |
\r
4065 ((unsigned int) AT91C_PB25_DTR1 )); // Peripheral B
\r
4066 // Configure PIO controllers to periph mode
\r
4067 AT91F_PIO_CfgPeriph(
\r
4068 AT91C_BASE_PIOA, // PIO controller base address
\r
4069 ((unsigned int) AT91C_PA7_SCK1 ) |
\r
4070 ((unsigned int) AT91C_PA8_RTS1 ) |
\r
4071 ((unsigned int) AT91C_PA6_TXD1 ) |
\r
4072 ((unsigned int) AT91C_PA5_RXD1 ) |
\r
4073 ((unsigned int) AT91C_PA9_CTS1 ), // Peripheral A
\r
4074 0); // Peripheral B
\r
4077 //*----------------------------------------------------------------------------
\r
4078 //* \fn AT91F_US0_CfgPMC
\r
4079 //* \brief Enable Peripheral clock in PMC for US0
\r
4080 //*----------------------------------------------------------------------------
\r
4081 __inline void AT91F_US0_CfgPMC (void)
\r
4083 AT91F_PMC_EnablePeriphClock(
\r
4084 AT91C_BASE_PMC, // PIO controller base address
\r
4085 ((unsigned int) 1 << AT91C_ID_US0));
\r
4088 //*----------------------------------------------------------------------------
\r
4089 //* \fn AT91F_US0_CfgPIO
\r
4090 //* \brief Configure PIO controllers to drive US0 signals
\r
4091 //*----------------------------------------------------------------------------
\r
4092 __inline void AT91F_US0_CfgPIO (void)
\r
4094 // Configure PIO controllers to periph mode
\r
4095 AT91F_PIO_CfgPeriph(
\r
4096 AT91C_BASE_PIOA, // PIO controller base address
\r
4097 ((unsigned int) AT91C_PA0_RXD0 ) |
\r
4098 ((unsigned int) AT91C_PA4_CTS0 ) |
\r
4099 ((unsigned int) AT91C_PA3_RTS0 ) |
\r
4100 ((unsigned int) AT91C_PA2_SCK0 ) |
\r
4101 ((unsigned int) AT91C_PA1_TXD0 ), // Peripheral A
\r
4102 0); // Peripheral B
\r
4105 //*----------------------------------------------------------------------------
\r
4106 //* \fn AT91F_SPI1_CfgPMC
\r
4107 //* \brief Enable Peripheral clock in PMC for SPI1
\r
4108 //*----------------------------------------------------------------------------
\r
4109 __inline void AT91F_SPI1_CfgPMC (void)
\r
4111 AT91F_PMC_EnablePeriphClock(
\r
4112 AT91C_BASE_PMC, // PIO controller base address
\r
4113 ((unsigned int) 1 << AT91C_ID_SPI1));
\r
4116 //*----------------------------------------------------------------------------
\r
4117 //* \fn AT91F_SPI1_CfgPIO
\r
4118 //* \brief Configure PIO controllers to drive SPI1 signals
\r
4119 //*----------------------------------------------------------------------------
\r
4120 __inline void AT91F_SPI1_CfgPIO (void)
\r
4122 // Configure PIO controllers to periph mode
\r
4123 AT91F_PIO_CfgPeriph(
\r
4124 AT91C_BASE_PIOB, // PIO controller base address
\r
4125 0, // Peripheral A
\r
4126 ((unsigned int) AT91C_PB16_NPCS13 ) |
\r
4127 ((unsigned int) AT91C_PB10_NPCS11 ) |
\r
4128 ((unsigned int) AT91C_PB11_NPCS12 )); // Peripheral B
\r
4129 // Configure PIO controllers to periph mode
\r
4130 AT91F_PIO_CfgPeriph(
\r
4131 AT91C_BASE_PIOA, // PIO controller base address
\r
4132 0, // Peripheral A
\r
4133 ((unsigned int) AT91C_PA4_NPCS13 ) |
\r
4134 ((unsigned int) AT91C_PA29_NPCS13 ) |
\r
4135 ((unsigned int) AT91C_PA21_NPCS10 ) |
\r
4136 ((unsigned int) AT91C_PA22_SPCK1 ) |
\r
4137 ((unsigned int) AT91C_PA25_NPCS11 ) |
\r
4138 ((unsigned int) AT91C_PA2_NPCS11 ) |
\r
4139 ((unsigned int) AT91C_PA24_MISO1 ) |
\r
4140 ((unsigned int) AT91C_PA3_NPCS12 ) |
\r
4141 ((unsigned int) AT91C_PA26_NPCS12 ) |
\r
4142 ((unsigned int) AT91C_PA23_MOSI1 )); // Peripheral B
\r
4145 //*----------------------------------------------------------------------------
\r
4146 //* \fn AT91F_SPI0_CfgPMC
\r
4147 //* \brief Enable Peripheral clock in PMC for SPI0
\r
4148 //*----------------------------------------------------------------------------
\r
4149 __inline void AT91F_SPI0_CfgPMC (void)
\r
4151 AT91F_PMC_EnablePeriphClock(
\r
4152 AT91C_BASE_PMC, // PIO controller base address
\r
4153 ((unsigned int) 1 << AT91C_ID_SPI0));
\r
4156 //*----------------------------------------------------------------------------
\r
4157 //* \fn AT91F_SPI0_CfgPIO
\r
4158 //* \brief Configure PIO controllers to drive SPI0 signals
\r
4159 //*----------------------------------------------------------------------------
\r
4160 __inline void AT91F_SPI0_CfgPIO (void)
\r
4162 // Configure PIO controllers to periph mode
\r
4163 AT91F_PIO_CfgPeriph(
\r
4164 AT91C_BASE_PIOB, // PIO controller base address
\r
4165 0, // Peripheral A
\r
4166 ((unsigned int) AT91C_PB13_NPCS01 ) |
\r
4167 ((unsigned int) AT91C_PB17_NPCS03 ) |
\r
4168 ((unsigned int) AT91C_PB14_NPCS02 )); // Peripheral B
\r
4169 // Configure PIO controllers to periph mode
\r
4170 AT91F_PIO_CfgPeriph(
\r
4171 AT91C_BASE_PIOA, // PIO controller base address
\r
4172 ((unsigned int) AT91C_PA16_MISO0 ) |
\r
4173 ((unsigned int) AT91C_PA13_NPCS01 ) |
\r
4174 ((unsigned int) AT91C_PA15_NPCS03 ) |
\r
4175 ((unsigned int) AT91C_PA17_MOSI0 ) |
\r
4176 ((unsigned int) AT91C_PA18_SPCK0 ) |
\r
4177 ((unsigned int) AT91C_PA14_NPCS02 ) |
\r
4178 ((unsigned int) AT91C_PA12_NPCS00 ), // Peripheral A
\r
4179 ((unsigned int) AT91C_PA7_NPCS01 ) |
\r
4180 ((unsigned int) AT91C_PA9_NPCS03 ) |
\r
4181 ((unsigned int) AT91C_PA8_NPCS02 )); // Peripheral B
\r
4184 //*----------------------------------------------------------------------------
\r
4185 //* \fn AT91F_PITC_CfgPMC
\r
4186 //* \brief Enable Peripheral clock in PMC for PITC
\r
4187 //*----------------------------------------------------------------------------
\r
4188 __inline void AT91F_PITC_CfgPMC (void)
\r
4190 AT91F_PMC_EnablePeriphClock(
\r
4191 AT91C_BASE_PMC, // PIO controller base address
\r
4192 ((unsigned int) 1 << AT91C_ID_SYS));
\r
4195 //*----------------------------------------------------------------------------
\r
4196 //* \fn AT91F_AIC_CfgPMC
\r
4197 //* \brief Enable Peripheral clock in PMC for AIC
\r
4198 //*----------------------------------------------------------------------------
\r
4199 __inline void AT91F_AIC_CfgPMC (void)
\r
4201 AT91F_PMC_EnablePeriphClock(
\r
4202 AT91C_BASE_PMC, // PIO controller base address
\r
4203 ((unsigned int) 1 << AT91C_ID_FIQ) |
\r
4204 ((unsigned int) 1 << AT91C_ID_IRQ0) |
\r
4205 ((unsigned int) 1 << AT91C_ID_IRQ1));
\r
4208 //*----------------------------------------------------------------------------
\r
4209 //* \fn AT91F_AIC_CfgPIO
\r
4210 //* \brief Configure PIO controllers to drive AIC signals
\r
4211 //*----------------------------------------------------------------------------
\r
4212 __inline void AT91F_AIC_CfgPIO (void)
\r
4214 // Configure PIO controllers to periph mode
\r
4215 AT91F_PIO_CfgPeriph(
\r
4216 AT91C_BASE_PIOA, // PIO controller base address
\r
4217 ((unsigned int) AT91C_PA30_IRQ0 ) |
\r
4218 ((unsigned int) AT91C_PA29_FIQ ), // Peripheral A
\r
4219 ((unsigned int) AT91C_PA14_IRQ1 )); // Peripheral B
\r
4222 //*----------------------------------------------------------------------------
\r
4223 //* \fn AT91F_AES_CfgPMC
\r
4224 //* \brief Enable Peripheral clock in PMC for AES
\r
4225 //*----------------------------------------------------------------------------
\r
4226 __inline void AT91F_AES_CfgPMC (void)
\r
4228 AT91F_PMC_EnablePeriphClock(
\r
4229 AT91C_BASE_PMC, // PIO controller base address
\r
4230 ((unsigned int) 1 << AT91C_ID_AES));
\r
4233 //*----------------------------------------------------------------------------
\r
4234 //* \fn AT91F_TWI_CfgPMC
\r
4235 //* \brief Enable Peripheral clock in PMC for TWI
\r
4236 //*----------------------------------------------------------------------------
\r
4237 __inline void AT91F_TWI_CfgPMC (void)
\r
4239 AT91F_PMC_EnablePeriphClock(
\r
4240 AT91C_BASE_PMC, // PIO controller base address
\r
4241 ((unsigned int) 1 << AT91C_ID_TWI));
\r
4244 //*----------------------------------------------------------------------------
\r
4245 //* \fn AT91F_TWI_CfgPIO
\r
4246 //* \brief Configure PIO controllers to drive TWI signals
\r
4247 //*----------------------------------------------------------------------------
\r
4248 __inline void AT91F_TWI_CfgPIO (void)
\r
4250 // Configure PIO controllers to periph mode
\r
4251 AT91F_PIO_CfgPeriph(
\r
4252 AT91C_BASE_PIOA, // PIO controller base address
\r
4253 ((unsigned int) AT91C_PA11_TWCK ) |
\r
4254 ((unsigned int) AT91C_PA10_TWD ), // Peripheral A
\r
4255 0); // Peripheral B
\r
4258 //*----------------------------------------------------------------------------
\r
4259 //* \fn AT91F_ADC_CfgPMC
\r
4260 //* \brief Enable Peripheral clock in PMC for ADC
\r
4261 //*----------------------------------------------------------------------------
\r
4262 __inline void AT91F_ADC_CfgPMC (void)
\r
4264 AT91F_PMC_EnablePeriphClock(
\r
4265 AT91C_BASE_PMC, // PIO controller base address
\r
4266 ((unsigned int) 1 << AT91C_ID_ADC));
\r
4269 //*----------------------------------------------------------------------------
\r
4270 //* \fn AT91F_ADC_CfgPIO
\r
4271 //* \brief Configure PIO controllers to drive ADC signals
\r
4272 //*----------------------------------------------------------------------------
\r
4273 __inline void AT91F_ADC_CfgPIO (void)
\r
4275 // Configure PIO controllers to periph mode
\r
4276 AT91F_PIO_CfgPeriph(
\r
4277 AT91C_BASE_PIOB, // PIO controller base address
\r
4278 0, // Peripheral A
\r
4279 ((unsigned int) AT91C_PB18_ADTRG )); // Peripheral B
\r
4282 //*----------------------------------------------------------------------------
\r
4283 //* \fn AT91F_PWMC_CH3_CfgPIO
\r
4284 //* \brief Configure PIO controllers to drive PWMC_CH3 signals
\r
4285 //*----------------------------------------------------------------------------
\r
4286 __inline void AT91F_PWMC_CH3_CfgPIO (void)
\r
4288 // Configure PIO controllers to periph mode
\r
4289 AT91F_PIO_CfgPeriph(
\r
4290 AT91C_BASE_PIOB, // PIO controller base address
\r
4291 ((unsigned int) AT91C_PB22_PWM3 ), // Peripheral A
\r
4292 ((unsigned int) AT91C_PB30_PWM3 )); // Peripheral B
\r
4295 //*----------------------------------------------------------------------------
\r
4296 //* \fn AT91F_PWMC_CH2_CfgPIO
\r
4297 //* \brief Configure PIO controllers to drive PWMC_CH2 signals
\r
4298 //*----------------------------------------------------------------------------
\r
4299 __inline void AT91F_PWMC_CH2_CfgPIO (void)
\r
4301 // Configure PIO controllers to periph mode
\r
4302 AT91F_PIO_CfgPeriph(
\r
4303 AT91C_BASE_PIOB, // PIO controller base address
\r
4304 ((unsigned int) AT91C_PB21_PWM2 ), // Peripheral A
\r
4305 ((unsigned int) AT91C_PB29_PWM2 )); // Peripheral B
\r
4308 //*----------------------------------------------------------------------------
\r
4309 //* \fn AT91F_PWMC_CH1_CfgPIO
\r
4310 //* \brief Configure PIO controllers to drive PWMC_CH1 signals
\r
4311 //*----------------------------------------------------------------------------
\r
4312 __inline void AT91F_PWMC_CH1_CfgPIO (void)
\r
4314 // Configure PIO controllers to periph mode
\r
4315 AT91F_PIO_CfgPeriph(
\r
4316 AT91C_BASE_PIOB, // PIO controller base address
\r
4317 ((unsigned int) AT91C_PB20_PWM1 ), // Peripheral A
\r
4318 ((unsigned int) AT91C_PB28_PWM1 )); // Peripheral B
\r
4321 //*----------------------------------------------------------------------------
\r
4322 //* \fn AT91F_PWMC_CH0_CfgPIO
\r
4323 //* \brief Configure PIO controllers to drive PWMC_CH0 signals
\r
4324 //*----------------------------------------------------------------------------
\r
4325 __inline void AT91F_PWMC_CH0_CfgPIO (void)
\r
4327 // Configure PIO controllers to periph mode
\r
4328 AT91F_PIO_CfgPeriph(
\r
4329 AT91C_BASE_PIOB, // PIO controller base address
\r
4330 ((unsigned int) AT91C_PB19_PWM0 ), // Peripheral A
\r
4331 ((unsigned int) AT91C_PB27_PWM0 )); // Peripheral B
\r
4334 //*----------------------------------------------------------------------------
\r
4335 //* \fn AT91F_RTTC_CfgPMC
\r
4336 //* \brief Enable Peripheral clock in PMC for RTTC
\r
4337 //*----------------------------------------------------------------------------
\r
4338 __inline void AT91F_RTTC_CfgPMC (void)
\r
4340 AT91F_PMC_EnablePeriphClock(
\r
4341 AT91C_BASE_PMC, // PIO controller base address
\r
4342 ((unsigned int) 1 << AT91C_ID_SYS));
\r
4345 //*----------------------------------------------------------------------------
\r
4346 //* \fn AT91F_UDP_CfgPMC
\r
4347 //* \brief Enable Peripheral clock in PMC for UDP
\r
4348 //*----------------------------------------------------------------------------
\r
4349 __inline void AT91F_UDP_CfgPMC (void)
\r
4351 AT91F_PMC_EnablePeriphClock(
\r
4352 AT91C_BASE_PMC, // PIO controller base address
\r
4353 ((unsigned int) 1 << AT91C_ID_UDP));
\r
4356 //*----------------------------------------------------------------------------
\r
4357 //* \fn AT91F_TDES_CfgPMC
\r
4358 //* \brief Enable Peripheral clock in PMC for TDES
\r
4359 //*----------------------------------------------------------------------------
\r
4360 __inline void AT91F_TDES_CfgPMC (void)
\r
4362 AT91F_PMC_EnablePeriphClock(
\r
4363 AT91C_BASE_PMC, // PIO controller base address
\r
4364 ((unsigned int) 1 << AT91C_ID_TDES));
\r
4367 //*----------------------------------------------------------------------------
\r
4368 //* \fn AT91F_EMAC_CfgPMC
\r
4369 //* \brief Enable Peripheral clock in PMC for EMAC
\r
4370 //*----------------------------------------------------------------------------
\r
4371 __inline void AT91F_EMAC_CfgPMC (void)
\r
4373 AT91F_PMC_EnablePeriphClock(
\r
4374 AT91C_BASE_PMC, // PIO controller base address
\r
4375 ((unsigned int) 1 << AT91C_ID_EMAC));
\r
4378 //*----------------------------------------------------------------------------
\r
4379 //* \fn AT91F_EMAC_CfgPIO
\r
4380 //* \brief Configure PIO controllers to drive EMAC signals
\r
4381 //*----------------------------------------------------------------------------
\r
4382 __inline void AT91F_EMAC_CfgPIO (void)
\r
4384 // Configure PIO controllers to periph mode
\r
4385 AT91F_PIO_CfgPeriph(
\r
4386 AT91C_BASE_PIOB, // PIO controller base address
\r
4387 ((unsigned int) AT91C_PB2_ETX0 ) |
\r
4388 ((unsigned int) AT91C_PB12_ETXER ) |
\r
4389 ((unsigned int) AT91C_PB16_ECOL ) |
\r
4390 ((unsigned int) AT91C_PB11_ETX3 ) |
\r
4391 ((unsigned int) AT91C_PB6_ERX1 ) |
\r
4392 ((unsigned int) AT91C_PB15_ERXDV ) |
\r
4393 ((unsigned int) AT91C_PB13_ERX2 ) |
\r
4394 ((unsigned int) AT91C_PB3_ETX1 ) |
\r
4395 ((unsigned int) AT91C_PB8_EMDC ) |
\r
4396 ((unsigned int) AT91C_PB5_ERX0 ) |
\r
4397 //((unsigned int) AT91C_PB18_EF100 ) |
\r
4398 ((unsigned int) AT91C_PB14_ERX3 ) |
\r
4399 ((unsigned int) AT91C_PB4_ECRS_ECRSDV) |
\r
4400 ((unsigned int) AT91C_PB1_ETXEN ) |
\r
4401 ((unsigned int) AT91C_PB10_ETX2 ) |
\r
4402 ((unsigned int) AT91C_PB0_ETXCK_EREFCK) |
\r
4403 ((unsigned int) AT91C_PB9_EMDIO ) |
\r
4404 ((unsigned int) AT91C_PB7_ERXER ) |
\r
4405 ((unsigned int) AT91C_PB17_ERXCK ), // Peripheral A
\r
4406 0); // Peripheral B
\r
4409 //*----------------------------------------------------------------------------
\r
4410 //* \fn AT91F_TC0_CfgPMC
\r
4411 //* \brief Enable Peripheral clock in PMC for TC0
\r
4412 //*----------------------------------------------------------------------------
\r
4413 __inline void AT91F_TC0_CfgPMC (void)
\r
4415 AT91F_PMC_EnablePeriphClock(
\r
4416 AT91C_BASE_PMC, // PIO controller base address
\r
4417 ((unsigned int) 1 << AT91C_ID_TC0));
\r
4420 //*----------------------------------------------------------------------------
\r
4421 //* \fn AT91F_TC0_CfgPIO
\r
4422 //* \brief Configure PIO controllers to drive TC0 signals
\r
4423 //*----------------------------------------------------------------------------
\r
4424 __inline void AT91F_TC0_CfgPIO (void)
\r
4426 // Configure PIO controllers to periph mode
\r
4427 AT91F_PIO_CfgPeriph(
\r
4428 AT91C_BASE_PIOB, // PIO controller base address
\r
4429 ((unsigned int) AT91C_PB23_TIOA0 ) |
\r
4430 ((unsigned int) AT91C_PB24_TIOB0 ), // Peripheral A
\r
4431 ((unsigned int) AT91C_PB12_TCLK0 )); // Peripheral B
\r
4434 //*----------------------------------------------------------------------------
\r
4435 //* \fn AT91F_TC1_CfgPMC
\r
4436 //* \brief Enable Peripheral clock in PMC for TC1
\r
4437 //*----------------------------------------------------------------------------
\r
4438 __inline void AT91F_TC1_CfgPMC (void)
\r
4440 AT91F_PMC_EnablePeriphClock(
\r
4441 AT91C_BASE_PMC, // PIO controller base address
\r
4442 ((unsigned int) 1 << AT91C_ID_TC1));
\r
4445 //*----------------------------------------------------------------------------
\r
4446 //* \fn AT91F_TC1_CfgPIO
\r
4447 //* \brief Configure PIO controllers to drive TC1 signals
\r
4448 //*----------------------------------------------------------------------------
\r
4449 __inline void AT91F_TC1_CfgPIO (void)
\r
4451 // Configure PIO controllers to periph mode
\r
4452 AT91F_PIO_CfgPeriph(
\r
4453 AT91C_BASE_PIOB, // PIO controller base address
\r
4454 ((unsigned int) AT91C_PB25_TIOA1 ) |
\r
4455 ((unsigned int) AT91C_PB26_TIOB1 ), // Peripheral A
\r
4456 ((unsigned int) AT91C_PB19_TCLK1 )); // Peripheral B
\r
4459 //*----------------------------------------------------------------------------
\r
4460 //* \fn AT91F_TC2_CfgPMC
\r
4461 //* \brief Enable Peripheral clock in PMC for TC2
\r
4462 //*----------------------------------------------------------------------------
\r
4463 __inline void AT91F_TC2_CfgPMC (void)
\r
4465 AT91F_PMC_EnablePeriphClock(
\r
4466 AT91C_BASE_PMC, // PIO controller base address
\r
4467 ((unsigned int) 1 << AT91C_ID_TC2));
\r
4470 //*----------------------------------------------------------------------------
\r
4471 //* \fn AT91F_TC2_CfgPIO
\r
4472 //* \brief Configure PIO controllers to drive TC2 signals
\r
4473 //*----------------------------------------------------------------------------
\r
4474 __inline void AT91F_TC2_CfgPIO (void)
\r
4476 // Configure PIO controllers to periph mode
\r
4477 AT91F_PIO_CfgPeriph(
\r
4478 AT91C_BASE_PIOB, // PIO controller base address
\r
4479 ((unsigned int) AT91C_PB28_TIOB2 ) |
\r
4480 ((unsigned int) AT91C_PB27_TIOA2 ), // Peripheral A
\r
4481 0); // Peripheral B
\r
4482 // Configure PIO controllers to periph mode
\r
4483 AT91F_PIO_CfgPeriph(
\r
4484 AT91C_BASE_PIOA, // PIO controller base address
\r
4485 0, // Peripheral A
\r
4486 ((unsigned int) AT91C_PA15_TCLK2 )); // Peripheral B
\r
4489 //*----------------------------------------------------------------------------
\r
4490 //* \fn AT91F_MC_CfgPMC
\r
4491 //* \brief Enable Peripheral clock in PMC for MC
\r
4492 //*----------------------------------------------------------------------------
\r
4493 __inline void AT91F_MC_CfgPMC (void)
\r
4495 AT91F_PMC_EnablePeriphClock(
\r
4496 AT91C_BASE_PMC, // PIO controller base address
\r
4497 ((unsigned int) 1 << AT91C_ID_SYS));
\r
4500 //*----------------------------------------------------------------------------
\r
4501 //* \fn AT91F_PIOA_CfgPMC
\r
4502 //* \brief Enable Peripheral clock in PMC for PIOA
\r
4503 //*----------------------------------------------------------------------------
\r
4504 __inline void AT91F_PIOA_CfgPMC (void)
\r
4506 AT91F_PMC_EnablePeriphClock(
\r
4507 AT91C_BASE_PMC, // PIO controller base address
\r
4508 ((unsigned int) 1 << AT91C_ID_PIOA));
\r
4511 //*----------------------------------------------------------------------------
\r
4512 //* \fn AT91F_PIOB_CfgPMC
\r
4513 //* \brief Enable Peripheral clock in PMC for PIOB
\r
4514 //*----------------------------------------------------------------------------
\r
4515 __inline void AT91F_PIOB_CfgPMC (void)
\r
4517 AT91F_PMC_EnablePeriphClock(
\r
4518 AT91C_BASE_PMC, // PIO controller base address
\r
4519 ((unsigned int) 1 << AT91C_ID_PIOB));
\r
4522 //*----------------------------------------------------------------------------
\r
4523 //* \fn AT91F_CAN_CfgPMC
\r
4524 //* \brief Enable Peripheral clock in PMC for CAN
\r
4525 //*----------------------------------------------------------------------------
\r
4526 __inline void AT91F_CAN_CfgPMC (void)
\r
4528 AT91F_PMC_EnablePeriphClock(
\r
4529 AT91C_BASE_PMC, // PIO controller base address
\r
4530 ((unsigned int) 1 << AT91C_ID_CAN));
\r
4533 //*----------------------------------------------------------------------------
\r
4534 //* \fn AT91F_CAN_CfgPIO
\r
4535 //* \brief Configure PIO controllers to drive CAN signals
\r
4536 //*----------------------------------------------------------------------------
\r
4537 __inline void AT91F_CAN_CfgPIO (void)
\r
4539 // Configure PIO controllers to periph mode
\r
4540 AT91F_PIO_CfgPeriph(
\r
4541 AT91C_BASE_PIOA, // PIO controller base address
\r
4542 ((unsigned int) AT91C_PA20_CANTX ) |
\r
4543 ((unsigned int) AT91C_PA19_CANRX ), // Peripheral A
\r
4544 0); // Peripheral B
\r
4547 //*----------------------------------------------------------------------------
\r
4548 //* \fn AT91F_PWMC_CfgPMC
\r
4549 //* \brief Enable Peripheral clock in PMC for PWMC
\r
4550 //*----------------------------------------------------------------------------
\r
4551 __inline void AT91F_PWMC_CfgPMC (void)
\r
4553 AT91F_PMC_EnablePeriphClock(
\r
4554 AT91C_BASE_PMC, // PIO controller base address
\r
4555 ((unsigned int) 1 << AT91C_ID_PWMC));
\r
4558 #endif // lib_AT91SAM7X256_H
\r