1 //*----------------------------------------------------------------------------
\r
2 //* ATMEL Microcontroller Software Support - ROUSSET -
\r
3 //*----------------------------------------------------------------------------
\r
4 //* The software is delivered "AS IS" without warranty or condition of any
\r
5 //* kind, either express, implied or statutory. This includes without
\r
6 //* limitation any warranty or condition with respect to merchantability or
\r
7 //* fitness for any particular purpose, or against the infringements of
\r
8 //* intellectual property rights of others.
\r
9 //*----------------------------------------------------------------------------
\r
10 //* File Name : lib_AT91SAM7S64.h
\r
11 //* Object : AT91SAM7S64 inlined functions
\r
12 //* Generated : AT91 SW Application Group 07/16/2004 (07:43:09)
\r
14 //* CVS Reference : /lib_MC_SAM.h/1.3/Thu Mar 25 15:19:14 2004//
\r
15 //* CVS Reference : /lib_pdc_1363d.h/1.2/Wed Feb 19 09:25:22 2003//
\r
16 //* CVS Reference : /lib_dbgu.h/1.1/Fri Jan 31 12:18:40 2003//
\r
17 //* CVS Reference : /lib_ssc.h/1.4/Fri Jan 31 12:19:20 2003//
\r
18 //* CVS Reference : /lib_spi2.h/1.1/Mon Aug 25 13:23:52 2003//
\r
19 //* CVS Reference : /lib_PWM_SAM.h/1.3/Thu Jan 22 10:10:50 2004//
\r
20 //* CVS Reference : /lib_tc_1753b.h/1.1/Fri Jan 31 12:20:02 2003//
\r
21 //* CVS Reference : /lib_pmc_SAM.h/1.6/Tue Apr 27 13:53:52 2004//
\r
22 //* CVS Reference : /lib_adc.h/1.6/Fri Oct 17 08:12:38 2003//
\r
23 //* CVS Reference : /lib_pio.h/1.3/Fri Jan 31 12:18:56 2003//
\r
24 //* CVS Reference : /lib_twi.h/1.2/Fri Jan 31 12:19:38 2003//
\r
25 //* CVS Reference : /lib_usart.h/1.5/Thu Nov 21 16:01:54 2002//
\r
26 //* CVS Reference : /lib_udp.h/1.3/Fri Jan 31 12:19:48 2003//
\r
27 //* CVS Reference : /lib_aic.h/1.3/Fri Jul 12 07:46:12 2002//
\r
28 //*----------------------------------------------------------------------------
\r
30 #ifndef lib_AT91SAM7S64_H
\r
31 #define lib_AT91SAM7S64_H
\r
33 /* *****************************************************************************
\r
35 ***************************************************************************** */
\r
37 #define AT91C_MC_CORRECT_KEY ((unsigned int) 0x5A << 24) // (MC) Correct Protect Key
\r
39 //*----------------------------------------------------------------------------
\r
40 //* \fn AT91F_MC_Remap
\r
41 //* \brief Make Remap
\r
42 //*----------------------------------------------------------------------------
\r
43 __inline void AT91F_MC_Remap (void) //
\r
45 AT91PS_MC pMC = (AT91PS_MC) AT91C_BASE_MC;
\r
47 pMC->MC_RCR = AT91C_MC_RCB;
\r
50 //*----------------------------------------------------------------------------
\r
51 //* \fn AT91F_MC_EFC_CfgModeReg
\r
52 //* \brief Configure the EFC Mode Register of the MC controller
\r
53 //*----------------------------------------------------------------------------
\r
54 __inline void AT91F_MC_EFC_CfgModeReg (
\r
55 AT91PS_MC pMC, // pointer to a MC controller
\r
56 unsigned int mode) // mode register
\r
58 // Write to the FMR register
\r
62 //*----------------------------------------------------------------------------
\r
63 //* \fn AT91F_MC_EFC_GetModeReg
\r
64 //* \brief Return MC EFC Mode Regsiter
\r
65 //*----------------------------------------------------------------------------
\r
66 __inline unsigned int AT91F_MC_EFC_GetModeReg(
\r
67 AT91PS_MC pMC) // pointer to a MC controller
\r
72 //*----------------------------------------------------------------------------
\r
73 //* \fn AT91F_MC_EFC_ComputeFMCN
\r
74 //* \brief Return MC EFC Mode Regsiter
\r
75 //*----------------------------------------------------------------------------
\r
76 __inline unsigned int AT91F_MC_EFC_ComputeFMCN(
\r
77 int master_clock) // master clock in Hz
\r
79 return (master_clock/1000000 +2);
\r
82 //*----------------------------------------------------------------------------
\r
83 //* \fn AT91F_MC_EFC_PerformCmd
\r
84 //* \brief Perform EFC Command
\r
85 //*----------------------------------------------------------------------------
\r
86 __inline void AT91F_MC_EFC_PerformCmd (
\r
87 AT91PS_MC pMC, // pointer to a MC controller
\r
88 unsigned int transfer_cmd)
\r
90 pMC->MC_FCR = transfer_cmd;
\r
93 //*----------------------------------------------------------------------------
\r
94 //* \fn AT91F_MC_EFC_GetStatus
\r
95 //* \brief Return MC EFC Status
\r
96 //*----------------------------------------------------------------------------
\r
97 __inline unsigned int AT91F_MC_EFC_GetStatus(
\r
98 AT91PS_MC pMC) // pointer to a MC controller
\r
100 return pMC->MC_FSR;
\r
103 //*----------------------------------------------------------------------------
\r
104 //* \fn AT91F_MC_EFC_IsInterruptMasked
\r
105 //* \brief Test if EFC MC Interrupt is Masked
\r
106 //*----------------------------------------------------------------------------
\r
107 __inline unsigned int AT91F_MC_EFC_IsInterruptMasked(
\r
108 AT91PS_MC pMC, // \arg pointer to a MC controller
\r
109 unsigned int flag) // \arg flag to be tested
\r
111 return (AT91F_MC_EFC_GetModeReg(pMC) & flag);
\r
114 //*----------------------------------------------------------------------------
\r
115 //* \fn AT91F_MC_EFC_IsInterruptSet
\r
116 //* \brief Test if EFC MC Interrupt is Set
\r
117 //*----------------------------------------------------------------------------
\r
118 __inline unsigned int AT91F_MC_EFC_IsInterruptSet(
\r
119 AT91PS_MC pMC, // \arg pointer to a MC controller
\r
120 unsigned int flag) // \arg flag to be tested
\r
122 return (AT91F_MC_EFC_GetStatus(pMC) & flag);
\r
125 /* *****************************************************************************
\r
126 SOFTWARE API FOR PDC
\r
127 ***************************************************************************** */
\r
128 //*----------------------------------------------------------------------------
\r
129 //* \fn AT91F_PDC_SetNextRx
\r
130 //* \brief Set the next receive transfer descriptor
\r
131 //*----------------------------------------------------------------------------
\r
132 __inline void AT91F_PDC_SetNextRx (
\r
133 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
134 char *address, // \arg address to the next bloc to be received
\r
135 unsigned int bytes) // \arg number of bytes to be received
\r
137 pPDC->PDC_RNPR = (unsigned int) address;
\r
138 pPDC->PDC_RNCR = bytes;
\r
141 //*----------------------------------------------------------------------------
\r
142 //* \fn AT91F_PDC_SetNextTx
\r
143 //* \brief Set the next transmit transfer descriptor
\r
144 //*----------------------------------------------------------------------------
\r
145 __inline void AT91F_PDC_SetNextTx (
\r
146 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
147 char *address, // \arg address to the next bloc to be transmitted
\r
148 unsigned int bytes) // \arg number of bytes to be transmitted
\r
150 pPDC->PDC_TNPR = (unsigned int) address;
\r
151 pPDC->PDC_TNCR = bytes;
\r
154 //*----------------------------------------------------------------------------
\r
155 //* \fn AT91F_PDC_SetRx
\r
156 //* \brief Set the receive transfer descriptor
\r
157 //*----------------------------------------------------------------------------
\r
158 __inline void AT91F_PDC_SetRx (
\r
159 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
160 char *address, // \arg address to the next bloc to be received
\r
161 unsigned int bytes) // \arg number of bytes to be received
\r
163 pPDC->PDC_RPR = (unsigned int) address;
\r
164 pPDC->PDC_RCR = bytes;
\r
167 //*----------------------------------------------------------------------------
\r
168 //* \fn AT91F_PDC_SetTx
\r
169 //* \brief Set the transmit transfer descriptor
\r
170 //*----------------------------------------------------------------------------
\r
171 __inline void AT91F_PDC_SetTx (
\r
172 AT91PS_PDC pPDC, // \arg pointer to a PDC controller
\r
173 char *address, // \arg address to the next bloc to be transmitted
\r
174 unsigned int bytes) // \arg number of bytes to be transmitted
\r
176 pPDC->PDC_TPR = (unsigned int) address;
\r
177 pPDC->PDC_TCR = bytes;
\r
180 //*----------------------------------------------------------------------------
\r
181 //* \fn AT91F_PDC_EnableTx
\r
182 //* \brief Enable transmit
\r
183 //*----------------------------------------------------------------------------
\r
184 __inline void AT91F_PDC_EnableTx (
\r
185 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
187 pPDC->PDC_PTCR = AT91C_PDC_TXTEN;
\r
190 //*----------------------------------------------------------------------------
\r
191 //* \fn AT91F_PDC_EnableRx
\r
192 //* \brief Enable receive
\r
193 //*----------------------------------------------------------------------------
\r
194 __inline void AT91F_PDC_EnableRx (
\r
195 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
197 pPDC->PDC_PTCR = AT91C_PDC_RXTEN;
\r
200 //*----------------------------------------------------------------------------
\r
201 //* \fn AT91F_PDC_DisableTx
\r
202 //* \brief Disable transmit
\r
203 //*----------------------------------------------------------------------------
\r
204 __inline void AT91F_PDC_DisableTx (
\r
205 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
207 pPDC->PDC_PTCR = AT91C_PDC_TXTDIS;
\r
210 //*----------------------------------------------------------------------------
\r
211 //* \fn AT91F_PDC_DisableRx
\r
212 //* \brief Disable receive
\r
213 //*----------------------------------------------------------------------------
\r
214 __inline void AT91F_PDC_DisableRx (
\r
215 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
217 pPDC->PDC_PTCR = AT91C_PDC_RXTDIS;
\r
220 //*----------------------------------------------------------------------------
\r
221 //* \fn AT91F_PDC_IsTxEmpty
\r
222 //* \brief Test if the current transfer descriptor has been sent
\r
223 //*----------------------------------------------------------------------------
\r
224 __inline int AT91F_PDC_IsTxEmpty ( // \return return 1 if transfer is complete
\r
225 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
227 return !(pPDC->PDC_TCR);
\r
230 //*----------------------------------------------------------------------------
\r
231 //* \fn AT91F_PDC_IsNextTxEmpty
\r
232 //* \brief Test if the next transfer descriptor has been moved to the current td
\r
233 //*----------------------------------------------------------------------------
\r
234 __inline int AT91F_PDC_IsNextTxEmpty ( // \return return 1 if transfer is complete
\r
235 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
237 return !(pPDC->PDC_TNCR);
\r
240 //*----------------------------------------------------------------------------
\r
241 //* \fn AT91F_PDC_IsRxEmpty
\r
242 //* \brief Test if the current transfer descriptor has been filled
\r
243 //*----------------------------------------------------------------------------
\r
244 __inline int AT91F_PDC_IsRxEmpty ( // \return return 1 if transfer is complete
\r
245 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
247 return !(pPDC->PDC_RCR);
\r
250 //*----------------------------------------------------------------------------
\r
251 //* \fn AT91F_PDC_IsNextRxEmpty
\r
252 //* \brief Test if the next transfer descriptor has been moved to the current td
\r
253 //*----------------------------------------------------------------------------
\r
254 __inline int AT91F_PDC_IsNextRxEmpty ( // \return return 1 if transfer is complete
\r
255 AT91PS_PDC pPDC ) // \arg pointer to a PDC controller
\r
257 return !(pPDC->PDC_RNCR);
\r
260 //*----------------------------------------------------------------------------
\r
261 //* \fn AT91F_PDC_Open
\r
262 //* \brief Open PDC: disable TX and RX reset transfer descriptors, re-enable RX and TX
\r
263 //*----------------------------------------------------------------------------
\r
264 __inline void AT91F_PDC_Open (
\r
265 AT91PS_PDC pPDC) // \arg pointer to a PDC controller
\r
267 //* Disable the RX and TX PDC transfer requests
\r
268 AT91F_PDC_DisableRx(pPDC);
\r
269 AT91F_PDC_DisableTx(pPDC);
\r
271 //* Reset all Counter register Next buffer first
\r
272 AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);
\r
273 AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);
\r
274 AT91F_PDC_SetTx(pPDC, (char *) 0, 0);
\r
275 AT91F_PDC_SetRx(pPDC, (char *) 0, 0);
\r
277 //* Enable the RX and TX PDC transfer requests
\r
278 AT91F_PDC_EnableRx(pPDC);
\r
279 AT91F_PDC_EnableTx(pPDC);
\r
282 //*----------------------------------------------------------------------------
\r
283 //* \fn AT91F_PDC_Close
\r
284 //* \brief Close PDC: disable TX and RX reset transfer descriptors
\r
285 //*----------------------------------------------------------------------------
\r
286 __inline void AT91F_PDC_Close (
\r
287 AT91PS_PDC pPDC) // \arg pointer to a PDC controller
\r
289 //* Disable the RX and TX PDC transfer requests
\r
290 AT91F_PDC_DisableRx(pPDC);
\r
291 AT91F_PDC_DisableTx(pPDC);
\r
293 //* Reset all Counter register Next buffer first
\r
294 AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);
\r
295 AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);
\r
296 AT91F_PDC_SetTx(pPDC, (char *) 0, 0);
\r
297 AT91F_PDC_SetRx(pPDC, (char *) 0, 0);
\r
301 //*----------------------------------------------------------------------------
\r
302 //* \fn AT91F_PDC_SendFrame
\r
303 //* \brief Close PDC: disable TX and RX reset transfer descriptors
\r
304 //*----------------------------------------------------------------------------
\r
305 __inline unsigned int AT91F_PDC_SendFrame(
\r
308 unsigned int szBuffer,
\r
310 unsigned int szNextBuffer )
\r
312 if (AT91F_PDC_IsTxEmpty(pPDC)) {
\r
313 //* Buffer and next buffer can be initialized
\r
314 AT91F_PDC_SetTx(pPDC, pBuffer, szBuffer);
\r
315 AT91F_PDC_SetNextTx(pPDC, pNextBuffer, szNextBuffer);
\r
318 else if (AT91F_PDC_IsNextTxEmpty(pPDC)) {
\r
319 //* Only one buffer can be initialized
\r
320 AT91F_PDC_SetNextTx(pPDC, pBuffer, szBuffer);
\r
324 //* All buffer are in use...
\r
329 //*----------------------------------------------------------------------------
\r
330 //* \fn AT91F_PDC_ReceiveFrame
\r
331 //* \brief Close PDC: disable TX and RX reset transfer descriptors
\r
332 //*----------------------------------------------------------------------------
\r
333 __inline unsigned int AT91F_PDC_ReceiveFrame (
\r
336 unsigned int szBuffer,
\r
338 unsigned int szNextBuffer )
\r
340 if (AT91F_PDC_IsRxEmpty(pPDC)) {
\r
341 //* Buffer and next buffer can be initialized
\r
342 AT91F_PDC_SetRx(pPDC, pBuffer, szBuffer);
\r
343 AT91F_PDC_SetNextRx(pPDC, pNextBuffer, szNextBuffer);
\r
346 else if (AT91F_PDC_IsNextRxEmpty(pPDC)) {
\r
347 //* Only one buffer can be initialized
\r
348 AT91F_PDC_SetNextRx(pPDC, pBuffer, szBuffer);
\r
352 //* All buffer are in use...
\r
356 /* *****************************************************************************
\r
357 SOFTWARE API FOR DBGU
\r
358 ***************************************************************************** */
\r
359 //*----------------------------------------------------------------------------
\r
360 //* \fn AT91F_DBGU_InterruptEnable
\r
361 //* \brief Enable DBGU Interrupt
\r
362 //*----------------------------------------------------------------------------
\r
363 __inline void AT91F_DBGU_InterruptEnable(
\r
364 AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
\r
365 unsigned int flag) // \arg dbgu interrupt to be enabled
\r
367 pDbgu->DBGU_IER = flag;
\r
370 //*----------------------------------------------------------------------------
\r
371 //* \fn AT91F_DBGU_InterruptDisable
\r
372 //* \brief Disable DBGU Interrupt
\r
373 //*----------------------------------------------------------------------------
\r
374 __inline void AT91F_DBGU_InterruptDisable(
\r
375 AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
\r
376 unsigned int flag) // \arg dbgu interrupt to be disabled
\r
378 pDbgu->DBGU_IDR = flag;
\r
381 //*----------------------------------------------------------------------------
\r
382 //* \fn AT91F_DBGU_GetInterruptMaskStatus
\r
383 //* \brief Return DBGU Interrupt Mask Status
\r
384 //*----------------------------------------------------------------------------
\r
385 __inline unsigned int AT91F_DBGU_GetInterruptMaskStatus( // \return DBGU Interrupt Mask Status
\r
386 AT91PS_DBGU pDbgu) // \arg pointer to a DBGU controller
\r
388 return pDbgu->DBGU_IMR;
\r
391 //*----------------------------------------------------------------------------
\r
392 //* \fn AT91F_DBGU_IsInterruptMasked
\r
393 //* \brief Test if DBGU Interrupt is Masked
\r
394 //*----------------------------------------------------------------------------
\r
395 __inline int AT91F_DBGU_IsInterruptMasked(
\r
396 AT91PS_DBGU pDbgu, // \arg pointer to a DBGU controller
\r
397 unsigned int flag) // \arg flag to be tested
\r
399 return (AT91F_DBGU_GetInterruptMaskStatus(pDbgu) & flag);
\r
402 /* *****************************************************************************
\r
403 SOFTWARE API FOR SSC
\r
404 ***************************************************************************** */
\r
405 //* Define the standard I2S mode configuration
\r
407 //* Configuration to set in the SSC Transmit Clock Mode Register
\r
408 //* Parameters : nb_bit_by_slot : 8, 16 or 32 bits
\r
409 //* nb_slot_by_frame : number of channels
\r
410 #define AT91C_I2S_ASY_MASTER_TX_SETTING(nb_bit_by_slot, nb_slot_by_frame)( +\
\r
411 AT91C_SSC_CKS_DIV +\
\r
412 AT91C_SSC_CKO_CONTINOUS +\
\r
413 AT91C_SSC_CKG_NONE +\
\r
414 AT91C_SSC_START_FALL_RF +\
\r
415 AT91C_SSC_STTOUT +\
\r
416 ((1<<16) & AT91C_SSC_STTDLY) +\
\r
417 ((((nb_bit_by_slot*nb_slot_by_frame)/2)-1) <<24))
\r
420 //* Configuration to set in the SSC Transmit Frame Mode Register
\r
421 //* Parameters : nb_bit_by_slot : 8, 16 or 32 bits
\r
422 //* nb_slot_by_frame : number of channels
\r
423 #define AT91C_I2S_ASY_TX_FRAME_SETTING(nb_bit_by_slot, nb_slot_by_frame)( +\
\r
424 (nb_bit_by_slot-1) +\
\r
426 (((nb_slot_by_frame-1)<<8) & AT91C_SSC_DATNB) +\
\r
427 (((nb_bit_by_slot-1)<<16) & AT91C_SSC_FSLEN) +\
\r
428 AT91C_SSC_FSOS_NEGATIVE)
\r
431 //*----------------------------------------------------------------------------
\r
432 //* \fn AT91F_SSC_SetBaudrate
\r
433 //* \brief Set the baudrate according to the CPU clock
\r
434 //*----------------------------------------------------------------------------
\r
435 __inline void AT91F_SSC_SetBaudrate (
\r
436 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
437 unsigned int mainClock, // \arg peripheral clock
\r
438 unsigned int speed) // \arg SSC baudrate
\r
440 unsigned int baud_value;
\r
441 //* Define the baud rate divisor register
\r
446 baud_value = (unsigned int) (mainClock * 10)/(2*speed);
\r
447 if ((baud_value % 10) >= 5)
\r
448 baud_value = (baud_value / 10) + 1;
\r
453 pSSC->SSC_CMR = baud_value;
\r
456 //*----------------------------------------------------------------------------
\r
457 //* \fn AT91F_SSC_Configure
\r
458 //* \brief Configure SSC
\r
459 //*----------------------------------------------------------------------------
\r
460 __inline void AT91F_SSC_Configure (
\r
461 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
462 unsigned int syst_clock, // \arg System Clock Frequency
\r
463 unsigned int baud_rate, // \arg Expected Baud Rate Frequency
\r
464 unsigned int clock_rx, // \arg Receiver Clock Parameters
\r
465 unsigned int mode_rx, // \arg mode Register to be programmed
\r
466 unsigned int clock_tx, // \arg Transmitter Clock Parameters
\r
467 unsigned int mode_tx) // \arg mode Register to be programmed
\r
469 //* Disable interrupts
\r
470 pSSC->SSC_IDR = (unsigned int) -1;
\r
472 //* Reset receiver and transmitter
\r
473 pSSC->SSC_CR = AT91C_SSC_SWRST | AT91C_SSC_RXDIS | AT91C_SSC_TXDIS ;
\r
475 //* Define the Clock Mode Register
\r
476 AT91F_SSC_SetBaudrate(pSSC, syst_clock, baud_rate);
\r
478 //* Write the Receive Clock Mode Register
\r
479 pSSC->SSC_RCMR = clock_rx;
\r
481 //* Write the Transmit Clock Mode Register
\r
482 pSSC->SSC_TCMR = clock_tx;
\r
484 //* Write the Receive Frame Mode Register
\r
485 pSSC->SSC_RFMR = mode_rx;
\r
487 //* Write the Transmit Frame Mode Register
\r
488 pSSC->SSC_TFMR = mode_tx;
\r
490 //* Clear Transmit and Receive Counters
\r
491 AT91F_PDC_Open((AT91PS_PDC) &(pSSC->SSC_RPR));
\r
496 //*----------------------------------------------------------------------------
\r
497 //* \fn AT91F_SSC_EnableRx
\r
498 //* \brief Enable receiving datas
\r
499 //*----------------------------------------------------------------------------
\r
500 __inline void AT91F_SSC_EnableRx (
\r
501 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
503 //* Enable receiver
\r
504 pSSC->SSC_CR = AT91C_SSC_RXEN;
\r
507 //*----------------------------------------------------------------------------
\r
508 //* \fn AT91F_SSC_DisableRx
\r
509 //* \brief Disable receiving datas
\r
510 //*----------------------------------------------------------------------------
\r
511 __inline void AT91F_SSC_DisableRx (
\r
512 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
514 //* Disable receiver
\r
515 pSSC->SSC_CR = AT91C_SSC_RXDIS;
\r
518 //*----------------------------------------------------------------------------
\r
519 //* \fn AT91F_SSC_EnableTx
\r
520 //* \brief Enable sending datas
\r
521 //*----------------------------------------------------------------------------
\r
522 __inline void AT91F_SSC_EnableTx (
\r
523 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
525 //* Enable transmitter
\r
526 pSSC->SSC_CR = AT91C_SSC_TXEN;
\r
529 //*----------------------------------------------------------------------------
\r
530 //* \fn AT91F_SSC_DisableTx
\r
531 //* \brief Disable sending datas
\r
532 //*----------------------------------------------------------------------------
\r
533 __inline void AT91F_SSC_DisableTx (
\r
534 AT91PS_SSC pSSC) // \arg pointer to a SSC controller
\r
536 //* Disable transmitter
\r
537 pSSC->SSC_CR = AT91C_SSC_TXDIS;
\r
540 //*----------------------------------------------------------------------------
\r
541 //* \fn AT91F_SSC_EnableIt
\r
542 //* \brief Enable SSC IT
\r
543 //*----------------------------------------------------------------------------
\r
544 __inline void AT91F_SSC_EnableIt (
\r
545 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
546 unsigned int flag) // \arg IT to be enabled
\r
548 //* Write to the IER register
\r
549 pSSC->SSC_IER = flag;
\r
552 //*----------------------------------------------------------------------------
\r
553 //* \fn AT91F_SSC_DisableIt
\r
554 //* \brief Disable SSC IT
\r
555 //*----------------------------------------------------------------------------
\r
556 __inline void AT91F_SSC_DisableIt (
\r
557 AT91PS_SSC pSSC, // \arg pointer to a SSC controller
\r
558 unsigned int flag) // \arg IT to be disabled
\r
560 //* Write to the IDR register
\r
561 pSSC->SSC_IDR = flag;
\r
564 //*----------------------------------------------------------------------------
\r
565 //* \fn AT91F_SSC_ReceiveFrame
\r
566 //* \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
567 //*----------------------------------------------------------------------------
\r
568 __inline unsigned int AT91F_SSC_ReceiveFrame (
\r
571 unsigned int szBuffer,
\r
573 unsigned int szNextBuffer )
\r
575 return AT91F_PDC_ReceiveFrame(
\r
576 (AT91PS_PDC) &(pSSC->SSC_RPR),
\r
583 //*----------------------------------------------------------------------------
\r
584 //* \fn AT91F_SSC_SendFrame
\r
585 //* \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
586 //*----------------------------------------------------------------------------
\r
587 __inline unsigned int AT91F_SSC_SendFrame(
\r
590 unsigned int szBuffer,
\r
592 unsigned int szNextBuffer )
\r
594 return AT91F_PDC_SendFrame(
\r
595 (AT91PS_PDC) &(pSSC->SSC_RPR),
\r
602 //*----------------------------------------------------------------------------
\r
603 //* \fn AT91F_SSC_GetInterruptMaskStatus
\r
604 //* \brief Return SSC Interrupt Mask Status
\r
605 //*----------------------------------------------------------------------------
\r
606 __inline unsigned int AT91F_SSC_GetInterruptMaskStatus( // \return SSC Interrupt Mask Status
\r
607 AT91PS_SSC pSsc) // \arg pointer to a SSC controller
\r
609 return pSsc->SSC_IMR;
\r
612 //*----------------------------------------------------------------------------
\r
613 //* \fn AT91F_SSC_IsInterruptMasked
\r
614 //* \brief Test if SSC Interrupt is Masked
\r
615 //*----------------------------------------------------------------------------
\r
616 __inline int AT91F_SSC_IsInterruptMasked(
\r
617 AT91PS_SSC pSsc, // \arg pointer to a SSC controller
\r
618 unsigned int flag) // \arg flag to be tested
\r
620 return (AT91F_SSC_GetInterruptMaskStatus(pSsc) & flag);
\r
623 /* *****************************************************************************
\r
624 SOFTWARE API FOR SPI
\r
625 ***************************************************************************** */
\r
626 //*----------------------------------------------------------------------------
\r
627 //* \fn AT91F_SPI_Open
\r
628 //* \brief Open a SPI Port
\r
629 //*----------------------------------------------------------------------------
\r
630 __inline unsigned int AT91F_SPI_Open (
\r
631 const unsigned int null) // \arg
\r
633 /* NOT DEFINED AT THIS MOMENT */
\r
637 //*----------------------------------------------------------------------------
\r
638 //* \fn AT91F_SPI_CfgCs
\r
639 //* \brief Configure SPI chip select register
\r
640 //*----------------------------------------------------------------------------
\r
641 __inline void AT91F_SPI_CfgCs (
\r
642 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
643 int cs, // SPI cs number (0 to 3)
\r
644 int val) // chip select register
\r
646 //* Write to the CSR register
\r
647 *(pSPI->SPI_CSR + cs) = val;
\r
650 //*----------------------------------------------------------------------------
\r
651 //* \fn AT91F_SPI_EnableIt
\r
652 //* \brief Enable SPI interrupt
\r
653 //*----------------------------------------------------------------------------
\r
654 __inline void AT91F_SPI_EnableIt (
\r
655 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
656 unsigned int flag) // IT to be enabled
\r
658 //* Write to the IER register
\r
659 pSPI->SPI_IER = flag;
\r
662 //*----------------------------------------------------------------------------
\r
663 //* \fn AT91F_SPI_DisableIt
\r
664 //* \brief Disable SPI interrupt
\r
665 //*----------------------------------------------------------------------------
\r
666 __inline void AT91F_SPI_DisableIt (
\r
667 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
668 unsigned int flag) // IT to be disabled
\r
670 //* Write to the IDR register
\r
671 pSPI->SPI_IDR = flag;
\r
674 //*----------------------------------------------------------------------------
\r
675 //* \fn AT91F_SPI_Reset
\r
676 //* \brief Reset the SPI controller
\r
677 //*----------------------------------------------------------------------------
\r
678 __inline void AT91F_SPI_Reset (
\r
679 AT91PS_SPI pSPI // pointer to a SPI controller
\r
682 //* Write to the CR register
\r
683 pSPI->SPI_CR = AT91C_SPI_SWRST;
\r
686 //*----------------------------------------------------------------------------
\r
687 //* \fn AT91F_SPI_Enable
\r
688 //* \brief Enable the SPI controller
\r
689 //*----------------------------------------------------------------------------
\r
690 __inline void AT91F_SPI_Enable (
\r
691 AT91PS_SPI pSPI // pointer to a SPI controller
\r
694 //* Write to the CR register
\r
695 pSPI->SPI_CR = AT91C_SPI_SPIEN;
\r
698 //*----------------------------------------------------------------------------
\r
699 //* \fn AT91F_SPI_Disable
\r
700 //* \brief Disable the SPI controller
\r
701 //*----------------------------------------------------------------------------
\r
702 __inline void AT91F_SPI_Disable (
\r
703 AT91PS_SPI pSPI // pointer to a SPI controller
\r
706 //* Write to the CR register
\r
707 pSPI->SPI_CR = AT91C_SPI_SPIDIS;
\r
710 //*----------------------------------------------------------------------------
\r
711 //* \fn AT91F_SPI_CfgMode
\r
712 //* \brief Enable the SPI controller
\r
713 //*----------------------------------------------------------------------------
\r
714 __inline void AT91F_SPI_CfgMode (
\r
715 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
716 int mode) // mode register
\r
718 //* Write to the MR register
\r
719 pSPI->SPI_MR = mode;
\r
722 //*----------------------------------------------------------------------------
\r
723 //* \fn AT91F_SPI_CfgPCS
\r
724 //* \brief Switch to the correct PCS of SPI Mode Register : Fixed Peripheral Selected
\r
725 //*----------------------------------------------------------------------------
\r
726 __inline void AT91F_SPI_CfgPCS (
\r
727 AT91PS_SPI pSPI, // pointer to a SPI controller
\r
728 char PCS_Device) // PCS of the Device
\r
730 //* Write to the MR register
\r
731 pSPI->SPI_MR &= 0xFFF0FFFF;
\r
732 pSPI->SPI_MR |= ( (PCS_Device<<16) & AT91C_SPI_PCS );
\r
735 //*----------------------------------------------------------------------------
\r
736 //* \fn AT91F_SPI_ReceiveFrame
\r
737 //* \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
738 //*----------------------------------------------------------------------------
\r
739 __inline unsigned int AT91F_SPI_ReceiveFrame (
\r
742 unsigned int szBuffer,
\r
744 unsigned int szNextBuffer )
\r
746 return AT91F_PDC_ReceiveFrame(
\r
747 (AT91PS_PDC) &(pSPI->SPI_RPR),
\r
754 //*----------------------------------------------------------------------------
\r
755 //* \fn AT91F_SPI_SendFrame
\r
756 //* \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
757 //*----------------------------------------------------------------------------
\r
758 __inline unsigned int AT91F_SPI_SendFrame(
\r
761 unsigned int szBuffer,
\r
763 unsigned int szNextBuffer )
\r
765 return AT91F_PDC_SendFrame(
\r
766 (AT91PS_PDC) &(pSPI->SPI_RPR),
\r
773 //*----------------------------------------------------------------------------
\r
774 //* \fn AT91F_SPI_Close
\r
775 //* \brief Close SPI: disable IT disable transfert, close PDC
\r
776 //*----------------------------------------------------------------------------
\r
777 __inline void AT91F_SPI_Close (
\r
778 AT91PS_SPI pSPI) // \arg pointer to a SPI controller
\r
780 //* Reset all the Chip Select register
\r
781 pSPI->SPI_CSR[0] = 0 ;
\r
782 pSPI->SPI_CSR[1] = 0 ;
\r
783 pSPI->SPI_CSR[2] = 0 ;
\r
784 pSPI->SPI_CSR[3] = 0 ;
\r
786 //* Reset the SPI mode
\r
789 //* Disable all interrupts
\r
790 pSPI->SPI_IDR = 0xFFFFFFFF ;
\r
792 //* Abort the Peripheral Data Transfers
\r
793 AT91F_PDC_Close((AT91PS_PDC) &(pSPI->SPI_RPR));
\r
795 //* Disable receiver and transmitter and stop any activity immediately
\r
796 pSPI->SPI_CR = AT91C_SPI_SPIDIS;
\r
799 //*----------------------------------------------------------------------------
\r
800 //* \fn AT91F_SPI_PutChar
\r
801 //* \brief Send a character,does not check if ready to send
\r
802 //*----------------------------------------------------------------------------
\r
803 __inline void AT91F_SPI_PutChar (
\r
805 unsigned int character,
\r
806 unsigned int cs_number )
\r
808 unsigned int value_for_cs;
\r
809 value_for_cs = (~(1 << cs_number)) & 0xF; //Place a zero among a 4 ONEs number
\r
810 pSPI->SPI_TDR = (character & 0xFFFF) | (value_for_cs << 16);
\r
813 //*----------------------------------------------------------------------------
\r
814 //* \fn AT91F_SPI_GetChar
\r
815 //* \brief Receive a character,does not check if a character is available
\r
816 //*----------------------------------------------------------------------------
\r
817 __inline int AT91F_SPI_GetChar (
\r
818 const AT91PS_SPI pSPI)
\r
820 return((pSPI->SPI_RDR) & 0xFFFF);
\r
823 //*----------------------------------------------------------------------------
\r
824 //* \fn AT91F_SPI_GetInterruptMaskStatus
\r
825 //* \brief Return SPI Interrupt Mask Status
\r
826 //*----------------------------------------------------------------------------
\r
827 __inline unsigned int AT91F_SPI_GetInterruptMaskStatus( // \return SPI Interrupt Mask Status
\r
828 AT91PS_SPI pSpi) // \arg pointer to a SPI controller
\r
830 return pSpi->SPI_IMR;
\r
833 //*----------------------------------------------------------------------------
\r
834 //* \fn AT91F_SPI_IsInterruptMasked
\r
835 //* \brief Test if SPI Interrupt is Masked
\r
836 //*----------------------------------------------------------------------------
\r
837 __inline int AT91F_SPI_IsInterruptMasked(
\r
838 AT91PS_SPI pSpi, // \arg pointer to a SPI controller
\r
839 unsigned int flag) // \arg flag to be tested
\r
841 return (AT91F_SPI_GetInterruptMaskStatus(pSpi) & flag);
\r
844 /* *****************************************************************************
\r
845 SOFTWARE API FOR PWMC
\r
846 ***************************************************************************** */
\r
847 //*----------------------------------------------------------------------------
\r
848 //* \fn AT91F_PWM_GetStatus
\r
849 //* \brief Return PWM Interrupt Status
\r
850 //*----------------------------------------------------------------------------
\r
851 __inline unsigned int AT91F_PWMC_GetStatus( // \return PWM Interrupt Status
\r
852 AT91PS_PWMC pPWM) // pointer to a PWM controller
\r
854 return pPWM->PWMC_SR;
\r
857 //*----------------------------------------------------------------------------
\r
858 //* \fn AT91F_PWM_InterruptEnable
\r
859 //* \brief Enable PWM Interrupt
\r
860 //*----------------------------------------------------------------------------
\r
861 __inline void AT91F_PWMC_InterruptEnable(
\r
862 AT91PS_PWMC pPwm, // \arg pointer to a PWM controller
\r
863 unsigned int flag) // \arg PWM interrupt to be enabled
\r
865 pPwm->PWMC_IER = flag;
\r
868 //*----------------------------------------------------------------------------
\r
869 //* \fn AT91F_PWM_InterruptDisable
\r
870 //* \brief Disable PWM Interrupt
\r
871 //*----------------------------------------------------------------------------
\r
872 __inline void AT91F_PWMC_InterruptDisable(
\r
873 AT91PS_PWMC pPwm, // \arg pointer to a PWM controller
\r
874 unsigned int flag) // \arg PWM interrupt to be disabled
\r
876 pPwm->PWMC_IDR = flag;
\r
879 //*----------------------------------------------------------------------------
\r
880 //* \fn AT91F_PWM_GetInterruptMaskStatus
\r
881 //* \brief Return PWM Interrupt Mask Status
\r
882 //*----------------------------------------------------------------------------
\r
883 __inline unsigned int AT91F_PWMC_GetInterruptMaskStatus( // \return PWM Interrupt Mask Status
\r
884 AT91PS_PWMC pPwm) // \arg pointer to a PWM controller
\r
886 return pPwm->PWMC_IMR;
\r
889 //*----------------------------------------------------------------------------
\r
890 //* \fn AT91F_PWM_IsInterruptMasked
\r
891 //* \brief Test if PWM Interrupt is Masked
\r
892 //*----------------------------------------------------------------------------
\r
893 __inline unsigned int AT91F_PWMC_IsInterruptMasked(
\r
894 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
895 unsigned int flag) // \arg flag to be tested
\r
897 return (AT91F_PWMC_GetInterruptMaskStatus(pPWM) & flag);
\r
900 //*----------------------------------------------------------------------------
\r
901 //* \fn AT91F_PWM_IsStatusSet
\r
902 //* \brief Test if PWM Interrupt is Set
\r
903 //*----------------------------------------------------------------------------
\r
904 __inline unsigned int AT91F_PWMC_IsStatusSet(
\r
905 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
906 unsigned int flag) // \arg flag to be tested
\r
908 return (AT91F_PWMC_GetStatus(pPWM) & flag);
\r
911 //*----------------------------------------------------------------------------
\r
912 //* \fn AT91F_PWM_CfgChannel
\r
913 //* \brief Test if PWM Interrupt is Set
\r
914 //*----------------------------------------------------------------------------
\r
915 __inline void AT91F_PWMC_CfgChannel(
\r
916 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
917 unsigned int channelId, // \arg PWM channel ID
\r
918 unsigned int mode, // \arg PWM mode
\r
919 unsigned int period, // \arg PWM period
\r
920 unsigned int duty) // \arg PWM duty cycle
\r
922 pPWM->PWMC_CH[channelId].PWMC_CMR = mode;
\r
923 pPWM->PWMC_CH[channelId].PWMC_CDTYR = duty;
\r
924 pPWM->PWMC_CH[channelId].PWMC_CPRDR = period;
\r
927 //*----------------------------------------------------------------------------
\r
928 //* \fn AT91F_PWM_StartChannel
\r
929 //* \brief Enable channel
\r
930 //*----------------------------------------------------------------------------
\r
931 __inline void AT91F_PWMC_StartChannel(
\r
932 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
933 unsigned int flag) // \arg Channels IDs to be enabled
\r
935 pPWM->PWMC_ENA = flag;
\r
938 //*----------------------------------------------------------------------------
\r
939 //* \fn AT91F_PWM_StopChannel
\r
940 //* \brief Disable channel
\r
941 //*----------------------------------------------------------------------------
\r
942 __inline void AT91F_PWMC_StopChannel(
\r
943 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
944 unsigned int flag) // \arg Channels IDs to be enabled
\r
946 pPWM->PWMC_DIS = flag;
\r
949 //*----------------------------------------------------------------------------
\r
950 //* \fn AT91F_PWM_UpdateChannel
\r
951 //* \brief Update Period or Duty Cycle
\r
952 //*----------------------------------------------------------------------------
\r
953 __inline void AT91F_PWMC_UpdateChannel(
\r
954 AT91PS_PWMC pPWM, // \arg pointer to a PWM controller
\r
955 unsigned int channelId, // \arg PWM channel ID
\r
956 unsigned int update) // \arg Channels IDs to be enabled
\r
958 pPWM->PWMC_CH[channelId].PWMC_CUPDR = update;
\r
961 /* *****************************************************************************
\r
962 SOFTWARE API FOR TC
\r
963 ***************************************************************************** */
\r
964 //*----------------------------------------------------------------------------
\r
965 //* \fn AT91F_TC_InterruptEnable
\r
966 //* \brief Enable TC Interrupt
\r
967 //*----------------------------------------------------------------------------
\r
968 __inline void AT91F_TC_InterruptEnable(
\r
969 AT91PS_TC pTc, // \arg pointer to a TC controller
\r
970 unsigned int flag) // \arg TC interrupt to be enabled
\r
972 pTc->TC_IER = flag;
\r
975 //*----------------------------------------------------------------------------
\r
976 //* \fn AT91F_TC_InterruptDisable
\r
977 //* \brief Disable TC Interrupt
\r
978 //*----------------------------------------------------------------------------
\r
979 __inline void AT91F_TC_InterruptDisable(
\r
980 AT91PS_TC pTc, // \arg pointer to a TC controller
\r
981 unsigned int flag) // \arg TC interrupt to be disabled
\r
983 pTc->TC_IDR = flag;
\r
986 //*----------------------------------------------------------------------------
\r
987 //* \fn AT91F_TC_GetInterruptMaskStatus
\r
988 //* \brief Return TC Interrupt Mask Status
\r
989 //*----------------------------------------------------------------------------
\r
990 __inline unsigned int AT91F_TC_GetInterruptMaskStatus( // \return TC Interrupt Mask Status
\r
991 AT91PS_TC pTc) // \arg pointer to a TC controller
\r
993 return pTc->TC_IMR;
\r
996 //*----------------------------------------------------------------------------
\r
997 //* \fn AT91F_TC_IsInterruptMasked
\r
998 //* \brief Test if TC Interrupt is Masked
\r
999 //*----------------------------------------------------------------------------
\r
1000 __inline int AT91F_TC_IsInterruptMasked(
\r
1001 AT91PS_TC pTc, // \arg pointer to a TC controller
\r
1002 unsigned int flag) // \arg flag to be tested
\r
1004 return (AT91F_TC_GetInterruptMaskStatus(pTc) & flag);
\r
1007 /* *****************************************************************************
\r
1008 SOFTWARE API FOR PMC
\r
1009 ***************************************************************************** */
\r
1010 //*----------------------------------------------------------------------------
\r
1011 //* \fn AT91F_PMC_CfgSysClkEnableReg
\r
1012 //* \brief Configure the System Clock Enable Register of the PMC controller
\r
1013 //*----------------------------------------------------------------------------
\r
1014 __inline void AT91F_PMC_CfgSysClkEnableReg (
\r
1015 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1016 unsigned int mode)
\r
1018 //* Write to the SCER register
\r
1019 pPMC->PMC_SCER = mode;
\r
1022 //*----------------------------------------------------------------------------
\r
1023 //* \fn AT91F_PMC_CfgSysClkDisableReg
\r
1024 //* \brief Configure the System Clock Disable Register of the PMC controller
\r
1025 //*----------------------------------------------------------------------------
\r
1026 __inline void AT91F_PMC_CfgSysClkDisableReg (
\r
1027 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1028 unsigned int mode)
\r
1030 //* Write to the SCDR register
\r
1031 pPMC->PMC_SCDR = mode;
\r
1034 //*----------------------------------------------------------------------------
\r
1035 //* \fn AT91F_PMC_GetSysClkStatusReg
\r
1036 //* \brief Return the System Clock Status Register of the PMC controller
\r
1037 //*----------------------------------------------------------------------------
\r
1038 __inline unsigned int AT91F_PMC_GetSysClkStatusReg (
\r
1039 AT91PS_PMC pPMC // pointer to a CAN controller
\r
1042 return pPMC->PMC_SCSR;
\r
1045 //*----------------------------------------------------------------------------
\r
1046 //* \fn AT91F_PMC_EnablePeriphClock
\r
1047 //* \brief Enable peripheral clock
\r
1048 //*----------------------------------------------------------------------------
\r
1049 __inline void AT91F_PMC_EnablePeriphClock (
\r
1050 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1051 unsigned int periphIds) // \arg IDs of peripherals to enable
\r
1053 pPMC->PMC_PCER = periphIds;
\r
1056 //*----------------------------------------------------------------------------
\r
1057 //* \fn AT91F_PMC_DisablePeriphClock
\r
1058 //* \brief Disable peripheral clock
\r
1059 //*----------------------------------------------------------------------------
\r
1060 __inline void AT91F_PMC_DisablePeriphClock (
\r
1061 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1062 unsigned int periphIds) // \arg IDs of peripherals to enable
\r
1064 pPMC->PMC_PCDR = periphIds;
\r
1067 //*----------------------------------------------------------------------------
\r
1068 //* \fn AT91F_PMC_GetPeriphClock
\r
1069 //* \brief Get peripheral clock status
\r
1070 //*----------------------------------------------------------------------------
\r
1071 __inline unsigned int AT91F_PMC_GetPeriphClock (
\r
1072 AT91PS_PMC pPMC) // \arg pointer to PMC controller
\r
1074 return pPMC->PMC_PCSR;
\r
1077 //*----------------------------------------------------------------------------
\r
1078 //* \fn AT91F_CKGR_CfgMainOscillatorReg
\r
1079 //* \brief Cfg the main oscillator
\r
1080 //*----------------------------------------------------------------------------
\r
1081 __inline void AT91F_CKGR_CfgMainOscillatorReg (
\r
1082 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1083 unsigned int mode)
\r
1085 pCKGR->CKGR_MOR = mode;
\r
1088 //*----------------------------------------------------------------------------
\r
1089 //* \fn AT91F_CKGR_GetMainOscillatorReg
\r
1090 //* \brief Cfg the main oscillator
\r
1091 //*----------------------------------------------------------------------------
\r
1092 __inline unsigned int AT91F_CKGR_GetMainOscillatorReg (
\r
1093 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1095 return pCKGR->CKGR_MOR;
\r
1098 //*----------------------------------------------------------------------------
\r
1099 //* \fn AT91F_CKGR_EnableMainOscillator
\r
1100 //* \brief Enable the main oscillator
\r
1101 //*----------------------------------------------------------------------------
\r
1102 __inline void AT91F_CKGR_EnableMainOscillator(
\r
1103 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1105 pCKGR->CKGR_MOR |= AT91C_CKGR_MOSCEN;
\r
1108 //*----------------------------------------------------------------------------
\r
1109 //* \fn AT91F_CKGR_DisableMainOscillator
\r
1110 //* \brief Disable the main oscillator
\r
1111 //*----------------------------------------------------------------------------
\r
1112 __inline void AT91F_CKGR_DisableMainOscillator (
\r
1113 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1115 pCKGR->CKGR_MOR &= ~AT91C_CKGR_MOSCEN;
\r
1118 //*----------------------------------------------------------------------------
\r
1119 //* \fn AT91F_CKGR_CfgMainOscStartUpTime
\r
1120 //* \brief Cfg MOR Register according to the main osc startup time
\r
1121 //*----------------------------------------------------------------------------
\r
1122 __inline void AT91F_CKGR_CfgMainOscStartUpTime (
\r
1123 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1124 unsigned int startup_time, // \arg main osc startup time in microsecond (us)
\r
1125 unsigned int slowClock) // \arg slowClock in Hz
\r
1127 pCKGR->CKGR_MOR &= ~AT91C_CKGR_OSCOUNT;
\r
1128 pCKGR->CKGR_MOR |= ((slowClock * startup_time)/(8*1000000)) << 8;
\r
1131 //*----------------------------------------------------------------------------
\r
1132 //* \fn AT91F_CKGR_GetMainClockFreqReg
\r
1133 //* \brief Cfg the main oscillator
\r
1134 //*----------------------------------------------------------------------------
\r
1135 __inline unsigned int AT91F_CKGR_GetMainClockFreqReg (
\r
1136 AT91PS_CKGR pCKGR) // \arg pointer to CKGR controller
\r
1138 return pCKGR->CKGR_MCFR;
\r
1141 //*----------------------------------------------------------------------------
\r
1142 //* \fn AT91F_CKGR_GetMainClock
\r
1143 //* \brief Return Main clock in Hz
\r
1144 //*----------------------------------------------------------------------------
\r
1145 __inline unsigned int AT91F_CKGR_GetMainClock (
\r
1146 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1147 unsigned int slowClock) // \arg slowClock in Hz
\r
1149 return ((pCKGR->CKGR_MCFR & AT91C_CKGR_MAINF) * slowClock) >> 4;
\r
1152 //*----------------------------------------------------------------------------
\r
1153 //* \fn AT91F_PMC_CfgMCKReg
\r
1154 //* \brief Cfg Master Clock Register
\r
1155 //*----------------------------------------------------------------------------
\r
1156 __inline void AT91F_PMC_CfgMCKReg (
\r
1157 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1158 unsigned int mode)
\r
1160 pPMC->PMC_MCKR = mode;
\r
1163 //*----------------------------------------------------------------------------
\r
1164 //* \fn AT91F_PMC_GetMCKReg
\r
1165 //* \brief Return Master Clock Register
\r
1166 //*----------------------------------------------------------------------------
\r
1167 __inline unsigned int AT91F_PMC_GetMCKReg(
\r
1168 AT91PS_PMC pPMC) // \arg pointer to PMC controller
\r
1170 return pPMC->PMC_MCKR;
\r
1173 //*------------------------------------------------------------------------------
\r
1174 //* \fn AT91F_PMC_GetMasterClock
\r
1175 //* \brief Return master clock in Hz which correponds to processor clock for ARM7
\r
1176 //*------------------------------------------------------------------------------
\r
1177 __inline unsigned int AT91F_PMC_GetMasterClock (
\r
1178 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1179 AT91PS_CKGR pCKGR, // \arg pointer to CKGR controller
\r
1180 unsigned int slowClock) // \arg slowClock in Hz
\r
1182 unsigned int reg = pPMC->PMC_MCKR;
\r
1183 unsigned int prescaler = (1 << ((reg & AT91C_PMC_PRES) >> 2));
\r
1184 unsigned int pllDivider, pllMultiplier;
\r
1186 switch (reg & AT91C_PMC_CSS) {
\r
1187 case AT91C_PMC_CSS_SLOW_CLK: // Slow clock selected
\r
1188 return slowClock / prescaler;
\r
1189 case AT91C_PMC_CSS_MAIN_CLK: // Main clock is selected
\r
1190 return AT91F_CKGR_GetMainClock(pCKGR, slowClock) / prescaler;
\r
1191 case AT91C_PMC_CSS_PLL_CLK: // PLLB clock is selected
\r
1192 reg = pCKGR->CKGR_PLLR;
\r
1193 pllDivider = (reg & AT91C_CKGR_DIV);
\r
1194 pllMultiplier = ((reg & AT91C_CKGR_MUL) >> 16) + 1;
\r
1195 return AT91F_CKGR_GetMainClock(pCKGR, slowClock) / pllDivider * pllMultiplier / prescaler;
\r
1200 //*----------------------------------------------------------------------------
\r
1201 //* \fn AT91F_PMC_EnablePCK
\r
1202 //* \brief Enable peripheral clock
\r
1203 //*----------------------------------------------------------------------------
\r
1204 __inline void AT91F_PMC_EnablePCK (
\r
1205 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1206 unsigned int pck, // \arg Peripheral clock identifier 0 .. 7
\r
1207 unsigned int mode)
\r
1209 pPMC->PMC_PCKR[pck] = mode;
\r
1210 pPMC->PMC_SCER = (1 << pck) << 8;
\r
1213 //*----------------------------------------------------------------------------
\r
1214 //* \fn AT91F_PMC_DisablePCK
\r
1215 //* \brief Enable peripheral clock
\r
1216 //*----------------------------------------------------------------------------
\r
1217 __inline void AT91F_PMC_DisablePCK (
\r
1218 AT91PS_PMC pPMC, // \arg pointer to PMC controller
\r
1219 unsigned int pck) // \arg Peripheral clock identifier 0 .. 7
\r
1221 pPMC->PMC_SCDR = (1 << pck) << 8;
\r
1224 //*----------------------------------------------------------------------------
\r
1225 //* \fn AT91F_PMC_EnableIt
\r
1226 //* \brief Enable PMC interrupt
\r
1227 //*----------------------------------------------------------------------------
\r
1228 __inline void AT91F_PMC_EnableIt (
\r
1229 AT91PS_PMC pPMC, // pointer to a PMC controller
\r
1230 unsigned int flag) // IT to be enabled
\r
1232 //* Write to the IER register
\r
1233 pPMC->PMC_IER = flag;
\r
1236 //*----------------------------------------------------------------------------
\r
1237 //* \fn AT91F_PMC_DisableIt
\r
1238 //* \brief Disable PMC interrupt
\r
1239 //*----------------------------------------------------------------------------
\r
1240 __inline void AT91F_PMC_DisableIt (
\r
1241 AT91PS_PMC pPMC, // pointer to a PMC controller
\r
1242 unsigned int flag) // IT to be disabled
\r
1244 //* Write to the IDR register
\r
1245 pPMC->PMC_IDR = flag;
\r
1248 //*----------------------------------------------------------------------------
\r
1249 //* \fn AT91F_PMC_GetStatus
\r
1250 //* \brief Return PMC Interrupt Status
\r
1251 //*----------------------------------------------------------------------------
\r
1252 __inline unsigned int AT91F_PMC_GetStatus( // \return PMC Interrupt Status
\r
1253 AT91PS_PMC pPMC) // pointer to a PMC controller
\r
1255 return pPMC->PMC_SR;
\r
1258 //*----------------------------------------------------------------------------
\r
1259 //* \fn AT91F_PMC_GetInterruptMaskStatus
\r
1260 //* \brief Return PMC Interrupt Mask Status
\r
1261 //*----------------------------------------------------------------------------
\r
1262 __inline unsigned int AT91F_PMC_GetInterruptMaskStatus( // \return PMC Interrupt Mask Status
\r
1263 AT91PS_PMC pPMC) // pointer to a PMC controller
\r
1265 return pPMC->PMC_IMR;
\r
1268 //*----------------------------------------------------------------------------
\r
1269 //* \fn AT91F_PMC_IsInterruptMasked
\r
1270 //* \brief Test if PMC Interrupt is Masked
\r
1271 //*----------------------------------------------------------------------------
\r
1272 __inline unsigned int AT91F_PMC_IsInterruptMasked(
\r
1273 AT91PS_PMC pPMC, // \arg pointer to a PMC controller
\r
1274 unsigned int flag) // \arg flag to be tested
\r
1276 return (AT91F_PMC_GetInterruptMaskStatus(pPMC) & flag);
\r
1279 //*----------------------------------------------------------------------------
\r
1280 //* \fn AT91F_PMC_IsStatusSet
\r
1281 //* \brief Test if PMC Status is Set
\r
1282 //*----------------------------------------------------------------------------
\r
1283 __inline unsigned int AT91F_PMC_IsStatusSet(
\r
1284 AT91PS_PMC pPMC, // \arg pointer to a PMC controller
\r
1285 unsigned int flag) // \arg flag to be tested
\r
1287 return (AT91F_PMC_GetStatus(pPMC) & flag);
\r
1288 }/* *****************************************************************************
\r
1289 SOFTWARE API FOR ADC
\r
1290 ***************************************************************************** */
\r
1291 //*----------------------------------------------------------------------------
\r
1292 //* \fn AT91F_ADC_EnableIt
\r
1293 //* \brief Enable ADC interrupt
\r
1294 //*----------------------------------------------------------------------------
\r
1295 __inline void AT91F_ADC_EnableIt (
\r
1296 AT91PS_ADC pADC, // pointer to a ADC controller
\r
1297 unsigned int flag) // IT to be enabled
\r
1299 //* Write to the IER register
\r
1300 pADC->ADC_IER = flag;
\r
1303 //*----------------------------------------------------------------------------
\r
1304 //* \fn AT91F_ADC_DisableIt
\r
1305 //* \brief Disable ADC interrupt
\r
1306 //*----------------------------------------------------------------------------
\r
1307 __inline void AT91F_ADC_DisableIt (
\r
1308 AT91PS_ADC pADC, // pointer to a ADC controller
\r
1309 unsigned int flag) // IT to be disabled
\r
1311 //* Write to the IDR register
\r
1312 pADC->ADC_IDR = flag;
\r
1315 //*----------------------------------------------------------------------------
\r
1316 //* \fn AT91F_ADC_GetStatus
\r
1317 //* \brief Return ADC Interrupt Status
\r
1318 //*----------------------------------------------------------------------------
\r
1319 __inline unsigned int AT91F_ADC_GetStatus( // \return ADC Interrupt Status
\r
1320 AT91PS_ADC pADC) // pointer to a ADC controller
\r
1322 return pADC->ADC_SR;
\r
1325 //*----------------------------------------------------------------------------
\r
1326 //* \fn AT91F_ADC_GetInterruptMaskStatus
\r
1327 //* \brief Return ADC Interrupt Mask Status
\r
1328 //*----------------------------------------------------------------------------
\r
1329 __inline unsigned int AT91F_ADC_GetInterruptMaskStatus( // \return ADC Interrupt Mask Status
\r
1330 AT91PS_ADC pADC) // pointer to a ADC controller
\r
1332 return pADC->ADC_IMR;
\r
1335 //*----------------------------------------------------------------------------
\r
1336 //* \fn AT91F_ADC_IsInterruptMasked
\r
1337 //* \brief Test if ADC Interrupt is Masked
\r
1338 //*----------------------------------------------------------------------------
\r
1339 __inline unsigned int AT91F_ADC_IsInterruptMasked(
\r
1340 AT91PS_ADC pADC, // \arg pointer to a ADC controller
\r
1341 unsigned int flag) // \arg flag to be tested
\r
1343 return (AT91F_ADC_GetInterruptMaskStatus(pADC) & flag);
\r
1346 //*----------------------------------------------------------------------------
\r
1347 //* \fn AT91F_ADC_IsStatusSet
\r
1348 //* \brief Test if ADC Status is Set
\r
1349 //*----------------------------------------------------------------------------
\r
1350 __inline unsigned int AT91F_ADC_IsStatusSet(
\r
1351 AT91PS_ADC pADC, // \arg pointer to a ADC controller
\r
1352 unsigned int flag) // \arg flag to be tested
\r
1354 return (AT91F_ADC_GetStatus(pADC) & flag);
\r
1357 //*----------------------------------------------------------------------------
\r
1358 //* \fn AT91F_ADC_CfgModeReg
\r
1359 //* \brief Configure the Mode Register of the ADC controller
\r
1360 //*----------------------------------------------------------------------------
\r
1361 __inline void AT91F_ADC_CfgModeReg (
\r
1362 AT91PS_ADC pADC, // pointer to a ADC controller
\r
1363 unsigned int mode) // mode register
\r
1365 //* Write to the MR register
\r
1366 pADC->ADC_MR = mode;
\r
1369 //*----------------------------------------------------------------------------
\r
1370 //* \fn AT91F_ADC_GetModeReg
\r
1371 //* \brief Return the Mode Register of the ADC controller value
\r
1372 //*----------------------------------------------------------------------------
\r
1373 __inline unsigned int AT91F_ADC_GetModeReg (
\r
1374 AT91PS_ADC pADC // pointer to a ADC controller
\r
1377 return pADC->ADC_MR;
\r
1380 //*----------------------------------------------------------------------------
\r
1381 //* \fn AT91F_ADC_CfgTimings
\r
1382 //* \brief Configure the different necessary timings of the ADC controller
\r
1383 //*----------------------------------------------------------------------------
\r
1384 __inline void AT91F_ADC_CfgTimings (
\r
1385 AT91PS_ADC pADC, // pointer to a ADC controller
\r
1386 unsigned int mck_clock, // in MHz
\r
1387 unsigned int adc_clock, // in MHz
\r
1388 unsigned int startup_time, // in us
\r
1389 unsigned int sample_and_hold_time) // in ns
\r
1391 unsigned int prescal,startup,shtim;
\r
1393 prescal = mck_clock/(2*adc_clock) - 1;
\r
1394 startup = adc_clock*startup_time/8 - 1;
\r
1395 shtim = adc_clock*sample_and_hold_time/1000 - 1;
\r
1397 //* Write to the MR register
\r
1398 pADC->ADC_MR = ( (prescal<<8) & AT91C_ADC_PRESCAL) | ( (startup<<16) & AT91C_ADC_STARTUP) | ( (shtim<<24) & AT91C_ADC_SHTIM);
\r
1401 //*----------------------------------------------------------------------------
\r
1402 //* \fn AT91F_ADC_EnableChannel
\r
1403 //* \brief Return ADC Timer Register Value
\r
1404 //*----------------------------------------------------------------------------
\r
1405 __inline void AT91F_ADC_EnableChannel (
\r
1406 AT91PS_ADC pADC, // pointer to a ADC controller
\r
1407 unsigned int channel) // mode register
\r
1409 //* Write to the CHER register
\r
1410 pADC->ADC_CHER = channel;
\r
1413 //*----------------------------------------------------------------------------
\r
1414 //* \fn AT91F_ADC_DisableChannel
\r
1415 //* \brief Return ADC Timer Register Value
\r
1416 //*----------------------------------------------------------------------------
\r
1417 __inline void AT91F_ADC_DisableChannel (
\r
1418 AT91PS_ADC pADC, // pointer to a ADC controller
\r
1419 unsigned int channel) // mode register
\r
1421 //* Write to the CHDR register
\r
1422 pADC->ADC_CHDR = channel;
\r
1425 //*----------------------------------------------------------------------------
\r
1426 //* \fn AT91F_ADC_GetChannelStatus
\r
1427 //* \brief Return ADC Timer Register Value
\r
1428 //*----------------------------------------------------------------------------
\r
1429 __inline unsigned int AT91F_ADC_GetChannelStatus (
\r
1430 AT91PS_ADC pADC // pointer to a ADC controller
\r
1433 return pADC->ADC_CHSR;
\r
1436 //*----------------------------------------------------------------------------
\r
1437 //* \fn AT91F_ADC_StartConversion
\r
1438 //* \brief Software request for a analog to digital conversion
\r
1439 //*----------------------------------------------------------------------------
\r
1440 __inline void AT91F_ADC_StartConversion (
\r
1441 AT91PS_ADC pADC // pointer to a ADC controller
\r
1444 pADC->ADC_CR = AT91C_ADC_START;
\r
1447 //*----------------------------------------------------------------------------
\r
1448 //* \fn AT91F_ADC_SoftReset
\r
1449 //* \brief Software reset
\r
1450 //*----------------------------------------------------------------------------
\r
1451 __inline void AT91F_ADC_SoftReset (
\r
1452 AT91PS_ADC pADC // pointer to a ADC controller
\r
1455 pADC->ADC_CR = AT91C_ADC_SWRST;
\r
1458 //*----------------------------------------------------------------------------
\r
1459 //* \fn AT91F_ADC_GetLastConvertedData
\r
1460 //* \brief Return the Last Converted Data
\r
1461 //*----------------------------------------------------------------------------
\r
1462 __inline unsigned int AT91F_ADC_GetLastConvertedData (
\r
1463 AT91PS_ADC pADC // pointer to a ADC controller
\r
1466 return pADC->ADC_LCDR;
\r
1469 //*----------------------------------------------------------------------------
\r
1470 //* \fn AT91F_ADC_GetConvertedDataCH0
\r
1471 //* \brief Return the Channel 0 Converted Data
\r
1472 //*----------------------------------------------------------------------------
\r
1473 __inline unsigned int AT91F_ADC_GetConvertedDataCH0 (
\r
1474 AT91PS_ADC pADC // pointer to a ADC controller
\r
1477 return pADC->ADC_CDR0;
\r
1480 //*----------------------------------------------------------------------------
\r
1481 //* \fn AT91F_ADC_GetConvertedDataCH1
\r
1482 //* \brief Return the Channel 1 Converted Data
\r
1483 //*----------------------------------------------------------------------------
\r
1484 __inline unsigned int AT91F_ADC_GetConvertedDataCH1 (
\r
1485 AT91PS_ADC pADC // pointer to a ADC controller
\r
1488 return pADC->ADC_CDR1;
\r
1491 //*----------------------------------------------------------------------------
\r
1492 //* \fn AT91F_ADC_GetConvertedDataCH2
\r
1493 //* \brief Return the Channel 2 Converted Data
\r
1494 //*----------------------------------------------------------------------------
\r
1495 __inline unsigned int AT91F_ADC_GetConvertedDataCH2 (
\r
1496 AT91PS_ADC pADC // pointer to a ADC controller
\r
1499 return pADC->ADC_CDR2;
\r
1502 //*----------------------------------------------------------------------------
\r
1503 //* \fn AT91F_ADC_GetConvertedDataCH3
\r
1504 //* \brief Return the Channel 3 Converted Data
\r
1505 //*----------------------------------------------------------------------------
\r
1506 __inline unsigned int AT91F_ADC_GetConvertedDataCH3 (
\r
1507 AT91PS_ADC pADC // pointer to a ADC controller
\r
1510 return pADC->ADC_CDR3;
\r
1513 //*----------------------------------------------------------------------------
\r
1514 //* \fn AT91F_ADC_GetConvertedDataCH4
\r
1515 //* \brief Return the Channel 4 Converted Data
\r
1516 //*----------------------------------------------------------------------------
\r
1517 __inline unsigned int AT91F_ADC_GetConvertedDataCH4 (
\r
1518 AT91PS_ADC pADC // pointer to a ADC controller
\r
1521 return pADC->ADC_CDR4;
\r
1524 //*----------------------------------------------------------------------------
\r
1525 //* \fn AT91F_ADC_GetConvertedDataCH5
\r
1526 //* \brief Return the Channel 5 Converted Data
\r
1527 //*----------------------------------------------------------------------------
\r
1528 __inline unsigned int AT91F_ADC_GetConvertedDataCH5 (
\r
1529 AT91PS_ADC pADC // pointer to a ADC controller
\r
1532 return pADC->ADC_CDR5;
\r
1535 //*----------------------------------------------------------------------------
\r
1536 //* \fn AT91F_ADC_GetConvertedDataCH6
\r
1537 //* \brief Return the Channel 6 Converted Data
\r
1538 //*----------------------------------------------------------------------------
\r
1539 __inline unsigned int AT91F_ADC_GetConvertedDataCH6 (
\r
1540 AT91PS_ADC pADC // pointer to a ADC controller
\r
1543 return pADC->ADC_CDR6;
\r
1546 //*----------------------------------------------------------------------------
\r
1547 //* \fn AT91F_ADC_GetConvertedDataCH7
\r
1548 //* \brief Return the Channel 7 Converted Data
\r
1549 //*----------------------------------------------------------------------------
\r
1550 __inline unsigned int AT91F_ADC_GetConvertedDataCH7 (
\r
1551 AT91PS_ADC pADC // pointer to a ADC controller
\r
1554 return pADC->ADC_CDR7;
\r
1557 /* *****************************************************************************
\r
1558 SOFTWARE API FOR PIO
\r
1559 ***************************************************************************** */
\r
1560 //*----------------------------------------------------------------------------
\r
1561 //* \fn AT91F_PIO_CfgPeriph
\r
1562 //* \brief Enable pins to be drived by peripheral
\r
1563 //*----------------------------------------------------------------------------
\r
1564 __inline void AT91F_PIO_CfgPeriph(
\r
1565 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1566 unsigned int periphAEnable, // \arg PERIPH A to enable
\r
1567 unsigned int periphBEnable) // \arg PERIPH B to enable
\r
1570 pPio->PIO_ASR = periphAEnable;
\r
1571 pPio->PIO_BSR = periphBEnable;
\r
1572 pPio->PIO_PDR = (periphAEnable | periphBEnable); // Set in Periph mode
\r
1575 //*----------------------------------------------------------------------------
\r
1576 //* \fn AT91F_PIO_CfgOutput
\r
1577 //* \brief Enable PIO in output mode
\r
1578 //*----------------------------------------------------------------------------
\r
1579 __inline void AT91F_PIO_CfgOutput(
\r
1580 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1581 unsigned int pioEnable) // \arg PIO to be enabled
\r
1583 pPio->PIO_PER = pioEnable; // Set in PIO mode
\r
1584 pPio->PIO_OER = pioEnable; // Configure in Output
\r
1587 //*----------------------------------------------------------------------------
\r
1588 //* \fn AT91F_PIO_CfgInput
\r
1589 //* \brief Enable PIO in input mode
\r
1590 //*----------------------------------------------------------------------------
\r
1591 __inline void AT91F_PIO_CfgInput(
\r
1592 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1593 unsigned int inputEnable) // \arg PIO to be enabled
\r
1596 pPio->PIO_ODR = inputEnable;
\r
1597 pPio->PIO_PER = inputEnable;
\r
1600 //*----------------------------------------------------------------------------
\r
1601 //* \fn AT91F_PIO_CfgOpendrain
\r
1602 //* \brief Configure PIO in open drain
\r
1603 //*----------------------------------------------------------------------------
\r
1604 __inline void AT91F_PIO_CfgOpendrain(
\r
1605 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1606 unsigned int multiDrvEnable) // \arg pio to be configured in open drain
\r
1608 // Configure the multi-drive option
\r
1609 pPio->PIO_MDDR = ~multiDrvEnable;
\r
1610 pPio->PIO_MDER = multiDrvEnable;
\r
1613 //*----------------------------------------------------------------------------
\r
1614 //* \fn AT91F_PIO_CfgPullup
\r
1615 //* \brief Enable pullup on PIO
\r
1616 //*----------------------------------------------------------------------------
\r
1617 __inline void AT91F_PIO_CfgPullup(
\r
1618 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1619 unsigned int pullupEnable) // \arg enable pullup on PIO
\r
1621 // Connect or not Pullup
\r
1622 pPio->PIO_PPUDR = ~pullupEnable;
\r
1623 pPio->PIO_PPUER = pullupEnable;
\r
1626 //*----------------------------------------------------------------------------
\r
1627 //* \fn AT91F_PIO_CfgDirectDrive
\r
1628 //* \brief Enable direct drive on PIO
\r
1629 //*----------------------------------------------------------------------------
\r
1630 __inline void AT91F_PIO_CfgDirectDrive(
\r
1631 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1632 unsigned int directDrive) // \arg PIO to be configured with direct drive
\r
1635 // Configure the Direct Drive
\r
1636 pPio->PIO_OWDR = ~directDrive;
\r
1637 pPio->PIO_OWER = directDrive;
\r
1640 //*----------------------------------------------------------------------------
\r
1641 //* \fn AT91F_PIO_CfgInputFilter
\r
1642 //* \brief Enable input filter on input PIO
\r
1643 //*----------------------------------------------------------------------------
\r
1644 __inline void AT91F_PIO_CfgInputFilter(
\r
1645 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1646 unsigned int inputFilter) // \arg PIO to be configured with input filter
\r
1649 // Configure the Direct Drive
\r
1650 pPio->PIO_IFDR = ~inputFilter;
\r
1651 pPio->PIO_IFER = inputFilter;
\r
1654 //*----------------------------------------------------------------------------
\r
1655 //* \fn AT91F_PIO_GetInput
\r
1656 //* \brief Return PIO input value
\r
1657 //*----------------------------------------------------------------------------
\r
1658 __inline unsigned int AT91F_PIO_GetInput( // \return PIO input
\r
1659 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1661 return pPio->PIO_PDSR;
\r
1664 //*----------------------------------------------------------------------------
\r
1665 //* \fn AT91F_PIO_IsInputSet
\r
1666 //* \brief Test if PIO is input flag is active
\r
1667 //*----------------------------------------------------------------------------
\r
1668 __inline int AT91F_PIO_IsInputSet(
\r
1669 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1670 unsigned int flag) // \arg flag to be tested
\r
1672 return (AT91F_PIO_GetInput(pPio) & flag);
\r
1676 //*----------------------------------------------------------------------------
\r
1677 //* \fn AT91F_PIO_SetOutput
\r
1678 //* \brief Set to 1 output PIO
\r
1679 //*----------------------------------------------------------------------------
\r
1680 __inline void AT91F_PIO_SetOutput(
\r
1681 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1682 unsigned int flag) // \arg output to be set
\r
1684 pPio->PIO_SODR = flag;
\r
1687 //*----------------------------------------------------------------------------
\r
1688 //* \fn AT91F_PIO_ClearOutput
\r
1689 //* \brief Set to 0 output PIO
\r
1690 //*----------------------------------------------------------------------------
\r
1691 __inline void AT91F_PIO_ClearOutput(
\r
1692 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1693 unsigned int flag) // \arg output to be cleared
\r
1695 pPio->PIO_CODR = flag;
\r
1698 //*----------------------------------------------------------------------------
\r
1699 //* \fn AT91F_PIO_ForceOutput
\r
1700 //* \brief Force output when Direct drive option is enabled
\r
1701 //*----------------------------------------------------------------------------
\r
1702 __inline void AT91F_PIO_ForceOutput(
\r
1703 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1704 unsigned int flag) // \arg output to be forced
\r
1706 pPio->PIO_ODSR = flag;
\r
1709 //*----------------------------------------------------------------------------
\r
1710 //* \fn AT91F_PIO_Enable
\r
1711 //* \brief Enable PIO
\r
1712 //*----------------------------------------------------------------------------
\r
1713 __inline void AT91F_PIO_Enable(
\r
1714 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1715 unsigned int flag) // \arg pio to be enabled
\r
1717 pPio->PIO_PER = flag;
\r
1720 //*----------------------------------------------------------------------------
\r
1721 //* \fn AT91F_PIO_Disable
\r
1722 //* \brief Disable PIO
\r
1723 //*----------------------------------------------------------------------------
\r
1724 __inline void AT91F_PIO_Disable(
\r
1725 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1726 unsigned int flag) // \arg pio to be disabled
\r
1728 pPio->PIO_PDR = flag;
\r
1731 //*----------------------------------------------------------------------------
\r
1732 //* \fn AT91F_PIO_GetStatus
\r
1733 //* \brief Return PIO Status
\r
1734 //*----------------------------------------------------------------------------
\r
1735 __inline unsigned int AT91F_PIO_GetStatus( // \return PIO Status
\r
1736 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1738 return pPio->PIO_PSR;
\r
1741 //*----------------------------------------------------------------------------
\r
1742 //* \fn AT91F_PIO_IsSet
\r
1743 //* \brief Test if PIO is Set
\r
1744 //*----------------------------------------------------------------------------
\r
1745 __inline int AT91F_PIO_IsSet(
\r
1746 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1747 unsigned int flag) // \arg flag to be tested
\r
1749 return (AT91F_PIO_GetStatus(pPio) & flag);
\r
1752 //*----------------------------------------------------------------------------
\r
1753 //* \fn AT91F_PIO_OutputEnable
\r
1754 //* \brief Output Enable PIO
\r
1755 //*----------------------------------------------------------------------------
\r
1756 __inline void AT91F_PIO_OutputEnable(
\r
1757 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1758 unsigned int flag) // \arg pio output to be enabled
\r
1760 pPio->PIO_OER = flag;
\r
1763 //*----------------------------------------------------------------------------
\r
1764 //* \fn AT91F_PIO_OutputDisable
\r
1765 //* \brief Output Enable PIO
\r
1766 //*----------------------------------------------------------------------------
\r
1767 __inline void AT91F_PIO_OutputDisable(
\r
1768 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1769 unsigned int flag) // \arg pio output to be disabled
\r
1771 pPio->PIO_ODR = flag;
\r
1774 //*----------------------------------------------------------------------------
\r
1775 //* \fn AT91F_PIO_GetOutputStatus
\r
1776 //* \brief Return PIO Output Status
\r
1777 //*----------------------------------------------------------------------------
\r
1778 __inline unsigned int AT91F_PIO_GetOutputStatus( // \return PIO Output Status
\r
1779 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1781 return pPio->PIO_OSR;
\r
1784 //*----------------------------------------------------------------------------
\r
1785 //* \fn AT91F_PIO_IsOuputSet
\r
1786 //* \brief Test if PIO Output is Set
\r
1787 //*----------------------------------------------------------------------------
\r
1788 __inline int AT91F_PIO_IsOutputSet(
\r
1789 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1790 unsigned int flag) // \arg flag to be tested
\r
1792 return (AT91F_PIO_GetOutputStatus(pPio) & flag);
\r
1795 //*----------------------------------------------------------------------------
\r
1796 //* \fn AT91F_PIO_InputFilterEnable
\r
1797 //* \brief Input Filter Enable PIO
\r
1798 //*----------------------------------------------------------------------------
\r
1799 __inline void AT91F_PIO_InputFilterEnable(
\r
1800 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1801 unsigned int flag) // \arg pio input filter to be enabled
\r
1803 pPio->PIO_IFER = flag;
\r
1806 //*----------------------------------------------------------------------------
\r
1807 //* \fn AT91F_PIO_InputFilterDisable
\r
1808 //* \brief Input Filter Disable PIO
\r
1809 //*----------------------------------------------------------------------------
\r
1810 __inline void AT91F_PIO_InputFilterDisable(
\r
1811 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1812 unsigned int flag) // \arg pio input filter to be disabled
\r
1814 pPio->PIO_IFDR = flag;
\r
1817 //*----------------------------------------------------------------------------
\r
1818 //* \fn AT91F_PIO_GetInputFilterStatus
\r
1819 //* \brief Return PIO Input Filter Status
\r
1820 //*----------------------------------------------------------------------------
\r
1821 __inline unsigned int AT91F_PIO_GetInputFilterStatus( // \return PIO Input Filter Status
\r
1822 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1824 return pPio->PIO_IFSR;
\r
1827 //*----------------------------------------------------------------------------
\r
1828 //* \fn AT91F_PIO_IsInputFilterSet
\r
1829 //* \brief Test if PIO Input filter is Set
\r
1830 //*----------------------------------------------------------------------------
\r
1831 __inline int AT91F_PIO_IsInputFilterSet(
\r
1832 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1833 unsigned int flag) // \arg flag to be tested
\r
1835 return (AT91F_PIO_GetInputFilterStatus(pPio) & flag);
\r
1838 //*----------------------------------------------------------------------------
\r
1839 //* \fn AT91F_PIO_GetOutputDataStatus
\r
1840 //* \brief Return PIO Output Data Status
\r
1841 //*----------------------------------------------------------------------------
\r
1842 __inline unsigned int AT91F_PIO_GetOutputDataStatus( // \return PIO Output Data Status
\r
1843 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1845 return pPio->PIO_ODSR;
\r
1848 //*----------------------------------------------------------------------------
\r
1849 //* \fn AT91F_PIO_InterruptEnable
\r
1850 //* \brief Enable PIO Interrupt
\r
1851 //*----------------------------------------------------------------------------
\r
1852 __inline void AT91F_PIO_InterruptEnable(
\r
1853 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1854 unsigned int flag) // \arg pio interrupt to be enabled
\r
1856 pPio->PIO_IER = flag;
\r
1859 //*----------------------------------------------------------------------------
\r
1860 //* \fn AT91F_PIO_InterruptDisable
\r
1861 //* \brief Disable PIO Interrupt
\r
1862 //*----------------------------------------------------------------------------
\r
1863 __inline void AT91F_PIO_InterruptDisable(
\r
1864 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1865 unsigned int flag) // \arg pio interrupt to be disabled
\r
1867 pPio->PIO_IDR = flag;
\r
1870 //*----------------------------------------------------------------------------
\r
1871 //* \fn AT91F_PIO_GetInterruptMaskStatus
\r
1872 //* \brief Return PIO Interrupt Mask Status
\r
1873 //*----------------------------------------------------------------------------
\r
1874 __inline unsigned int AT91F_PIO_GetInterruptMaskStatus( // \return PIO Interrupt Mask Status
\r
1875 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1877 return pPio->PIO_IMR;
\r
1880 //*----------------------------------------------------------------------------
\r
1881 //* \fn AT91F_PIO_GetInterruptStatus
\r
1882 //* \brief Return PIO Interrupt Status
\r
1883 //*----------------------------------------------------------------------------
\r
1884 __inline unsigned int AT91F_PIO_GetInterruptStatus( // \return PIO Interrupt Status
\r
1885 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1887 return pPio->PIO_ISR;
\r
1890 //*----------------------------------------------------------------------------
\r
1891 //* \fn AT91F_PIO_IsInterruptMasked
\r
1892 //* \brief Test if PIO Interrupt is Masked
\r
1893 //*----------------------------------------------------------------------------
\r
1894 __inline int AT91F_PIO_IsInterruptMasked(
\r
1895 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1896 unsigned int flag) // \arg flag to be tested
\r
1898 return (AT91F_PIO_GetInterruptMaskStatus(pPio) & flag);
\r
1901 //*----------------------------------------------------------------------------
\r
1902 //* \fn AT91F_PIO_IsInterruptSet
\r
1903 //* \brief Test if PIO Interrupt is Set
\r
1904 //*----------------------------------------------------------------------------
\r
1905 __inline int AT91F_PIO_IsInterruptSet(
\r
1906 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1907 unsigned int flag) // \arg flag to be tested
\r
1909 return (AT91F_PIO_GetInterruptStatus(pPio) & flag);
\r
1912 //*----------------------------------------------------------------------------
\r
1913 //* \fn AT91F_PIO_MultiDriverEnable
\r
1914 //* \brief Multi Driver Enable PIO
\r
1915 //*----------------------------------------------------------------------------
\r
1916 __inline void AT91F_PIO_MultiDriverEnable(
\r
1917 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1918 unsigned int flag) // \arg pio to be enabled
\r
1920 pPio->PIO_MDER = flag;
\r
1923 //*----------------------------------------------------------------------------
\r
1924 //* \fn AT91F_PIO_MultiDriverDisable
\r
1925 //* \brief Multi Driver Disable PIO
\r
1926 //*----------------------------------------------------------------------------
\r
1927 __inline void AT91F_PIO_MultiDriverDisable(
\r
1928 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1929 unsigned int flag) // \arg pio to be disabled
\r
1931 pPio->PIO_MDDR = flag;
\r
1934 //*----------------------------------------------------------------------------
\r
1935 //* \fn AT91F_PIO_GetMultiDriverStatus
\r
1936 //* \brief Return PIO Multi Driver Status
\r
1937 //*----------------------------------------------------------------------------
\r
1938 __inline unsigned int AT91F_PIO_GetMultiDriverStatus( // \return PIO Multi Driver Status
\r
1939 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1941 return pPio->PIO_MDSR;
\r
1944 //*----------------------------------------------------------------------------
\r
1945 //* \fn AT91F_PIO_IsMultiDriverSet
\r
1946 //* \brief Test if PIO MultiDriver is Set
\r
1947 //*----------------------------------------------------------------------------
\r
1948 __inline int AT91F_PIO_IsMultiDriverSet(
\r
1949 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1950 unsigned int flag) // \arg flag to be tested
\r
1952 return (AT91F_PIO_GetMultiDriverStatus(pPio) & flag);
\r
1955 //*----------------------------------------------------------------------------
\r
1956 //* \fn AT91F_PIO_A_RegisterSelection
\r
1957 //* \brief PIO A Register Selection
\r
1958 //*----------------------------------------------------------------------------
\r
1959 __inline void AT91F_PIO_A_RegisterSelection(
\r
1960 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1961 unsigned int flag) // \arg pio A register selection
\r
1963 pPio->PIO_ASR = flag;
\r
1966 //*----------------------------------------------------------------------------
\r
1967 //* \fn AT91F_PIO_B_RegisterSelection
\r
1968 //* \brief PIO B Register Selection
\r
1969 //*----------------------------------------------------------------------------
\r
1970 __inline void AT91F_PIO_B_RegisterSelection(
\r
1971 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1972 unsigned int flag) // \arg pio B register selection
\r
1974 pPio->PIO_BSR = flag;
\r
1977 //*----------------------------------------------------------------------------
\r
1978 //* \fn AT91F_PIO_Get_AB_RegisterStatus
\r
1979 //* \brief Return PIO Interrupt Status
\r
1980 //*----------------------------------------------------------------------------
\r
1981 __inline unsigned int AT91F_PIO_Get_AB_RegisterStatus( // \return PIO AB Register Status
\r
1982 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
1984 return pPio->PIO_ABSR;
\r
1987 //*----------------------------------------------------------------------------
\r
1988 //* \fn AT91F_PIO_IsAB_RegisterSet
\r
1989 //* \brief Test if PIO AB Register is Set
\r
1990 //*----------------------------------------------------------------------------
\r
1991 __inline int AT91F_PIO_IsAB_RegisterSet(
\r
1992 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
1993 unsigned int flag) // \arg flag to be tested
\r
1995 return (AT91F_PIO_Get_AB_RegisterStatus(pPio) & flag);
\r
1998 //*----------------------------------------------------------------------------
\r
1999 //* \fn AT91F_PIO_OutputWriteEnable
\r
2000 //* \brief Output Write Enable PIO
\r
2001 //*----------------------------------------------------------------------------
\r
2002 __inline void AT91F_PIO_OutputWriteEnable(
\r
2003 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
2004 unsigned int flag) // \arg pio output write to be enabled
\r
2006 pPio->PIO_OWER = flag;
\r
2009 //*----------------------------------------------------------------------------
\r
2010 //* \fn AT91F_PIO_OutputWriteDisable
\r
2011 //* \brief Output Write Disable PIO
\r
2012 //*----------------------------------------------------------------------------
\r
2013 __inline void AT91F_PIO_OutputWriteDisable(
\r
2014 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
2015 unsigned int flag) // \arg pio output write to be disabled
\r
2017 pPio->PIO_OWDR = flag;
\r
2020 //*----------------------------------------------------------------------------
\r
2021 //* \fn AT91F_PIO_GetOutputWriteStatus
\r
2022 //* \brief Return PIO Output Write Status
\r
2023 //*----------------------------------------------------------------------------
\r
2024 __inline unsigned int AT91F_PIO_GetOutputWriteStatus( // \return PIO Output Write Status
\r
2025 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
2027 return pPio->PIO_OWSR;
\r
2030 //*----------------------------------------------------------------------------
\r
2031 //* \fn AT91F_PIO_IsOutputWriteSet
\r
2032 //* \brief Test if PIO OutputWrite is Set
\r
2033 //*----------------------------------------------------------------------------
\r
2034 __inline int AT91F_PIO_IsOutputWriteSet(
\r
2035 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
2036 unsigned int flag) // \arg flag to be tested
\r
2038 return (AT91F_PIO_GetOutputWriteStatus(pPio) & flag);
\r
2041 //*----------------------------------------------------------------------------
\r
2042 //* \fn AT91F_PIO_GetCfgPullup
\r
2043 //* \brief Return PIO Configuration Pullup
\r
2044 //*----------------------------------------------------------------------------
\r
2045 __inline unsigned int AT91F_PIO_GetCfgPullup( // \return PIO Configuration Pullup
\r
2046 AT91PS_PIO pPio) // \arg pointer to a PIO controller
\r
2048 return pPio->PIO_PPUSR;
\r
2051 //*----------------------------------------------------------------------------
\r
2052 //* \fn AT91F_PIO_IsOutputDataStatusSet
\r
2053 //* \brief Test if PIO Output Data Status is Set
\r
2054 //*----------------------------------------------------------------------------
\r
2055 __inline int AT91F_PIO_IsOutputDataStatusSet(
\r
2056 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
2057 unsigned int flag) // \arg flag to be tested
\r
2059 return (AT91F_PIO_GetOutputDataStatus(pPio) & flag);
\r
2062 //*----------------------------------------------------------------------------
\r
2063 //* \fn AT91F_PIO_IsCfgPullupStatusSet
\r
2064 //* \brief Test if PIO Configuration Pullup Status is Set
\r
2065 //*----------------------------------------------------------------------------
\r
2066 __inline int AT91F_PIO_IsCfgPullupStatusSet(
\r
2067 AT91PS_PIO pPio, // \arg pointer to a PIO controller
\r
2068 unsigned int flag) // \arg flag to be tested
\r
2070 return (~AT91F_PIO_GetCfgPullup(pPio) & flag);
\r
2073 /* *****************************************************************************
\r
2074 SOFTWARE API FOR TWI
\r
2075 ***************************************************************************** */
\r
2076 //*----------------------------------------------------------------------------
\r
2077 //* \fn AT91F_TWI_EnableIt
\r
2078 //* \brief Enable TWI IT
\r
2079 //*----------------------------------------------------------------------------
\r
2080 __inline void AT91F_TWI_EnableIt (
\r
2081 AT91PS_TWI pTWI, // \arg pointer to a TWI controller
\r
2082 unsigned int flag) // \arg IT to be enabled
\r
2084 //* Write to the IER register
\r
2085 pTWI->TWI_IER = flag;
\r
2088 //*----------------------------------------------------------------------------
\r
2089 //* \fn AT91F_TWI_DisableIt
\r
2090 //* \brief Disable TWI IT
\r
2091 //*----------------------------------------------------------------------------
\r
2092 __inline void AT91F_TWI_DisableIt (
\r
2093 AT91PS_TWI pTWI, // \arg pointer to a TWI controller
\r
2094 unsigned int flag) // \arg IT to be disabled
\r
2096 //* Write to the IDR register
\r
2097 pTWI->TWI_IDR = flag;
\r
2100 //*----------------------------------------------------------------------------
\r
2101 //* \fn AT91F_TWI_Configure
\r
2102 //* \brief Configure TWI in master mode
\r
2103 //*----------------------------------------------------------------------------
\r
2104 __inline void AT91F_TWI_Configure ( AT91PS_TWI pTWI ) // \arg pointer to a TWI controller
\r
2106 //* Disable interrupts
\r
2107 pTWI->TWI_IDR = (unsigned int) -1;
\r
2109 //* Reset peripheral
\r
2110 pTWI->TWI_CR = AT91C_TWI_SWRST;
\r
2112 //* Set Master mode
\r
2113 pTWI->TWI_CR = AT91C_TWI_MSEN | AT91C_TWI_SVDIS;
\r
2117 //*----------------------------------------------------------------------------
\r
2118 //* \fn AT91F_TWI_GetInterruptMaskStatus
\r
2119 //* \brief Return TWI Interrupt Mask Status
\r
2120 //*----------------------------------------------------------------------------
\r
2121 __inline unsigned int AT91F_TWI_GetInterruptMaskStatus( // \return TWI Interrupt Mask Status
\r
2122 AT91PS_TWI pTwi) // \arg pointer to a TWI controller
\r
2124 return pTwi->TWI_IMR;
\r
2127 //*----------------------------------------------------------------------------
\r
2128 //* \fn AT91F_TWI_IsInterruptMasked
\r
2129 //* \brief Test if TWI Interrupt is Masked
\r
2130 //*----------------------------------------------------------------------------
\r
2131 __inline int AT91F_TWI_IsInterruptMasked(
\r
2132 AT91PS_TWI pTwi, // \arg pointer to a TWI controller
\r
2133 unsigned int flag) // \arg flag to be tested
\r
2135 return (AT91F_TWI_GetInterruptMaskStatus(pTwi) & flag);
\r
2138 /* *****************************************************************************
\r
2139 SOFTWARE API FOR USART
\r
2140 ***************************************************************************** */
\r
2141 //*----------------------------------------------------------------------------
\r
2142 //* \fn AT91F_US_Baudrate
\r
2143 //* \brief Calculate the baudrate
\r
2144 //* Standard Asynchronous Mode : 8 bits , 1 stop , no parity
\r
2145 #define AT91C_US_ASYNC_MODE ( AT91C_US_USMODE_NORMAL + \
\r
2146 AT91C_US_NBSTOP_1_BIT + \
\r
2147 AT91C_US_PAR_NONE + \
\r
2148 AT91C_US_CHRL_8_BITS + \
\r
2149 AT91C_US_CLKS_CLOCK )
\r
2151 //* Standard External Asynchronous Mode : 8 bits , 1 stop , no parity
\r
2152 #define AT91C_US_ASYNC_SCK_MODE ( AT91C_US_USMODE_NORMAL + \
\r
2153 AT91C_US_NBSTOP_1_BIT + \
\r
2154 AT91C_US_PAR_NONE + \
\r
2155 AT91C_US_CHRL_8_BITS + \
\r
2156 AT91C_US_CLKS_EXT )
\r
2158 //* Standard Synchronous Mode : 8 bits , 1 stop , no parity
\r
2159 #define AT91C_US_SYNC_MODE ( AT91C_US_SYNC + \
\r
2160 AT91C_US_USMODE_NORMAL + \
\r
2161 AT91C_US_NBSTOP_1_BIT + \
\r
2162 AT91C_US_PAR_NONE + \
\r
2163 AT91C_US_CHRL_8_BITS + \
\r
2164 AT91C_US_CLKS_CLOCK )
\r
2166 //* SCK used Label
\r
2167 #define AT91C_US_SCK_USED (AT91C_US_CKLO | AT91C_US_CLKS_EXT)
\r
2169 //* Standard ISO T=0 Mode : 8 bits , 1 stop , parity
\r
2170 #define AT91C_US_ISO_READER_MODE ( AT91C_US_USMODE_ISO7816_0 + \
\r
2171 AT91C_US_CLKS_CLOCK +\
\r
2172 AT91C_US_NBSTOP_1_BIT + \
\r
2173 AT91C_US_PAR_EVEN + \
\r
2174 AT91C_US_CHRL_8_BITS + \
\r
2178 //* Standard IRDA mode
\r
2179 #define AT91C_US_ASYNC_IRDA_MODE ( AT91C_US_USMODE_IRDA + \
\r
2180 AT91C_US_NBSTOP_1_BIT + \
\r
2181 AT91C_US_PAR_NONE + \
\r
2182 AT91C_US_CHRL_8_BITS + \
\r
2183 AT91C_US_CLKS_CLOCK )
\r
2185 //*----------------------------------------------------------------------------
\r
2186 //* \fn AT91F_US_Baudrate
\r
2187 //* \brief Caluculate baud_value according to the main clock and the baud rate
\r
2188 //*----------------------------------------------------------------------------
\r
2189 __inline unsigned int AT91F_US_Baudrate (
\r
2190 const unsigned int main_clock, // \arg peripheral clock
\r
2191 const unsigned int baud_rate) // \arg UART baudrate
\r
2193 unsigned int baud_value = ((main_clock*10)/(baud_rate * 16));
\r
2194 if ((baud_value % 10) >= 5)
\r
2195 baud_value = (baud_value / 10) + 1;
\r
2198 return baud_value;
\r
2201 //*----------------------------------------------------------------------------
\r
2202 //* \fn AT91F_US_SetBaudrate
\r
2203 //* \brief Set the baudrate according to the CPU clock
\r
2204 //*----------------------------------------------------------------------------
\r
2205 __inline void AT91F_US_SetBaudrate (
\r
2206 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2207 unsigned int mainClock, // \arg peripheral clock
\r
2208 unsigned int speed) // \arg UART baudrate
\r
2210 //* Define the baud rate divisor register
\r
2211 pUSART->US_BRGR = AT91F_US_Baudrate(mainClock, speed);
\r
2214 //*----------------------------------------------------------------------------
\r
2215 //* \fn AT91F_US_SetTimeguard
\r
2216 //* \brief Set USART timeguard
\r
2217 //*----------------------------------------------------------------------------
\r
2218 __inline void AT91F_US_SetTimeguard (
\r
2219 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2220 unsigned int timeguard) // \arg timeguard value
\r
2222 //* Write the Timeguard Register
\r
2223 pUSART->US_TTGR = timeguard ;
\r
2226 //*----------------------------------------------------------------------------
\r
2227 //* \fn AT91F_US_EnableIt
\r
2228 //* \brief Enable USART IT
\r
2229 //*----------------------------------------------------------------------------
\r
2230 __inline void AT91F_US_EnableIt (
\r
2231 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2232 unsigned int flag) // \arg IT to be enabled
\r
2234 //* Write to the IER register
\r
2235 pUSART->US_IER = flag;
\r
2238 //*----------------------------------------------------------------------------
\r
2239 //* \fn AT91F_US_DisableIt
\r
2240 //* \brief Disable USART IT
\r
2241 //*----------------------------------------------------------------------------
\r
2242 __inline void AT91F_US_DisableIt (
\r
2243 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2244 unsigned int flag) // \arg IT to be disabled
\r
2246 //* Write to the IER register
\r
2247 pUSART->US_IDR = flag;
\r
2250 //*----------------------------------------------------------------------------
\r
2251 //* \fn AT91F_US_Configure
\r
2252 //* \brief Configure USART
\r
2253 //*----------------------------------------------------------------------------
\r
2254 __inline void AT91F_US_Configure (
\r
2255 AT91PS_USART pUSART, // \arg pointer to a USART controller
\r
2256 unsigned int mainClock, // \arg peripheral clock
\r
2257 unsigned int mode , // \arg mode Register to be programmed
\r
2258 unsigned int baudRate , // \arg baudrate to be programmed
\r
2259 unsigned int timeguard ) // \arg timeguard to be programmed
\r
2261 //* Disable interrupts
\r
2262 pUSART->US_IDR = (unsigned int) -1;
\r
2264 //* Reset receiver and transmitter
\r
2265 pUSART->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS ;
\r
2267 //* Define the baud rate divisor register
\r
2268 AT91F_US_SetBaudrate(pUSART, mainClock, baudRate);
\r
2270 //* Write the Timeguard Register
\r
2271 AT91F_US_SetTimeguard(pUSART, timeguard);
\r
2273 //* Clear Transmit and Receive Counters
\r
2274 AT91F_PDC_Open((AT91PS_PDC) &(pUSART->US_RPR));
\r
2276 //* Define the USART mode
\r
2277 pUSART->US_MR = mode ;
\r
2281 //*----------------------------------------------------------------------------
\r
2282 //* \fn AT91F_US_EnableRx
\r
2283 //* \brief Enable receiving characters
\r
2284 //*----------------------------------------------------------------------------
\r
2285 __inline void AT91F_US_EnableRx (
\r
2286 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2288 //* Enable receiver
\r
2289 pUSART->US_CR = AT91C_US_RXEN;
\r
2292 //*----------------------------------------------------------------------------
\r
2293 //* \fn AT91F_US_EnableTx
\r
2294 //* \brief Enable sending characters
\r
2295 //*----------------------------------------------------------------------------
\r
2296 __inline void AT91F_US_EnableTx (
\r
2297 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2299 //* Enable transmitter
\r
2300 pUSART->US_CR = AT91C_US_TXEN;
\r
2303 //*----------------------------------------------------------------------------
\r
2304 //* \fn AT91F_US_ResetRx
\r
2305 //* \brief Reset Receiver and re-enable it
\r
2306 //*----------------------------------------------------------------------------
\r
2307 __inline void AT91F_US_ResetRx (
\r
2308 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2310 //* Reset receiver
\r
2311 pUSART->US_CR = AT91C_US_RSTRX;
\r
2312 //* Re-Enable receiver
\r
2313 pUSART->US_CR = AT91C_US_RXEN;
\r
2316 //*----------------------------------------------------------------------------
\r
2317 //* \fn AT91F_US_ResetTx
\r
2318 //* \brief Reset Transmitter and re-enable it
\r
2319 //*----------------------------------------------------------------------------
\r
2320 __inline void AT91F_US_ResetTx (
\r
2321 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2323 //* Reset transmitter
\r
2324 pUSART->US_CR = AT91C_US_RSTTX;
\r
2325 //* Enable transmitter
\r
2326 pUSART->US_CR = AT91C_US_TXEN;
\r
2329 //*----------------------------------------------------------------------------
\r
2330 //* \fn AT91F_US_DisableRx
\r
2331 //* \brief Disable Receiver
\r
2332 //*----------------------------------------------------------------------------
\r
2333 __inline void AT91F_US_DisableRx (
\r
2334 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2336 //* Disable receiver
\r
2337 pUSART->US_CR = AT91C_US_RXDIS;
\r
2340 //*----------------------------------------------------------------------------
\r
2341 //* \fn AT91F_US_DisableTx
\r
2342 //* \brief Disable Transmitter
\r
2343 //*----------------------------------------------------------------------------
\r
2344 __inline void AT91F_US_DisableTx (
\r
2345 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2347 //* Disable transmitter
\r
2348 pUSART->US_CR = AT91C_US_TXDIS;
\r
2351 //*----------------------------------------------------------------------------
\r
2352 //* \fn AT91F_US_Close
\r
2353 //* \brief Close USART: disable IT disable receiver and transmitter, close PDC
\r
2354 //*----------------------------------------------------------------------------
\r
2355 __inline void AT91F_US_Close (
\r
2356 AT91PS_USART pUSART) // \arg pointer to a USART controller
\r
2358 //* Reset the baud rate divisor register
\r
2359 pUSART->US_BRGR = 0 ;
\r
2361 //* Reset the USART mode
\r
2362 pUSART->US_MR = 0 ;
\r
2364 //* Reset the Timeguard Register
\r
2365 pUSART->US_TTGR = 0;
\r
2367 //* Disable all interrupts
\r
2368 pUSART->US_IDR = 0xFFFFFFFF ;
\r
2370 //* Abort the Peripheral Data Transfers
\r
2371 AT91F_PDC_Close((AT91PS_PDC) &(pUSART->US_RPR));
\r
2373 //* Disable receiver and transmitter and stop any activity immediately
\r
2374 pUSART->US_CR = AT91C_US_TXDIS | AT91C_US_RXDIS | AT91C_US_RSTTX | AT91C_US_RSTRX ;
\r
2377 //*----------------------------------------------------------------------------
\r
2378 //* \fn AT91F_US_TxReady
\r
2379 //* \brief Return 1 if a character can be written in US_THR
\r
2380 //*----------------------------------------------------------------------------
\r
2381 __inline unsigned int AT91F_US_TxReady (
\r
2382 AT91PS_USART pUSART ) // \arg pointer to a USART controller
\r
2384 return (pUSART->US_CSR & AT91C_US_TXRDY);
\r
2387 //*----------------------------------------------------------------------------
\r
2388 //* \fn AT91F_US_RxReady
\r
2389 //* \brief Return 1 if a character can be read in US_RHR
\r
2390 //*----------------------------------------------------------------------------
\r
2391 __inline unsigned int AT91F_US_RxReady (
\r
2392 AT91PS_USART pUSART ) // \arg pointer to a USART controller
\r
2394 return (pUSART->US_CSR & AT91C_US_RXRDY);
\r
2397 //*----------------------------------------------------------------------------
\r
2398 //* \fn AT91F_US_Error
\r
2399 //* \brief Return the error flag
\r
2400 //*----------------------------------------------------------------------------
\r
2401 __inline unsigned int AT91F_US_Error (
\r
2402 AT91PS_USART pUSART ) // \arg pointer to a USART controller
\r
2404 return (pUSART->US_CSR &
\r
2405 (AT91C_US_OVRE | // Overrun error
\r
2406 AT91C_US_FRAME | // Framing error
\r
2407 AT91C_US_PARE)); // Parity error
\r
2410 //*----------------------------------------------------------------------------
\r
2411 //* \fn AT91F_US_PutChar
\r
2412 //* \brief Send a character,does not check if ready to send
\r
2413 //*----------------------------------------------------------------------------
\r
2414 __inline void AT91F_US_PutChar (
\r
2415 AT91PS_USART pUSART,
\r
2418 pUSART->US_THR = (character & 0x1FF);
\r
2421 //*----------------------------------------------------------------------------
\r
2422 //* \fn AT91F_US_GetChar
\r
2423 //* \brief Receive a character,does not check if a character is available
\r
2424 //*----------------------------------------------------------------------------
\r
2425 __inline int AT91F_US_GetChar (
\r
2426 const AT91PS_USART pUSART)
\r
2428 return((pUSART->US_RHR) & 0x1FF);
\r
2431 //*----------------------------------------------------------------------------
\r
2432 //* \fn AT91F_US_SendFrame
\r
2433 //* \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
2434 //*----------------------------------------------------------------------------
\r
2435 __inline unsigned int AT91F_US_SendFrame(
\r
2436 AT91PS_USART pUSART,
\r
2438 unsigned int szBuffer,
\r
2439 char *pNextBuffer,
\r
2440 unsigned int szNextBuffer )
\r
2442 return AT91F_PDC_SendFrame(
\r
2443 (AT91PS_PDC) &(pUSART->US_RPR),
\r
2450 //*----------------------------------------------------------------------------
\r
2451 //* \fn AT91F_US_ReceiveFrame
\r
2452 //* \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
2453 //*----------------------------------------------------------------------------
\r
2454 __inline unsigned int AT91F_US_ReceiveFrame (
\r
2455 AT91PS_USART pUSART,
\r
2457 unsigned int szBuffer,
\r
2458 char *pNextBuffer,
\r
2459 unsigned int szNextBuffer )
\r
2461 return AT91F_PDC_ReceiveFrame(
\r
2462 (AT91PS_PDC) &(pUSART->US_RPR),
\r
2469 //*----------------------------------------------------------------------------
\r
2470 //* \fn AT91F_US_SetIrdaFilter
\r
2471 //* \brief Set the value of IrDa filter tregister
\r
2472 //*----------------------------------------------------------------------------
\r
2473 __inline void AT91F_US_SetIrdaFilter (
\r
2474 AT91PS_USART pUSART,
\r
2475 unsigned char value
\r
2478 pUSART->US_IF = value;
\r
2481 /* *****************************************************************************
\r
2482 SOFTWARE API FOR UDP
\r
2483 ***************************************************************************** */
\r
2484 //*----------------------------------------------------------------------------
\r
2485 //* \fn AT91F_UDP_EnableIt
\r
2486 //* \brief Enable UDP IT
\r
2487 //*----------------------------------------------------------------------------
\r
2488 __inline void AT91F_UDP_EnableIt (
\r
2489 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2490 unsigned int flag) // \arg IT to be enabled
\r
2492 //* Write to the IER register
\r
2493 pUDP->UDP_IER = flag;
\r
2496 //*----------------------------------------------------------------------------
\r
2497 //* \fn AT91F_UDP_DisableIt
\r
2498 //* \brief Disable UDP IT
\r
2499 //*----------------------------------------------------------------------------
\r
2500 __inline void AT91F_UDP_DisableIt (
\r
2501 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2502 unsigned int flag) // \arg IT to be disabled
\r
2504 //* Write to the IDR register
\r
2505 pUDP->UDP_IDR = flag;
\r
2508 //*----------------------------------------------------------------------------
\r
2509 //* \fn AT91F_UDP_SetAddress
\r
2510 //* \brief Set UDP functional address
\r
2511 //*----------------------------------------------------------------------------
\r
2512 __inline void AT91F_UDP_SetAddress (
\r
2513 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2514 unsigned char address) // \arg new UDP address
\r
2516 pUDP->UDP_FADDR = (AT91C_UDP_FEN | address);
\r
2519 //*----------------------------------------------------------------------------
\r
2520 //* \fn AT91F_UDP_EnableEp
\r
2521 //* \brief Enable Endpoint
\r
2522 //*----------------------------------------------------------------------------
\r
2523 __inline void AT91F_UDP_EnableEp (
\r
2524 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2525 unsigned int flag) // \arg endpoints to be enabled
\r
2527 pUDP->UDP_GLBSTATE |= flag;
\r
2530 //*----------------------------------------------------------------------------
\r
2531 //* \fn AT91F_UDP_DisableEp
\r
2532 //* \brief Enable Endpoint
\r
2533 //*----------------------------------------------------------------------------
\r
2534 __inline void AT91F_UDP_DisableEp (
\r
2535 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2536 unsigned int flag) // \arg endpoints to be enabled
\r
2538 pUDP->UDP_GLBSTATE &= ~(flag);
\r
2541 //*----------------------------------------------------------------------------
\r
2542 //* \fn AT91F_UDP_SetState
\r
2543 //* \brief Set UDP Device state
\r
2544 //*----------------------------------------------------------------------------
\r
2545 __inline void AT91F_UDP_SetState (
\r
2546 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2547 unsigned int flag) // \arg new UDP address
\r
2549 pUDP->UDP_GLBSTATE &= ~(AT91C_UDP_FADDEN | AT91C_UDP_CONFG);
\r
2550 pUDP->UDP_GLBSTATE |= flag;
\r
2553 //*----------------------------------------------------------------------------
\r
2554 //* \fn AT91F_UDP_GetState
\r
2555 //* \brief return UDP Device state
\r
2556 //*----------------------------------------------------------------------------
\r
2557 __inline unsigned int AT91F_UDP_GetState ( // \return the UDP device state
\r
2558 AT91PS_UDP pUDP) // \arg pointer to a UDP controller
\r
2560 return (pUDP->UDP_GLBSTATE & (AT91C_UDP_FADDEN | AT91C_UDP_CONFG));
\r
2563 //*----------------------------------------------------------------------------
\r
2564 //* \fn AT91F_UDP_ResetEp
\r
2565 //* \brief Reset UDP endpoint
\r
2566 //*----------------------------------------------------------------------------
\r
2567 __inline void AT91F_UDP_ResetEp ( // \return the UDP device state
\r
2568 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2569 unsigned int flag) // \arg Endpoints to be reset
\r
2571 pUDP->UDP_RSTEP = flag;
\r
2574 //*----------------------------------------------------------------------------
\r
2575 //* \fn AT91F_UDP_EpStall
\r
2576 //* \brief Endpoint will STALL requests
\r
2577 //*----------------------------------------------------------------------------
\r
2578 __inline void AT91F_UDP_EpStall(
\r
2579 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2580 unsigned char endpoint) // \arg endpoint number
\r
2582 pUDP->UDP_CSR[endpoint] |= AT91C_UDP_FORCESTALL;
\r
2585 //*----------------------------------------------------------------------------
\r
2586 //* \fn AT91F_UDP_EpWrite
\r
2587 //* \brief Write value in the DPR
\r
2588 //*----------------------------------------------------------------------------
\r
2589 __inline void AT91F_UDP_EpWrite(
\r
2590 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2591 unsigned char endpoint, // \arg endpoint number
\r
2592 unsigned char value) // \arg value to be written in the DPR
\r
2594 pUDP->UDP_FDR[endpoint] = value;
\r
2597 //*----------------------------------------------------------------------------
\r
2598 //* \fn AT91F_UDP_EpRead
\r
2599 //* \brief Return value from the DPR
\r
2600 //*----------------------------------------------------------------------------
\r
2601 __inline unsigned int AT91F_UDP_EpRead(
\r
2602 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2603 unsigned char endpoint) // \arg endpoint number
\r
2605 return pUDP->UDP_FDR[endpoint];
\r
2608 //*----------------------------------------------------------------------------
\r
2609 //* \fn AT91F_UDP_EpEndOfWr
\r
2610 //* \brief Notify the UDP that values in DPR are ready to be sent
\r
2611 //*----------------------------------------------------------------------------
\r
2612 __inline void AT91F_UDP_EpEndOfWr(
\r
2613 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2614 unsigned char endpoint) // \arg endpoint number
\r
2616 pUDP->UDP_CSR[endpoint] |= AT91C_UDP_TXPKTRDY;
\r
2619 //*----------------------------------------------------------------------------
\r
2620 //* \fn AT91F_UDP_EpClear
\r
2621 //* \brief Clear flag in the endpoint CSR register
\r
2622 //*----------------------------------------------------------------------------
\r
2623 __inline void AT91F_UDP_EpClear(
\r
2624 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2625 unsigned char endpoint, // \arg endpoint number
\r
2626 unsigned int flag) // \arg flag to be cleared
\r
2628 pUDP->UDP_CSR[endpoint] &= ~(flag);
\r
2631 //*----------------------------------------------------------------------------
\r
2632 //* \fn AT91F_UDP_EpSet
\r
2633 //* \brief Set flag in the endpoint CSR register
\r
2634 //*----------------------------------------------------------------------------
\r
2635 __inline void AT91F_UDP_EpSet(
\r
2636 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2637 unsigned char endpoint, // \arg endpoint number
\r
2638 unsigned int flag) // \arg flag to be cleared
\r
2640 pUDP->UDP_CSR[endpoint] |= flag;
\r
2643 //*----------------------------------------------------------------------------
\r
2644 //* \fn AT91F_UDP_EpStatus
\r
2645 //* \brief Return the endpoint CSR register
\r
2646 //*----------------------------------------------------------------------------
\r
2647 __inline unsigned int AT91F_UDP_EpStatus(
\r
2648 AT91PS_UDP pUDP, // \arg pointer to a UDP controller
\r
2649 unsigned char endpoint) // \arg endpoint number
\r
2651 return pUDP->UDP_CSR[endpoint];
\r
2654 //*----------------------------------------------------------------------------
\r
2655 //* \fn AT91F_UDP_GetInterruptMaskStatus
\r
2656 //* \brief Return UDP Interrupt Mask Status
\r
2657 //*----------------------------------------------------------------------------
\r
2658 __inline unsigned int AT91F_UDP_GetInterruptMaskStatus( // \return UDP Interrupt Mask Status
\r
2659 AT91PS_UDP pUdp) // \arg pointer to a UDP controller
\r
2661 return pUdp->UDP_IMR;
\r
2664 //*----------------------------------------------------------------------------
\r
2665 //* \fn AT91F_UDP_IsInterruptMasked
\r
2666 //* \brief Test if UDP Interrupt is Masked
\r
2667 //*----------------------------------------------------------------------------
\r
2668 __inline int AT91F_UDP_IsInterruptMasked(
\r
2669 AT91PS_UDP pUdp, // \arg pointer to a UDP controller
\r
2670 unsigned int flag) // \arg flag to be tested
\r
2672 return (AT91F_UDP_GetInterruptMaskStatus(pUdp) & flag);
\r
2675 /* *****************************************************************************
\r
2676 SOFTWARE API FOR AIC
\r
2677 ***************************************************************************** */
\r
2678 #define AT91C_AIC_BRANCH_OPCODE ((void (*) ()) 0xE51FFF20) // ldr, pc, [pc, #-&F20]
\r
2680 //*----------------------------------------------------------------------------
\r
2681 //* \fn AT91F_AIC_ConfigureIt
\r
2682 //* \brief Interrupt Handler Initialization
\r
2683 //*----------------------------------------------------------------------------
\r
2684 __inline unsigned int AT91F_AIC_ConfigureIt (
\r
2685 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2686 unsigned int irq_id, // \arg interrupt number to initialize
\r
2687 unsigned int priority, // \arg priority to give to the interrupt
\r
2688 unsigned int src_type, // \arg activation and sense of activation
\r
2689 void (*newHandler) (void) ) // \arg address of the interrupt handler
\r
2691 unsigned int oldHandler;
\r
2692 unsigned int mask ;
\r
2694 oldHandler = pAic->AIC_SVR[irq_id];
\r
2696 mask = 0x1 << irq_id ;
\r
2697 //* Disable the interrupt on the interrupt controller
\r
2698 pAic->AIC_IDCR = mask ;
\r
2699 //* Save the interrupt handler routine pointer and the interrupt priority
\r
2700 pAic->AIC_SVR[irq_id] = (unsigned int) newHandler ;
\r
2701 //* Store the Source Mode Register
\r
2702 pAic->AIC_SMR[irq_id] = src_type | priority ;
\r
2703 //* Clear the interrupt on the interrupt controller
\r
2704 pAic->AIC_ICCR = mask ;
\r
2706 return oldHandler;
\r
2709 //*----------------------------------------------------------------------------
\r
2710 //* \fn AT91F_AIC_EnableIt
\r
2711 //* \brief Enable corresponding IT number
\r
2712 //*----------------------------------------------------------------------------
\r
2713 __inline void AT91F_AIC_EnableIt (
\r
2714 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2715 unsigned int irq_id ) // \arg interrupt number to initialize
\r
2717 //* Enable the interrupt on the interrupt controller
\r
2718 pAic->AIC_IECR = 0x1 << irq_id ;
\r
2721 //*----------------------------------------------------------------------------
\r
2722 //* \fn AT91F_AIC_DisableIt
\r
2723 //* \brief Disable corresponding IT number
\r
2724 //*----------------------------------------------------------------------------
\r
2725 __inline void AT91F_AIC_DisableIt (
\r
2726 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2727 unsigned int irq_id ) // \arg interrupt number to initialize
\r
2729 unsigned int mask = 0x1 << irq_id;
\r
2730 //* Disable the interrupt on the interrupt controller
\r
2731 pAic->AIC_IDCR = mask ;
\r
2732 //* Clear the interrupt on the Interrupt Controller ( if one is pending )
\r
2733 pAic->AIC_ICCR = mask ;
\r
2736 //*----------------------------------------------------------------------------
\r
2737 //* \fn AT91F_AIC_ClearIt
\r
2738 //* \brief Clear corresponding IT number
\r
2739 //*----------------------------------------------------------------------------
\r
2740 __inline void AT91F_AIC_ClearIt (
\r
2741 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2742 unsigned int irq_id) // \arg interrupt number to initialize
\r
2744 //* Clear the interrupt on the Interrupt Controller ( if one is pending )
\r
2745 pAic->AIC_ICCR = (0x1 << irq_id);
\r
2748 //*----------------------------------------------------------------------------
\r
2749 //* \fn AT91F_AIC_AcknowledgeIt
\r
2750 //* \brief Acknowledge corresponding IT number
\r
2751 //*----------------------------------------------------------------------------
\r
2752 __inline void AT91F_AIC_AcknowledgeIt (
\r
2753 AT91PS_AIC pAic) // \arg pointer to the AIC registers
\r
2755 pAic->AIC_EOICR = pAic->AIC_EOICR;
\r
2758 //*----------------------------------------------------------------------------
\r
2759 //* \fn AT91F_AIC_SetExceptionVector
\r
2760 //* \brief Configure vector handler
\r
2761 //*----------------------------------------------------------------------------
\r
2762 __inline unsigned int AT91F_AIC_SetExceptionVector (
\r
2763 unsigned int *pVector, // \arg pointer to the AIC registers
\r
2764 void (*Handler) () ) // \arg Interrupt Handler
\r
2766 unsigned int oldVector = *pVector;
\r
2768 if ((unsigned int) Handler == (unsigned int) AT91C_AIC_BRANCH_OPCODE)
\r
2769 *pVector = (unsigned int) AT91C_AIC_BRANCH_OPCODE;
\r
2771 *pVector = (((((unsigned int) Handler) - ((unsigned int) pVector) - 0x8) >> 2) & 0x00FFFFFF) | 0xEA000000;
\r
2776 //*----------------------------------------------------------------------------
\r
2777 //* \fn AT91F_AIC_Trig
\r
2778 //* \brief Trig an IT
\r
2779 //*----------------------------------------------------------------------------
\r
2780 __inline void AT91F_AIC_Trig (
\r
2781 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2782 unsigned int irq_id) // \arg interrupt number
\r
2784 pAic->AIC_ISCR = (0x1 << irq_id) ;
\r
2787 //*----------------------------------------------------------------------------
\r
2788 //* \fn AT91F_AIC_IsActive
\r
2789 //* \brief Test if an IT is active
\r
2790 //*----------------------------------------------------------------------------
\r
2791 __inline unsigned int AT91F_AIC_IsActive (
\r
2792 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2793 unsigned int irq_id) // \arg Interrupt Number
\r
2795 return (pAic->AIC_ISR & (0x1 << irq_id));
\r
2798 //*----------------------------------------------------------------------------
\r
2799 //* \fn AT91F_AIC_IsPending
\r
2800 //* \brief Test if an IT is pending
\r
2801 //*----------------------------------------------------------------------------
\r
2802 __inline unsigned int AT91F_AIC_IsPending (
\r
2803 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2804 unsigned int irq_id) // \arg Interrupt Number
\r
2806 return (pAic->AIC_IPR & (0x1 << irq_id));
\r
2809 //*----------------------------------------------------------------------------
\r
2810 //* \fn AT91F_AIC_Open
\r
2811 //* \brief Set exception vectors and AIC registers to default values
\r
2812 //*----------------------------------------------------------------------------
\r
2813 __inline void AT91F_AIC_Open(
\r
2814 AT91PS_AIC pAic, // \arg pointer to the AIC registers
\r
2815 void (*IrqHandler) (), // \arg Default IRQ vector exception
\r
2816 void (*FiqHandler) (), // \arg Default FIQ vector exception
\r
2817 void (*DefaultHandler) (), // \arg Default Handler set in ISR
\r
2818 void (*SpuriousHandler) (), // \arg Default Spurious Handler
\r
2819 unsigned int protectMode) // \arg Debug Control Register
\r
2823 // Disable all interrupts and set IVR to the default handler
\r
2824 for (i = 0; i < 32; ++i) {
\r
2825 AT91F_AIC_DisableIt(pAic, i);
\r
2826 AT91F_AIC_ConfigureIt(pAic, i, AT91C_AIC_PRIOR_LOWEST, AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, DefaultHandler);
\r
2829 // Set the IRQ exception vector
\r
2830 AT91F_AIC_SetExceptionVector((unsigned int *) 0x18, IrqHandler);
\r
2831 // Set the Fast Interrupt exception vector
\r
2832 AT91F_AIC_SetExceptionVector((unsigned int *) 0x1C, FiqHandler);
\r
2834 pAic->AIC_SPU = (unsigned int) SpuriousHandler;
\r
2835 pAic->AIC_DCR = protectMode;
\r
2837 //*----------------------------------------------------------------------------
\r
2838 //* \fn AT91F_MC_CfgPMC
\r
2839 //* \brief Enable Peripheral clock in PMC for MC
\r
2840 //*----------------------------------------------------------------------------
\r
2841 __inline void AT91F_MC_CfgPMC (void)
\r
2843 AT91F_PMC_EnablePeriphClock(
\r
2844 AT91C_BASE_PMC, // PIO controller base address
\r
2845 ((unsigned int) 1 << AT91C_ID_SYS));
\r
2848 //*----------------------------------------------------------------------------
\r
2849 //* \fn AT91F_DBGU_CfgPMC
\r
2850 //* \brief Enable Peripheral clock in PMC for DBGU
\r
2851 //*----------------------------------------------------------------------------
\r
2852 __inline void AT91F_DBGU_CfgPMC (void)
\r
2854 AT91F_PMC_EnablePeriphClock(
\r
2855 AT91C_BASE_PMC, // PIO controller base address
\r
2856 ((unsigned int) 1 << AT91C_ID_SYS));
\r
2859 //*----------------------------------------------------------------------------
\r
2860 //* \fn AT91F_DBGU_CfgPIO
\r
2861 //* \brief Configure PIO controllers to drive DBGU signals
\r
2862 //*----------------------------------------------------------------------------
\r
2863 __inline void AT91F_DBGU_CfgPIO (void)
\r
2865 // Configure PIO controllers to periph mode
\r
2866 AT91F_PIO_CfgPeriph(
\r
2867 AT91C_BASE_PIOA, // PIO controller base address
\r
2868 ((unsigned int) AT91C_PA10_DTXD ) |
\r
2869 ((unsigned int) AT91C_PA9_DRXD ), // Peripheral A
\r
2870 0); // Peripheral B
\r
2873 //*----------------------------------------------------------------------------
\r
2874 //* \fn AT91F_PWMC_CH3_CfgPIO
\r
2875 //* \brief Configure PIO controllers to drive PWMC_CH3 signals
\r
2876 //*----------------------------------------------------------------------------
\r
2877 __inline void AT91F_PWMC_CH3_CfgPIO (void)
\r
2879 // Configure PIO controllers to periph mode
\r
2880 AT91F_PIO_CfgPeriph(
\r
2881 AT91C_BASE_PIOA, // PIO controller base address
\r
2882 0, // Peripheral A
\r
2883 ((unsigned int) AT91C_PA14_PWM3 ) |
\r
2884 ((unsigned int) AT91C_PA7_PWM3 )); // Peripheral B
\r
2887 //*----------------------------------------------------------------------------
\r
2888 //* \fn AT91F_PWMC_CH2_CfgPIO
\r
2889 //* \brief Configure PIO controllers to drive PWMC_CH2 signals
\r
2890 //*----------------------------------------------------------------------------
\r
2891 __inline void AT91F_PWMC_CH2_CfgPIO (void)
\r
2893 // Configure PIO controllers to periph mode
\r
2894 AT91F_PIO_CfgPeriph(
\r
2895 AT91C_BASE_PIOA, // PIO controller base address
\r
2896 ((unsigned int) AT91C_PA2_PWM2 ), // Peripheral A
\r
2897 ((unsigned int) AT91C_PA25_PWM2 ) |
\r
2898 ((unsigned int) AT91C_PA13_PWM2 )); // Peripheral B
\r
2901 //*----------------------------------------------------------------------------
\r
2902 //* \fn AT91F_PWMC_CH1_CfgPIO
\r
2903 //* \brief Configure PIO controllers to drive PWMC_CH1 signals
\r
2904 //*----------------------------------------------------------------------------
\r
2905 __inline void AT91F_PWMC_CH1_CfgPIO (void)
\r
2907 // Configure PIO controllers to periph mode
\r
2908 AT91F_PIO_CfgPeriph(
\r
2909 AT91C_BASE_PIOA, // PIO controller base address
\r
2910 ((unsigned int) AT91C_PA1_PWM1 ), // Peripheral A
\r
2911 ((unsigned int) AT91C_PA24_PWM1 ) |
\r
2912 ((unsigned int) AT91C_PA12_PWM1 )); // Peripheral B
\r
2915 //*----------------------------------------------------------------------------
\r
2916 //* \fn AT91F_PWMC_CH0_CfgPIO
\r
2917 //* \brief Configure PIO controllers to drive PWMC_CH0 signals
\r
2918 //*----------------------------------------------------------------------------
\r
2919 __inline void AT91F_PWMC_CH0_CfgPIO (void)
\r
2921 // Configure PIO controllers to periph mode
\r
2922 AT91F_PIO_CfgPeriph(
\r
2923 AT91C_BASE_PIOA, // PIO controller base address
\r
2924 ((unsigned int) AT91C_PA0_PWM0 ), // Peripheral A
\r
2925 ((unsigned int) AT91C_PA23_PWM0 ) |
\r
2926 ((unsigned int) AT91C_PA11_PWM0 )); // Peripheral B
\r
2929 //*----------------------------------------------------------------------------
\r
2930 //* \fn AT91F_SSC_CfgPMC
\r
2931 //* \brief Enable Peripheral clock in PMC for SSC
\r
2932 //*----------------------------------------------------------------------------
\r
2933 __inline void AT91F_SSC_CfgPMC (void)
\r
2935 AT91F_PMC_EnablePeriphClock(
\r
2936 AT91C_BASE_PMC, // PIO controller base address
\r
2937 ((unsigned int) 1 << AT91C_ID_SSC));
\r
2940 //*----------------------------------------------------------------------------
\r
2941 //* \fn AT91F_SSC_CfgPIO
\r
2942 //* \brief Configure PIO controllers to drive SSC signals
\r
2943 //*----------------------------------------------------------------------------
\r
2944 __inline void AT91F_SSC_CfgPIO (void)
\r
2946 // Configure PIO controllers to periph mode
\r
2947 AT91F_PIO_CfgPeriph(
\r
2948 AT91C_BASE_PIOA, // PIO controller base address
\r
2949 ((unsigned int) AT91C_PA17_TD ) |
\r
2950 ((unsigned int) AT91C_PA15_TF ) |
\r
2951 ((unsigned int) AT91C_PA19_RK ) |
\r
2952 ((unsigned int) AT91C_PA18_RD ) |
\r
2953 ((unsigned int) AT91C_PA20_RF ) |
\r
2954 ((unsigned int) AT91C_PA16_TK ), // Peripheral A
\r
2955 0); // Peripheral B
\r
2958 //*----------------------------------------------------------------------------
\r
2959 //* \fn AT91F_SPI_CfgPMC
\r
2960 //* \brief Enable Peripheral clock in PMC for SPI
\r
2961 //*----------------------------------------------------------------------------
\r
2962 __inline void AT91F_SPI_CfgPMC (void)
\r
2964 AT91F_PMC_EnablePeriphClock(
\r
2965 AT91C_BASE_PMC, // PIO controller base address
\r
2966 ((unsigned int) 1 << AT91C_ID_SPI));
\r
2969 //*----------------------------------------------------------------------------
\r
2970 //* \fn AT91F_SPI_CfgPIO
\r
2971 //* \brief Configure PIO controllers to drive SPI signals
\r
2972 //*----------------------------------------------------------------------------
\r
2973 __inline void AT91F_SPI_CfgPIO (void)
\r
2975 // Configure PIO controllers to periph mode
\r
2976 AT91F_PIO_CfgPeriph(
\r
2977 AT91C_BASE_PIOA, // PIO controller base address
\r
2978 ((unsigned int) AT91C_PA11_NPCS0 ) |
\r
2979 ((unsigned int) AT91C_PA13_MOSI ) |
\r
2980 ((unsigned int) AT91C_PA31_NPCS1 ) |
\r
2981 ((unsigned int) AT91C_PA12_MISO ) |
\r
2982 ((unsigned int) AT91C_PA14_SPCK ), // Peripheral A
\r
2983 ((unsigned int) AT91C_PA9_NPCS1 ) |
\r
2984 ((unsigned int) AT91C_PA30_NPCS2 ) |
\r
2985 ((unsigned int) AT91C_PA10_NPCS2 ) |
\r
2986 ((unsigned int) AT91C_PA22_NPCS3 ) |
\r
2987 ((unsigned int) AT91C_PA3_NPCS3 ) |
\r
2988 ((unsigned int) AT91C_PA5_NPCS3 )); // Peripheral B
\r
2991 //*----------------------------------------------------------------------------
\r
2992 //* \fn AT91F_PWMC_CfgPMC
\r
2993 //* \brief Enable Peripheral clock in PMC for PWMC
\r
2994 //*----------------------------------------------------------------------------
\r
2995 __inline void AT91F_PWMC_CfgPMC (void)
\r
2997 AT91F_PMC_EnablePeriphClock(
\r
2998 AT91C_BASE_PMC, // PIO controller base address
\r
2999 ((unsigned int) 1 << AT91C_ID_PWMC));
\r
3002 //*----------------------------------------------------------------------------
\r
3003 //* \fn AT91F_TC2_CfgPMC
\r
3004 //* \brief Enable Peripheral clock in PMC for TC2
\r
3005 //*----------------------------------------------------------------------------
\r
3006 __inline void AT91F_TC2_CfgPMC (void)
\r
3008 AT91F_PMC_EnablePeriphClock(
\r
3009 AT91C_BASE_PMC, // PIO controller base address
\r
3010 ((unsigned int) 1 << AT91C_ID_TC2));
\r
3013 //*----------------------------------------------------------------------------
\r
3014 //* \fn AT91F_TC2_CfgPIO
\r
3015 //* \brief Configure PIO controllers to drive TC2 signals
\r
3016 //*----------------------------------------------------------------------------
\r
3017 __inline void AT91F_TC2_CfgPIO (void)
\r
3019 // Configure PIO controllers to periph mode
\r
3020 AT91F_PIO_CfgPeriph(
\r
3021 AT91C_BASE_PIOA, // PIO controller base address
\r
3022 0, // Peripheral A
\r
3023 ((unsigned int) AT91C_PA26_TIOA2 ) |
\r
3024 ((unsigned int) AT91C_PA27_TIOB2 ) |
\r
3025 ((unsigned int) AT91C_PA29_TCLK2 )); // Peripheral B
\r
3028 //*----------------------------------------------------------------------------
\r
3029 //* \fn AT91F_TC1_CfgPMC
\r
3030 //* \brief Enable Peripheral clock in PMC for TC1
\r
3031 //*----------------------------------------------------------------------------
\r
3032 __inline void AT91F_TC1_CfgPMC (void)
\r
3034 AT91F_PMC_EnablePeriphClock(
\r
3035 AT91C_BASE_PMC, // PIO controller base address
\r
3036 ((unsigned int) 1 << AT91C_ID_TC1));
\r
3039 //*----------------------------------------------------------------------------
\r
3040 //* \fn AT91F_TC1_CfgPIO
\r
3041 //* \brief Configure PIO controllers to drive TC1 signals
\r
3042 //*----------------------------------------------------------------------------
\r
3043 __inline void AT91F_TC1_CfgPIO (void)
\r
3045 // Configure PIO controllers to periph mode
\r
3046 AT91F_PIO_CfgPeriph(
\r
3047 AT91C_BASE_PIOA, // PIO controller base address
\r
3048 0, // Peripheral A
\r
3049 ((unsigned int) AT91C_PA15_TIOA1 ) |
\r
3050 ((unsigned int) AT91C_PA16_TIOB1 ) |
\r
3051 ((unsigned int) AT91C_PA28_TCLK1 )); // Peripheral B
\r
3054 //*----------------------------------------------------------------------------
\r
3055 //* \fn AT91F_TC0_CfgPMC
\r
3056 //* \brief Enable Peripheral clock in PMC for TC0
\r
3057 //*----------------------------------------------------------------------------
\r
3058 __inline void AT91F_TC0_CfgPMC (void)
\r
3060 AT91F_PMC_EnablePeriphClock(
\r
3061 AT91C_BASE_PMC, // PIO controller base address
\r
3062 ((unsigned int) 1 << AT91C_ID_TC0));
\r
3065 //*----------------------------------------------------------------------------
\r
3066 //* \fn AT91F_TC0_CfgPIO
\r
3067 //* \brief Configure PIO controllers to drive TC0 signals
\r
3068 //*----------------------------------------------------------------------------
\r
3069 __inline void AT91F_TC0_CfgPIO (void)
\r
3071 // Configure PIO controllers to periph mode
\r
3072 AT91F_PIO_CfgPeriph(
\r
3073 AT91C_BASE_PIOA, // PIO controller base address
\r
3074 0, // Peripheral A
\r
3075 ((unsigned int) AT91C_PA0_TIOA0 ) |
\r
3076 ((unsigned int) AT91C_PA1_TIOB0 ) |
\r
3077 ((unsigned int) AT91C_PA4_TCLK0 )); // Peripheral B
\r
3080 //*----------------------------------------------------------------------------
\r
3081 //* \fn AT91F_PMC_CfgPMC
\r
3082 //* \brief Enable Peripheral clock in PMC for PMC
\r
3083 //*----------------------------------------------------------------------------
\r
3084 __inline void AT91F_PMC_CfgPMC (void)
\r
3086 AT91F_PMC_EnablePeriphClock(
\r
3087 AT91C_BASE_PMC, // PIO controller base address
\r
3088 ((unsigned int) 1 << AT91C_ID_SYS));
\r
3091 //*----------------------------------------------------------------------------
\r
3092 //* \fn AT91F_PMC_CfgPIO
\r
3093 //* \brief Configure PIO controllers to drive PMC signals
\r
3094 //*----------------------------------------------------------------------------
\r
3095 __inline void AT91F_PMC_CfgPIO (void)
\r
3097 // Configure PIO controllers to periph mode
\r
3098 AT91F_PIO_CfgPeriph(
\r
3099 AT91C_BASE_PIOA, // PIO controller base address
\r
3100 0, // Peripheral A
\r
3101 ((unsigned int) AT91C_PA17_PCK1 ) |
\r
3102 ((unsigned int) AT91C_PA21_PCK1 ) |
\r
3103 ((unsigned int) AT91C_PA31_PCK2 ) |
\r
3104 ((unsigned int) AT91C_PA18_PCK2 ) |
\r
3105 ((unsigned int) AT91C_PA6_PCK0 )); // Peripheral B
\r
3108 //*----------------------------------------------------------------------------
\r
3109 //* \fn AT91F_ADC_CfgPMC
\r
3110 //* \brief Enable Peripheral clock in PMC for ADC
\r
3111 //*----------------------------------------------------------------------------
\r
3112 __inline void AT91F_ADC_CfgPMC (void)
\r
3114 AT91F_PMC_EnablePeriphClock(
\r
3115 AT91C_BASE_PMC, // PIO controller base address
\r
3116 ((unsigned int) 1 << AT91C_ID_ADC));
\r
3119 //*----------------------------------------------------------------------------
\r
3120 //* \fn AT91F_ADC_CfgPIO
\r
3121 //* \brief Configure PIO controllers to drive ADC signals
\r
3122 //*----------------------------------------------------------------------------
\r
3123 __inline void AT91F_ADC_CfgPIO (void)
\r
3125 // Configure PIO controllers to periph mode
\r
3126 AT91F_PIO_CfgPeriph(
\r
3127 AT91C_BASE_PIOA, // PIO controller base address
\r
3128 0, // Peripheral A
\r
3129 ((unsigned int) AT91C_PA8_ADTRG )); // Peripheral B
\r
3132 //*----------------------------------------------------------------------------
\r
3133 //* \fn AT91F_PIOA_CfgPMC
\r
3134 //* \brief Enable Peripheral clock in PMC for PIOA
\r
3135 //*----------------------------------------------------------------------------
\r
3136 __inline void AT91F_PIOA_CfgPMC (void)
\r
3138 AT91F_PMC_EnablePeriphClock(
\r
3139 AT91C_BASE_PMC, // PIO controller base address
\r
3140 ((unsigned int) 1 << AT91C_ID_PIOA));
\r
3143 //*----------------------------------------------------------------------------
\r
3144 //* \fn AT91F_TWI_CfgPMC
\r
3145 //* \brief Enable Peripheral clock in PMC for TWI
\r
3146 //*----------------------------------------------------------------------------
\r
3147 __inline void AT91F_TWI_CfgPMC (void)
\r
3149 AT91F_PMC_EnablePeriphClock(
\r
3150 AT91C_BASE_PMC, // PIO controller base address
\r
3151 ((unsigned int) 1 << AT91C_ID_TWI));
\r
3154 //*----------------------------------------------------------------------------
\r
3155 //* \fn AT91F_TWI_CfgPIO
\r
3156 //* \brief Configure PIO controllers to drive TWI signals
\r
3157 //*----------------------------------------------------------------------------
\r
3158 __inline void AT91F_TWI_CfgPIO (void)
\r
3160 // Configure PIO controllers to periph mode
\r
3161 AT91F_PIO_CfgPeriph(
\r
3162 AT91C_BASE_PIOA, // PIO controller base address
\r
3163 ((unsigned int) AT91C_PA3_TWD ) |
\r
3164 ((unsigned int) AT91C_PA4_TWCK ), // Peripheral A
\r
3165 0); // Peripheral B
\r
3168 //*----------------------------------------------------------------------------
\r
3169 //* \fn AT91F_US1_CfgPMC
\r
3170 //* \brief Enable Peripheral clock in PMC for US1
\r
3171 //*----------------------------------------------------------------------------
\r
3172 __inline void AT91F_US1_CfgPMC (void)
\r
3174 AT91F_PMC_EnablePeriphClock(
\r
3175 AT91C_BASE_PMC, // PIO controller base address
\r
3176 ((unsigned int) 1 << AT91C_ID_US1));
\r
3179 //*----------------------------------------------------------------------------
\r
3180 //* \fn AT91F_US1_CfgPIO
\r
3181 //* \brief Configure PIO controllers to drive US1 signals
\r
3182 //*----------------------------------------------------------------------------
\r
3183 __inline void AT91F_US1_CfgPIO (void)
\r
3185 // Configure PIO controllers to periph mode
\r
3186 AT91F_PIO_CfgPeriph(
\r
3187 AT91C_BASE_PIOA, // PIO controller base address
\r
3188 ((unsigned int) AT91C_PA21_RXD1 ) |
\r
3189 ((unsigned int) AT91C_PA27_DTR1 ) |
\r
3190 ((unsigned int) AT91C_PA26_DCD1 ) |
\r
3191 ((unsigned int) AT91C_PA22_TXD1 ) |
\r
3192 ((unsigned int) AT91C_PA24_RTS1 ) |
\r
3193 ((unsigned int) AT91C_PA23_SCK1 ) |
\r
3194 ((unsigned int) AT91C_PA28_DSR1 ) |
\r
3195 ((unsigned int) AT91C_PA29_RI1 ) |
\r
3196 ((unsigned int) AT91C_PA25_CTS1 ), // Peripheral A
\r
3197 0); // Peripheral B
\r
3200 //*----------------------------------------------------------------------------
\r
3201 //* \fn AT91F_US0_CfgPMC
\r
3202 //* \brief Enable Peripheral clock in PMC for US0
\r
3203 //*----------------------------------------------------------------------------
\r
3204 __inline void AT91F_US0_CfgPMC (void)
\r
3206 AT91F_PMC_EnablePeriphClock(
\r
3207 AT91C_BASE_PMC, // PIO controller base address
\r
3208 ((unsigned int) 1 << AT91C_ID_US0));
\r
3211 //*----------------------------------------------------------------------------
\r
3212 //* \fn AT91F_US0_CfgPIO
\r
3213 //* \brief Configure PIO controllers to drive US0 signals
\r
3214 //*----------------------------------------------------------------------------
\r
3215 __inline void AT91F_US0_CfgPIO (void)
\r
3217 // Configure PIO controllers to periph mode
\r
3218 AT91F_PIO_CfgPeriph(
\r
3219 AT91C_BASE_PIOA, // PIO controller base address
\r
3220 ((unsigned int) AT91C_PA5_RXD0 ) |
\r
3221 ((unsigned int) AT91C_PA6_TXD0 ) |
\r
3222 ((unsigned int) AT91C_PA7_RTS0 ) |
\r
3223 ((unsigned int) AT91C_PA8_CTS0 ), // Peripheral A
\r
3224 ((unsigned int) AT91C_PA2_SCK0 )); // Peripheral B
\r
3227 //*----------------------------------------------------------------------------
\r
3228 //* \fn AT91F_UDP_CfgPMC
\r
3229 //* \brief Enable Peripheral clock in PMC for UDP
\r
3230 //*----------------------------------------------------------------------------
\r
3231 __inline void AT91F_UDP_CfgPMC (void)
\r
3233 AT91F_PMC_EnablePeriphClock(
\r
3234 AT91C_BASE_PMC, // PIO controller base address
\r
3235 ((unsigned int) 1 << AT91C_ID_UDP));
\r
3238 //*----------------------------------------------------------------------------
\r
3239 //* \fn AT91F_AIC_CfgPMC
\r
3240 //* \brief Enable Peripheral clock in PMC for AIC
\r
3241 //*----------------------------------------------------------------------------
\r
3242 __inline void AT91F_AIC_CfgPMC (void)
\r
3244 AT91F_PMC_EnablePeriphClock(
\r
3245 AT91C_BASE_PMC, // PIO controller base address
\r
3246 ((unsigned int) 1 << AT91C_ID_IRQ0) |
\r
3247 ((unsigned int) 1 << AT91C_ID_FIQ) |
\r
3248 ((unsigned int) 1 << AT91C_ID_IRQ1));
\r
3251 //*----------------------------------------------------------------------------
\r
3252 //* \fn AT91F_AIC_CfgPIO
\r
3253 //* \brief Configure PIO controllers to drive AIC signals
\r
3254 //*----------------------------------------------------------------------------
\r
3255 __inline void AT91F_AIC_CfgPIO (void)
\r
3257 // Configure PIO controllers to periph mode
\r
3258 AT91F_PIO_CfgPeriph(
\r
3259 AT91C_BASE_PIOA, // PIO controller base address
\r
3260 ((unsigned int) AT91C_PA30_IRQ1 ), // Peripheral A
\r
3261 ((unsigned int) AT91C_PA20_IRQ0 ) |
\r
3262 ((unsigned int) AT91C_PA19_FIQ )); // Peripheral B
\r
3265 #endif // lib_AT91SAM7S64_H
\r