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