lib_AT91SAM7X256.h 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. /** ---------------------------------------------------------------------------- */
  2. /** ATMEL Microcontroller Software Support - ROUSSET - */
  3. /** ---------------------------------------------------------------------------- */
  4. /** DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
  5. /** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  6. /** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
  7. /** DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
  8. /** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
  9. /** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
  10. /** OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  11. /** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
  12. /** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
  13. /** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  14. /** ---------------------------------------------------------------------------- */
  15. /** File Name : lib_AT91SAM7X256.h */
  16. /** Object : AT91SAM7X256 inlined functions */
  17. /** Generated : AT91 SW Application Group 05/20/2005 (16:22:29) */
  18. /** */
  19. /** CVS Reference : /lib_dbgu.h/1.1/Fri Jan 31 12:18:40 2003// */
  20. /** CVS Reference : /lib_pmc_SAM7X.h/1.1/Tue Feb 1 08:32:10 2005// */
  21. /** CVS Reference : /lib_VREG_6085B.h/1.1/Tue Feb 1 16:20:47 2005// */
  22. /** CVS Reference : /lib_rstc_6098A.h/1.1/Wed Oct 6 10:39:20 2004// */
  23. /** CVS Reference : /lib_ssc.h/1.4/Fri Jan 31 12:19:20 2003// */
  24. /** CVS Reference : /lib_wdtc_6080A.h/1.1/Wed Oct 6 10:38:30 2004// */
  25. /** CVS Reference : /lib_usart.h/1.5/Thu Nov 21 16:01:54 2002// */
  26. /** CVS Reference : /lib_spi2.h/1.1/Mon Aug 25 14:23:52 2003// */
  27. /** CVS Reference : /lib_pitc_6079A.h/1.2/Tue Nov 9 14:43:56 2004// */
  28. /** CVS Reference : /lib_aic_6075b.h/1.1/Fri May 20 14:01:19 2005// */
  29. /** CVS Reference : /lib_aes_6149a.h/1.1/Mon Jan 17 07:43:09 2005// */
  30. /** CVS Reference : /lib_twi.h/1.3/Mon Jul 19 14:27:58 2004// */
  31. /** CVS Reference : /lib_adc.h/1.6/Fri Oct 17 09:12:38 2003// */
  32. /** CVS Reference : /lib_rttc_6081A.h/1.1/Wed Oct 6 10:39:38 2004// */
  33. /** CVS Reference : /lib_udp.h/1.4/Wed Feb 16 08:39:34 2005// */
  34. /** CVS Reference : /lib_des3_6150a.h/1.1/Mon Jan 17 09:19:19 2005// */
  35. /** CVS Reference : /lib_tc_1753b.h/1.1/Fri Jan 31 12:20:02 2003// */
  36. /** CVS Reference : /lib_MC_SAM7X.h/1.1/Thu Mar 25 15:19:14 2004// */
  37. /** CVS Reference : /lib_pio.h/1.3/Fri Jan 31 12:18:56 2003// */
  38. /** CVS Reference : /lib_can_AT91.h/1.4/Fri Oct 17 09:12:50 2003// */
  39. /** CVS Reference : /lib_PWM_SAM.h/1.3/Thu Jan 22 10:10:50 2004// */
  40. /** CVS Reference : /lib_pdc.h/1.2/Tue Jul 2 13:29:40 2002// */
  41. /** ---------------------------------------------------------------------------- */
  42. #ifndef lib_AT91SAM7X256_H
  43. #define lib_AT91SAM7X256_H
  44. /* *****************************************************************************
  45. * SOFTWARE API FOR AIC
  46. ***************************************************************************** */
  47. #define AT91C_AIC_BRANCH_OPCODE ( ( void ( * )() ) 0xE51FFF20 ) /* ldr, pc, [pc, #-&F20] */
  48. /**---------------------------------------------------------------------------- */
  49. /** \fn AT91F_AIC_ConfigureIt */
  50. /** \brief Interrupt Handler Initialization */
  51. /**---------------------------------------------------------------------------- */
  52. __inline unsigned int AT91F_AIC_ConfigureIt( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  53. unsigned int irq_id, /* \arg interrupt number to initialize */
  54. unsigned int priority, /* \arg priority to give to the interrupt */
  55. unsigned int src_type, /* \arg activation and sense of activation */
  56. void ( * newHandler )( void ) ) /* \arg address of the interrupt handler */
  57. {
  58. unsigned int oldHandler;
  59. unsigned int mask;
  60. oldHandler = pAic->AIC_SVR[ irq_id ];
  61. mask = 0x1 << irq_id;
  62. /** Disable the interrupt on the interrupt controller */
  63. pAic->AIC_IDCR = mask;
  64. /** Save the interrupt handler routine pointer and the interrupt priority */
  65. pAic->AIC_SVR[ irq_id ] = ( unsigned int ) newHandler;
  66. /** Store the Source Mode Register */
  67. pAic->AIC_SMR[ irq_id ] = src_type | priority;
  68. /** Clear the interrupt on the interrupt controller */
  69. pAic->AIC_ICCR = mask;
  70. return oldHandler;
  71. }
  72. /**---------------------------------------------------------------------------- */
  73. /** \fn AT91F_AIC_EnableIt */
  74. /** \brief Enable corresponding IT number */
  75. /**---------------------------------------------------------------------------- */
  76. __inline void AT91F_AIC_EnableIt( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  77. unsigned int irq_id ) /* \arg interrupt number to initialize */
  78. {
  79. /** Enable the interrupt on the interrupt controller */
  80. pAic->AIC_IECR = 0x1 << irq_id;
  81. }
  82. /**---------------------------------------------------------------------------- */
  83. /** \fn AT91F_AIC_DisableIt */
  84. /** \brief Disable corresponding IT number */
  85. /**---------------------------------------------------------------------------- */
  86. __inline void AT91F_AIC_DisableIt( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  87. unsigned int irq_id ) /* \arg interrupt number to initialize */
  88. {
  89. unsigned int mask = 0x1 << irq_id;
  90. /** Disable the interrupt on the interrupt controller */
  91. pAic->AIC_IDCR = mask;
  92. /** Clear the interrupt on the Interrupt Controller ( if one is pending ) */
  93. pAic->AIC_ICCR = mask;
  94. }
  95. /**---------------------------------------------------------------------------- */
  96. /** \fn AT91F_AIC_ClearIt */
  97. /** \brief Clear corresponding IT number */
  98. /**---------------------------------------------------------------------------- */
  99. __inline void AT91F_AIC_ClearIt( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  100. unsigned int irq_id ) /* \arg interrupt number to initialize */
  101. {
  102. /** Clear the interrupt on the Interrupt Controller ( if one is pending ) */
  103. pAic->AIC_ICCR = ( 0x1 << irq_id );
  104. }
  105. /**---------------------------------------------------------------------------- */
  106. /** \fn AT91F_AIC_AcknowledgeIt */
  107. /** \brief Acknowledge corresponding IT number */
  108. /**---------------------------------------------------------------------------- */
  109. __inline void AT91F_AIC_AcknowledgeIt( AT91PS_AIC pAic ) /* \arg pointer to the AIC registers */
  110. {
  111. pAic->AIC_EOICR = pAic->AIC_EOICR;
  112. }
  113. /**---------------------------------------------------------------------------- */
  114. /** \fn AT91F_AIC_SetExceptionVector */
  115. /** \brief Configure vector handler */
  116. /**---------------------------------------------------------------------------- */
  117. __inline unsigned int AT91F_AIC_SetExceptionVector( unsigned int * pVector, /* \arg pointer to the AIC registers */
  118. void ( * Handler )() ) /* \arg Interrupt Handler */
  119. {
  120. unsigned int oldVector = *pVector;
  121. if( ( unsigned int ) Handler == ( unsigned int ) AT91C_AIC_BRANCH_OPCODE )
  122. {
  123. *pVector = ( unsigned int ) AT91C_AIC_BRANCH_OPCODE;
  124. }
  125. else
  126. {
  127. *pVector = ( ( ( ( ( unsigned int ) Handler ) - ( ( unsigned int ) pVector ) - 0x8 ) >> 2 ) & 0x00FFFFFF ) | 0xEA000000;
  128. }
  129. return oldVector;
  130. }
  131. /**---------------------------------------------------------------------------- */
  132. /** \fn AT91F_AIC_Trig */
  133. /** \brief Trig an IT */
  134. /**---------------------------------------------------------------------------- */
  135. __inline void AT91F_AIC_Trig( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  136. unsigned int irq_id ) /* \arg interrupt number */
  137. {
  138. pAic->AIC_ISCR = ( 0x1 << irq_id );
  139. }
  140. /**---------------------------------------------------------------------------- */
  141. /** \fn AT91F_AIC_IsActive */
  142. /** \brief Test if an IT is active */
  143. /**---------------------------------------------------------------------------- */
  144. __inline unsigned int AT91F_AIC_IsActive( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  145. unsigned int irq_id ) /* \arg Interrupt Number */
  146. {
  147. return( pAic->AIC_ISR & ( 0x1 << irq_id ) );
  148. }
  149. /**---------------------------------------------------------------------------- */
  150. /** \fn AT91F_AIC_IsPending */
  151. /** \brief Test if an IT is pending */
  152. /**---------------------------------------------------------------------------- */
  153. __inline unsigned int AT91F_AIC_IsPending( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  154. unsigned int irq_id ) /* \arg Interrupt Number */
  155. {
  156. return( pAic->AIC_IPR & ( 0x1 << irq_id ) );
  157. }
  158. /**---------------------------------------------------------------------------- */
  159. /** \fn AT91F_AIC_Open */
  160. /** \brief Set exception vectors and AIC registers to default values */
  161. /**---------------------------------------------------------------------------- */
  162. __inline void AT91F_AIC_Open( AT91PS_AIC pAic, /* \arg pointer to the AIC registers */
  163. void ( * IrqHandler )(), /* \arg Default IRQ vector exception */
  164. void ( * FiqHandler )(), /* \arg Default FIQ vector exception */
  165. void ( * DefaultHandler )(), /* \arg Default Handler set in ISR */
  166. void ( * SpuriousHandler )(), /* \arg Default Spurious Handler */
  167. unsigned int protectMode ) /* \arg Debug Control Register */
  168. {
  169. int i;
  170. /* Disable all interrupts and set IVR to the default handler */
  171. for( i = 0; i < 32; ++i )
  172. {
  173. AT91F_AIC_DisableIt( pAic, i );
  174. AT91F_AIC_ConfigureIt( pAic, i, AT91C_AIC_PRIOR_LOWEST, AT91C_AIC_SRCTYPE_HIGH_LEVEL, DefaultHandler );
  175. }
  176. /* Set the IRQ exception vector */
  177. AT91F_AIC_SetExceptionVector( ( unsigned int * ) 0x18, IrqHandler );
  178. /* Set the Fast Interrupt exception vector */
  179. AT91F_AIC_SetExceptionVector( ( unsigned int * ) 0x1C, FiqHandler );
  180. pAic->AIC_SPU = ( unsigned int ) SpuriousHandler;
  181. pAic->AIC_DCR = protectMode;
  182. }
  183. /* *****************************************************************************
  184. * SOFTWARE API FOR PDC
  185. ***************************************************************************** */
  186. /**---------------------------------------------------------------------------- */
  187. /** \fn AT91F_PDC_SetNextRx */
  188. /** \brief Set the next receive transfer descriptor */
  189. /**---------------------------------------------------------------------------- */
  190. __inline void AT91F_PDC_SetNextRx( AT91PS_PDC pPDC, /* \arg pointer to a PDC controller */
  191. char * address, /* \arg address to the next block to be received */
  192. unsigned int bytes ) /* \arg number of bytes to be received */
  193. {
  194. pPDC->PDC_RNPR = ( unsigned int ) address;
  195. pPDC->PDC_RNCR = bytes;
  196. }
  197. /**---------------------------------------------------------------------------- */
  198. /** \fn AT91F_PDC_SetNextTx */
  199. /** \brief Set the next transmit transfer descriptor */
  200. /**---------------------------------------------------------------------------- */
  201. __inline void AT91F_PDC_SetNextTx( AT91PS_PDC pPDC, /* \arg pointer to a PDC controller */
  202. char * address, /* \arg address to the next block to be transmitted */
  203. unsigned int bytes ) /* \arg number of bytes to be transmitted */
  204. {
  205. pPDC->PDC_TNPR = ( unsigned int ) address;
  206. pPDC->PDC_TNCR = bytes;
  207. }
  208. /**---------------------------------------------------------------------------- */
  209. /** \fn AT91F_PDC_SetRx */
  210. /** \brief Set the receive transfer descriptor */
  211. /**---------------------------------------------------------------------------- */
  212. __inline void AT91F_PDC_SetRx( AT91PS_PDC pPDC, /* \arg pointer to a PDC controller */
  213. char * address, /* \arg address to the next block to be received */
  214. unsigned int bytes ) /* \arg number of bytes to be received */
  215. {
  216. pPDC->PDC_RPR = ( unsigned int ) address;
  217. pPDC->PDC_RCR = bytes;
  218. }
  219. /**---------------------------------------------------------------------------- */
  220. /** \fn AT91F_PDC_SetTx */
  221. /** \brief Set the transmit transfer descriptor */
  222. /**---------------------------------------------------------------------------- */
  223. __inline void AT91F_PDC_SetTx( AT91PS_PDC pPDC, /* \arg pointer to a PDC controller */
  224. char * address, /* \arg address to the next block to be transmitted */
  225. unsigned int bytes ) /* \arg number of bytes to be transmitted */
  226. {
  227. pPDC->PDC_TPR = ( unsigned int ) address;
  228. pPDC->PDC_TCR = bytes;
  229. }
  230. /**---------------------------------------------------------------------------- */
  231. /** \fn AT91F_PDC_EnableTx */
  232. /** \brief Enable transmit */
  233. /**---------------------------------------------------------------------------- */
  234. __inline void AT91F_PDC_EnableTx( AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  235. {
  236. pPDC->PDC_PTCR = AT91C_PDC_TXTEN;
  237. }
  238. /**---------------------------------------------------------------------------- */
  239. /** \fn AT91F_PDC_EnableRx */
  240. /** \brief Enable receive */
  241. /**---------------------------------------------------------------------------- */
  242. __inline void AT91F_PDC_EnableRx( AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  243. {
  244. pPDC->PDC_PTCR = AT91C_PDC_RXTEN;
  245. }
  246. /**---------------------------------------------------------------------------- */
  247. /** \fn AT91F_PDC_DisableTx */
  248. /** \brief Disable transmit */
  249. /**---------------------------------------------------------------------------- */
  250. __inline void AT91F_PDC_DisableTx( AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  251. {
  252. pPDC->PDC_PTCR = AT91C_PDC_TXTDIS;
  253. }
  254. /**---------------------------------------------------------------------------- */
  255. /** \fn AT91F_PDC_DisableRx */
  256. /** \brief Disable receive */
  257. /**---------------------------------------------------------------------------- */
  258. __inline void AT91F_PDC_DisableRx( AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  259. {
  260. pPDC->PDC_PTCR = AT91C_PDC_RXTDIS;
  261. }
  262. /**---------------------------------------------------------------------------- */
  263. /** \fn AT91F_PDC_IsTxEmpty */
  264. /** \brief Test if the current transfer descriptor has been sent */
  265. /**---------------------------------------------------------------------------- */
  266. __inline int AT91F_PDC_IsTxEmpty( /* \return return 1 if transfer is complete */
  267. AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  268. {
  269. return !( pPDC->PDC_TCR );
  270. }
  271. /**---------------------------------------------------------------------------- */
  272. /** \fn AT91F_PDC_IsNextTxEmpty */
  273. /** \brief Test if the next transfer descriptor has been moved to the current td */
  274. /**---------------------------------------------------------------------------- */
  275. __inline int AT91F_PDC_IsNextTxEmpty( /* \return return 1 if transfer is complete */
  276. AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  277. {
  278. return !( pPDC->PDC_TNCR );
  279. }
  280. /**---------------------------------------------------------------------------- */
  281. /** \fn AT91F_PDC_IsRxEmpty */
  282. /** \brief Test if the current transfer descriptor has been filled */
  283. /**---------------------------------------------------------------------------- */
  284. __inline int AT91F_PDC_IsRxEmpty( /* \return return 1 if transfer is complete */
  285. AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  286. {
  287. return !( pPDC->PDC_RCR );
  288. }
  289. /**---------------------------------------------------------------------------- */
  290. /** \fn AT91F_PDC_IsNextRxEmpty */
  291. /** \brief Test if the next transfer descriptor has been moved to the current td */
  292. /**---------------------------------------------------------------------------- */
  293. __inline int AT91F_PDC_IsNextRxEmpty( /* \return return 1 if transfer is complete */
  294. AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  295. {
  296. return !( pPDC->PDC_RNCR );
  297. }
  298. /**---------------------------------------------------------------------------- */
  299. /** \fn AT91F_PDC_Open */
  300. /** \brief Open PDC: disable TX and RX reset transfer descriptors, re-enable RX and TX */
  301. /**---------------------------------------------------------------------------- */
  302. __inline void AT91F_PDC_Open( AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  303. {
  304. /** Disable the RX and TX PDC transfer requests */
  305. AT91F_PDC_DisableRx( pPDC );
  306. AT91F_PDC_DisableTx( pPDC );
  307. /** Reset all Counter register Next buffer first */
  308. AT91F_PDC_SetNextTx( pPDC, ( char * ) 0, 0 );
  309. AT91F_PDC_SetNextRx( pPDC, ( char * ) 0, 0 );
  310. AT91F_PDC_SetTx( pPDC, ( char * ) 0, 0 );
  311. AT91F_PDC_SetRx( pPDC, ( char * ) 0, 0 );
  312. /** Enable the RX and TX PDC transfer requests */
  313. AT91F_PDC_EnableRx( pPDC );
  314. AT91F_PDC_EnableTx( pPDC );
  315. }
  316. /**---------------------------------------------------------------------------- */
  317. /** \fn AT91F_PDC_Close */
  318. /** \brief Close PDC: disable TX and RX reset transfer descriptors */
  319. /**---------------------------------------------------------------------------- */
  320. __inline void AT91F_PDC_Close( AT91PS_PDC pPDC ) /* \arg pointer to a PDC controller */
  321. {
  322. /** Disable the RX and TX PDC transfer requests */
  323. AT91F_PDC_DisableRx( pPDC );
  324. AT91F_PDC_DisableTx( pPDC );
  325. /** Reset all Counter register Next buffer first */
  326. AT91F_PDC_SetNextTx( pPDC, ( char * ) 0, 0 );
  327. AT91F_PDC_SetNextRx( pPDC, ( char * ) 0, 0 );
  328. AT91F_PDC_SetTx( pPDC, ( char * ) 0, 0 );
  329. AT91F_PDC_SetRx( pPDC, ( char * ) 0, 0 );
  330. }
  331. /**---------------------------------------------------------------------------- */
  332. /** \fn AT91F_PDC_SendFrame */
  333. /** \brief Close PDC: disable TX and RX reset transfer descriptors */
  334. /**---------------------------------------------------------------------------- */
  335. __inline unsigned int AT91F_PDC_SendFrame( AT91PS_PDC pPDC,
  336. char * pBuffer,
  337. unsigned int szBuffer,
  338. char * pNextBuffer,
  339. unsigned int szNextBuffer )
  340. {
  341. if( AT91F_PDC_IsTxEmpty( pPDC ) )
  342. {
  343. /** Buffer and next buffer can be initialized */
  344. AT91F_PDC_SetTx( pPDC, pBuffer, szBuffer );
  345. AT91F_PDC_SetNextTx( pPDC, pNextBuffer, szNextBuffer );
  346. return 2;
  347. }
  348. else if( AT91F_PDC_IsNextTxEmpty( pPDC ) )
  349. {
  350. /** Only one buffer can be initialized */
  351. AT91F_PDC_SetNextTx( pPDC, pBuffer, szBuffer );
  352. return 1;
  353. }
  354. else
  355. {
  356. /** All buffer are in use... */
  357. return 0;
  358. }
  359. }
  360. /**---------------------------------------------------------------------------- */
  361. /** \fn AT91F_PDC_ReceiveFrame */
  362. /** \brief Close PDC: disable TX and RX reset transfer descriptors */
  363. /**---------------------------------------------------------------------------- */
  364. __inline unsigned int AT91F_PDC_ReceiveFrame( AT91PS_PDC pPDC,
  365. char * pBuffer,
  366. unsigned int szBuffer,
  367. char * pNextBuffer,
  368. unsigned int szNextBuffer )
  369. {
  370. if( AT91F_PDC_IsRxEmpty( pPDC ) )
  371. {
  372. /** Buffer and next buffer can be initialized */
  373. AT91F_PDC_SetRx( pPDC, pBuffer, szBuffer );
  374. AT91F_PDC_SetNextRx( pPDC, pNextBuffer, szNextBuffer );
  375. return 2;
  376. }
  377. else if( AT91F_PDC_IsNextRxEmpty( pPDC ) )
  378. {
  379. /** Only one buffer can be initialized */
  380. AT91F_PDC_SetNextRx( pPDC, pBuffer, szBuffer );
  381. return 1;
  382. }
  383. else
  384. {
  385. /** All buffer are in use... */
  386. return 0;
  387. }
  388. }
  389. /* *****************************************************************************
  390. * SOFTWARE API FOR DBGU
  391. ***************************************************************************** */
  392. /**---------------------------------------------------------------------------- */
  393. /** \fn AT91F_DBGU_InterruptEnable */
  394. /** \brief Enable DBGU Interrupt */
  395. /**---------------------------------------------------------------------------- */
  396. __inline void AT91F_DBGU_InterruptEnable( AT91PS_DBGU pDbgu, /* \arg pointer to a DBGU controller */
  397. unsigned int flag ) /* \arg dbgu interrupt to be enabled */
  398. {
  399. pDbgu->DBGU_IER = flag;
  400. }
  401. /**---------------------------------------------------------------------------- */
  402. /** \fn AT91F_DBGU_InterruptDisable */
  403. /** \brief Disable DBGU Interrupt */
  404. /**---------------------------------------------------------------------------- */
  405. __inline void AT91F_DBGU_InterruptDisable( AT91PS_DBGU pDbgu, /* \arg pointer to a DBGU controller */
  406. unsigned int flag ) /* \arg dbgu interrupt to be disabled */
  407. {
  408. pDbgu->DBGU_IDR = flag;
  409. }
  410. /**---------------------------------------------------------------------------- */
  411. /** \fn AT91F_DBGU_GetInterruptMaskStatus */
  412. /** \brief Return DBGU Interrupt Mask Status */
  413. /**---------------------------------------------------------------------------- */
  414. __inline unsigned int AT91F_DBGU_GetInterruptMaskStatus( /* \return DBGU Interrupt Mask Status */
  415. AT91PS_DBGU pDbgu ) /* \arg pointer to a DBGU controller */
  416. {
  417. return pDbgu->DBGU_IMR;
  418. }
  419. /**---------------------------------------------------------------------------- */
  420. /** \fn AT91F_DBGU_IsInterruptMasked */
  421. /** \brief Test if DBGU Interrupt is Masked */
  422. /**---------------------------------------------------------------------------- */
  423. __inline int AT91F_DBGU_IsInterruptMasked( AT91PS_DBGU pDbgu, /* \arg pointer to a DBGU controller */
  424. unsigned int flag ) /* \arg flag to be tested */
  425. {
  426. return( AT91F_DBGU_GetInterruptMaskStatus( pDbgu ) & flag );
  427. }
  428. /* *****************************************************************************
  429. * SOFTWARE API FOR PIO
  430. ***************************************************************************** */
  431. /**---------------------------------------------------------------------------- */
  432. /** \fn AT91F_PIO_CfgPeriph */
  433. /** \brief Enable pins to be derived by peripheral */
  434. /**---------------------------------------------------------------------------- */
  435. __inline void AT91F_PIO_CfgPeriph( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  436. unsigned int periphAEnable, /* \arg PERIPH A to enable */
  437. unsigned int periphBEnable ) /* \arg PERIPH B to enable */
  438. {
  439. pPio->PIO_ASR = periphAEnable;
  440. pPio->PIO_BSR = periphBEnable;
  441. pPio->PIO_PDR = ( periphAEnable | periphBEnable ); /* Set in Periph mode */
  442. }
  443. /**---------------------------------------------------------------------------- */
  444. /** \fn AT91F_PIO_CfgOutput */
  445. /** \brief Enable PIO in output mode */
  446. /**---------------------------------------------------------------------------- */
  447. __inline void AT91F_PIO_CfgOutput( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  448. unsigned int pioEnable ) /* \arg PIO to be enabled */
  449. {
  450. pPio->PIO_PER = pioEnable; /* Set in PIO mode */
  451. pPio->PIO_OER = pioEnable; /* Configure in Output */
  452. }
  453. /**---------------------------------------------------------------------------- */
  454. /** \fn AT91F_PIO_CfgInput */
  455. /** \brief Enable PIO in input mode */
  456. /**---------------------------------------------------------------------------- */
  457. __inline void AT91F_PIO_CfgInput( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  458. unsigned int inputEnable ) /* \arg PIO to be enabled */
  459. {
  460. /* Disable output */
  461. pPio->PIO_ODR = inputEnable;
  462. pPio->PIO_PER = inputEnable;
  463. }
  464. /**---------------------------------------------------------------------------- */
  465. /** \fn AT91F_PIO_CfgOpendrain */
  466. /** \brief Configure PIO in open drain */
  467. /**---------------------------------------------------------------------------- */
  468. __inline void AT91F_PIO_CfgOpendrain( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  469. unsigned int multiDrvEnable ) /* \arg pio to be configured in open drain */
  470. {
  471. /* Configure the multi-drive option */
  472. pPio->PIO_MDDR = ~multiDrvEnable;
  473. pPio->PIO_MDER = multiDrvEnable;
  474. }
  475. /**---------------------------------------------------------------------------- */
  476. /** \fn AT91F_PIO_CfgPullup */
  477. /** \brief Enable pullup on PIO */
  478. /**---------------------------------------------------------------------------- */
  479. __inline void AT91F_PIO_CfgPullup( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  480. unsigned int pullupEnable ) /* \arg enable pullup on PIO */
  481. {
  482. /* Connect or not Pullup */
  483. pPio->PIO_PPUDR = ~pullupEnable;
  484. pPio->PIO_PPUER = pullupEnable;
  485. }
  486. /**---------------------------------------------------------------------------- */
  487. /** \fn AT91F_PIO_CfgDirectDrive */
  488. /** \brief Enable direct drive on PIO */
  489. /**---------------------------------------------------------------------------- */
  490. __inline void AT91F_PIO_CfgDirectDrive( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  491. unsigned int directDrive ) /* \arg PIO to be configured with direct drive */
  492. {
  493. /* Configure the Direct Drive */
  494. pPio->PIO_OWDR = ~directDrive;
  495. pPio->PIO_OWER = directDrive;
  496. }
  497. /**---------------------------------------------------------------------------- */
  498. /** \fn AT91F_PIO_CfgInputFilter */
  499. /** \brief Enable input filter on input PIO */
  500. /**---------------------------------------------------------------------------- */
  501. __inline void AT91F_PIO_CfgInputFilter( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  502. unsigned int inputFilter ) /* \arg PIO to be configured with input filter */
  503. {
  504. /* Configure the Direct Drive */
  505. pPio->PIO_IFDR = ~inputFilter;
  506. pPio->PIO_IFER = inputFilter;
  507. }
  508. /**---------------------------------------------------------------------------- */
  509. /** \fn AT91F_PIO_GetInput */
  510. /** \brief Return PIO input value */
  511. /**---------------------------------------------------------------------------- */
  512. __inline unsigned int AT91F_PIO_GetInput( /* \return PIO input */
  513. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  514. {
  515. return pPio->PIO_PDSR;
  516. }
  517. /**---------------------------------------------------------------------------- */
  518. /** \fn AT91F_PIO_IsInputSet */
  519. /** \brief Test if PIO is input flag is active */
  520. /**---------------------------------------------------------------------------- */
  521. __inline int AT91F_PIO_IsInputSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  522. unsigned int flag ) /* \arg flag to be tested */
  523. {
  524. return( AT91F_PIO_GetInput( pPio ) & flag );
  525. }
  526. /**---------------------------------------------------------------------------- */
  527. /** \fn AT91F_PIO_SetOutput */
  528. /** \brief Set to 1 output PIO */
  529. /**---------------------------------------------------------------------------- */
  530. __inline void AT91F_PIO_SetOutput( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  531. unsigned int flag ) /* \arg output to be set */
  532. {
  533. pPio->PIO_SODR = flag;
  534. }
  535. /**---------------------------------------------------------------------------- */
  536. /** \fn AT91F_PIO_ClearOutput */
  537. /** \brief Set to 0 output PIO */
  538. /**---------------------------------------------------------------------------- */
  539. __inline void AT91F_PIO_ClearOutput( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  540. unsigned int flag ) /* \arg output to be cleared */
  541. {
  542. pPio->PIO_CODR = flag;
  543. }
  544. /**---------------------------------------------------------------------------- */
  545. /** \fn AT91F_PIO_ForceOutput */
  546. /** \brief Force output when Direct drive option is enabled */
  547. /**---------------------------------------------------------------------------- */
  548. __inline void AT91F_PIO_ForceOutput( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  549. unsigned int flag ) /* \arg output to be forced */
  550. {
  551. pPio->PIO_ODSR = flag;
  552. }
  553. /**---------------------------------------------------------------------------- */
  554. /** \fn AT91F_PIO_Enable */
  555. /** \brief Enable PIO */
  556. /**---------------------------------------------------------------------------- */
  557. __inline void AT91F_PIO_Enable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  558. unsigned int flag ) /* \arg pio to be enabled */
  559. {
  560. pPio->PIO_PER = flag;
  561. }
  562. /**---------------------------------------------------------------------------- */
  563. /** \fn AT91F_PIO_Disable */
  564. /** \brief Disable PIO */
  565. /**---------------------------------------------------------------------------- */
  566. __inline void AT91F_PIO_Disable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  567. unsigned int flag ) /* \arg pio to be disabled */
  568. {
  569. pPio->PIO_PDR = flag;
  570. }
  571. /**---------------------------------------------------------------------------- */
  572. /** \fn AT91F_PIO_GetStatus */
  573. /** \brief Return PIO Status */
  574. /**---------------------------------------------------------------------------- */
  575. __inline unsigned int AT91F_PIO_GetStatus( /* \return PIO Status */
  576. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  577. {
  578. return pPio->PIO_PSR;
  579. }
  580. /**---------------------------------------------------------------------------- */
  581. /** \fn AT91F_PIO_IsSet */
  582. /** \brief Test if PIO is Set */
  583. /**---------------------------------------------------------------------------- */
  584. __inline int AT91F_PIO_IsSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  585. unsigned int flag ) /* \arg flag to be tested */
  586. {
  587. return( AT91F_PIO_GetStatus( pPio ) & flag );
  588. }
  589. /**---------------------------------------------------------------------------- */
  590. /** \fn AT91F_PIO_OutputEnable */
  591. /** \brief Output Enable PIO */
  592. /**---------------------------------------------------------------------------- */
  593. __inline void AT91F_PIO_OutputEnable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  594. unsigned int flag ) /* \arg pio output to be enabled */
  595. {
  596. pPio->PIO_OER = flag;
  597. }
  598. /**---------------------------------------------------------------------------- */
  599. /** \fn AT91F_PIO_OutputDisable */
  600. /** \brief Output Enable PIO */
  601. /**---------------------------------------------------------------------------- */
  602. __inline void AT91F_PIO_OutputDisable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  603. unsigned int flag ) /* \arg pio output to be disabled */
  604. {
  605. pPio->PIO_ODR = flag;
  606. }
  607. /**---------------------------------------------------------------------------- */
  608. /** \fn AT91F_PIO_GetOutputStatus */
  609. /** \brief Return PIO Output Status */
  610. /**---------------------------------------------------------------------------- */
  611. __inline unsigned int AT91F_PIO_GetOutputStatus( /* \return PIO Output Status */
  612. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  613. {
  614. return pPio->PIO_OSR;
  615. }
  616. /**---------------------------------------------------------------------------- */
  617. /** \fn AT91F_PIO_IsOuputSet */
  618. /** \brief Test if PIO Output is Set */
  619. /**---------------------------------------------------------------------------- */
  620. __inline int AT91F_PIO_IsOutputSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  621. unsigned int flag ) /* \arg flag to be tested */
  622. {
  623. return( AT91F_PIO_GetOutputStatus( pPio ) & flag );
  624. }
  625. /**---------------------------------------------------------------------------- */
  626. /** \fn AT91F_PIO_InputFilterEnable */
  627. /** \brief Input Filter Enable PIO */
  628. /**---------------------------------------------------------------------------- */
  629. __inline void AT91F_PIO_InputFilterEnable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  630. unsigned int flag ) /* \arg pio input filter to be enabled */
  631. {
  632. pPio->PIO_IFER = flag;
  633. }
  634. /**---------------------------------------------------------------------------- */
  635. /** \fn AT91F_PIO_InputFilterDisable */
  636. /** \brief Input Filter Disable PIO */
  637. /**---------------------------------------------------------------------------- */
  638. __inline void AT91F_PIO_InputFilterDisable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  639. unsigned int flag ) /* \arg pio input filter to be disabled */
  640. {
  641. pPio->PIO_IFDR = flag;
  642. }
  643. /**---------------------------------------------------------------------------- */
  644. /** \fn AT91F_PIO_GetInputFilterStatus */
  645. /** \brief Return PIO Input Filter Status */
  646. /**---------------------------------------------------------------------------- */
  647. __inline unsigned int AT91F_PIO_GetInputFilterStatus( /* \return PIO Input Filter Status */
  648. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  649. {
  650. return pPio->PIO_IFSR;
  651. }
  652. /**---------------------------------------------------------------------------- */
  653. /** \fn AT91F_PIO_IsInputFilterSet */
  654. /** \brief Test if PIO Input filter is Set */
  655. /**---------------------------------------------------------------------------- */
  656. __inline int AT91F_PIO_IsInputFilterSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  657. unsigned int flag ) /* \arg flag to be tested */
  658. {
  659. return( AT91F_PIO_GetInputFilterStatus( pPio ) & flag );
  660. }
  661. /**---------------------------------------------------------------------------- */
  662. /** \fn AT91F_PIO_GetOutputDataStatus */
  663. /** \brief Return PIO Output Data Status */
  664. /**---------------------------------------------------------------------------- */
  665. __inline unsigned int AT91F_PIO_GetOutputDataStatus( /* \return PIO Output Data Status */
  666. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  667. {
  668. return pPio->PIO_ODSR;
  669. }
  670. /**---------------------------------------------------------------------------- */
  671. /** \fn AT91F_PIO_InterruptEnable */
  672. /** \brief Enable PIO Interrupt */
  673. /**---------------------------------------------------------------------------- */
  674. __inline void AT91F_PIO_InterruptEnable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  675. unsigned int flag ) /* \arg pio interrupt to be enabled */
  676. {
  677. pPio->PIO_IER = flag;
  678. }
  679. /**---------------------------------------------------------------------------- */
  680. /** \fn AT91F_PIO_InterruptDisable */
  681. /** \brief Disable PIO Interrupt */
  682. /**---------------------------------------------------------------------------- */
  683. __inline void AT91F_PIO_InterruptDisable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  684. unsigned int flag ) /* \arg pio interrupt to be disabled */
  685. {
  686. pPio->PIO_IDR = flag;
  687. }
  688. /**---------------------------------------------------------------------------- */
  689. /** \fn AT91F_PIO_GetInterruptMaskStatus */
  690. /** \brief Return PIO Interrupt Mask Status */
  691. /**---------------------------------------------------------------------------- */
  692. __inline unsigned int AT91F_PIO_GetInterruptMaskStatus( /* \return PIO Interrupt Mask Status */
  693. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  694. {
  695. return pPio->PIO_IMR;
  696. }
  697. /**---------------------------------------------------------------------------- */
  698. /** \fn AT91F_PIO_GetInterruptStatus */
  699. /** \brief Return PIO Interrupt Status */
  700. /**---------------------------------------------------------------------------- */
  701. __inline unsigned int AT91F_PIO_GetInterruptStatus( /* \return PIO Interrupt Status */
  702. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  703. {
  704. return pPio->PIO_ISR;
  705. }
  706. /**---------------------------------------------------------------------------- */
  707. /** \fn AT91F_PIO_IsInterruptMasked */
  708. /** \brief Test if PIO Interrupt is Masked */
  709. /**---------------------------------------------------------------------------- */
  710. __inline int AT91F_PIO_IsInterruptMasked( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  711. unsigned int flag ) /* \arg flag to be tested */
  712. {
  713. return( AT91F_PIO_GetInterruptMaskStatus( pPio ) & flag );
  714. }
  715. /**---------------------------------------------------------------------------- */
  716. /** \fn AT91F_PIO_IsInterruptSet */
  717. /** \brief Test if PIO Interrupt is Set */
  718. /**---------------------------------------------------------------------------- */
  719. __inline int AT91F_PIO_IsInterruptSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  720. unsigned int flag ) /* \arg flag to be tested */
  721. {
  722. return( AT91F_PIO_GetInterruptStatus( pPio ) & flag );
  723. }
  724. /**---------------------------------------------------------------------------- */
  725. /** \fn AT91F_PIO_MultiDriverEnable */
  726. /** \brief Multi Driver Enable PIO */
  727. /**---------------------------------------------------------------------------- */
  728. __inline void AT91F_PIO_MultiDriverEnable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  729. unsigned int flag ) /* \arg pio to be enabled */
  730. {
  731. pPio->PIO_MDER = flag;
  732. }
  733. /**---------------------------------------------------------------------------- */
  734. /** \fn AT91F_PIO_MultiDriverDisable */
  735. /** \brief Multi Driver Disable PIO */
  736. /**---------------------------------------------------------------------------- */
  737. __inline void AT91F_PIO_MultiDriverDisable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  738. unsigned int flag ) /* \arg pio to be disabled */
  739. {
  740. pPio->PIO_MDDR = flag;
  741. }
  742. /**---------------------------------------------------------------------------- */
  743. /** \fn AT91F_PIO_GetMultiDriverStatus */
  744. /** \brief Return PIO Multi Driver Status */
  745. /**---------------------------------------------------------------------------- */
  746. __inline unsigned int AT91F_PIO_GetMultiDriverStatus( /* \return PIO Multi Driver Status */
  747. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  748. {
  749. return pPio->PIO_MDSR;
  750. }
  751. /**---------------------------------------------------------------------------- */
  752. /** \fn AT91F_PIO_IsMultiDriverSet */
  753. /** \brief Test if PIO MultiDriver is Set */
  754. /**---------------------------------------------------------------------------- */
  755. __inline int AT91F_PIO_IsMultiDriverSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  756. unsigned int flag ) /* \arg flag to be tested */
  757. {
  758. return( AT91F_PIO_GetMultiDriverStatus( pPio ) & flag );
  759. }
  760. /**---------------------------------------------------------------------------- */
  761. /** \fn AT91F_PIO_A_RegisterSelection */
  762. /** \brief PIO A Register Selection */
  763. /**---------------------------------------------------------------------------- */
  764. __inline void AT91F_PIO_A_RegisterSelection( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  765. unsigned int flag ) /* \arg pio A register selection */
  766. {
  767. pPio->PIO_ASR = flag;
  768. }
  769. /**---------------------------------------------------------------------------- */
  770. /** \fn AT91F_PIO_B_RegisterSelection */
  771. /** \brief PIO B Register Selection */
  772. /**---------------------------------------------------------------------------- */
  773. __inline void AT91F_PIO_B_RegisterSelection( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  774. unsigned int flag ) /* \arg pio B register selection */
  775. {
  776. pPio->PIO_BSR = flag;
  777. }
  778. /**---------------------------------------------------------------------------- */
  779. /** \fn AT91F_PIO_Get_AB_RegisterStatus */
  780. /** \brief Return PIO Interrupt Status */
  781. /**---------------------------------------------------------------------------- */
  782. __inline unsigned int AT91F_PIO_Get_AB_RegisterStatus( /* \return PIO AB Register Status */
  783. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  784. {
  785. return pPio->PIO_ABSR;
  786. }
  787. /**---------------------------------------------------------------------------- */
  788. /** \fn AT91F_PIO_IsAB_RegisterSet */
  789. /** \brief Test if PIO AB Register is Set */
  790. /**---------------------------------------------------------------------------- */
  791. __inline int AT91F_PIO_IsAB_RegisterSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  792. unsigned int flag ) /* \arg flag to be tested */
  793. {
  794. return( AT91F_PIO_Get_AB_RegisterStatus( pPio ) & flag );
  795. }
  796. /**---------------------------------------------------------------------------- */
  797. /** \fn AT91F_PIO_OutputWriteEnable */
  798. /** \brief Output Write Enable PIO */
  799. /**---------------------------------------------------------------------------- */
  800. __inline void AT91F_PIO_OutputWriteEnable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  801. unsigned int flag ) /* \arg pio output write to be enabled */
  802. {
  803. pPio->PIO_OWER = flag;
  804. }
  805. /**---------------------------------------------------------------------------- */
  806. /** \fn AT91F_PIO_OutputWriteDisable */
  807. /** \brief Output Write Disable PIO */
  808. /**---------------------------------------------------------------------------- */
  809. __inline void AT91F_PIO_OutputWriteDisable( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  810. unsigned int flag ) /* \arg pio output write to be disabled */
  811. {
  812. pPio->PIO_OWDR = flag;
  813. }
  814. /**---------------------------------------------------------------------------- */
  815. /** \fn AT91F_PIO_GetOutputWriteStatus */
  816. /** \brief Return PIO Output Write Status */
  817. /**---------------------------------------------------------------------------- */
  818. __inline unsigned int AT91F_PIO_GetOutputWriteStatus( /* \return PIO Output Write Status */
  819. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  820. {
  821. return pPio->PIO_OWSR;
  822. }
  823. /**---------------------------------------------------------------------------- */
  824. /** \fn AT91F_PIO_IsOutputWriteSet */
  825. /** \brief Test if PIO OutputWrite is Set */
  826. /**---------------------------------------------------------------------------- */
  827. __inline int AT91F_PIO_IsOutputWriteSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  828. unsigned int flag ) /* \arg flag to be tested */
  829. {
  830. return( AT91F_PIO_GetOutputWriteStatus( pPio ) & flag );
  831. }
  832. /**---------------------------------------------------------------------------- */
  833. /** \fn AT91F_PIO_GetCfgPullup */
  834. /** \brief Return PIO Configuration Pullup */
  835. /**---------------------------------------------------------------------------- */
  836. __inline unsigned int AT91F_PIO_GetCfgPullup( /* \return PIO Configuration Pullup */
  837. AT91PS_PIO pPio ) /* \arg pointer to a PIO controller */
  838. {
  839. return pPio->PIO_PPUSR;
  840. }
  841. /**---------------------------------------------------------------------------- */
  842. /** \fn AT91F_PIO_IsOutputDataStatusSet */
  843. /** \brief Test if PIO Output Data Status is Set */
  844. /**---------------------------------------------------------------------------- */
  845. __inline int AT91F_PIO_IsOutputDataStatusSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  846. unsigned int flag ) /* \arg flag to be tested */
  847. {
  848. return( AT91F_PIO_GetOutputDataStatus( pPio ) & flag );
  849. }
  850. /**---------------------------------------------------------------------------- */
  851. /** \fn AT91F_PIO_IsCfgPullupStatusSet */
  852. /** \brief Test if PIO Configuration Pullup Status is Set */
  853. /**---------------------------------------------------------------------------- */
  854. __inline int AT91F_PIO_IsCfgPullupStatusSet( AT91PS_PIO pPio, /* \arg pointer to a PIO controller */
  855. unsigned int flag ) /* \arg flag to be tested */
  856. {
  857. return( ~AT91F_PIO_GetCfgPullup( pPio ) & flag );
  858. }
  859. /* *****************************************************************************
  860. * SOFTWARE API FOR PMC
  861. ***************************************************************************** */
  862. /**---------------------------------------------------------------------------- */
  863. /** \fn AT91F_PMC_CfgSysClkEnableReg */
  864. /** \brief Configure the System Clock Enable Register of the PMC controller */
  865. /**---------------------------------------------------------------------------- */
  866. __inline void AT91F_PMC_CfgSysClkEnableReg( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  867. unsigned int mode )
  868. {
  869. /** Write to the SCER register */
  870. pPMC->PMC_SCER = mode;
  871. }
  872. /**---------------------------------------------------------------------------- */
  873. /** \fn AT91F_PMC_CfgSysClkDisableReg */
  874. /** \brief Configure the System Clock Disable Register of the PMC controller */
  875. /**---------------------------------------------------------------------------- */
  876. __inline void AT91F_PMC_CfgSysClkDisableReg( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  877. unsigned int mode )
  878. {
  879. /** Write to the SCDR register */
  880. pPMC->PMC_SCDR = mode;
  881. }
  882. /**---------------------------------------------------------------------------- */
  883. /** \fn AT91F_PMC_GetSysClkStatusReg */
  884. /** \brief Return the System Clock Status Register of the PMC controller */
  885. /**---------------------------------------------------------------------------- */
  886. __inline unsigned int AT91F_PMC_GetSysClkStatusReg( AT91PS_PMC pPMC /* pointer to a CAN controller */
  887. )
  888. {
  889. return pPMC->PMC_SCSR;
  890. }
  891. /**---------------------------------------------------------------------------- */
  892. /** \fn AT91F_PMC_EnablePeriphClock */
  893. /** \brief Enable peripheral clock */
  894. /**---------------------------------------------------------------------------- */
  895. __inline void AT91F_PMC_EnablePeriphClock( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  896. unsigned int periphIds ) /* \arg IDs of peripherals to enable */
  897. {
  898. pPMC->PMC_PCER = periphIds;
  899. }
  900. /**---------------------------------------------------------------------------- */
  901. /** \fn AT91F_PMC_DisablePeriphClock */
  902. /** \brief Disable peripheral clock */
  903. /**---------------------------------------------------------------------------- */
  904. __inline void AT91F_PMC_DisablePeriphClock( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  905. unsigned int periphIds ) /* \arg IDs of peripherals to enable */
  906. {
  907. pPMC->PMC_PCDR = periphIds;
  908. }
  909. /**---------------------------------------------------------------------------- */
  910. /** \fn AT91F_PMC_GetPeriphClock */
  911. /** \brief Get peripheral clock status */
  912. /**---------------------------------------------------------------------------- */
  913. __inline unsigned int AT91F_PMC_GetPeriphClock( AT91PS_PMC pPMC ) /* \arg pointer to PMC controller */
  914. {
  915. return pPMC->PMC_PCSR;
  916. }
  917. /**---------------------------------------------------------------------------- */
  918. /** \fn AT91F_CKGR_CfgMainOscillatorReg */
  919. /** \brief Cfg the main oscillator */
  920. /**---------------------------------------------------------------------------- */
  921. __inline void AT91F_CKGR_CfgMainOscillatorReg( AT91PS_CKGR pCKGR, /* \arg pointer to CKGR controller */
  922. unsigned int mode )
  923. {
  924. pCKGR->CKGR_MOR = mode;
  925. }
  926. /**---------------------------------------------------------------------------- */
  927. /** \fn AT91F_CKGR_GetMainOscillatorReg */
  928. /** \brief Cfg the main oscillator */
  929. /**---------------------------------------------------------------------------- */
  930. __inline unsigned int AT91F_CKGR_GetMainOscillatorReg( AT91PS_CKGR pCKGR ) /* \arg pointer to CKGR controller */
  931. {
  932. return pCKGR->CKGR_MOR;
  933. }
  934. /**---------------------------------------------------------------------------- */
  935. /** \fn AT91F_CKGR_EnableMainOscillator */
  936. /** \brief Enable the main oscillator */
  937. /**---------------------------------------------------------------------------- */
  938. __inline void AT91F_CKGR_EnableMainOscillator( AT91PS_CKGR pCKGR ) /* \arg pointer to CKGR controller */
  939. {
  940. pCKGR->CKGR_MOR |= AT91C_CKGR_MOSCEN;
  941. }
  942. /**---------------------------------------------------------------------------- */
  943. /** \fn AT91F_CKGR_DisableMainOscillator */
  944. /** \brief Disable the main oscillator */
  945. /**---------------------------------------------------------------------------- */
  946. __inline void AT91F_CKGR_DisableMainOscillator( AT91PS_CKGR pCKGR ) /* \arg pointer to CKGR controller */
  947. {
  948. pCKGR->CKGR_MOR &= ~AT91C_CKGR_MOSCEN;
  949. }
  950. /**---------------------------------------------------------------------------- */
  951. /** \fn AT91F_CKGR_CfgMainOscStartUpTime */
  952. /** \brief Cfg MOR Register according to the main osc startup time */
  953. /**---------------------------------------------------------------------------- */
  954. __inline void AT91F_CKGR_CfgMainOscStartUpTime( AT91PS_CKGR pCKGR, /* \arg pointer to CKGR controller */
  955. unsigned int startup_time, /* \arg main osc startup time in microsecond (us) */
  956. unsigned int slowClock ) /* \arg slowClock in Hz */
  957. {
  958. pCKGR->CKGR_MOR &= ~AT91C_CKGR_OSCOUNT;
  959. pCKGR->CKGR_MOR |= ( ( slowClock * startup_time ) / ( 8 * 1000000 ) ) << 8;
  960. }
  961. /**---------------------------------------------------------------------------- */
  962. /** \fn AT91F_CKGR_GetMainClockFreqReg */
  963. /** \brief Cfg the main oscillator */
  964. /**---------------------------------------------------------------------------- */
  965. __inline unsigned int AT91F_CKGR_GetMainClockFreqReg( AT91PS_CKGR pCKGR ) /* \arg pointer to CKGR controller */
  966. {
  967. return pCKGR->CKGR_MCFR;
  968. }
  969. /**---------------------------------------------------------------------------- */
  970. /** \fn AT91F_CKGR_GetMainClock */
  971. /** \brief Return Main clock in Hz */
  972. /**---------------------------------------------------------------------------- */
  973. __inline unsigned int AT91F_CKGR_GetMainClock( AT91PS_CKGR pCKGR, /* \arg pointer to CKGR controller */
  974. unsigned int slowClock ) /* \arg slowClock in Hz */
  975. {
  976. return ( ( pCKGR->CKGR_MCFR & AT91C_CKGR_MAINF ) * slowClock ) >> 4;
  977. }
  978. /**---------------------------------------------------------------------------- */
  979. /** \fn AT91F_PMC_CfgMCKReg */
  980. /** \brief Cfg Master Clock Register */
  981. /**---------------------------------------------------------------------------- */
  982. __inline void AT91F_PMC_CfgMCKReg( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  983. unsigned int mode )
  984. {
  985. pPMC->PMC_MCKR = mode;
  986. }
  987. /**---------------------------------------------------------------------------- */
  988. /** \fn AT91F_PMC_GetMCKReg */
  989. /** \brief Return Master Clock Register */
  990. /**---------------------------------------------------------------------------- */
  991. __inline unsigned int AT91F_PMC_GetMCKReg( AT91PS_PMC pPMC ) /* \arg pointer to PMC controller */
  992. {
  993. return pPMC->PMC_MCKR;
  994. }
  995. /**------------------------------------------------------------------------------ */
  996. /** \fn AT91F_PMC_GetMasterClock */
  997. /** \brief Return master clock in Hz which corresponds to processor clock for ARM7 */
  998. /**------------------------------------------------------------------------------ */
  999. __inline unsigned int AT91F_PMC_GetMasterClock( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  1000. AT91PS_CKGR pCKGR, /* \arg pointer to CKGR controller */
  1001. unsigned int slowClock ) /* \arg slowClock in Hz */
  1002. {
  1003. unsigned int reg = pPMC->PMC_MCKR;
  1004. unsigned int prescaler = ( 1 << ( ( reg & AT91C_PMC_PRES ) >> 2 ) );
  1005. unsigned int pllDivider, pllMultiplier;
  1006. switch( reg & AT91C_PMC_CSS )
  1007. {
  1008. case AT91C_PMC_CSS_SLOW_CLK: /* Slow clock selected */
  1009. return slowClock / prescaler;
  1010. case AT91C_PMC_CSS_MAIN_CLK: /* Main clock is selected */
  1011. return AT91F_CKGR_GetMainClock( pCKGR, slowClock ) / prescaler;
  1012. case AT91C_PMC_CSS_PLL_CLK: /* PLLB clock is selected */
  1013. reg = pCKGR->CKGR_PLLR;
  1014. pllDivider = ( reg & AT91C_CKGR_DIV );
  1015. pllMultiplier = ( ( reg & AT91C_CKGR_MUL ) >> 16 ) + 1;
  1016. return AT91F_CKGR_GetMainClock( pCKGR, slowClock ) / pllDivider * pllMultiplier / prescaler;
  1017. }
  1018. return 0;
  1019. }
  1020. /**---------------------------------------------------------------------------- */
  1021. /** \fn AT91F_PMC_EnablePCK */
  1022. /** \brief Enable peripheral clock */
  1023. /**---------------------------------------------------------------------------- */
  1024. __inline void AT91F_PMC_EnablePCK( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  1025. unsigned int pck, /* \arg Peripheral clock identifier 0 .. 7 */
  1026. unsigned int mode )
  1027. {
  1028. pPMC->PMC_PCKR[ pck ] = mode;
  1029. pPMC->PMC_SCER = ( 1 << pck ) << 8;
  1030. }
  1031. /**---------------------------------------------------------------------------- */
  1032. /** \fn AT91F_PMC_DisablePCK */
  1033. /** \brief Enable peripheral clock */
  1034. /**---------------------------------------------------------------------------- */
  1035. __inline void AT91F_PMC_DisablePCK( AT91PS_PMC pPMC, /* \arg pointer to PMC controller */
  1036. unsigned int pck ) /* \arg Peripheral clock identifier 0 .. 7 */
  1037. {
  1038. pPMC->PMC_SCDR = ( 1 << pck ) << 8;
  1039. }
  1040. /**---------------------------------------------------------------------------- */
  1041. /** \fn AT91F_PMC_EnableIt */
  1042. /** \brief Enable PMC interrupt */
  1043. /**---------------------------------------------------------------------------- */
  1044. __inline void AT91F_PMC_EnableIt( AT91PS_PMC pPMC, /* pointer to a PMC controller */
  1045. unsigned int flag ) /* IT to be enabled */
  1046. {
  1047. /** Write to the IER register */
  1048. pPMC->PMC_IER = flag;
  1049. }
  1050. /**---------------------------------------------------------------------------- */
  1051. /** \fn AT91F_PMC_DisableIt */
  1052. /** \brief Disable PMC interrupt */
  1053. /**---------------------------------------------------------------------------- */
  1054. __inline void AT91F_PMC_DisableIt( AT91PS_PMC pPMC, /* pointer to a PMC controller */
  1055. unsigned int flag ) /* IT to be disabled */
  1056. {
  1057. /** Write to the IDR register */
  1058. pPMC->PMC_IDR = flag;
  1059. }
  1060. /**---------------------------------------------------------------------------- */
  1061. /** \fn AT91F_PMC_GetStatus */
  1062. /** \brief Return PMC Interrupt Status */
  1063. /**---------------------------------------------------------------------------- */
  1064. __inline unsigned int AT91F_PMC_GetStatus( /* \return PMC Interrupt Status */
  1065. AT91PS_PMC pPMC ) /* pointer to a PMC controller */
  1066. {
  1067. return pPMC->PMC_SR;
  1068. }
  1069. /**---------------------------------------------------------------------------- */
  1070. /** \fn AT91F_PMC_GetInterruptMaskStatus */
  1071. /** \brief Return PMC Interrupt Mask Status */
  1072. /**---------------------------------------------------------------------------- */
  1073. __inline unsigned int AT91F_PMC_GetInterruptMaskStatus( /* \return PMC Interrupt Mask Status */
  1074. AT91PS_PMC pPMC ) /* pointer to a PMC controller */
  1075. {
  1076. return pPMC->PMC_IMR;
  1077. }
  1078. /**---------------------------------------------------------------------------- */
  1079. /** \fn AT91F_PMC_IsInterruptMasked */
  1080. /** \brief Test if PMC Interrupt is Masked */
  1081. /**---------------------------------------------------------------------------- */
  1082. __inline unsigned int AT91F_PMC_IsInterruptMasked( AT91PS_PMC pPMC, /* \arg pointer to a PMC controller */
  1083. unsigned int flag ) /* \arg flag to be tested */
  1084. {
  1085. return( AT91F_PMC_GetInterruptMaskStatus( pPMC ) & flag );
  1086. }
  1087. /**---------------------------------------------------------------------------- */
  1088. /** \fn AT91F_PMC_IsStatusSet */
  1089. /** \brief Test if PMC Status is Set */
  1090. /**---------------------------------------------------------------------------- */
  1091. __inline unsigned int AT91F_PMC_IsStatusSet( AT91PS_PMC pPMC, /* \arg pointer to a PMC controller */
  1092. unsigned int flag ) /* \arg flag to be tested */
  1093. {
  1094. return( AT91F_PMC_GetStatus( pPMC ) & flag );
  1095. } /* *****************************************************************************
  1096. * SOFTWARE API FOR RSTC
  1097. ***************************************************************************** */
  1098. /**---------------------------------------------------------------------------- */
  1099. /** \fn AT91F_RSTSoftReset */
  1100. /** \brief Start Software Reset */
  1101. /**---------------------------------------------------------------------------- */
  1102. __inline void AT91F_RSTSoftReset( AT91PS_RSTC pRSTC,
  1103. unsigned int reset )
  1104. {
  1105. pRSTC->RSTC_RCR = ( 0xA5000000 | reset );
  1106. }
  1107. /**---------------------------------------------------------------------------- */
  1108. /** \fn AT91F_RSTSetMode */
  1109. /** \brief Set Reset Mode */
  1110. /**---------------------------------------------------------------------------- */
  1111. __inline void AT91F_RSTSetMode( AT91PS_RSTC pRSTC,
  1112. unsigned int mode )
  1113. {
  1114. pRSTC->RSTC_RMR = ( 0xA5000000 | mode );
  1115. }
  1116. /**---------------------------------------------------------------------------- */
  1117. /** \fn AT91F_RSTGetMode */
  1118. /** \brief Get Reset Mode */
  1119. /**---------------------------------------------------------------------------- */
  1120. __inline unsigned int AT91F_RSTGetMode( AT91PS_RSTC pRSTC )
  1121. {
  1122. return( pRSTC->RSTC_RMR );
  1123. }
  1124. /**---------------------------------------------------------------------------- */
  1125. /** \fn AT91F_RSTGetStatus */
  1126. /** \brief Get Reset Status */
  1127. /**---------------------------------------------------------------------------- */
  1128. __inline unsigned int AT91F_RSTGetStatus( AT91PS_RSTC pRSTC )
  1129. {
  1130. return( pRSTC->RSTC_RSR );
  1131. }
  1132. /**---------------------------------------------------------------------------- */
  1133. /** \fn AT91F_RSTIsSoftRstActive */
  1134. /** \brief Return !=0 if software reset is still not completed */
  1135. /**---------------------------------------------------------------------------- */
  1136. __inline unsigned int AT91F_RSTIsSoftRstActive( AT91PS_RSTC pRSTC )
  1137. {
  1138. return( ( pRSTC->RSTC_RSR ) & AT91C_RSTC_SRCMP );
  1139. }
  1140. /* *****************************************************************************
  1141. * SOFTWARE API FOR RTTC
  1142. ***************************************************************************** */
  1143. /**-------------------------------------------------------------------------------------- */
  1144. /** \fn AT91F_SetRTT_TimeBase() */
  1145. /** \brief Set the RTT prescaler according to the TimeBase in ms */
  1146. /**-------------------------------------------------------------------------------------- */
  1147. __inline unsigned int AT91F_RTTSetTimeBase( AT91PS_RTTC pRTTC,
  1148. unsigned int ms )
  1149. {
  1150. if( ms > 2000 )
  1151. {
  1152. return 1; /* AT91C_TIME_OUT_OF_RANGE */
  1153. }
  1154. pRTTC->RTTC_RTMR &= ~0xFFFF;
  1155. pRTTC->RTTC_RTMR |= ( ( ( ms << 15 ) / 1000 ) & 0xFFFF );
  1156. return 0;
  1157. }
  1158. /**-------------------------------------------------------------------------------------- */
  1159. /** \fn AT91F_RTTSetPrescaler() */
  1160. /** \brief Set the new prescaler value */
  1161. /**-------------------------------------------------------------------------------------- */
  1162. __inline unsigned int AT91F_RTTSetPrescaler( AT91PS_RTTC pRTTC,
  1163. unsigned int rtpres )
  1164. {
  1165. pRTTC->RTTC_RTMR &= ~0xFFFF;
  1166. pRTTC->RTTC_RTMR |= ( rtpres & 0xFFFF );
  1167. return( pRTTC->RTTC_RTMR );
  1168. }
  1169. /**-------------------------------------------------------------------------------------- */
  1170. /** \fn AT91F_RTTRestart() */
  1171. /** \brief Restart the RTT prescaler */
  1172. /**-------------------------------------------------------------------------------------- */
  1173. __inline void AT91F_RTTRestart( AT91PS_RTTC pRTTC )
  1174. {
  1175. pRTTC->RTTC_RTMR |= AT91C_RTTC_RTTRST;
  1176. }
  1177. /**-------------------------------------------------------------------------------------- */
  1178. /** \fn AT91F_RTT_SetAlarmINT() */
  1179. /** \brief Enable RTT Alarm Interrupt */
  1180. /**-------------------------------------------------------------------------------------- */
  1181. __inline void AT91F_RTTSetAlarmINT( AT91PS_RTTC pRTTC )
  1182. {
  1183. pRTTC->RTTC_RTMR |= AT91C_RTTC_ALMIEN;
  1184. }
  1185. /**-------------------------------------------------------------------------------------- */
  1186. /** \fn AT91F_RTT_ClearAlarmINT() */
  1187. /** \brief Disable RTT Alarm Interrupt */
  1188. /**-------------------------------------------------------------------------------------- */
  1189. __inline void AT91F_RTTClearAlarmINT( AT91PS_RTTC pRTTC )
  1190. {
  1191. pRTTC->RTTC_RTMR &= ~AT91C_RTTC_ALMIEN;
  1192. }
  1193. /**-------------------------------------------------------------------------------------- */
  1194. /** \fn AT91F_RTT_SetRttIncINT() */
  1195. /** \brief Enable RTT INC Interrupt */
  1196. /**-------------------------------------------------------------------------------------- */
  1197. __inline void AT91F_RTTSetRttIncINT( AT91PS_RTTC pRTTC )
  1198. {
  1199. pRTTC->RTTC_RTMR |= AT91C_RTTC_RTTINCIEN;
  1200. }
  1201. /**-------------------------------------------------------------------------------------- */
  1202. /** \fn AT91F_RTT_ClearRttIncINT() */
  1203. /** \brief Disable RTT INC Interrupt */
  1204. /**-------------------------------------------------------------------------------------- */
  1205. __inline void AT91F_RTTClearRttIncINT( AT91PS_RTTC pRTTC )
  1206. {
  1207. pRTTC->RTTC_RTMR &= ~AT91C_RTTC_RTTINCIEN;
  1208. }
  1209. /**-------------------------------------------------------------------------------------- */
  1210. /** \fn AT91F_RTT_SetAlarmValue() */
  1211. /** \brief Set RTT Alarm Value */
  1212. /**-------------------------------------------------------------------------------------- */
  1213. __inline void AT91F_RTTSetAlarmValue( AT91PS_RTTC pRTTC,
  1214. unsigned int alarm )
  1215. {
  1216. pRTTC->RTTC_RTAR = alarm;
  1217. }
  1218. /**-------------------------------------------------------------------------------------- */
  1219. /** \fn AT91F_RTT_GetAlarmValue() */
  1220. /** \brief Get RTT Alarm Value */
  1221. /**-------------------------------------------------------------------------------------- */
  1222. __inline unsigned int AT91F_RTTGetAlarmValue( AT91PS_RTTC pRTTC )
  1223. {
  1224. return( pRTTC->RTTC_RTAR );
  1225. }
  1226. /**-------------------------------------------------------------------------------------- */
  1227. /** \fn AT91F_RTTGetStatus() */
  1228. /** \brief Read the RTT status */
  1229. /**-------------------------------------------------------------------------------------- */
  1230. __inline unsigned int AT91F_RTTGetStatus( AT91PS_RTTC pRTTC )
  1231. {
  1232. return( pRTTC->RTTC_RTSR );
  1233. }
  1234. /**-------------------------------------------------------------------------------------- */
  1235. /** \fn AT91F_RTT_ReadValue() */
  1236. /** \brief Read the RTT value */
  1237. /**-------------------------------------------------------------------------------------- */
  1238. __inline unsigned int AT91F_RTTReadValue( AT91PS_RTTC pRTTC )
  1239. {
  1240. register volatile unsigned int val1, val2;
  1241. do
  1242. {
  1243. val1 = pRTTC->RTTC_RTVR;
  1244. val2 = pRTTC->RTTC_RTVR;
  1245. }
  1246. while( val1 != val2 );
  1247. return( val1 );
  1248. }
  1249. /* *****************************************************************************
  1250. * SOFTWARE API FOR PITC
  1251. ***************************************************************************** */
  1252. /**---------------------------------------------------------------------------- */
  1253. /** \fn AT91F_PITInit */
  1254. /** \brief System timer init : period in */