]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_LM3S316_IAR/hw_include/pdc.c
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / CORTEX_LM3S316_IAR / hw_include / pdc.c
1 //*****************************************************************************\r
2 //\r
3 // pdc.c - Driver for the Peripheral Device Controller (PDC) on the Stellaris\r
4 //         development board.\r
5 //\r
6 // Copyright (c) 2005,2006 Luminary Micro, Inc.  All rights reserved.\r
7 //\r
8 // Software License Agreement\r
9 //\r
10 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and\r
11 // exclusively on LMI's Stellaris Family of microcontroller products.\r
12 //\r
13 // The software is owned by LMI and/or its suppliers, and is protected under\r
14 // applicable copyright laws.  All rights are reserved.  Any use in violation\r
15 // of the foregoing restrictions may subject the user to criminal sanctions\r
16 // under applicable laws, as well as to civil liability for the breach of the\r
17 // terms and conditions of this license.\r
18 //\r
19 // THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED\r
20 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\r
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.\r
22 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR\r
23 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.\r
24 //\r
25 // This is part of revision 635 of the Stellaris Driver Library.\r
26 //\r
27 //*****************************************************************************\r
28 \r
29 //*****************************************************************************\r
30 //\r
31 //! \addtogroup utilities_api\r
32 //! @{\r
33 //\r
34 //*****************************************************************************\r
35 \r
36 #include "hw_memmap.h"\r
37 #include "hw_types.h"\r
38 #include "debug.h"\r
39 #include "gpio.h"\r
40 #include "ssi.h"\r
41 #include "sysctl.h"\r
42 #include "pdc.h"\r
43 \r
44 //*****************************************************************************\r
45 //\r
46 //! Initializes the connection to the PDC.\r
47 //!\r
48 //! This function will enable clocking to the SSI and GPIO A modules, configure\r
49 //! the GPIO pins to be used for an SSI interface, and it will configure the\r
50 //! SSI as a 1 Mbps master device, operating in MOTO mode.  It will also enable\r
51 //! the SSI module, and will enable the chip select for the PDC on the\r
52 //! Stellaris development board.\r
53 //!\r
54 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
55 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
56 //!\r
57 //! \return None.\r
58 //\r
59 //*****************************************************************************\r
60 void\r
61 PDCInit(void)\r
62 {\r
63     //\r
64     // Enable the peripherals used to drive the PDC.\r
65     //\r
66     SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI);\r
67     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);\r
68 \r
69     //\r
70     // Configure the appropriate pins to be SSI instead of GPIO.\r
71     //\r
72     GPIODirModeSet(GPIO_PORTA_BASE, SSI_CLK | SSI_TX | SSI_RX,\r
73                    GPIO_DIR_MODE_HW);\r
74     GPIODirModeSet(GPIO_PORTA_BASE, SSI_CS, GPIO_DIR_MODE_OUT);\r
75     GPIOPadConfigSet(GPIO_PORTA_BASE, SSI_CLK, GPIO_STRENGTH_4MA,\r
76                      GPIO_PIN_TYPE_STD_WPU);\r
77 \r
78     //\r
79     // Configure the SSI port.\r
80     //\r
81     SSIConfigSetExpClk(SSI_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,\r
82                        SSI_MODE_MASTER, 1000000, 8);\r
83     SSIEnable(SSI_BASE);\r
84 \r
85     //\r
86     // Reset the PDC SSI state machine.  The chip select needs to be held low\r
87     // for 100ns; the procedure call overhead more than accounts for this time.\r
88     //\r
89     GPIOPinWrite(GPIO_PORTA_BASE, PDC_CS, 0);\r
90     GPIOPinWrite(GPIO_PORTA_BASE, PDC_CS, PDC_CS);\r
91 }\r
92 \r
93 //*****************************************************************************\r
94 //\r
95 //! Read a PDC register.\r
96 //!\r
97 //! \param ucAddr specifies the PDC register to read.\r
98 //!\r
99 //! This function will perform the SSI transfers required to read a register in\r
100 //! the PDC on the Stellaris development board.\r
101 //!\r
102 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
103 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
104 //!\r
105 //! \return Returns the value read from the PDC.\r
106 //\r
107 //*****************************************************************************\r
108 unsigned char\r
109 PDCRead(unsigned char ucAddr)\r
110 {\r
111     unsigned long ulTemp;\r
112 \r
113     //\r
114     // Send address and read command.\r
115     //\r
116     SSIDataPut(SSI_BASE, (ucAddr & 0x0F) | PDC_RD);\r
117 \r
118     //\r
119     // Dummy write to force read.\r
120     //\r
121     SSIDataPut(SSI_BASE, 0x00);\r
122 \r
123     //\r
124     // Flush data read during address write.\r
125     //\r
126     SSIDataGet(SSI_BASE, &ulTemp);\r
127 \r
128     //\r
129     // If the LCD control register or RAM is being read, then an additional\r
130     // byte needs to be transferred.\r
131     //\r
132     if((ucAddr == PDC_LCD_CSR) || (ucAddr == PDC_LCD_RAM))\r
133     {\r
134         //\r
135         // Dummy write to force read.\r
136         //\r
137         SSIDataPut(SSI_BASE, 0x00);\r
138 \r
139         //\r
140         // Flush read data.\r
141         //\r
142         SSIDataGet(SSI_BASE, &ulTemp);\r
143     }\r
144 \r
145     //\r
146     // Read valid data.\r
147     //\r
148     SSIDataGet(SSI_BASE, &ulTemp);\r
149 \r
150     //\r
151     // Return the data read.\r
152     //\r
153     return(ulTemp & 0xFF);\r
154 }\r
155 \r
156 //*****************************************************************************\r
157 //\r
158 //! Write a PDC register.\r
159 //!\r
160 //! \param ucAddr specifies the PDC register to write.\r
161 //! \param ucData specifies the data to write.\r
162 //!\r
163 //! This function will perform the SSI transfers required to write a register\r
164 //! in the PDC on the Stellaris development board.\r
165 //!\r
166 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
167 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
168 //!\r
169 //! \return None.\r
170 //\r
171 //*****************************************************************************\r
172 void\r
173 PDCWrite(unsigned char ucAddr, unsigned char ucData)\r
174 {\r
175     unsigned long ulTemp;\r
176 \r
177     //\r
178     // Send address and write command.\r
179     //\r
180     SSIDataPut(SSI_BASE, (ucAddr & 0x0F) | PDC_WR);\r
181 \r
182     //\r
183     // Write the data.\r
184     //\r
185     SSIDataPut(SSI_BASE, ucData);\r
186 \r
187     //\r
188     // Flush data read during address write.\r
189     //\r
190     SSIDataGet(SSI_BASE, &ulTemp);\r
191 \r
192     //\r
193     // Flush data read during data write.\r
194     //\r
195     SSIDataGet(SSI_BASE, &ulTemp);\r
196 }\r
197 \r
198 //*****************************************************************************\r
199 //\r
200 //! Read the current value of the PDC DIP switches.\r
201 //!\r
202 //! This function will read the current value of the DIP switches attached to\r
203 //! the PDC on the Stellaris development board.\r
204 //!\r
205 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
206 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
207 //!\r
208 //! \return The current state of the DIP switches.\r
209 //\r
210 //*****************************************************************************\r
211 unsigned char\r
212 PDCDIPRead(void)\r
213 {\r
214     return(PDCRead(PDC_DSW));\r
215 }\r
216 \r
217 //*****************************************************************************\r
218 //\r
219 //! Write to the PDC LEDs.\r
220 //!\r
221 //! \param ucLED value to write to the LEDs.\r
222 //!\r
223 //! This function set the state of the LEDs connected to the PDC on the\r
224 //! Stellaris development board.\r
225 //!\r
226 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
227 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
228 //!\r
229 //! \return None.\r
230 //\r
231 //*****************************************************************************\r
232 void\r
233 PDCLEDWrite(unsigned char ucLED)\r
234 {\r
235     PDCWrite(PDC_LED, ucLED);\r
236 }\r
237 \r
238 //*****************************************************************************\r
239 //\r
240 //! Read the current status of the PDC LEDs.\r
241 //!\r
242 //! This function will read the state of the LEDs connected to the PDC on the\r
243 //! Stellaris development board.\r
244 //!\r
245 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
246 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
247 //!\r
248 //! \return The value currently displayed by the LEDs.\r
249 //\r
250 //*****************************************************************************\r
251 unsigned char\r
252 PDCLEDRead(void)\r
253 {\r
254     return(PDCRead(PDC_LED));\r
255 }\r
256 \r
257 //*****************************************************************************\r
258 //\r
259 //! Initializes the LCD display.\r
260 //!\r
261 //! This function will set up the LCD display for writing. It will set the\r
262 //! data bus to 8 bits, set the number of lines to 2, and the font size to\r
263 //! 5x10. It will also turn the display off, clear the display, turn the\r
264 //! display back on, and enable the backlight.\r
265 //!\r
266 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
267 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
268 //!\r
269 //! \note The PDC must be initialized via the PDCInit() function before this\r
270 //! function can be called.  Also, it may be necessary to adjust the contrast\r
271 //! potentiometer in order to discern any output on the LCD display.\r
272 //!\r
273 //! \return None.\r
274 //\r
275 //*****************************************************************************\r
276 void\r
277 PDCLCDInit(void)\r
278 {\r
279     unsigned char pucCfg[] =\r
280     {\r
281         0x3C,   // Number of lines = 2 / font = 5x10\r
282         0x08,   // Display off\r
283         0x01,   // Display clear\r
284         0x06,   // Entry mode [cursor dir][shift]\r
285         0x0C,   // Display on [display on][curson on][blinking on]\r
286     };\r
287     unsigned long ulIdx;\r
288 \r
289     //\r
290     // Set the data bus width to eight bits.\r
291     //\r
292     PDCWrite(PDC_LCD_CSR, 0x30);\r
293 \r
294     //\r
295     // Wait for 4.1ms by reading the PDC version register enough times to\r
296     // guarantee that amount of time has passed.\r
297     //\r
298     for(ulIdx = 0; ulIdx < 257; ulIdx++)\r
299     {\r
300         PDCRead(PDC_VER);\r
301     }\r
302 \r
303     //\r
304     // Set the data bus width to eight bits.\r
305     //\r
306     PDCWrite(PDC_LCD_CSR, 0x30);\r
307 \r
308     //\r
309     // Wait for 100us by reading the PDC version register enough times to\r
310     // guarantee that amount of time has passed.  This works out to 112us plus\r
311     // overhead.\r
312     //\r
313     for(ulIdx = 0; ulIdx < 7; ulIdx++)\r
314     {\r
315         PDCRead(PDC_VER);\r
316     }\r
317 \r
318     //\r
319     // Set the data bus width to eight bits.\r
320     //\r
321     PDCWrite(PDC_LCD_CSR, 0x30);\r
322 \r
323     //\r
324     // Configure the LCD.\r
325     //\r
326     for(ulIdx = 0; ulIdx < (sizeof(pucCfg) / sizeof(pucCfg[0])); ulIdx++)\r
327     {\r
328         //\r
329         // Wait until the LCD has finished executing any previous command.\r
330         //\r
331         while((PDCRead(PDC_LCD_CSR) & LCD_B_BUSY))\r
332         {\r
333         }\r
334 \r
335         //\r
336         // Write the next configuration byte.\r
337         //\r
338         PDCWrite(PDC_LCD_CSR, pucCfg[ulIdx]);\r
339     }\r
340 }\r
341 \r
342 //*****************************************************************************\r
343 //\r
344 //! Turns on the backlight.\r
345 //!\r
346 //! This function turns on the backlight on the LCD.\r
347 //!\r
348 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
349 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
350 //!\r
351 //! \return None.\r
352 //\r
353 //*****************************************************************************\r
354 void\r
355 PDCLCDBacklightOn(void)\r
356 {\r
357     PDCWrite(PDC_CSR, 0x01);\r
358 }\r
359 \r
360 //*****************************************************************************\r
361 //\r
362 //! Turn off the backlight.\r
363 //!\r
364 //! This function turns off the backlight on the LCD.\r
365 //!\r
366 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
367 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
368 //!\r
369 //! \return None.\r
370 //\r
371 //*****************************************************************************\r
372 void\r
373 PDCLCDBacklightOff(void)\r
374 {\r
375     PDCWrite(PDC_CSR, 0x00);\r
376 }\r
377 \r
378 //*****************************************************************************\r
379 //\r
380 //! Clear the screen.\r
381 //!\r
382 //! This function clears the contents of the LCD screen.  The cursor will be\r
383 //! returned to the upper left corner.\r
384 //!\r
385 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
386 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
387 //!\r
388 //! \return None.\r
389 //\r
390 //*****************************************************************************\r
391 void\r
392 PDCLCDClear(void)\r
393 {\r
394     //\r
395     // Wait until the LCD has finished executing any previous command.\r
396     //\r
397     while((PDCRead(PDC_LCD_CSR) & LCD_B_BUSY))\r
398     {\r
399     }\r
400 \r
401     //\r
402     // Write the clear display command.\r
403     //\r
404     PDCWrite(PDC_LCD_CSR, LCD_CLEAR);\r
405 }\r
406 \r
407 //*****************************************************************************\r
408 //\r
409 //! Write a character pattern to the LCD.\r
410 //!\r
411 //! \param ucChar is the character index to create.  Valid values are zero\r
412 //! through seven.\r
413 //! \param pucData is the data for the character pattern.  It contains eight\r
414 //! bytes, with the first byte being the top row of the pattern.  In each byte,\r
415 //! the LSB is the right pixel of the pattern.\r
416 //!\r
417 //! This function will write a character pattern into the LCD for use as a\r
418 //! character to be displayed.  After writing the pattern, it can be used on\r
419 //! the LCD by writing the corresponding character index to the display.\r
420 //!\r
421 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
422 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
423 //!\r
424 //! \return None.\r
425 //\r
426 //*****************************************************************************\r
427 void\r
428 PDCLCDCreateChar(unsigned char ucChar, unsigned char *pucData)\r
429 {\r
430     //\r
431     // Check the arguments.\r
432     //\r
433     ASSERT(ucChar < 8);\r
434 \r
435     //\r
436     // Wait until the LCD has finished executing any previous command.\r
437     //\r
438     while((PDCRead(PDC_LCD_CSR) & LCD_B_BUSY))\r
439     {\r
440     }\r
441 \r
442     //\r
443     // Write the character pattern memory address.\r
444     //\r
445     PDCWrite(PDC_LCD_CSR, LCD_CGADDR + (ucChar * 8));\r
446 \r
447     //\r
448     // Write the pattern to chacter pattern memory.\r
449     //\r
450     for(ucChar = 0; ucChar < 8; ucChar++)\r
451     {\r
452         //\r
453         // Wait until the LCD has finished executing any previous command.\r
454         //\r
455         while((PDCRead(PDC_LCD_CSR) & LCD_B_BUSY))\r
456         {\r
457         }\r
458 \r
459         //\r
460         // Write this row of the pattern.\r
461         //\r
462         PDCWrite(PDC_LCD_RAM, *pucData++);\r
463     }\r
464 }\r
465 \r
466 //*****************************************************************************\r
467 //\r
468 //! Set the position of the cursor.\r
469 //!\r
470 //! \param ucX is the horizontal position.  Valid values are zero through\r
471 //! fifteen.\r
472 //! \param ucY is the vertical position.. Valid values are zero and one.\r
473 //!\r
474 //! This function will move the cursor to the specified position.  All\r
475 //! characters written to the LCD are placed at the current cursor position,\r
476 //! which is automatically advanced.\r
477 //!\r
478 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
479 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
480 //!\r
481 //! \return None.\r
482 //\r
483 //*****************************************************************************\r
484 void\r
485 PDCLCDSetPos(unsigned char ucX, unsigned char ucY)\r
486 {\r
487     //\r
488     // Check the arguments.\r
489     //\r
490     ASSERT(ucX < 16);\r
491     ASSERT(ucY < 2);\r
492 \r
493     //\r
494     // Wait until the LCD has finished executing any previous command.\r
495     //\r
496     while((PDCRead(PDC_LCD_CSR) & LCD_B_BUSY))\r
497     {\r
498     }\r
499 \r
500     //\r
501     // Set the cursor position.\r
502     //\r
503     PDCWrite(PDC_LCD_CSR, LCD_DDADDR | (0x40 * ucY) + ucX);\r
504 }\r
505 \r
506 //*****************************************************************************\r
507 //\r
508 //! Writes a string to the LCD display.\r
509 //!\r
510 //! \param pcStr pointer to the string to be displayed.\r
511 //! \param ulCount is the number of characters to be displayed.\r
512 //!\r
513 //! This function will display a string on the LCD at the current cursor\r
514 //! position.  It is the caller's responsibility to position the cursor to the\r
515 //! place where the string should be displayed (either explicitly via\r
516 //! PDCLCDSetPos() or implicitly from where the cursor was left after a\r
517 //! previous call to PDCLCDWrite()), and to properly account for the LCD\r
518 //! boundary (line wrapping is not automatically performed).  Null characters\r
519 //! are not treated special and are written to the LCD, which interprets it as\r
520 //! a special programmable character glyph (see PDCLCDCreateChar()).\r
521 //!\r
522 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
523 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
524 //!\r
525 //! \return None.\r
526 //\r
527 //*****************************************************************************\r
528 void\r
529 PDCLCDWrite(const char *pcStr, unsigned long ulCount)\r
530 {\r
531     //\r
532     // Write the string to the LCD.\r
533     //\r
534     while(ulCount--)\r
535     {\r
536         //\r
537         // Wait until the LCD has finished executing any previous command.\r
538         //\r
539         while((PDCRead(PDC_LCD_CSR) & LCD_B_BUSY))\r
540         {\r
541         }\r
542 \r
543         //\r
544         // Write this character to the LCD.\r
545         //\r
546         PDCWrite(PDC_LCD_RAM, *pcStr++);\r
547     }\r
548 }\r
549 \r
550 //*****************************************************************************\r
551 //\r
552 //! Reads a GPIO direction register.\r
553 //!\r
554 //! \param ucIdx is the index of the GPIO direction register to read; valid\r
555 //! values are 0, 1, and 2.\r
556 //!\r
557 //! This function reads one of the GPIO direction registers in the PDC.  The\r
558 //! direction bit is set for pins that are outputs and clear for pins that are\r
559 //! inputs.\r
560 //!\r
561 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
562 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
563 //!\r
564 //! \return The contents of the direction register.\r
565 //\r
566 //*****************************************************************************\r
567 unsigned char\r
568 PDCGPIODirRead(unsigned char ucIdx)\r
569 {\r
570     //\r
571     // Check the argument.\r
572     //\r
573     ASSERT((ucIdx == 0) || (ucIdx == 1) || (ucIdx == 2));\r
574 \r
575     //\r
576     // Read the requested direction register.\r
577     //\r
578     if(ucIdx == 0)\r
579     {\r
580         return(PDCRead(PDC_GPXDIR));\r
581     }\r
582     else if(ucIdx == 1)\r
583     {\r
584         return(PDCRead(PDC_GPYDIR));\r
585     }\r
586     else\r
587     {\r
588         return(PDCRead(PDC_GPZDIR));\r
589     }\r
590 }\r
591 \r
592 //*****************************************************************************\r
593 //\r
594 //! Write a GPIO direction register.\r
595 //!\r
596 //! \param ucIdx is the index of the GPIO direction register to write; valid\r
597 //! values are 0, 1, and 2.\r
598 //! \param ucValue is the value to write to the GPIO direction register.\r
599 //!\r
600 //! This function writes ones of the GPIO direction registers in the PDC.  The\r
601 //! direction bit should be set for pins that are to be outputs and clear for\r
602 //! pins that are to be inputs.\r
603 //!\r
604 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
605 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
606 //!\r
607 //! \return None.\r
608 //\r
609 //*****************************************************************************\r
610 void\r
611 PDCGPIODirWrite(unsigned char ucIdx, unsigned char ucValue)\r
612 {\r
613     //\r
614     // Check the arguments.\r
615     //\r
616     ASSERT((ucIdx == 0) || (ucIdx == 1) || (ucIdx == 2));\r
617 \r
618     //\r
619     // Write the requested direction register.\r
620     //\r
621     if(ucIdx == 0)\r
622     {\r
623         PDCWrite(PDC_GPXDIR, ucValue);\r
624     }\r
625     else if(ucIdx == 1)\r
626     {\r
627         PDCWrite(PDC_GPYDIR, ucValue);\r
628     }\r
629     else\r
630     {\r
631         PDCWrite(PDC_GPZDIR, ucValue);\r
632     }\r
633 }\r
634 \r
635 //*****************************************************************************\r
636 //\r
637 //! Reads a GPIO data register.\r
638 //!\r
639 //! \param ucIdx is the index of the GPIO direction register to read; valid\r
640 //! values are 0, 1, and 2.\r
641 //!\r
642 //! This function reads one of the GPIO data registers in the PDC.  The value\r
643 //! returned for a pin is the value being driven out for outputs or the value\r
644 //! being read for inputs.\r
645 //!\r
646 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
647 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
648 //!\r
649 //! \return The contents of the data register.\r
650 //\r
651 //*****************************************************************************\r
652 unsigned char\r
653 PDCGPIORead(unsigned char ucIdx)\r
654 {\r
655     //\r
656     // Check the argument.\r
657     //\r
658     ASSERT((ucIdx == 0) || (ucIdx == 1) || (ucIdx == 2));\r
659 \r
660     //\r
661     // Read the requested data register.\r
662     //\r
663     if(ucIdx == 0)\r
664     {\r
665         return(PDCRead(PDC_GPXDAT));\r
666     }\r
667     else if(ucIdx == 1)\r
668     {\r
669         return(PDCRead(PDC_GPYDAT));\r
670     }\r
671     else\r
672     {\r
673         return(PDCRead(PDC_GPZDAT));\r
674     }\r
675 }\r
676 \r
677 //*****************************************************************************\r
678 //\r
679 //! Write a GPIO data register.\r
680 //!\r
681 //! \param ucIdx is the index of the GPIO data register to write; valid values\r
682 //! are 0, 1, and 2.\r
683 //! \param ucValue is the value to write to the GPIO data register.\r
684 //!\r
685 //! This function writes one of the GPIO direction registers in the PDC.  The\r
686 //! written to a pin is driven out for output pins and ignored for input pins.\r
687 //!\r
688 //! This function is contained in <tt>utils/pdc.c</tt>, with\r
689 //! <tt>utils/pdc.h</tt> containing the API definition for use by applications.\r
690 //!\r
691 //! \return None.\r
692 //\r
693 //*****************************************************************************\r
694 void\r
695 PDCGPIOWrite(unsigned char ucIdx, unsigned char ucValue)\r
696 {\r
697     //\r
698     // Check the arguments.\r
699     //\r
700     ASSERT((ucIdx == 0) || (ucIdx == 1) || (ucIdx == 2));\r
701 \r
702     //\r
703     // Write the requested data register.\r
704     //\r
705     if(ucIdx == 0)\r
706     {\r
707         PDCWrite(PDC_GPXDAT, ucValue);\r
708     }\r
709     else if(ucIdx == 1)\r
710     {\r
711         PDCWrite(PDC_GPYDAT, ucValue);\r
712     }\r
713     else\r
714     {\r
715         PDCWrite(PDC_GPZDAT, ucValue);\r
716     }\r
717 }\r
718 \r
719 //*****************************************************************************\r
720 //\r
721 // Close the Doxygen group.\r
722 //! @}\r
723 //\r
724 //*****************************************************************************\r