]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_LM3S811_IAR/LuminaryCode/gpio.c
UpdUpdate IAR projects to use Embedded Workbench V5.11.
[freertos] / Demo / CORTEX_LM3S811_IAR / LuminaryCode / gpio.c
1 //*****************************************************************************\r
2 //\r
3 // gpio.c - API for GPIO ports\r
4 //\r
5 // Copyright (c) 2005,2006 Luminary Micro, Inc.  All rights reserved.\r
6 //\r
7 // Software License Agreement\r
8 //\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and\r
10 // exclusively on LMI's Stellaris Family of microcontroller products.\r
11 //\r
12 // The software is owned by LMI and/or its suppliers, and is protected under\r
13 // applicable copyright laws.  All rights are reserved.  Any use in violation\r
14 // of the foregoing restrictions may subject the user to criminal sanctions\r
15 // under applicable laws, as well as to civil liability for the breach of the\r
16 // terms and conditions of this license.\r
17 //\r
18 // THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED\r
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\r
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.\r
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR\r
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.\r
23 //\r
24 // This is part of revision 991 of the Stellaris Driver Library.\r
25 //\r
26 //*****************************************************************************\r
27 \r
28 //*****************************************************************************\r
29 //\r
30 //! \addtogroup gpio_api\r
31 //! @{\r
32 //\r
33 //*****************************************************************************\r
34 \r
35 #include "../hw_gpio.h"\r
36 #include "../hw_ints.h"\r
37 #include "../hw_memmap.h"\r
38 #include "../hw_types.h"\r
39 #include "debug.h"\r
40 #include "gpio.h"\r
41 #include "interrupt.h"\r
42 \r
43 //*****************************************************************************\r
44 //\r
45 //! \internal\r
46 //! Get GPIO interrupt number.\r
47 //!\r
48 //! \param ulPort base address of the selected GPIO port\r
49 //!\r
50 //! Given a GPIO base address, returns the corresponding interrupt number.\r
51 //!\r
52 //! \return Returns a GPIO interrupt number, or -1 if \e ulPort is invalid.\r
53 //\r
54 //*****************************************************************************\r
55 #if defined(GROUP_getintnumber) || defined(BUILD_ALL)\r
56 long\r
57 GPIOGetIntNumber(unsigned long ulPort)\r
58 {\r
59     unsigned int ulInt;\r
60 \r
61     //\r
62     // Determine the GPIO interrupt number for the given module.\r
63     //\r
64     switch(ulPort)\r
65     {\r
66         case GPIO_PORTA_BASE:\r
67         {\r
68             ulInt = INT_GPIOA;\r
69             break;\r
70         }\r
71 \r
72         case GPIO_PORTB_BASE:\r
73         {\r
74             ulInt = INT_GPIOB;\r
75             break;\r
76         }\r
77 \r
78         case GPIO_PORTC_BASE:\r
79         {\r
80             ulInt = INT_GPIOC;\r
81             break;\r
82         }\r
83 \r
84         case GPIO_PORTD_BASE:\r
85         {\r
86             ulInt = INT_GPIOD;\r
87             break;\r
88         }\r
89 \r
90         case GPIO_PORTE_BASE:\r
91         {\r
92             ulInt = INT_GPIOE;\r
93             break;\r
94         }\r
95 \r
96         default:\r
97         {\r
98             return(-1);\r
99         }\r
100     }\r
101 \r
102     //\r
103     // Return GPIO interrupt number.\r
104     //\r
105     return(ulInt);\r
106 }\r
107 #else\r
108 extern long GPIOGetIntNumber(unsigned long ulPort);\r
109 #endif\r
110 \r
111 //*****************************************************************************\r
112 //\r
113 //! Sets the direction and mode of the specified pins of the selected\r
114 //! GPIO port.\r
115 //!\r
116 //! \param ulPort base address of the selected GPIO port\r
117 //! \param ucPins bit-packed representation of the specified pins\r
118 //! \param ulPinIO pin direction and/or mode\r
119 //!\r
120 //! This function will set the specified pins on the selected GPIO port\r
121 //! as either an input or output under software control, or it will set the\r
122 //! pin to be under hardware control.\r
123 //!\r
124 //! The parameter \e ulPinIO is an enumerated data type that can be one of\r
125 //! the following values:\r
126 //!\r
127 //! - \b GPIO_DIR_MODE_IN\r
128 //! - \b GPIO_DIR_MODE_OUT\r
129 //! - \b GPIO_DIR_MODE_HW\r
130 //!\r
131 //! where \b GPIO_DIR_MODE_IN specifies that the pin will be programmed as\r
132 //! a software controlled input, \b GPIO_DIR_MODE_OUT specifies that the pin\r
133 //! will be programmed as a software controlled output, and\r
134 //! \b GPIO_DIR_MODE_HW specifies that the pin will be placed under\r
135 //! hardware control.\r
136 //!\r
137 //! The pins are specified using a bit-packed byte, where each bit that is\r
138 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
139 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
140 //!\r
141 //! \return None.\r
142 //\r
143 //*****************************************************************************\r
144 #if defined(GROUP_dirmodeset) || defined(BUILD_ALL) || defined(DOXYGEN)\r
145 void\r
146 GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,\r
147                unsigned long ulPinIO)\r
148 {\r
149     //\r
150     // Check the arguments.\r
151     //\r
152     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
153            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
154            (ulPort == GPIO_PORTE_BASE));\r
155     ASSERT((ulPinIO == GPIO_DIR_MODE_IN) || (ulPinIO == GPIO_DIR_MODE_OUT) ||\r
156            (ulPinIO == GPIO_DIR_MODE_HW));\r
157 \r
158     //\r
159     // Set the pin direction and mode.\r
160     //\r
161     HWREG(ulPort + GPIO_O_DIR) = ((ulPinIO & 1) ?\r
162                                   (HWREG(ulPort + GPIO_O_DIR) | ucPins) :\r
163                                   (HWREG(ulPort + GPIO_O_DIR) & ~(ucPins)));\r
164     HWREG(ulPort + GPIO_O_AFSEL) = ((ulPinIO & 2) ?\r
165                                     (HWREG(ulPort + GPIO_O_AFSEL) | ucPins) :\r
166                                     (HWREG(ulPort + GPIO_O_AFSEL) &\r
167                                      ~(ucPins)));\r
168 }\r
169 #endif\r
170 \r
171 //*****************************************************************************\r
172 //\r
173 //! Gets the direction and mode of a specified pin of the selected\r
174 //! GPIO port.\r
175 //!\r
176 //! \param ulPort base address of the selected GPIO port\r
177 //! \param ucPin pin number of the specified pin, relative to the selected\r
178 //! GPIO port.\r
179 //!\r
180 //! This function gets the direction and control mode for a specified pin on\r
181 //! the selected GPIO port. The pin can be configured as either an input or\r
182 //! output under software control, or it can be under hardware control. The\r
183 //! type of control and direction are returned as an enumerated data type.\r
184 //!\r
185 //! \return Returns one of the enumerated data types described for\r
186 //! GPIODirModeSet().\r
187 //\r
188 //*****************************************************************************\r
189 #if defined(GROUP_dirmodeget) || defined(BUILD_ALL) || defined(DOXYGEN)\r
190 unsigned long\r
191 GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)\r
192 {\r
193     unsigned long ulDir, ulAFSEL;\r
194 \r
195     //\r
196     // Check the arguments.\r
197     //\r
198     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
199            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
200            (ulPort == GPIO_PORTE_BASE));\r
201     ASSERT(ucPin < 8);\r
202 \r
203     //\r
204     // Convert from a pin number to a bit position.\r
205     //\r
206     ucPin = 1 << ucPin;\r
207 \r
208     //\r
209     // Return the pin direction and mode.\r
210     //\r
211     ulDir = HWREG(ulPort + GPIO_O_DIR);\r
212     ulAFSEL = HWREG(ulPort + GPIO_O_AFSEL);\r
213     return(((ulDir & ucPin) ? 1 : 0) | ((ulAFSEL & ucPin) ? 2 : 0));\r
214 }\r
215 #endif\r
216 \r
217 //*****************************************************************************\r
218 //\r
219 //! Sets the interrupt type for the specified pins of the selected GPIO\r
220 //! port.\r
221 //!\r
222 //! \param ulPort base address of the selected GPIO port\r
223 //! \param ucPins bit-packed representation of the specified pins\r
224 //! \param ulIntType specifies the type of interrupt trigger mechanism\r
225 //!\r
226 //! This function sets up the various interrupt trigger mechanisms for the\r
227 //! specified pins on the selected GPIO port.\r
228 //!\r
229 //! The parameter \e ulIntType is an enumerated data type that can be one of\r
230 //! the following values:\r
231 //!\r
232 //! - \b GPIO_FALLING_EDGE\r
233 //! - \b GPIO_RISING_EDGE\r
234 //! - \b GPIO_BOTH_EDGES\r
235 //! - \b GPIO_LOW_LEVEL\r
236 //! - \b GPIO_HIGH_LEVEL\r
237 //!\r
238 //! where the different values describe the interrupt detection mechanism\r
239 //! (edge or level) and the particular triggering event (falling, rising,\r
240 //! or both edges for edge detect, low or high for level detect).\r
241 //!\r
242 //! The pins are specified using a bit-packed byte, where each bit that is\r
243 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
244 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
245 //!\r
246 //! \note In order to avoid any spurious interrupts, the user must\r
247 //! ensure that the GPIO inputs remain stable for the duration of\r
248 //! this function.\r
249 //!\r
250 //! \return None.\r
251 //\r
252 //*****************************************************************************\r
253 #if defined(GROUP_inttypeset) || defined(BUILD_ALL) || defined(DOXYGEN)\r
254 void\r
255 GPIOIntTypeSet(unsigned long ulPort, unsigned char ucPins,\r
256                unsigned long ulIntType)\r
257 {\r
258     //\r
259     // Check the arguments.\r
260     //\r
261     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
262            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
263            (ulPort == GPIO_PORTE_BASE));\r
264     ASSERT((ulIntType == GPIO_FALLING_EDGE) ||\r
265            (ulIntType == GPIO_RISING_EDGE) ||\r
266            (ulIntType == GPIO_BOTH_EDGES) ||\r
267            (ulIntType == GPIO_LOW_LEVEL) ||\r
268            (ulIntType == GPIO_HIGH_LEVEL));\r
269 \r
270     //\r
271     // Set the pin interrupt type.\r
272     //\r
273     HWREG(ulPort + GPIO_O_IBE) = ((ulIntType & 1) ?\r
274                                   (HWREG(ulPort + GPIO_O_IBE) | ucPins) :\r
275                                   (HWREG(ulPort + GPIO_O_IBE) & ~(ucPins)));\r
276     HWREG(ulPort + GPIO_O_IS) = ((ulIntType & 2) ?\r
277                                  (HWREG(ulPort + GPIO_O_IS) | ucPins) :\r
278                                  (HWREG(ulPort + GPIO_O_IS) & ~(ucPins)));\r
279     HWREG(ulPort + GPIO_O_IEV) = ((ulIntType & 4) ?\r
280                                   (HWREG(ulPort + GPIO_O_IEV) | ucPins) :\r
281                                   (HWREG(ulPort + GPIO_O_IEV) & ~(ucPins)));\r
282 }\r
283 #endif\r
284 \r
285 //*****************************************************************************\r
286 //\r
287 //! Gets the interrupt type for the specified pin of the selected GPIO\r
288 //! port.\r
289 //!\r
290 //! \param ulPort base address of the selected GPIO port\r
291 //! \param ucPin pin number of the specified pin, relative to the selected\r
292 //! GPIO port.\r
293 //!\r
294 //! This function gets the interrupt type for a specified pin on the selected\r
295 //! GPIO port. The pin can be configured as a falling edge, rising edge, or\r
296 //! both edge detected interrupt, or it can be configured as a low level or\r
297 //! high level detected interrupt. The type of interrupt detection mechanism\r
298 //! is returned as an enumerated data type.\r
299 //!\r
300 //! \return Returns one of the enumerated data types described for\r
301 //! GPIOIntTypeSet().\r
302 //\r
303 //*****************************************************************************\r
304 #if defined(GROUP_inttypeget) || defined(BUILD_ALL) || defined(DOXYGEN)\r
305 unsigned long\r
306 GPIOIntTypeGet(unsigned long ulPort, unsigned char ucPin)\r
307 {\r
308     unsigned long ulIBE, ulIS, ulIEV;\r
309 \r
310     //\r
311     // Check the arguments.\r
312     //\r
313     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
314            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
315            (ulPort == GPIO_PORTE_BASE));\r
316     ASSERT(ucPin < 8);\r
317 \r
318     //\r
319     // Convert from a pin number to a bit position.\r
320     //\r
321     ucPin = 1 << ucPin;\r
322 \r
323     //\r
324     // Return the pin interrupt type.\r
325     //\r
326     ulIBE = HWREG(ulPort + GPIO_O_IBE);\r
327     ulIS = HWREG(ulPort + GPIO_O_IS);\r
328     ulIEV = HWREG(ulPort + GPIO_O_IEV);\r
329     return(((ulIBE & ucPin) ? 1 : 0) | ((ulIS & ucPin) ? 2 : 0) |\r
330            ((ulIEV & ucPin) ? 4 : 0));\r
331 }\r
332 #endif\r
333 \r
334 //*****************************************************************************\r
335 //\r
336 //! Sets the pad configuration for the specified pins of the selected GPIO\r
337 //! port.\r
338 //!\r
339 //! \param ulPort is the base address of the GPIO port.\r
340 //! \param ucPins bit-packed representation of the specified pins.\r
341 //! \param ulStrength specifies the output drive strength.\r
342 //! \param ulPinType specifies the pin type.\r
343 //!\r
344 //! This function sets the drive strength and type for the specified pins\r
345 //! on the selected GPIO port.  For pins configured as input ports, the\r
346 //! pad is configured as requested, but the only real effect on the input\r
347 //! is the configuration of the pull-up or pull-down termination.\r
348 //!\r
349 //! The parameter \e ulStrength can be one of the following values:\r
350 //!\r
351 //! - \b GPIO_STRENGTH_2MA\r
352 //! - \b GPIO_STRENGTH_4MA\r
353 //! - \b GPIO_STRENGTH_8MA\r
354 //! - \b GPIO_STRENGTH_8MA_SC\r
355 //!\r
356 //! where \b GPIO_STRENGTH_xMA specifies either 2, 4, or 8 mA output drive\r
357 //! strength, and \b GPIO_OUT_STRENGTH_8MA_SC specifies 8 mA output drive with\r
358 //! slew control.\r
359 //!\r
360 //! The parameter \e ulPinType can be one of the following values:\r
361 //!\r
362 //! - \b GPIO_PIN_TYPE_STD\r
363 //! - \b GPIO_PIN_TYPE_STD_WPU\r
364 //! - \b GPIO_PIN_TYPE_STD_WPD\r
365 //! - \b GPIO_PIN_TYPE_OD\r
366 //! - \b GPIO_PIN_TYPE_OD_WPU\r
367 //! - \b GPIO_PIN_TYPE_OD_WPD\r
368 //! - \b GPIO_PIN_TYPE_ANALOG\r
369 //!\r
370 //! where \b GPIO_PIN_TYPE_STD* specifies a push-pull pin, \b GPIO_PIN_TYPE_OD*\r
371 //! specifies an open-drain pin, \b *_WPU specifies a weak pull-up, \b *_WPD\r
372 //! specifies a weak pull-down, and \b GPIO_PIN_TYPE_ANALOG specifies an\r
373 //! analog input (for the comparators).\r
374 //!\r
375 //! The pins are specified using a bit-packed byte, where each bit that is\r
376 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
377 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
378 //!\r
379 //! \return None.\r
380 //\r
381 //*****************************************************************************\r
382 #if defined(GROUP_padconfigset) || defined(BUILD_ALL) || defined(DOXYGEN)\r
383 void\r
384 GPIOPadConfigSet(unsigned long ulPort, unsigned char ucPins,\r
385                  unsigned long ulStrength, unsigned long ulPinType)\r
386 {\r
387     //\r
388     // Check the arguments.\r
389     //\r
390     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
391            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
392            (ulPort == GPIO_PORTE_BASE));\r
393     ASSERT((ulStrength == GPIO_STRENGTH_2MA) ||\r
394            (ulStrength == GPIO_STRENGTH_4MA) ||\r
395            (ulStrength == GPIO_STRENGTH_8MA) ||\r
396            (ulStrength == GPIO_STRENGTH_8MA_SC));\r
397     ASSERT((ulPinType == GPIO_PIN_TYPE_STD) ||\r
398            (ulPinType == GPIO_PIN_TYPE_STD_WPU) ||\r
399            (ulPinType == GPIO_PIN_TYPE_STD_WPD) ||\r
400            (ulPinType == GPIO_PIN_TYPE_OD) ||\r
401            (ulPinType == GPIO_PIN_TYPE_OD_WPU) ||\r
402            (ulPinType == GPIO_PIN_TYPE_OD_WPD) ||\r
403            (ulPinType == GPIO_PIN_TYPE_ANALOG))\r
404 \r
405     //\r
406     // Set the output drive strength.\r
407     //\r
408     HWREG(ulPort + GPIO_O_DR2R) = ((ulStrength & 1) ?\r
409                                    (HWREG(ulPort + GPIO_O_DR2R) | ucPins) :\r
410                                    (HWREG(ulPort + GPIO_O_DR2R) & ~(ucPins)));\r
411     HWREG(ulPort + GPIO_O_DR4R) = ((ulStrength & 2) ?\r
412                                    (HWREG(ulPort + GPIO_O_DR4R) | ucPins) :\r
413                                    (HWREG(ulPort + GPIO_O_DR4R) & ~(ucPins)));\r
414     HWREG(ulPort + GPIO_O_DR8R) = ((ulStrength & 4) ?\r
415                                    (HWREG(ulPort + GPIO_O_DR8R) | ucPins) :\r
416                                    (HWREG(ulPort + GPIO_O_DR8R) & ~(ucPins)));\r
417     HWREG(ulPort + GPIO_O_SLR) = ((ulStrength & 8) ?\r
418                                   (HWREG(ulPort + GPIO_O_SLR) | ucPins) :\r
419                                   (HWREG(ulPort + GPIO_O_SLR) & ~(ucPins)));\r
420 \r
421     //\r
422     // Set the pin type.\r
423     //\r
424     HWREG(ulPort + GPIO_O_ODR) = ((ulPinType & 1) ?\r
425                                   (HWREG(ulPort + GPIO_O_ODR) | ucPins) :\r
426                                   (HWREG(ulPort + GPIO_O_ODR) & ~(ucPins)));\r
427     HWREG(ulPort + GPIO_O_PUR) = ((ulPinType & 2) ?\r
428                                   (HWREG(ulPort + GPIO_O_PUR) | ucPins) :\r
429                                   (HWREG(ulPort + GPIO_O_PUR) & ~(ucPins)));\r
430     HWREG(ulPort + GPIO_O_PDR) = ((ulPinType & 4) ?\r
431                                   (HWREG(ulPort + GPIO_O_PDR) | ucPins) :\r
432                                   (HWREG(ulPort + GPIO_O_PDR) & ~(ucPins)));\r
433     HWREG(ulPort + GPIO_O_DEN) = ((ulPinType & 8) ?\r
434                                   (HWREG(ulPort + GPIO_O_DEN) | ucPins) :\r
435                                   (HWREG(ulPort + GPIO_O_DEN) & ~(ucPins)));\r
436 }\r
437 #endif\r
438 \r
439 //*****************************************************************************\r
440 //\r
441 //! Gets the pad configuration for the specified pin of the selected GPIO\r
442 //! port.\r
443 //!\r
444 //! \param ulPort base address of the selected GPIO port\r
445 //! \param ucPin pin number of the specified pin, relative to the selected\r
446 //! GPIO port.\r
447 //! \param pulStrength pointer to storage for the output drive strength\r
448 //! \param pulPinType pointer to storage for the output drive type\r
449 //!\r
450 //! This function gets the pad configuration for a specified pin on the\r
451 //! selected GPIO port. The values returned in \e eStrength and \e eOutType\r
452 //! correspond to the values used in GPIOPadConfigSet(). This function also\r
453 //! works for pins configured as input pins; however, the only meaningful\r
454 //! data returned is whether the pin is terminated with a pull-up or\r
455 //! down resistor.\r
456 //!\r
457 //! \return None\r
458 //\r
459 //*****************************************************************************\r
460 #if defined(GROUP_padconfigget) || defined(BUILD_ALL) || defined(DOXYGEN)\r
461 void\r
462 GPIOPadConfigGet(unsigned long ulPort, unsigned char ucPin,\r
463                  unsigned long *pulStrength, unsigned long *pulPinType)\r
464 {\r
465     unsigned long ulTemp1, ulTemp2, ulTemp3, ulTemp4;\r
466 \r
467     //\r
468     // Check the arguments.\r
469     //\r
470     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
471            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
472            (ulPort == GPIO_PORTE_BASE));\r
473     ASSERT(ucPin < 8);\r
474 \r
475     //\r
476     // Convert from a pin number to a bit position.\r
477     //\r
478     ucPin = (1 << ucPin);\r
479 \r
480     //\r
481     // Get the drive strength for this pin.\r
482     //\r
483     ulTemp1 = HWREG(ulPort + GPIO_O_DR2R);\r
484     ulTemp2 = HWREG(ulPort + GPIO_O_DR4R);\r
485     ulTemp3 = HWREG(ulPort + GPIO_O_DR8R);\r
486     ulTemp4 = HWREG(ulPort + GPIO_O_SLR);\r
487     *pulStrength = (((ulTemp1 & ucPin) ? 1 : 0) | ((ulTemp2 & ucPin) ? 2 : 0) |\r
488                     ((ulTemp3 & ucPin) ? 4 : 0) | ((ulTemp4 & ucPin) ? 8 : 0));\r
489 \r
490     //\r
491     // Get the pin type.\r
492     //\r
493     ulTemp1 = HWREG(ulPort + GPIO_O_ODR);\r
494     ulTemp2 = HWREG(ulPort + GPIO_O_PUR);\r
495     ulTemp3 = HWREG(ulPort + GPIO_O_PDR);\r
496     ulTemp4 = HWREG(ulPort + GPIO_O_DEN);\r
497     *pulPinType = (((ulTemp1 & ucPin) ? 1 : 0) | ((ulTemp2 & ucPin) ? 2 : 0) |\r
498                    ((ulTemp3 & ucPin) ? 4 : 0) | ((ulTemp4 & ucPin) ? 8 : 0));\r
499 }\r
500 #endif\r
501 \r
502 //*****************************************************************************\r
503 //\r
504 //! Enables interrupts for the specified pins of the selected GPIO port.\r
505 //!\r
506 //! \param ulPort base address of the selected GPIO port\r
507 //! \param ucPins bit-packed representation of the specified pins\r
508 //!\r
509 //! Unmasks the interrupt for the specified pins.\r
510 //!\r
511 //! The pins are specified using a bit-packed byte, where each bit that is\r
512 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
513 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
514 //!\r
515 //! \return None.\r
516 //\r
517 //*****************************************************************************\r
518 #if defined(GROUP_pinintenable) || defined(BUILD_ALL) || defined(DOXYGEN)\r
519 void\r
520 GPIOPinIntEnable(unsigned long ulPort, unsigned char ucPins)\r
521 {\r
522     //\r
523     // Check the arguments.\r
524     //\r
525     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
526            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
527            (ulPort == GPIO_PORTE_BASE));\r
528 \r
529     //\r
530     // Enable the interrupts.\r
531     //\r
532     HWREG(ulPort + GPIO_O_IM) |= ucPins;\r
533 }\r
534 #endif\r
535 \r
536 //*****************************************************************************\r
537 //\r
538 //! Disables interrupts for the specified pins of the selected GPIO port.\r
539 //!\r
540 //! \param ulPort base address of the selected GPIO port\r
541 //! \param ucPins bit-packed representation of the specified pins\r
542 //!\r
543 //! Masks the interrupt for the specified pins.\r
544 //!\r
545 //! The pins are specified using a bit-packed byte, where each bit that is\r
546 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
547 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
548 //!\r
549 //! \return None.\r
550 //\r
551 //*****************************************************************************\r
552 #if defined(GROUP_pinintdisable) || defined(BUILD_ALL) || defined(DOXYGEN)\r
553 void\r
554 GPIOPinIntDisable(unsigned long ulPort, unsigned char ucPins)\r
555 {\r
556     //\r
557     // Check the arguments.\r
558     //\r
559     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
560            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
561            (ulPort == GPIO_PORTE_BASE));\r
562 \r
563     //\r
564     // Disable the interrupts.\r
565     //\r
566     HWREG(ulPort + GPIO_O_IM) &= ~(ucPins);\r
567 }\r
568 #endif\r
569 \r
570 //*****************************************************************************\r
571 //\r
572 //! Gets interrupt status for all the pins of the selected GPIO port.\r
573 //!\r
574 //! \param ulPort base address of the selected GPIO port\r
575 //! \param bMasked specifies whether masked or raw interrupt\r
576 //! status is returned\r
577 //!\r
578 //! If \e bMasked is set as \b true, then the masked interrupt status is\r
579 //! returned; otherwise, the raw interrupt status will be returned.\r
580 //!\r
581 //! \return Returns a bit-packed byte, where each bit that is set identifies\r
582 //! an active masked or raw interrupt, and where bit 0 of the byte\r
583 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc. Bits\r
584 //! 31:8 should be ignored.\r
585 //\r
586 //*****************************************************************************\r
587 #if defined(GROUP_pinintstatus) || defined(BUILD_ALL) || defined(DOXYGEN)\r
588 long\r
589 GPIOPinIntStatus(unsigned long ulPort, tBoolean bMasked)\r
590 {\r
591     //\r
592     // Check the arguments.\r
593     //\r
594     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
595            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
596            (ulPort == GPIO_PORTE_BASE));\r
597 \r
598     //\r
599     // Return the interrupt status.\r
600     //\r
601     if(bMasked)\r
602     {\r
603         return(HWREG(ulPort + GPIO_O_MIS));\r
604     }\r
605     else\r
606     {\r
607         return(HWREG(ulPort + GPIO_O_RIS));\r
608     }\r
609 }\r
610 #endif\r
611 \r
612 //*****************************************************************************\r
613 //\r
614 //! Clears the interrupt for the specified pins of the selected GPIO port.\r
615 //!\r
616 //! \param ulPort base address of the selected GPIO port\r
617 //! \param ucPins bit-packed representation of the specified pins\r
618 //!\r
619 //! Clears the interrupt for the specified pins.\r
620 //!\r
621 //! The pins are specified using a bit-packed byte, where each bit that is\r
622 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
623 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
624 //!\r
625 //! \return None.\r
626 //\r
627 //*****************************************************************************\r
628 #if defined(GROUP_pinintclear) || defined(BUILD_ALL) || defined(DOXYGEN)\r
629 void\r
630 GPIOPinIntClear(unsigned long ulPort, unsigned char ucPins)\r
631 {\r
632     //\r
633     // Check the arguments.\r
634     //\r
635     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
636            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
637            (ulPort == GPIO_PORTE_BASE));\r
638 \r
639     //\r
640     // Clear the interrupts.\r
641     //\r
642     HWREG(ulPort + GPIO_O_ICR) = ucPins;\r
643 }\r
644 #endif\r
645 \r
646 //*****************************************************************************\r
647 //\r
648 //! Registers an interrupt handler for the selected GPIO port.\r
649 //!\r
650 //! \param ulPort base address of the selected GPIO port\r
651 //! \param pfIntHandler pointer to the GPIO port interrupt handling function\r
652 //!\r
653 //! This function will ensure that the interrupt handler specified by \e\r
654 //! pfIntHandler is called when an interrupt is detected from the selected\r
655 //! GPIO port. This function will also enable the corresponding GPIO\r
656 //! interrupt in the interrupt controller; individual pin interrupts and\r
657 //! interrupt sources must be enabled with GPIOPinIntEnable().\r
658 //!\r
659 //! \sa IntRegister() for important information about registering interrupt\r
660 //! handlers.\r
661 //!\r
662 //! \return None.\r
663 //\r
664 //*****************************************************************************\r
665 #if defined(GROUP_portintregister) || defined(BUILD_ALL) || defined(DOXYGEN)\r
666 void\r
667 GPIOPortIntRegister(unsigned long ulPort, void (*pfIntHandler)(void))\r
668 {\r
669     //\r
670     // Check the arguments.\r
671     //\r
672     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
673            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
674            (ulPort == GPIO_PORTE_BASE));\r
675 \r
676     //\r
677     // Get the interrupt number associated with the specified GPIO.\r
678     //\r
679     ulPort = GPIOGetIntNumber(ulPort);\r
680 \r
681     //\r
682     // Register the interrupt handler.\r
683     //\r
684     IntRegister(ulPort, pfIntHandler);\r
685 \r
686     //\r
687     // Enable the GPIO interrupt.\r
688     //\r
689     IntEnable(ulPort);\r
690 }\r
691 #endif\r
692 \r
693 //*****************************************************************************\r
694 //\r
695 //! Removes an interrupt handler for the selected GPIO port.\r
696 //!\r
697 //! \param ulPort base address of the selected GPIO port\r
698 //!\r
699 //! This function will unregister the interrupt handler for the specified\r
700 //! GPIO port.  This function will also disable the corresponding\r
701 //! GPIO port interrupt in the interrupt controller; individual GPIO interrupts\r
702 //! and interrupt sources must be disabled with GPIOPinIntDisable().\r
703 //!\r
704 //! \sa IntRegister() for important information about registering interrupt\r
705 //! handlers.\r
706 //!\r
707 //! \return None.\r
708 //\r
709 //*****************************************************************************\r
710 #if defined(GROUP_portintunregister) || defined(BUILD_ALL) || defined(DOXYGEN)\r
711 void\r
712 GPIOPortIntUnregister(unsigned long ulPort)\r
713 {\r
714     //\r
715     // Check the arguments.\r
716     //\r
717     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
718            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
719            (ulPort == GPIO_PORTE_BASE));\r
720 \r
721     //\r
722     // Get the interrupt number associated with the specified GPIO.\r
723     //\r
724     ulPort = GPIOGetIntNumber(ulPort);\r
725 \r
726     //\r
727     // Disable the GPIO interrupt.\r
728     //\r
729     IntDisable(ulPort);\r
730 \r
731     //\r
732     // Unregister the interrupt handler.\r
733     //\r
734     IntUnregister(ulPort);\r
735 }\r
736 #endif\r
737 \r
738 //*****************************************************************************\r
739 //\r
740 //! Reads the values present at the specified pins of the selected GPIO port.\r
741 //!\r
742 //! \param ulPort base address of the selected GPIO port\r
743 //! \param ucPins bit-packed representation of the specified pins\r
744 //!\r
745 //! The values at the specified pins are read, as specified by \e ucPins.\r
746 //! Values are returned for both input and output pins, and the value\r
747 //! for pins that are not specified by \e ucPins are set to 0.\r
748 //!\r
749 //! The pins are specified using a bit-packed byte, where each bit that is\r
750 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
751 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
752 //!\r
753 //! \return Returns a bit-packed byte providing the state of the specified\r
754 //! pin, where bit 0 of the byte represents GPIO port pin 0, bit 1 represents\r
755 //! GPIO port pin 1, etc. Any bit that is not specified by \e ucPins\r
756 //! is returned as a 0. Bits 31:8 should be ignored.\r
757 //\r
758 //*****************************************************************************\r
759 #if defined(GROUP_pinread) || defined(BUILD_ALL) || defined(DOXYGEN)\r
760 long\r
761 GPIOPinRead(unsigned long ulPort, unsigned char ucPins)\r
762 {\r
763     //\r
764     // Check the arguments.\r
765     //\r
766     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
767            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
768            (ulPort == GPIO_PORTE_BASE));\r
769 \r
770     //\r
771     // Return the pin value(s).\r
772     //\r
773     return(HWREG(ulPort + (GPIO_O_DATA + (ucPins << 2))));\r
774 }\r
775 #endif\r
776 \r
777 //*****************************************************************************\r
778 //\r
779 //! Writes a value at the specified pins of the selected GPIO port.\r
780 //!\r
781 //! \param ulPort base address of the selected GPIO port\r
782 //! \param ucPins bit-packed representation of the specified pins\r
783 //! \param ucVal value to write to the specified pins\r
784 //!\r
785 //! Writes the corresponding bit values to the output pins specified\r
786 //! by \e ucPins. Writing to a pin configured as an input pin has no\r
787 //! effect.\r
788 //!\r
789 //! The pins are specified using a bit-packed byte, where each bit that is\r
790 //! set identifies the pin to be accessed, and where bit 0 of the byte\r
791 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, etc.\r
792 //!\r
793 //! \return None.\r
794 //\r
795 //*****************************************************************************\r
796 #if defined(GROUP_pinwrite) || defined(BUILD_ALL) || defined(DOXYGEN)\r
797 void\r
798 GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal)\r
799 {\r
800     //\r
801     // Check the arguments.\r
802     //\r
803     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
804            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
805            (ulPort == GPIO_PORTE_BASE));\r
806 \r
807     //\r
808     // Write the pins.\r
809     //\r
810     HWREG(ulPort + (GPIO_O_DATA + (ucPins << 2))) = ucVal;\r
811 }\r
812 #endif\r
813 \r
814 //*****************************************************************************\r
815 //\r
816 //! Configures pin(s) for use as an analog comparator input.\r
817 //!\r
818 //! \param ulPort base address of the selected GPIO port\r
819 //! \param ucPins bit-packed representation of the specified pins\r
820 //!\r
821 //! The analog comparator input pins must be properly configured for the analog\r
822 //! comparator to function correctly.  This function provides the proper\r
823 //! configuration for those pins.\r
824 //!\r
825 //! \note This cannot be used to turn any pin into an analog comparator input;\r
826 //! it only configures an analog comparator pin for proper operation.\r
827 //!\r
828 //! \return None.\r
829 //\r
830 //*****************************************************************************\r
831 #if defined(GROUP_pintypecomparator) || defined(BUILD_ALL) || defined(DOXYGEN)\r
832 void\r
833 GPIOPinTypeComparator(unsigned long ulPort, unsigned char ucPins)\r
834 {\r
835     //\r
836     // Check the arguments.\r
837     //\r
838     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
839            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
840            (ulPort == GPIO_PORTE_BASE));\r
841 \r
842     //\r
843     // Make the pin(s) be inputs.\r
844     //\r
845     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_IN);\r
846 \r
847     //\r
848     // Set the pad(s) for analog operation.\r
849     //\r
850     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_ANALOG);\r
851 }\r
852 #endif\r
853 \r
854 //*****************************************************************************\r
855 //\r
856 //! Configures pin(s) for use by the I2C peripheral.\r
857 //!\r
858 //! \param ulPort base address of the selected GPIO port\r
859 //! \param ucPins bit-packed representation of the specified pins\r
860 //!\r
861 //! The I2C pins must be properly configured for the I2C peripheral to function\r
862 //! correctly.  This function provides the proper configuration for those pins.\r
863 //!\r
864 //! \note This cannot be used to turn any pin into an I2C pin; it only\r
865 //! configures an I2C pin for proper operation.\r
866 //!\r
867 //! \return None.\r
868 //\r
869 //*****************************************************************************\r
870 #if defined(GROUP_pintypei2c) || defined(BUILD_ALL) || defined(DOXYGEN)\r
871 void\r
872 GPIOPinTypeI2C(unsigned long ulPort, unsigned char ucPins)\r
873 {\r
874     //\r
875     // Check the arguments.\r
876     //\r
877     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
878            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
879            (ulPort == GPIO_PORTE_BASE));\r
880 \r
881     //\r
882     // Make the pin(s) be peripheral controlled.\r
883     //\r
884     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);\r
885 \r
886     //\r
887     // Set the pad(s) for open-drain operation with a weak pull-up.\r
888     //\r
889     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD_WPU);\r
890 }\r
891 #endif\r
892 \r
893 //*****************************************************************************\r
894 //\r
895 //! Configures pin(s) for use by the PWM peripheral.\r
896 //!\r
897 //! \param ulPort base address of the selected GPIO port\r
898 //! \param ucPins bit-packed representation of the specified pins\r
899 //!\r
900 //! The PWM pins must be properly configured for the PWM peripheral to function\r
901 //! correctly.  This function provides a typical configuration for those pins;\r
902 //! other configurations may work as well depending upon the board setup (for\r
903 //! example, using the on-chip pull-ups).\r
904 //!\r
905 //! \note This cannot be used to turn any pin into a PWM pin; it only\r
906 //! configures a PWM pin for proper operation.\r
907 //!\r
908 //! \return None.\r
909 //\r
910 //*****************************************************************************\r
911 #if defined(GROUP_pintypepwm) || defined(BUILD_ALL) || defined(DOXYGEN)\r
912 void\r
913 GPIOPinTypePWM(unsigned long ulPort, unsigned char ucPins)\r
914 {\r
915     //\r
916     // Check the arguments.\r
917     //\r
918     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
919            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
920            (ulPort == GPIO_PORTE_BASE));\r
921 \r
922     //\r
923     // Make the pin(s) be peripheral controlled.\r
924     //\r
925     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);\r
926 \r
927     //\r
928     // Set the pad(s) for standard push-pull operation.\r
929     //\r
930     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);\r
931 }\r
932 #endif\r
933 \r
934 //*****************************************************************************\r
935 //\r
936 //! Configures pin(s) for use by the QEI peripheral.\r
937 //!\r
938 //! \param ulPort base address of the selected GPIO port\r
939 //! \param ucPins bit-packed representation of the specified pins\r
940 //!\r
941 //! The QEI pins must be properly configured for the QEI peripheral to function\r
942 //! correctly.  This function provides a typical configuration for those pins;\r
943 //! other configurations may work as well depending upon the board setup (for\r
944 //! example, not using the on-chip pull-ups).\r
945 //!\r
946 //! \note This cannot be used to turn any pin into a QEI pin; it only\r
947 //! configures a QEI pin for proper operation.\r
948 //!\r
949 //! \return None.\r
950 //\r
951 //*****************************************************************************\r
952 #if defined(GROUP_pintypeqei) || defined(BUILD_ALL) || defined(DOXYGEN)\r
953 void\r
954 GPIOPinTypeQEI(unsigned long ulPort, unsigned char ucPins)\r
955 {\r
956     //\r
957     // Check the arguments.\r
958     //\r
959     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
960            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
961            (ulPort == GPIO_PORTE_BASE));\r
962 \r
963     //\r
964     // Make the pin(s) be peripheral controlled.\r
965     //\r
966     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);\r
967 \r
968     //\r
969     // Set the pad(s) for standard push-pull operation with a weak pull-up.\r
970     //\r
971     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);\r
972 }\r
973 #endif\r
974 \r
975 //*****************************************************************************\r
976 //\r
977 //! Configures pin(s) for use by the SSI peripheral.\r
978 //!\r
979 //! \param ulPort base address of the selected GPIO port\r
980 //! \param ucPins bit-packed representation of the specified pins\r
981 //!\r
982 //! The SSI pins must be properly configured for the SSI peripheral to function\r
983 //! correctly.  This function provides a typical configuration for those pins;\r
984 //! other configurations may work as well depending upon the board setup (for\r
985 //! example, using the on-chip pull-ups).\r
986 //!\r
987 //! \note This cannot be used to turn any pin into a SSI pin; it only\r
988 //! configures a SSI pin for proper operation.\r
989 //!\r
990 //! \return None.\r
991 //\r
992 //*****************************************************************************\r
993 #if defined(GROUP_pintypessi) || defined(BUILD_ALL) || defined(DOXYGEN)\r
994 void\r
995 GPIOPinTypeSSI(unsigned long ulPort, unsigned char ucPins)\r
996 {\r
997     //\r
998     // Check the arguments.\r
999     //\r
1000     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
1001            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
1002            (ulPort == GPIO_PORTE_BASE));\r
1003 \r
1004     //\r
1005     // Make the pin(s) be peripheral controlled.\r
1006     //\r
1007     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);\r
1008 \r
1009     //\r
1010     // Set the pad(s) for standard push-pull operation.\r
1011     //\r
1012     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);\r
1013 }\r
1014 #endif\r
1015 \r
1016 //*****************************************************************************\r
1017 //\r
1018 //! Configures pin(s) for use by the Timer peripheral.\r
1019 //!\r
1020 //! \param ulPort base address of the selected GPIO port\r
1021 //! \param ucPins bit-packed representation of the specified pins\r
1022 //!\r
1023 //! The CCP pins must be properly configured for the timer peripheral to\r
1024 //! function correctly.  This function provides a typical configuration for\r
1025 //! those pins; other configurations may work as well depending upon the board\r
1026 //! setup (for example, using the on-chip pull-ups).\r
1027 //!\r
1028 //! \note This cannot be used to turn any pin into a timer pin; it only\r
1029 //! configures a timer pin for proper operation.\r
1030 //!\r
1031 //! \return None.\r
1032 //\r
1033 //*****************************************************************************\r
1034 #if defined(GROUP_pintypetimer) || defined(BUILD_ALL) || defined(DOXYGEN)\r
1035 void\r
1036 GPIOPinTypeTimer(unsigned long ulPort, unsigned char ucPins)\r
1037 {\r
1038     //\r
1039     // Check the arguments.\r
1040     //\r
1041     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
1042            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
1043            (ulPort == GPIO_PORTE_BASE));\r
1044 \r
1045     //\r
1046     // Make the pin(s) be peripheral controlled.\r
1047     //\r
1048     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);\r
1049 \r
1050     //\r
1051     // Set the pad(s) for standard push-pull operation.\r
1052     //\r
1053     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);\r
1054 }\r
1055 #endif\r
1056 \r
1057 //*****************************************************************************\r
1058 //\r
1059 //! Configures pin(s) for use by the UART peripheral.\r
1060 //!\r
1061 //! \param ulPort base address of the selected GPIO port\r
1062 //! \param ucPins bit-packed representation of the specified pins\r
1063 //!\r
1064 //! The UART pins must be properly configured for the UART peripheral to\r
1065 //! function correctly.  This function provides a typical configuration for\r
1066 //! those pins; other configurations may work as well depending upon the board\r
1067 //! setup (for example, using the on-chip pull-ups).\r
1068 //!\r
1069 //! \note This cannot be used to turn any pin into a UART pin; it only\r
1070 //! configures a UART pin for proper operation.\r
1071 //!\r
1072 //! \return None.\r
1073 //\r
1074 //*****************************************************************************\r
1075 #if defined(GROUP_pintypeuart) || defined(BUILD_ALL) || defined(DOXYGEN)\r
1076 void\r
1077 GPIOPinTypeUART(unsigned long ulPort, unsigned char ucPins)\r
1078 {\r
1079     //\r
1080     // Check the arguments.\r
1081     //\r
1082     ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||\r
1083            (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||\r
1084            (ulPort == GPIO_PORTE_BASE));\r
1085 \r
1086     //\r
1087     // Make the pin(s) be peripheral controlled.\r
1088     //\r
1089     GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);\r
1090 \r
1091     //\r
1092     // Set the pad(s) for standard push-pull operation.\r
1093     //\r
1094     GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);\r
1095 }\r
1096 #endif\r
1097 \r
1098 //*****************************************************************************\r
1099 //\r
1100 // Close the Doxygen group.\r
1101 //! @}\r
1102 //\r
1103 //*****************************************************************************\r