1 /******************************************************************************
2 * Filename: gpio.h
3 * Revised: 2015-11-19 16:24:40 +0100 (Thu, 19 Nov 2015)
4 * Revision: 45170
5 *
6 * Description: Defines and prototypes for the GPIO.
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38
39 //*****************************************************************************
40 //
41 //! \addtogroup peripheral_group
42 //! @{
43 //! \addtogroup gpio_api
44 //! @{
45 //
46 //*****************************************************************************
47
48 #ifndef __GPIO_H__
49 #define __GPIO_H__
50
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61
62 #include <stdint.h>
63 #include <inc/hw_types.h>
64 #include <inc/hw_memmap.h>
65 #include <inc/hw_gpio.h>
66 #include <driverlib/debug.h>
67
68 //*****************************************************************************
69 //
70 // Check for legal range of variable dioNumber
71 //
72 //*****************************************************************************
73 #ifdef DRIVERLIB_DEBUG
74 static bool
dioNumberLegal(uint32_t dioNumber)75 dioNumberLegal( uint32_t dioNumber )
76 {
77 return ( dioNumber < (( HWREG( FCFG_BASE + FCFG1_O_IOCONF ) &
78 FCFG1_IOCONF_GPIO_CNT_M ) >>
79 FCFG1_IOCONF_GPIO_CNT_S ) );
80 }
81 #endif
82
83 //*****************************************************************************
84 //
85 // The following values define the bit field for the GPIO DIOs.
86 //
87 //*****************************************************************************
88 #define GPIO_DIO_0_MASK 0x00000001 // GPIO DIO 0 mask
89 #define GPIO_DIO_1_MASK 0x00000002 // GPIO DIO 1 mask
90 #define GPIO_DIO_2_MASK 0x00000004 // GPIO DIO 2 mask
91 #define GPIO_DIO_3_MASK 0x00000008 // GPIO DIO 3 mask
92 #define GPIO_DIO_4_MASK 0x00000010 // GPIO DIO 4 mask
93 #define GPIO_DIO_5_MASK 0x00000020 // GPIO DIO 5 mask
94 #define GPIO_DIO_6_MASK 0x00000040 // GPIO DIO 6 mask
95 #define GPIO_DIO_7_MASK 0x00000080 // GPIO DIO 7 mask
96 #define GPIO_DIO_8_MASK 0x00000100 // GPIO DIO 8 mask
97 #define GPIO_DIO_9_MASK 0x00000200 // GPIO DIO 9 mask
98 #define GPIO_DIO_10_MASK 0x00000400 // GPIO DIO 10 mask
99 #define GPIO_DIO_11_MASK 0x00000800 // GPIO DIO 11 mask
100 #define GPIO_DIO_12_MASK 0x00001000 // GPIO DIO 12 mask
101 #define GPIO_DIO_13_MASK 0x00002000 // GPIO DIO 13 mask
102 #define GPIO_DIO_14_MASK 0x00004000 // GPIO DIO 14 mask
103 #define GPIO_DIO_15_MASK 0x00008000 // GPIO DIO 15 mask
104 #define GPIO_DIO_16_MASK 0x00010000 // GPIO DIO 16 mask
105 #define GPIO_DIO_17_MASK 0x00020000 // GPIO DIO 17 mask
106 #define GPIO_DIO_18_MASK 0x00040000 // GPIO DIO 18 mask
107 #define GPIO_DIO_19_MASK 0x00080000 // GPIO DIO 19 mask
108 #define GPIO_DIO_20_MASK 0x00100000 // GPIO DIO 20 mask
109 #define GPIO_DIO_21_MASK 0x00200000 // GPIO DIO 21 mask
110 #define GPIO_DIO_22_MASK 0x00400000 // GPIO DIO 22 mask
111 #define GPIO_DIO_23_MASK 0x00800000 // GPIO DIO 23 mask
112 #define GPIO_DIO_24_MASK 0x01000000 // GPIO DIO 24 mask
113 #define GPIO_DIO_25_MASK 0x02000000 // GPIO DIO 25 mask
114 #define GPIO_DIO_26_MASK 0x04000000 // GPIO DIO 26 mask
115 #define GPIO_DIO_27_MASK 0x08000000 // GPIO DIO 27 mask
116 #define GPIO_DIO_28_MASK 0x10000000 // GPIO DIO 28 mask
117 #define GPIO_DIO_29_MASK 0x20000000 // GPIO DIO 29 mask
118 #define GPIO_DIO_30_MASK 0x40000000 // GPIO DIO 30 mask
119 #define GPIO_DIO_31_MASK 0x80000000 // GPIO DIO 31 mask
120 #define GPIO_DIO_ALL_MASK 0xFFFFFFFF // GPIO all DIOs mask
121
122 //*****************************************************************************
123 //
124 // Define constants that shall be passed as the outputEnableValue parameter to
125 // GPIO_setOutputEnableDio() and will be returned from the function
126 // GPIO_getOutputEnableDio().
127 //
128 //*****************************************************************************
129 #define GPIO_OUTPUT_DISABLE 0x00000000 // DIO output is disabled
130 #define GPIO_OUTPUT_ENABLE 0x00000001 // DIO output is enabled
131
132 //*****************************************************************************
133 //
134 // API Functions and prototypes
135 //
136 //*****************************************************************************
137
138 //*****************************************************************************
139 //
140 //! \brief Reads a specific DIO.
141 //!
142 //! \param dioNumber specifies the DIO to read (0-31).
143 //!
144 //! \return Returns 0 or 1 reflecting the input value of the specified DIO.
145 //!
146 //! \sa \ref GPIO_readMultiDio(), \ref GPIO_writeDio(), \ref GPIO_writeMultiDio()
147 //
148 //*****************************************************************************
149 __STATIC_INLINE uint32_t
GPIO_readDio(uint32_t dioNumber)150 GPIO_readDio( uint32_t dioNumber )
151 {
152 //
153 // Check the arguments.
154 //
155 ASSERT( dioNumberLegal( dioNumber ));
156
157 //
158 // Return the input value from the specified DIO.
159 //
160 return (( HWREG( GPIO_BASE + GPIO_O_DIN31_0 ) >> dioNumber ) & 1 );
161 }
162
163 //*****************************************************************************
164 //
165 //! \brief Reads the input value for the specified DIOs.
166 //!
167 //! This function returns the the input value for multiple DIOs.
168 //! The value returned is not shifted and hence matches the corresponding dioMask bits.
169 //!
170 //! \param dioMask is the bit-mask representation of the DIOs to read.
171 //! The parameter must be a bitwise OR'ed combination of the following:
172 //! - \ref GPIO_DIO_0_MASK
173 //! - ...
174 //! - \ref GPIO_DIO_31_MASK
175 //!
176 //! \return Returns a bit vector reflecting the input value of the corresponding DIOs.
177 //! - 0 : Corresponding DIO is low.
178 //! - 1 : Corresponding DIO is high.
179 //!
180 //! \sa \ref GPIO_readDio(), \ref GPIO_writeDio(), \ref GPIO_writeMultiDio()
181 //
182 //*****************************************************************************
183 __STATIC_INLINE uint32_t
GPIO_readMultiDio(uint32_t dioMask)184 GPIO_readMultiDio( uint32_t dioMask )
185 {
186 //
187 // Check the arguments.
188 //
189 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
190
191 //
192 // Return the input value from the specified DIOs.
193 //
194 return ( HWREG( GPIO_BASE + GPIO_O_DIN31_0 ) & dioMask );
195 }
196
197 //*****************************************************************************
198 //
199 //! \brief Writes a value to a specific DIO.
200 //!
201 //! \param dioNumber specifies the DIO to update (0-31).
202 //! \param value specifies the value to write
203 //! - 0 : Logic zero (low)
204 //! - 1 : Logic one (high)
205 //!
206 //! \return None
207 //!
208 //! \sa \ref GPIO_writeMultiDio(), \ref GPIO_readDio(), \ref GPIO_readMultiDio()
209 //
210 //*****************************************************************************
211 __STATIC_INLINE void
GPIO_writeDio(uint32_t dioNumber,uint32_t value)212 GPIO_writeDio( uint32_t dioNumber, uint32_t value )
213 {
214 //
215 // Check the arguments.
216 //
217 ASSERT( dioNumberLegal( dioNumber ));
218 ASSERT(( value == 0 ) || ( value == 1 ));
219
220 //
221 // Write 0 or 1 to the byte indexed DOUT map
222 //
223 HWREGB( GPIO_BASE + dioNumber ) = value;
224 }
225
226 //*****************************************************************************
227 //
228 //! \brief Writes masked data to the specified DIOs.
229 //!
230 //! Enables for writing multiple bits simultaneously.
231 //! The value to write must be shifted so it matches the corresponding dioMask bits.
232 //!
233 //! \note Note that this is a read-modify-write operation and hence not atomic.
234 //!
235 //! \param dioMask is the bit-mask representation of the DIOs to write.
236 //! The parameter must be a bitwise OR'ed combination of the following:
237 //! - \ref GPIO_DIO_0_MASK
238 //! - ...
239 //! - \ref GPIO_DIO_31_MASK
240 //! \param bitVectoredValue holds the value to be written to the corresponding DIO-bits.
241 //!
242 //! \return None
243 //!
244 //! \sa \ref GPIO_writeDio(), \ref GPIO_readDio(), \ref GPIO_readMultiDio()
245 //
246 //*****************************************************************************
247 __STATIC_INLINE void
GPIO_writeMultiDio(uint32_t dioMask,uint32_t bitVectoredValue)248 GPIO_writeMultiDio( uint32_t dioMask, uint32_t bitVectoredValue )
249 {
250 //
251 // Check the arguments.
252 //
253 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
254
255 HWREG( GPIO_BASE + GPIO_O_DOUT31_0 ) =
256 ( HWREG( GPIO_BASE + GPIO_O_DOUT31_0 ) & ~dioMask ) |
257 ( bitVectoredValue & dioMask );
258 }
259
260 //*****************************************************************************
261 //
262 //! \brief Sets a specific DIO to 1 (high).
263 //!
264 //! \param dioNumber specifies the DIO to set (0-31).
265 //!
266 //! \return None
267 //!
268 //! \sa \ref GPIO_setMultiDio(), \ref GPIO_clearDio(), \ref GPIO_clearMultiDio()
269 //
270 //*****************************************************************************
271 __STATIC_INLINE void
GPIO_setDio(uint32_t dioNumber)272 GPIO_setDio( uint32_t dioNumber )
273 {
274 //
275 // Check the arguments.
276 //
277 ASSERT( dioNumberLegal( dioNumber ));
278
279 //
280 // Set the specified DIO.
281 //
282 HWREG( GPIO_BASE + GPIO_O_DOUTSET31_0 ) = ( 1 << dioNumber );
283 }
284
285 //*****************************************************************************
286 //
287 //! \brief Sets the specified DIOs to 1 (high).
288 //!
289 //! \param dioMask is the bit-mask representation of the DIOs to set.
290 //! The parameter must be a bitwise OR'ed combination of the following:
291 //! - \ref GPIO_DIO_0_MASK
292 //! - ...
293 //! - \ref GPIO_DIO_31_MASK
294 //!
295 //! \return None
296 //!
297 //! \sa \ref GPIO_setDio(), \ref GPIO_clearDio(), \ref GPIO_clearMultiDio()
298 //
299 //*****************************************************************************
300 __STATIC_INLINE void
GPIO_setMultiDio(uint32_t dioMask)301 GPIO_setMultiDio( uint32_t dioMask )
302 {
303 //
304 // Check the arguments.
305 //
306 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
307
308 //
309 // Set the DIOs.
310 //
311 HWREG( GPIO_BASE + GPIO_O_DOUTSET31_0 ) = dioMask;
312 }
313
314 //*****************************************************************************
315 //
316 //! \brief Clears a specific DIO to 0 (low).
317 //!
318 //! \param dioNumber specifies the DIO to clear (0-31).
319 //!
320 //! \return None
321 //!
322 //! \sa \ref GPIO_clearMultiDio(), \ref GPIO_setDio(), \ref GPIO_setMultiDio()
323 //
324 //*****************************************************************************
325 __STATIC_INLINE void
GPIO_clearDio(uint32_t dioNumber)326 GPIO_clearDio( uint32_t dioNumber )
327 {
328 //
329 // Check the arguments.
330 //
331 ASSERT( dioNumberLegal( dioNumber ));
332
333 //
334 // Clear the specified DIO.
335 //
336 HWREG( GPIO_BASE + GPIO_O_DOUTCLR31_0 ) = ( 1 << dioNumber );
337 }
338
339 //*****************************************************************************
340 //
341 //! \brief Clears the specified DIOs to 0 (low).
342 //!
343 //! \param dioMask is the bit-mask representation of the DIOs to clear.
344 //! The parameter must be a bitwise OR'ed combination of the following:
345 //! - \ref GPIO_DIO_0_MASK
346 //! - ...
347 //! - \ref GPIO_DIO_31_MASK
348 //!
349 //! \return None
350 //!
351 //! \sa \ref GPIO_clearDio(), \ref GPIO_setDio(), \ref GPIO_setMultiDio()
352 //
353 //*****************************************************************************
354 __STATIC_INLINE void
GPIO_clearMultiDio(uint32_t dioMask)355 GPIO_clearMultiDio( uint32_t dioMask )
356 {
357 //
358 // Check the arguments.
359 //
360 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
361
362 //
363 // Clear the DIOs.
364 //
365 HWREG( GPIO_BASE + GPIO_O_DOUTCLR31_0 ) = dioMask;
366 }
367
368 //*****************************************************************************
369 //
370 //! \brief Toggles a specific DIO.
371 //!
372 //! \param dioNumber specifies the DIO to toggle (0-31).
373 //!
374 //! \return None
375 //!
376 //! \sa \ref GPIO_toggleMultiDio()
377 //
378 //*****************************************************************************
379 __STATIC_INLINE void
GPIO_toggleDio(uint32_t dioNumber)380 GPIO_toggleDio( uint32_t dioNumber )
381 {
382 //
383 // Check the arguments.
384 //
385 ASSERT( dioNumberLegal( dioNumber ));
386
387 //
388 // Toggle the specified DIO.
389 //
390 HWREG( GPIO_BASE + GPIO_O_DOUTTGL31_0 ) = ( 1 << dioNumber );
391 }
392
393 //*****************************************************************************
394 //
395 //! \brief Toggles the specified DIOs.
396 //!
397 //! \param dioMask is the bit-mask representation of the DIOs to toggle.
398 //! The parameter must be a bitwise OR'ed combination of the following:
399 //! - \ref GPIO_DIO_0_MASK
400 //! - ...
401 //! - \ref GPIO_DIO_31_MASK
402 //!
403 //! \return None
404 //!
405 //! \sa \ref GPIO_toggleDio()
406 //
407 //*****************************************************************************
408 __STATIC_INLINE void
GPIO_toggleMultiDio(uint32_t dioMask)409 GPIO_toggleMultiDio( uint32_t dioMask )
410 {
411 //
412 // Check the arguments.
413 //
414 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
415
416 //
417 // Toggle the DIOs.
418 //
419 HWREG( GPIO_BASE + GPIO_O_DOUTTGL31_0 ) = dioMask;
420 }
421
422 //*****************************************************************************
423 //
424 //! \brief Gets the output enable status of a specific DIO.
425 //!
426 //! This function returns the output enable status for the specified DIO.
427 //! The DIO can be configured as either input or output under software control.
428 //!
429 //! \param dioNumber specifies the DIO to get the output enable setting from (0-31).
430 //!
431 //! \return Returns one of the enumerated data types (0 or 1):
432 //! - \ref GPIO_OUTPUT_DISABLE : DIO output is disabled.
433 //! - \ref GPIO_OUTPUT_ENABLE : DIO output is enabled.
434 //!
435 //! \sa \ref GPIO_getOutputEnableMultiDio(), \ref GPIO_setOutputEnableDio(), \ref GPIO_setOutputEnableMultiDio()
436 //
437 //*****************************************************************************
438 __STATIC_INLINE uint32_t
GPIO_getOutputEnableDio(uint32_t dioNumber)439 GPIO_getOutputEnableDio( uint32_t dioNumber )
440 {
441 //
442 // Check the arguments.
443 //
444 ASSERT( dioNumberLegal( dioNumber ));
445
446 //
447 // Return the output enable status for the specified DIO.
448 //
449 return (( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) >> dioNumber ) & 1 );
450 }
451
452 //*****************************************************************************
453 //
454 //! \brief Gets the output enable setting of the specified DIOs.
455 //!
456 //! This function returns the output enable setting for multiple DIOs.
457 //! The value returned is not shifted and hence matches the corresponding dioMask bits.
458 //!
459 //! \param dioMask is the bit-mask representation of the DIOs to return the output enable settings from.
460 //! The parameter must be a bitwise OR'ed combination of the following:
461 //! - \ref GPIO_DIO_0_MASK
462 //! - ...
463 //! - \ref GPIO_DIO_31_MASK
464 //!
465 //! \return Returns the output enable setting for multiple DIOs as a bit vector corresponding to the dioMask bits.
466 //! - 0 : Corresponding DIO is configured with output disabled.
467 //! - 1 : Corresponding DIO is configured with output enabled.
468 //!
469 //! \sa \ref GPIO_getOutputEnableDio(), \ref GPIO_setOutputEnableDio(), \ref GPIO_setOutputEnableMultiDio()
470 //
471 //*****************************************************************************
472 __STATIC_INLINE uint32_t
GPIO_getOutputEnableMultiDio(uint32_t dioMask)473 GPIO_getOutputEnableMultiDio( uint32_t dioMask )
474 {
475 //
476 // Check the arguments.
477 //
478 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
479
480 //
481 // Return the output enable value for the specified DIOs.
482 //
483 return ( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) & dioMask );
484 }
485
486 //*****************************************************************************
487 //
488 //! \brief Sets output enable of a specific DIO.
489 //!
490 //! This function sets the GPIO output enable bit for the specified DIO.
491 //! The DIO can be configured as either input or output under software control.
492 //!
493 //! \param dioNumber specifies the DIO to configure (0-31).
494 //! \param outputEnableValue specifies the output enable setting of the specified DIO:
495 //! - \ref GPIO_OUTPUT_DISABLE : DIO output is disabled.
496 //! - \ref GPIO_OUTPUT_ENABLE : DIO output is enabled.
497 //!
498 //! \return None
499 //!
500 //! \sa \ref GPIO_setOutputEnableMultiDio(), \ref GPIO_getOutputEnableDio(), \ref GPIO_getOutputEnableMultiDio()
501 //
502 //*****************************************************************************
503 __STATIC_INLINE void
GPIO_setOutputEnableDio(uint32_t dioNumber,uint32_t outputEnableValue)504 GPIO_setOutputEnableDio( uint32_t dioNumber, uint32_t outputEnableValue )
505 {
506 //
507 // Check the arguments.
508 //
509 ASSERT( dioNumberLegal( dioNumber ));
510 ASSERT(( outputEnableValue == GPIO_OUTPUT_DISABLE ) ||
511 ( outputEnableValue == GPIO_OUTPUT_ENABLE ) );
512
513 //
514 // Update the output enable bit for the specified DIO.
515 //
516 HWREGBITW( GPIO_BASE + GPIO_O_DOE31_0, dioNumber ) = outputEnableValue;
517 }
518
519 //*****************************************************************************
520 //
521 //! \brief Configures the output enable setting for all specified DIOs.
522 //!
523 //! This function configures the output enable setting for the specified DIOs.
524 //! The output enable setting must be shifted so it matches the corresponding dioMask bits.
525 //! The DIOs can be configured as either an input or output under software control.
526 //!
527 //! \note Note that this is a read-modify-write operation and hence not atomic.
528 //!
529 //! \param dioMask is the bit-mask representation of the DIOs on which to configure the
530 //! output enable setting. The parameter must be a bitwise OR'ed combination of the following:
531 //! - \ref GPIO_DIO_0_MASK
532 //! - ...
533 //! - \ref GPIO_DIO_31_MASK
534 //! \param bitVectoredOutputEnable holds the output enable setting the corresponding DIO-bits:
535 //! - 0 : Corresponding DIO is configured with output disabled.
536 //! - 1 : Corresponding DIO is configured with output enabled.
537 //!
538 //! \return None
539 //!
540 //! \sa \ref GPIO_setOutputEnableDio(), \ref GPIO_getOutputEnableDio(), \ref GPIO_getOutputEnableMultiDio()
541 //
542 //*****************************************************************************
543 __STATIC_INLINE void
GPIO_setOutputEnableMultiDio(uint32_t dioMask,uint32_t bitVectoredOutputEnable)544 GPIO_setOutputEnableMultiDio( uint32_t dioMask, uint32_t bitVectoredOutputEnable )
545 {
546 //
547 // Check the arguments.
548 //
549 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
550
551 HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) =
552 ( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) & ~dioMask ) |
553 ( bitVectoredOutputEnable & dioMask );
554 }
555
556 //*****************************************************************************
557 //
558 //! \brief Gets the event status of a specific DIO.
559 //!
560 //! \param dioNumber specifies the DIO to get the event status from (0-31).
561 //!
562 //! \return Returns the current event status on the specified DIO.
563 //! - 0 : Non-triggered event.
564 //! - 1 : Triggered event.
565 //!
566 //! \sa \ref GPIO_getEventMultiDio(), \ref GPIO_clearEventDio(), \ref GPIO_clearEventMultiDio()
567 //
568 //*****************************************************************************
569 __STATIC_INLINE uint32_t
GPIO_getEventDio(uint32_t dioNumber)570 GPIO_getEventDio( uint32_t dioNumber )
571 {
572 //
573 // Check the arguments.
574 //
575 ASSERT( dioNumberLegal( dioNumber ));
576
577 //
578 // Return the event status for the specified DIO.
579 //
580 return (( HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) >> dioNumber ) & 1 );
581 }
582
583 //*****************************************************************************
584 //
585 //! \brief Gets the event status of the specified DIOs.
586 //!
587 //! This function returns the event status for multiple DIOs.
588 //! The value returned is not shifted and hence matches the corresponding dioMask bits.
589 //!
590 //! \param dioMask is the bit-mask representation of the DIOs to get the
591 //! event status from (0-31).
592 //! The parameter must be a bitwise OR'ed combination of the following:
593 //! - \ref GPIO_DIO_0_MASK
594 //! - ...
595 //! - \ref GPIO_DIO_31_MASK
596 //!
597 //! \return Returns a bit vector with the current event status correspondig to the specified DIOs.
598 //! - 0 : Corresponding DIO has no triggered event.
599 //! - 1 : Corresponding DIO has a triggered event.
600 //!
601 //! \sa \ref GPIO_getEventDio(), \ref GPIO_clearEventDio(), \ref GPIO_clearEventMultiDio()
602 //
603 //*****************************************************************************
604 __STATIC_INLINE uint32_t
GPIO_getEventMultiDio(uint32_t dioMask)605 GPIO_getEventMultiDio( uint32_t dioMask )
606 {
607 //
608 // Check the arguments.
609 //
610 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
611
612 //
613 // Return the event status for the specified DIO.
614 //
615 return ( HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) & dioMask );
616 }
617
618 //*****************************************************************************
619 //
620 //! \brief Clears the IO event status of a specific DIO.
621 //!
622 //! \param dioNumber specifies the DIO on which to clear the event status (0-31).
623 //!
624 //! \return None
625 //!
626 //! \sa \ref GPIO_clearEventMultiDio(), \ref GPIO_getEventDio(), \ref GPIO_getEventMultiDio()
627 //
628 //*****************************************************************************
629 __STATIC_INLINE void
GPIO_clearEventDio(uint32_t dioNumber)630 GPIO_clearEventDio( uint32_t dioNumber )
631 {
632 //
633 // Check the arguments.
634 //
635 ASSERT( dioNumberLegal( dioNumber ));
636
637 //
638 // Clear the event status for the specified DIO.
639 //
640 HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) = ( 1 << dioNumber );
641 }
642
643 //*****************************************************************************
644 //
645 //! \brief Clears the IO event status on the specified DIOs.
646 //!
647 //! \param dioMask is the bit-mask representation of the DIOs on which to
648 //! clear the events status.
649 //! The parameter must be a bitwise OR'ed combination of the following:
650 //! - \ref GPIO_DIO_0_MASK
651 //! - ...
652 //! - \ref GPIO_DIO_31_MASK
653 //!
654 //! \return None
655 //!
656 //! \sa \ref GPIO_clearEventDio(), \ref GPIO_getEventDio(), \ref GPIO_getEventMultiDio()
657 //
658 //*****************************************************************************
659 __STATIC_INLINE void
GPIO_clearEventMultiDio(uint32_t dioMask)660 GPIO_clearEventMultiDio( uint32_t dioMask )
661 {
662 //
663 // Check the arguments.
664 //
665 ASSERT( dioMask & GPIO_DIO_ALL_MASK );
666
667 //
668 // Clear the event status for the specified DIOs.
669 //
670 HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) = dioMask;
671 }
672
673 //*****************************************************************************
674 //
675 // Mark the end of the C bindings section for C++ compilers.
676 //
677 //*****************************************************************************
678 #ifdef __cplusplus
679 }
680 #endif
681
682 #endif // __GPIO_H__
683
684 //*****************************************************************************
685 //
686 //! Close the Doxygen group.
687 //! @}
688 //! @}
689 //
690 //*****************************************************************************
691