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