1 /*
2 * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33 //*****************************************************************************
34 //
35 // gpio.c
36 //
37 // Driver for the GPIO module.
38 //
39 //*****************************************************************************
40
41 //*****************************************************************************
42 //
43 //! \addtogroup GPIO_General_Purpose_InputOutput_api
44 //! @{
45 //
46 //*****************************************************************************
47
48 #include "inc/hw_types.h"
49 #include "inc/hw_gpio.h"
50 #include "inc/hw_ints.h"
51 #include "inc/hw_memmap.h"
52 #include "inc/hw_common_reg.h"
53 #include "debug.h"
54 #include "gpio.h"
55 #include "interrupt.h"
56
57
58 //*****************************************************************************
59 //
60 //! \internal
61 //! Checks a GPIO base address.
62 //!
63 //! \param ulPort is the base address of the GPIO port.
64 //!
65 //! This function determines if a GPIO port base address is valid.
66 //!
67 //! \return Returns \b true if the base address is valid and \b false
68 //! otherwise.
69 //
70 //*****************************************************************************
71 #ifdef DEBUG
72 static tBoolean
GPIOBaseValid(unsigned long ulPort)73 GPIOBaseValid(unsigned long ulPort)
74 {
75 return((ulPort == GPIOA0_BASE) ||
76 (ulPort == GPIOA1_BASE) ||
77 (ulPort == GPIOA2_BASE) ||
78 (ulPort == GPIOA3_BASE) ||
79 (ulPort == GPIOA4_BASE));
80 }
81 #endif
82
83 //*****************************************************************************
84 //
85 //! \internal
86 //! Gets the GPIO interrupt number.
87 //!
88 //! \param ulPort is the base address of the GPIO port.
89 //!
90 //! Given a GPIO base address, returns the corresponding interrupt number.
91 //!
92 //! \return Returns a GPIO interrupt number, or -1 if \e ulPort is invalid.
93 //
94 //*****************************************************************************
95 static long
GPIOGetIntNumber(unsigned long ulPort)96 GPIOGetIntNumber(unsigned long ulPort)
97 {
98 unsigned int ulInt;
99
100 //
101 // Determine the GPIO interrupt number for the given module.
102 //
103 switch(ulPort)
104 {
105 case GPIOA0_BASE:
106 {
107 ulInt = INT_GPIOA0;
108 break;
109 }
110
111 case GPIOA1_BASE:
112 {
113 ulInt = INT_GPIOA1;
114 break;
115 }
116
117 case GPIOA2_BASE:
118 {
119 ulInt = INT_GPIOA2;
120 break;
121 }
122
123 case GPIOA3_BASE:
124 {
125 ulInt = INT_GPIOA3;
126 break;
127 }
128
129 default:
130 {
131 return(-1);
132 }
133 }
134
135 //
136 // Return GPIO interrupt number.
137 //
138 return(ulInt);
139 }
140
141 //*****************************************************************************
142 //
143 //! Sets the direction and mode of the specified pin(s).
144 //!
145 //! \param ulPort is the base address of the GPIO port
146 //! \param ucPins is the bit-packed representation of the pin(s).
147 //! \param ulPinIO is the pin direction and/or mode.
148 //!
149 //! This function will set the specified pin(s) on the selected GPIO port
150 //! as either an input or output under software control, or it will set the
151 //! pin to be under hardware control.
152 //!
153 //! The parameter \e ulPinIO is an enumerated data type that can be one of
154 //! the following values:
155 //!
156 //! - \b GPIO_DIR_MODE_IN
157 //! - \b GPIO_DIR_MODE_OUT
158 //!
159 //! where \b GPIO_DIR_MODE_IN specifies that the pin will be programmed as
160 //! a software controlled input, \b GPIO_DIR_MODE_OUT specifies that the pin
161 //! will be programmed as a software controlled output.
162 //!
163 //! The pin(s) are specified using a bit-packed byte, where each bit that is
164 //! set identifies the pin to be accessed, and where bit 0 of the byte
165 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
166 //!
167 //! \note GPIOPadConfigSet() must also be used to configure the corresponding
168 //! pad(s) in order for them to propagate the signal to/from the GPIO.
169 //!
170 //! \return None.
171 //
172 //*****************************************************************************
173 void
GPIODirModeSet(unsigned long ulPort,unsigned char ucPins,unsigned long ulPinIO)174 GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,
175 unsigned long ulPinIO)
176 {
177 //
178 // Check the arguments.
179 //
180 ASSERT(GPIOBaseValid(ulPort));
181 ASSERT((ulPinIO == GPIO_DIR_MODE_IN) || (ulPinIO == GPIO_DIR_MODE_OUT));
182
183 //
184 // Set the pin direction and mode.
185 //
186 HWREG(ulPort + GPIO_O_GPIO_DIR) = ((ulPinIO & 1) ?
187 (HWREG(ulPort + GPIO_O_GPIO_DIR) | ucPins) :
188 (HWREG(ulPort + GPIO_O_GPIO_DIR) & ~(ucPins)));
189 }
190
191 //*****************************************************************************
192 //
193 //! Gets the direction and mode of a pin.
194 //!
195 //! \param ulPort is the base address of the GPIO port.
196 //! \param ucPin is the pin number.
197 //!
198 //! This function gets the direction and control mode for a specified pin on
199 //! the selected GPIO port. The pin can be configured as either an input or
200 //! output under software control, or it can be under hardware control. The
201 //! type of control and direction are returned as an enumerated data type.
202 //!
203 //! \return Returns one of the enumerated data types described for
204 //! GPIODirModeSet().
205 //
206 //*****************************************************************************
207 unsigned long
GPIODirModeGet(unsigned long ulPort,unsigned char ucPin)208 GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)
209 {
210 unsigned long ulDir;
211
212 //
213 // Check the arguments.
214 //
215 ASSERT(GPIOBaseValid(ulPort));
216 ASSERT(ucPin < 8);
217
218 //
219 // Convert from a pin number to a bit position.
220 //
221 ucPin = 1 << ucPin;
222
223 //
224 // Return the pin direction and mode.
225 //
226 ulDir = HWREG(ulPort + GPIO_O_GPIO_DIR);
227 return(((ulDir & ucPin) ? 1 : 0));
228 }
229
230 //*****************************************************************************
231 //
232 //! Sets the interrupt type for the specified pin(s).
233 //!
234 //! \param ulPort is the base address of the GPIO port.
235 //! \param ucPins is the bit-packed representation of the pin(s).
236 //! \param ulIntType specifies the type of interrupt trigger mechanism.
237 //!
238 //! This function sets up the various interrupt trigger mechanisms for the
239 //! specified pin(s) on the selected GPIO port.
240 //!
241 //! The parameter \e ulIntType is an enumerated data type that can be one of
242 //! the following values:
243 //!
244 //! - \b GPIO_FALLING_EDGE
245 //! - \b GPIO_RISING_EDGE
246 //! - \b GPIO_BOTH_EDGES
247 //! - \b GPIO_LOW_LEVEL
248 //! - \b GPIO_HIGH_LEVEL
249 //!
250 //! The pin(s) are specified using a bit-packed byte, where each bit that is
251 //! set identifies the pin to be accessed, and where bit 0 of the byte
252 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
253 //!
254 //! \note In order to avoid any spurious interrupts, the user must
255 //! ensure that the GPIO inputs remain stable for the duration of
256 //! this function.
257 //!
258 //! \return None.
259 //
260 //*****************************************************************************
261 void
GPIOIntTypeSet(unsigned long ulPort,unsigned char ucPins,unsigned long ulIntType)262 GPIOIntTypeSet(unsigned long ulPort, unsigned char ucPins,
263 unsigned long ulIntType)
264 {
265 //
266 // Check the arguments.
267 //
268 ASSERT(GPIOBaseValid(ulPort));
269 ASSERT((ulIntType == GPIO_FALLING_EDGE) ||
270 (ulIntType == GPIO_RISING_EDGE) || (ulIntType == GPIO_BOTH_EDGES) ||
271 (ulIntType == GPIO_LOW_LEVEL) || (ulIntType == GPIO_HIGH_LEVEL));
272
273 //
274 // Set the pin interrupt type.
275 //
276 HWREG(ulPort + GPIO_O_GPIO_IBE) = ((ulIntType & 1) ?
277 (HWREG(ulPort + GPIO_O_GPIO_IBE) | ucPins) :
278 (HWREG(ulPort + GPIO_O_GPIO_IBE) & ~(ucPins)));
279 HWREG(ulPort + GPIO_O_GPIO_IS) = ((ulIntType & 2) ?
280 (HWREG(ulPort + GPIO_O_GPIO_IS) | ucPins) :
281 (HWREG(ulPort + GPIO_O_GPIO_IS) & ~(ucPins)));
282 HWREG(ulPort + GPIO_O_GPIO_IEV) = ((ulIntType & 4) ?
283 (HWREG(ulPort + GPIO_O_GPIO_IEV) | ucPins) :
284 (HWREG(ulPort + GPIO_O_GPIO_IEV) & ~(ucPins)));
285 }
286
287 //*****************************************************************************
288 //
289 //! Gets the interrupt type for a pin.
290 //!
291 //! \param ulPort is the base address of the GPIO port.
292 //! \param ucPin is the pin number.
293 //!
294 //! This function gets the interrupt type for a specified pin on the selected
295 //! GPIO port. The pin can be configured as a falling edge, rising edge, or
296 //! both edge detected interrupt, or it can be configured as a low level or
297 //! high level detected interrupt. The type of interrupt detection mechanism
298 //! is returned as an enumerated data type.
299 //!
300 //! \return Returns one of the enumerated data types described for
301 //! GPIOIntTypeSet().
302 //
303 //*****************************************************************************
304 unsigned long
GPIOIntTypeGet(unsigned long ulPort,unsigned char ucPin)305 GPIOIntTypeGet(unsigned long ulPort, unsigned char ucPin)
306 {
307 unsigned long ulIBE, ulIS, ulIEV;
308
309 //
310 // Check the arguments.
311 //
312 ASSERT(GPIOBaseValid(ulPort));
313 ASSERT(ucPin < 8);
314
315 //
316 // Convert from a pin number to a bit position.
317 //
318 ucPin = 1 << ucPin;
319
320 //
321 // Return the pin interrupt type.
322 //
323 ulIBE = HWREG(ulPort + GPIO_O_GPIO_IBE);
324 ulIS = HWREG(ulPort + GPIO_O_GPIO_IS);
325 ulIEV = HWREG(ulPort + GPIO_O_GPIO_IEV);
326 return(((ulIBE & ucPin) ? 1 : 0) | ((ulIS & ucPin) ? 2 : 0) |
327 ((ulIEV & ucPin) ? 4 : 0));
328 }
329
330 //*****************************************************************************
331 //
332 //! Enables the specified GPIO interrupts.
333 //!
334 //! \param ulPort is the base address of the GPIO port.
335 //! \param ulIntFlags is the bit mask of the interrupt sources to enable.
336 //!
337 //! This function enables the indicated GPIO interrupt sources. Only the
338 //! sources that are enabled can be reflected to the processor interrupt;
339 //! disabled sources have no effect on the processor.
340 //!
341 //! The \e ulIntFlags parameter is the logical OR of any of the following:
342 //!
343 //! - \b GPIO_INT_DMA - interrupt due to GPIO triggered DMA Done
344 //! - \b GPIO_INT_PIN_0 - interrupt due to activity on Pin 0.
345 //! - \b GPIO_INT_PIN_1 - interrupt due to activity on Pin 1.
346 //! - \b GPIO_INT_PIN_2 - interrupt due to activity on Pin 2.
347 //! - \b GPIO_INT_PIN_3 - interrupt due to activity on Pin 3.
348 //! - \b GPIO_INT_PIN_4 - interrupt due to activity on Pin 4.
349 //! - \b GPIO_INT_PIN_5 - interrupt due to activity on Pin 5.
350 //! - \b GPIO_INT_PIN_6 - interrupt due to activity on Pin 6.
351 //! - \b GPIO_INT_PIN_7 - interrupt due to activity on Pin 7.
352 //!
353 //! \return None.
354 //
355 //*****************************************************************************
356 void
GPIOIntEnable(unsigned long ulPort,unsigned long ulIntFlags)357 GPIOIntEnable(unsigned long ulPort, unsigned long ulIntFlags)
358 {
359 //
360 // Check the arguments.
361 //
362 ASSERT(GPIOBaseValid(ulPort));
363
364 //
365 // Enable the interrupts.
366 //
367 HWREG(ulPort + GPIO_O_GPIO_IM) |= ulIntFlags;
368 }
369
370 //*****************************************************************************
371 //
372 //! Disables the specified GPIO interrupts.
373 //!
374 //! \param ulPort is the base address of the GPIO port.
375 //! \param ulIntFlags is the bit mask of the interrupt sources to disable.
376 //!
377 //! This function disables the indicated GPIO interrupt sources. Only the
378 //! sources that are enabled can be reflected to the processor interrupt;
379 //! disabled sources have no effect on the processor.
380 //!
381 //! The \e ulIntFlags parameter is the logical OR of any of the following:
382 //!
383 //! - \b GPIO_INT_DMA - interrupt due to GPIO triggered DMA Done
384 //! - \b GPIO_INT_PIN_0 - interrupt due to activity on Pin 0.
385 //! - \b GPIO_INT_PIN_1 - interrupt due to activity on Pin 1.
386 //! - \b GPIO_INT_PIN_2 - interrupt due to activity on Pin 2.
387 //! - \b GPIO_INT_PIN_3 - interrupt due to activity on Pin 3.
388 //! - \b GPIO_INT_PIN_4 - interrupt due to activity on Pin 4.
389 //! - \b GPIO_INT_PIN_5 - interrupt due to activity on Pin 5.
390 //! - \b GPIO_INT_PIN_6 - interrupt due to activity on Pin 6.
391 //! - \b GPIO_INT_PIN_7 - interrupt due to activity on Pin 7.
392 //!
393 //! \return None.
394 //
395 //*****************************************************************************
396 void
GPIOIntDisable(unsigned long ulPort,unsigned long ulIntFlags)397 GPIOIntDisable(unsigned long ulPort, unsigned long ulIntFlags)
398 {
399 //
400 // Check the arguments.
401 //
402 ASSERT(GPIOBaseValid(ulPort));
403
404 //
405 // Disable the interrupts.
406 //
407 HWREG(ulPort + GPIO_O_GPIO_IM) &= ~(ulIntFlags);
408 }
409
410 //*****************************************************************************
411 //
412 //! Gets interrupt status for the specified GPIO port.
413 //!
414 //! \param ulPort is the base address of the GPIO port.
415 //! \param bMasked specifies whether masked or raw interrupt status is
416 //! returned.
417 //!
418 //! If \e bMasked is set as \b true, then the masked interrupt status is
419 //! returned; otherwise, the raw interrupt status will be returned.
420 //!
421 //! \return Returns the current interrupt status, enumerated as a bit field of
422 //! values described in GPIOIntEnable().
423 //
424 //*****************************************************************************
425 long
GPIOIntStatus(unsigned long ulPort,tBoolean bMasked)426 GPIOIntStatus(unsigned long ulPort, tBoolean bMasked)
427 {
428 //
429 // Check the arguments.
430 //
431 ASSERT(GPIOBaseValid(ulPort));
432
433 //
434 // Return the interrupt status.
435 //
436 if(bMasked)
437 {
438 return(HWREG(ulPort + GPIO_O_GPIO_MIS));
439 }
440 else
441 {
442 return(HWREG(ulPort + GPIO_O_GPIO_RIS));
443 }
444 }
445
446 //*****************************************************************************
447 //
448 //! Clears the interrupt for the specified pin(s).
449 //!
450 //! \param ulPort is the base address of the GPIO port.
451 //! \param ulIntFlags is a bit mask of the interrupt sources to be cleared.
452 //!
453 //! Clears the interrupt for the specified pin(s).
454 //!
455 //! The \e ulIntFlags parameter has the same definition as the \e ulIntFlags
456 //! parameter to GPIOIntEnable().
457 //!
458 //!
459 //! \return None.
460 //
461 //*****************************************************************************
462 void
GPIOIntClear(unsigned long ulPort,unsigned long ulIntFlags)463 GPIOIntClear(unsigned long ulPort, unsigned long ulIntFlags)
464 {
465 //
466 // Check the arguments.
467 //
468 ASSERT(GPIOBaseValid(ulPort));
469
470 //
471 // Clear the interrupts.
472 //
473 HWREG(ulPort + GPIO_O_GPIO_ICR) = ulIntFlags;
474 }
475
476 //*****************************************************************************
477 //
478 //! Registers an interrupt handler for a GPIO port.
479 //!
480 //! \param ulPort is the base address of the GPIO port.
481 //! \param pfnIntHandler is a pointer to the GPIO port interrupt handling
482 //! function.
483 //!
484 //! This function will ensure that the interrupt handler specified by
485 //! \e pfnIntHandler is called when an interrupt is detected from the selected
486 //! GPIO port. This function will also enable the corresponding GPIO interrupt
487 //! in the interrupt controller; individual pin interrupts and interrupt
488 //! sources must be enabled with GPIOIntEnable().
489 //!
490 //! \sa IntRegister() for important information about registering interrupt
491 //! handlers.
492 //!
493 //! \return None.
494 //
495 //*****************************************************************************
496 void
GPIOIntRegister(unsigned long ulPort,void (* pfnIntHandler)(void))497 GPIOIntRegister(unsigned long ulPort, void (*pfnIntHandler)(void))
498 {
499 //
500 // Check the arguments.
501 //
502 ASSERT(GPIOBaseValid(ulPort));
503
504 //
505 // Get the interrupt number associated with the specified GPIO.
506 //
507 ulPort = GPIOGetIntNumber(ulPort);
508
509 //
510 // Register the interrupt handler.
511 //
512 IntRegister(ulPort, pfnIntHandler);
513
514 //
515 // Enable the GPIO interrupt.
516 //
517 IntEnable(ulPort);
518 }
519
520 //*****************************************************************************
521 //
522 //! Removes an interrupt handler for a GPIO port.
523 //!
524 //! \param ulPort is the base address of the GPIO port.
525 //!
526 //! This function will unregister the interrupt handler for the specified
527 //! GPIO port. This function will also disable the corresponding
528 //! GPIO port interrupt in the interrupt controller; individual GPIO interrupts
529 //! and interrupt sources must be disabled with GPIOIntDisable().
530 //!
531 //! \sa IntRegister() for important information about registering interrupt
532 //! handlers.
533 //!
534 //! \return None.
535 //
536 //*****************************************************************************
537 void
GPIOIntUnregister(unsigned long ulPort)538 GPIOIntUnregister(unsigned long ulPort)
539 {
540 //
541 // Check the arguments.
542 //
543 ASSERT(GPIOBaseValid(ulPort));
544
545 //
546 // Get the interrupt number associated with the specified GPIO.
547 //
548 ulPort = GPIOGetIntNumber(ulPort);
549
550 //
551 // Disable the GPIO interrupt.
552 //
553 IntDisable(ulPort);
554
555 //
556 // Unregister the interrupt handler.
557 //
558 IntUnregister(ulPort);
559 }
560
561 //*****************************************************************************
562 //
563 //! Reads the values present of the specified pin(s).
564 //!
565 //! \param ulPort is the base address of the GPIO port.
566 //! \param ucPins is the bit-packed representation of the pin(s).
567 //!
568 //! The values at the specified pin(s) are read, as specified by \e ucPins.
569 //! Values are returned for both input and output pin(s), and the value
570 //! for pin(s) that are not specified by \e ucPins are set to 0.
571 //!
572 //! The pin(s) are specified using a bit-packed byte, where each bit that is
573 //! set identifies the pin to be accessed, and where bit 0 of the byte
574 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
575 //!
576 //! \return Returns a bit-packed byte providing the state of the specified
577 //! pin, where bit 0 of the byte represents GPIO port pin 0, bit 1 represents
578 //! GPIO port pin 1, and so on. Any bit that is not specified by \e ucPins
579 //! is returned as a 0. Bits 31:8 should be ignored.
580 //
581 //*****************************************************************************
582 long
GPIOPinRead(unsigned long ulPort,unsigned char ucPins)583 GPIOPinRead(unsigned long ulPort, unsigned char ucPins)
584 {
585 //
586 // Check the arguments.
587 //
588 ASSERT(GPIOBaseValid(ulPort));
589
590 //
591 // Return the pin value(s).
592 //
593 return(HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))));
594 }
595
596 //*****************************************************************************
597 //
598 //! Writes a value to the specified pin(s).
599 //!
600 //! \param ulPort is the base address of the GPIO port.
601 //! \param ucPins is the bit-packed representation of the pin(s).
602 //! \param ucVal is the value to write to the pin(s).
603 //!
604 //! Writes the corresponding bit values to the output pin(s) specified by
605 //! \e ucPins. Writing to a pin configured as an input pin has no effect.
606 //!
607 //! The pin(s) are specified using a bit-packed byte, where each bit that is
608 //! set identifies the pin to be accessed, and where bit 0 of the byte
609 //! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
610 //!
611 //! \return None.
612 //
613 //*****************************************************************************
614 void
GPIOPinWrite(unsigned long ulPort,unsigned char ucPins,unsigned char ucVal)615 GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal)
616 {
617 //
618 // Check the arguments.
619 //
620 ASSERT(GPIOBaseValid(ulPort));
621
622 //
623 // Write the pins.
624 //
625 HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))) = ucVal;
626 }
627
628 //*****************************************************************************
629 //
630 //! Enables a GPIO port as a trigger to start a DMA transaction.
631 //!
632 //! \param ulPort is the base address of the GPIO port.
633 //!
634 //! This function enables a GPIO port to be used as a trigger to start a uDMA
635 //! transaction. The GPIO pin will still generate interrupts if the interrupt is
636 //! enabled for the selected pin.
637 //!
638 //! \return None.
639 //
640 //*****************************************************************************
641 void
GPIODMATriggerEnable(unsigned long ulPort)642 GPIODMATriggerEnable(unsigned long ulPort)
643 {
644 //
645 // Check the arguments.
646 //
647 ASSERT(GPIOBaseValid(ulPort));
648
649 //
650 // Set the pin as a DMA trigger.
651 //
652 if(ulPort == GPIOA0_BASE)
653 {
654 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x1;
655 }
656 else if(ulPort == GPIOA1_BASE)
657 {
658 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x2;
659 }
660 else if(ulPort == GPIOA2_BASE)
661 {
662 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x4;
663 }
664 else if(ulPort == GPIOA3_BASE)
665 {
666 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x8;
667 }
668 }
669
670 //*****************************************************************************
671 //
672 //! Disables a GPIO port as a trigger to start a DMA transaction.
673 //!
674 //! \param ulPort is the base address of the GPIO port.
675 //!
676 //! This function disables a GPIO port to be used as a trigger to start a uDMA
677 //! transaction. This function can be used to disable this feature if it was
678 //! enabled via a call to GPIODMATriggerEnable().
679 //!
680 //! \return None.
681 //
682 //*****************************************************************************
683 void
GPIODMATriggerDisable(unsigned long ulPort)684 GPIODMATriggerDisable(unsigned long ulPort)
685 {
686 //
687 // Check the arguments.
688 //
689 ASSERT(GPIOBaseValid(ulPort));
690
691 //
692 // Set the pin as a DMA trigger.
693 //
694 if(ulPort == GPIOA0_BASE)
695 {
696 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x1;
697 }
698 else if(ulPort == GPIOA1_BASE)
699 {
700 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x2;
701 }
702 else if(ulPort == GPIOA2_BASE)
703 {
704 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x4;
705 }
706 else if(ulPort == GPIOA3_BASE)
707 {
708 HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x8;
709 }
710 }
711
712
713 //
714 // Close the Doxygen group.
715 //! @}
716 //
717 //*****************************************************************************
718