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