summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/altera-cyclone-v/hwlib/include/alt_generalpurpose_io.h
blob: 0a7abaef8e953715fed261e6fd9865979c214481 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
/*! \file
 *  Altera - GPIO Module
 */

/******************************************************************************
*
* Copyright 2013 Altera Corporation. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
******************************************************************************/

#ifndef __ALT_GPIO_H__
#define __ALT_GPIO_H__

#include <stdint.h>
#include "hwlib.h"

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

#define     ALT_GPIO_BITMASK                0x1FFFFFFF

/* If the GPIO special test mode flag was not defined in the makefile,   */
    /* set the ALT_GPIO_DATAREAD_TEST_MODE flag to false to specify that     */
    /* the production code version of alt_gpio_port_data_read() is included. */
    /* If the flag is defined as true in the makefile, then the test version */
    /* located in the test code file is substituted instead of the version   */
    /* in this file.                                                         */
#ifndef     ALT_GPIO_DATAREAD_TEST_MODE
#define     ALT_GPIO_DATAREAD_TEST_MODE     false
#endif

/******************************************************************************/
/*! \addtogroup ALT_GPIO_API The General Purpose Input/Output Manager API
 *
 * This module defines the General Purpose Input/Output Manager API for
 * accessing, configuring, and controlling the General Purpose Input/Output
 * Manager resources. These include both the general-purpose GPIO signals and
 * the input-only GPI signals that are shared with the DDR interface.\n \n
 * The GPIO API presents two views or perspectives of the GPIO signals. The first
 * is to view the GPIO signals in a traditional way, as separate GPIO ports
 * each comprised of a number of GPIO bits. The second perspective is of a
 * unified flat view that presents the GPIO and GPI signals as a set of indexed
 * bits, a view that allows the programmer to mostly ignore the port and pin
 * hardware configuration and read/write/configure the GPIO and GPI signals
 * independently of the underlying hardware implementation.
 *
 * @{
 */

/******************************************************************************/
/*! \addtogroup ALT_GPIO_API_CONFIG General-Purpose IO Configuration Functions
 *
 * This functional group contains functions to control, configure and manage
 * the general-purpose IO signals as individual signals or as groups of signals.
 * This group of functions can operate on multiple bits within the same GPIO
 * port and accepts a bit mask to specify which bits an operation will operate on.
 * Other bits within the same GPIO port are not changed.
 *
 * This example shows how multiple drivers or applications can use this feature
 * to easily prevent conflict while accessing the same GPIO port:
 * \verbatim
 #define DRIVER_0_GPIO_MSK   0x0010FF03;
 #define DRIVER_1_GPIO_MSK   0x002000F8;
 #define DRIVER_2_GPIO_MSK   0x03C00004;
 #define DRIVER_3_GPIO_MSK   0x000F0000;

    alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_0_GPIO_MSK, init_val0);
    alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_1_GPIO_MSK, init_val1);
    alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_2_GPIO_MSK, init_val2);
    alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_3_GPIO_MSK, init_val3);
    alt_gpio_port_int_type_set(ALT_GPIO_PORTA, DRIVER_1_GPIO_MSK, config_val1);
 \endverbatim
 *
 *  @{
 */
/******************************************************************************/
/*!
 * This type definition enumerates the data direction (input or output) of
 * the GPIO signals.
 */

typedef enum ALT_GPIO_PIN_DIR_e
{
    /*! # */
    ALT_GPIO_PIN_INPUT,
    /*! # */
    ALT_GPIO_PIN_OUTPUT
} ALT_GPIO_PIN_DIR_t;

/******************************************************************************/
/*!
 * This type definition enumerates the type of interrupt source
 * (level-triggered or edge-triggered) of the GPIO signals.
 */

typedef enum ALT_GPIO_PIN_TYPE_e
{
    /*! # */
    ALT_GPIO_PIN_LEVEL_TRIG_INT,
    /*! # */
    ALT_GPIO_PIN_EDGE_TRIG_INT
} ALT_GPIO_PIN_TYPE_t;

/******************************************************************************/
/*!
 * This type definition enumerates the polarity of the interrupt sources
 * (falling-edge or rising-edge for edge-triggered interrupts, active-low or
 * active-high for level-triggered interrupts) of the GPIO signals.
 */

typedef enum ALT_GPIO_PIN_POL_e
{
    /*! Indicates active-low for level-triggered interrupts and
     * falling-edge for edge-triggered interrupts */
    ALT_GPIO_PIN_ACTIVE_LOW,

    /*! Indicates active-high for level-triggered interrupts and
     * rising-edge for edge-triggered interrupt */
    ALT_GPIO_PIN_ACTIVE_HIGH
} ALT_GPIO_PIN_POL_t;

/******************************************************************************/
/*!
 * This type definition enumerates whether or not the debounce metastability
 * flip-flops are inserted or not. These are used to debounce signals presented
 * to the GPIO inputs. A signal must be steady for two periods of the
 * gpio_db_clk clock before it is considered valid. The frequency of the
 * gpio_db_clk clock may be set using the Clock Manager API.
 */

typedef enum ALT_GPIO_PIN_DEBOUNCE_e
{
    /*! # */
    ALT_GPIO_PIN_NODEBOUNCE,
    /*! # */
    ALT_GPIO_PIN_DEBOUNCE
} ALT_GPIO_PIN_DEBOUNCE_t;

/******************************************************************************/
/*!
 * This type definition enumerates whether or not level-sensitive interrupts
 * are synchronized to the internal pclk_intr clock. It has no effect for GPIO
 * signals that are selected as outputs, or if the interrupt is not enabled,
 * or if the interrupt is set to be edge-triggered. This is a port-wide option.
 */

typedef enum ALT_GPIO_PIN_SYNC_e
{
    /*! # */
    ALT_GPIO_PIN_NOSYNC,
    /*! # */
    ALT_GPIO_PIN_SYNC
} ALT_GPIO_PIN_SYNC_t;

/******************************************************************************/
/*!
 * This type definition enumerates the possible data states of the GPIO bits.
 */

typedef enum ALT_GPIO_PIN_DATA_e
{
    /*! # */
    ALT_GPIO_PIN_DATAZERO,
    /*! # */
    ALT_GPIO_PIN_DATAONE
} ALT_GPIO_PIN_DATA_t;


/******************************************************************************/
/*!
 * This type definition enumerates the GPIO ports that the GPIO manager
 * handles.
 */

typedef enum ALT_GPIO_PORT_e
{
    /*!
     * \b Port \b A - 29-bit GPIO port A.
     */
    ALT_GPIO_PORTA,

    /*!
     * \b Port \b B - 29-bit GPIO port B.
     */
    ALT_GPIO_PORTB,

    /*!
     * \b Port \b C - 29-bit GPIO port C. \n 13 bits are used for GPIO signals,
     *                14 bits are used for GPI-only signals that are shared
     *                with the DDR interface, 2 bits are not used. Some signals
     *                may not be connected on some versions. See the relevant
     *                pin mux data.
     */
    ALT_GPIO_PORTC,

    /*!
     * \b Unknown \b Port - Used to indicate an error.
     */
    ALT_GPIO_PORT_UNKNOWN
} ALT_GPIO_PORT_t;


/******************************************************************************/
/*!
 * This type definition enumerates the individual bits within the GPIO ports
 * used by the GPIO manager. The bit-ordering must match the hardware
 * bit-ordering. Since the ordering and packing of bitfields is not
 * standardized in C/C++, the following are defined as masks. \n
 * For example, to set bits 3 and 4 of GPIO port B outputs (assuming the bits
 * had previously been set to outputs), the user could use the syntax: \par
 * \b alt_gpio_port_data_write(\b ALT_GPIO_PORTB, \b ALT_GPIO_BIT3 \b | \b
 * ALT_GPIO_BIT4);
 */

typedef enum ALT_GPIO_PORTBIT_e
{
    /*! # */
    ALT_GPIO_BIT0 = ALT_TWO_TO_POW0,
    /*! # */
    ALT_GPIO_BIT1 = ALT_TWO_TO_POW1,
    /*! # */
    ALT_GPIO_BIT2 = ALT_TWO_TO_POW2,
    /*! # */
    ALT_GPIO_BIT3 = ALT_TWO_TO_POW3,
    /*! # */
    ALT_GPIO_BIT4 = ALT_TWO_TO_POW4,
    /*! # */
    ALT_GPIO_BIT5 = ALT_TWO_TO_POW5,
    /*! # */
    ALT_GPIO_BIT6 = ALT_TWO_TO_POW6,
    /*! # */
    ALT_GPIO_BIT7 = ALT_TWO_TO_POW7,
    /*! #  */
    ALT_GPIO_BIT8 = ALT_TWO_TO_POW8,
    /*! # */
    ALT_GPIO_BIT9 = ALT_TWO_TO_POW9,
    /*! # */
    ALT_GPIO_BIT10 = ALT_TWO_TO_POW10,
    /*! # */
    ALT_GPIO_BIT11 = ALT_TWO_TO_POW11,
    /*! # */
    ALT_GPIO_BIT12 = ALT_TWO_TO_POW12,
    /*! # */
    ALT_GPIO_BIT13 = ALT_TWO_TO_POW13,
    /*! # */
    ALT_GPIO_BIT14 = ALT_TWO_TO_POW14,
    /*! # */
    ALT_GPIO_BIT15 = ALT_TWO_TO_POW15,
    /*! # */
    ALT_GPIO_BIT16 = ALT_TWO_TO_POW16,
    /*! # */
    ALT_GPIO_BIT17 = ALT_TWO_TO_POW17,
    /*! # */
    ALT_GPIO_BIT18 = ALT_TWO_TO_POW18,
    /*! # */
    ALT_GPIO_BIT19 = ALT_TWO_TO_POW19,
    /*! # */
    ALT_GPIO_BIT20 = ALT_TWO_TO_POW20,
    /*! # */
    ALT_GPIO_BIT21 = ALT_TWO_TO_POW21,
    /*! # */
    ALT_GPIO_BIT22 = ALT_TWO_TO_POW22,
    /*! # */
    ALT_GPIO_BIT23 = ALT_TWO_TO_POW23,
    /*! # */
    ALT_GPIO_BIT24 = ALT_TWO_TO_POW24,
    /*! # */
    ALT_GPIO_BIT25 = ALT_TWO_TO_POW25,
    /*! # */
    ALT_GPIO_BIT26 = ALT_TWO_TO_POW26,
    /*! # */
    ALT_GPIO_BIT27 = ALT_TWO_TO_POW27,
    /*! # */
    ALT_GPIO_BIT28 = ALT_TWO_TO_POW28,
    ALT_GPIO_BIT29 = ALT_TWO_TO_POW29,              /* Not currently used */
    ALT_GPIO_BIT30 = ALT_TWO_TO_POW30,              /* Not currently used */
    ALT_GPIO_BIT31 = (int32_t) (1UL<<31),           /* Not currently used */

    ALT_GPIO_BITNUM_MAX = (28),
    ALT_GPIO_BIT_MAX = (1 << ALT_GPIO_BITNUM_MAX),
    ALT_END_OF_GPIO_PORT_SIGNALS = (32)
} ALT_GPIO_PORTBIT_t;



/******************************************************************************/
/*!
 * Initialize the GPIO modules before use
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 */
ALT_STATUS_CODE alt_gpio_init(void);

/******************************************************************************/
/*!
 * Uninitialize the GPIO modules & return to reset state
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 */
ALT_STATUS_CODE alt_gpio_uninit(void);

/******************************************************************************/
/*!
 * Sets the specified GPIO data bits to use the data direction(s)
 * specified.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to apply this
 *              operation to. Other bits (where mask bits equal zero) are
 *              not changed. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to
 *              configure all data direction bits of the port.
 * \param       config
 *              The data-directions of the bits to be set in this operation.
 *              Individual bits are: \n \b 0 - Use as an input (default). \n
 *              \b 1 - Use as an output.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Bad input argument.
 */
ALT_STATUS_CODE alt_gpio_port_datadir_set(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, uint32_t config);

/******************************************************************************/
/*!
 * Returns the data direction configuration of selected bits of the
 * specified GPIO module.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to read and
 *              return. Other bits (where mask bits equal zero) are returned
 *              as zero. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to
 *              return all data direction bits of the port.
 *
 * \retval      uint32_t \n Individual bits are: \n \b 0 - The signal is
 *              configured as an input.
 *              \n \b 1 - The signal is configured as an output.
 *
 */
uint32_t alt_gpio_port_datadir_get(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask);

/******************************************************************************/
/*!
 * Sets the GPIO data outputs of the specified GPIO module to a logic one or
 * zero. Outputs are only set if the data direction for those bits is also
 * set to configure them as outputs.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (mask bits equal one) to apply this
 *              operation to. Other bits (mask bits equal zero) are
 *              not changed.
 * \param       val
 *              The 32-bit word to write to the GPIO outputs. Only the 29 LSBs
 *              are used. Setting the three MSBs causes an error.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Bad input argument.
 */
ALT_STATUS_CODE alt_gpio_port_data_write(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, uint32_t val);

/******************************************************************************/
/*!
 * Returns the value of the data inputs of the specified GPIO module. This is
 * the current logic value of the pin, whether set to be an input or an output.
 * \n If a given signal is set to be an output, this input value can be read to
 * determine if the pin is grounded, pulled high, or is floating.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to return. Other
 *              bits (where mask bits equal zero) are returned as zero. Specify
 *              mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all data bits of
 *              the port.
 *
 * \retval      uint32_t   The current value of the GPIO module input signals.
 */
uint32_t alt_gpio_port_data_read(ALT_GPIO_PORT_t gpio_pid, uint32_t mask);


/*! @} */
/******************************************************************************/
/*! \addtogroup ALT_GPIO_INT General-Purpose IO Interrupt Functions
 *
 * This functional group contains functions to control and manage the
 * interrupts of the General-Purpose IO modules.
 *
 * @{
 */
/******************************************************************************/
/*!
 * Sets edge-triggered or level-triggered interrupt configuration for the
 * specified signals of the specified GPIO module.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to apply this
 *              operation to. Other bits (where mask bits equal zero) are
 *              not changed. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to
 *              configure all interrupt type bits of the port.
 * \param       config
 *              The interrupt configuration to write. Individual bits
 *              are: \n \b 0 - Set the
 *              interrupt for this bit to be level-sensitive (default). \n \b
 *              1 - Set the interrupt for this bit to be edge-sensitive.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input data.
 */
ALT_STATUS_CODE alt_gpio_port_int_type_set(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, uint32_t config);

/******************************************************************************/
/*!
 * Returns the interrupt configuration (edge-triggered or level-triggered) for
 * the specified bits of the specified GPIO module.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to return. Other
 *              bits (where mask bits equal zero) are returned as zero. Specify
 *              mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all configuration
 *              bits of the port.
 * \retval      uint32_t
 *              The current interrupt source configuration. Individual bits
 *              are: \n \b 0 - The interrupt for this bit is set to be
 *              level-sensitive. \n \b 1 -
 *              The interrupt for this bit is set to be edge-sensitive.
 *
 */
uint32_t alt_gpio_port_int_type_get(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask);

/******************************************************************************/
/*!
 * Sets the interrupt polarity of the signals of the specified GPIO register
 * (when used as inputs) to active-high or active-low (for level-sensitive
 * interrupts) or to rising-edge or falling-edge (for edge-sensitive interrupts).
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to apply this
 *              operation to. Other bits (where mask bits equal zero) are
 *              not changed.
 * \param       config
 *              The interrupt polarity configuration to set. Individual bits
 *              are: \n \b 0 - Set the interrupt polarity for this bit to
 *              active-low or falling-edge mode (default). \n \b 1 - Set the
 *              interrupt polarity for this bit to active-high or rising-edge mode.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input data.
 */
ALT_STATUS_CODE alt_gpio_port_int_pol_set(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, uint32_t config);

/******************************************************************************/
/*!
 * Returns the active-high or active-low polarity configuration for the
 * possible interrupt sources of the specified GPIO module.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to return. Other
 *              bits (where mask bits equal zero) are returned as zero. Specify
 *              mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all the
 *              configuration bits of the port.
 *
 * \retval      uint32_t
 *              The current polarity configuration. Individual bits are: \n
 *              \b 0 = The interrupt polarity for this bit is set to
 *              active-low or falling-edge mode. \n \b 1 = The interrupt
 *              polarity for this bit is set to active-high or rising-edge mode.
 *
 */
uint32_t alt_gpio_port_int_pol_get(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask);


/*! @} */
/******************************************************************************/
/*! \addtogroup ALT_GPIO_API_CONFIG General-Purpose IO Configuration Functions
 *
 * @{
 */
/******************************************************************************/
/*!
 * Sets the debounce configuration for input signals of the specified GPIO
 * module. If debounce is selected, metastability flip-flops are inserted to
 * debounce signals presented to the GPIO inputs. A signal must be steady for
 * two periods of the gpio_db_clk clock before it is considered valid. The
 * frequency of the gpio_db_clk clock may be set using the Clock Manager API.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to apply this
 *              operation to. Other bits (where mask bits equal zero) are
 *              not changed. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to
 *              configure the debounce setting for all bits of the port.
 * \param       config
 *              The debounce configuration to set. Individual bits are: \n
 *              \b 0 - Debounce is not selected for this signal (default). \n
 *              \b 1 - Debounce is selected for this signal.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input data.
 */
ALT_STATUS_CODE alt_gpio_port_debounce_set(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, uint32_t config);

/******************************************************************************/
/*!
 * Returns the debounce configuration for the input signals of the specified
 * GPIO register. If debounce is selected, metastability flip-flops are
 * inserted to debounce signals presented to the GPIO inputs.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits (where mask bits equal one) to return. Other
 *              bits (where mask bits equal zero) are returned as zero. Specify
 *              mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all debounce
 *              configuration bits of the port.
 *
 * \retval      uint32_t
 *              The current debounce configuration.Individual bits are: \n
 *              \b 0 - Debounce is not selected for this signal. \n \b 1 -
 *              Debounce is selected for this signal.
 *
 */
uint32_t alt_gpio_port_debounce_get(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask);

/******************************************************************************/
/*!
 * Sets the synchronization configuration for the signals of the specified
 * GPIO register. This allows for synchronizing level-sensitive interrupts to
 * an internal clock signal. This is a port-wide option that controls all
 * level-sensitive interrupt signals of that GPIO port.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       config
 *              \n \b Any \b non-zero \b value - Synchronize to internal clock signal.
 *              \n \b Zero - Do not synchronize to internal clock signal.
 *
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input data.
 */
ALT_STATUS_CODE alt_gpio_port_sync_set(ALT_GPIO_PORT_t gpio_pid,
        uint32_t config);

/******************************************************************************/
/*!
 *
 * Returns the synchronization configuration for the signals of the
 * specified GPIO register. This allows for synchronizing level-sensitive
 * interrupts to the internal clock signal. This is a port-wide option that
 * controls all level-sensitive interrupt signals of that GPIO port.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.


 * \retval      ALT_E_TRUE      Synchronization to clock is enabled for
 *                              level-sensitive interrupts.
 * \retval      ALT_E_FALSE     Synchronization to clock is disabled for
 *                              level-sensitive interrupts.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.
 */
ALT_STATUS_CODE alt_gpio_port_sync_get(ALT_GPIO_PORT_t gpio_pid);

/******************************************************************************/
/*!
 * Configures a group of GPIO signals with identical setup parameters. Allows
 * for configuring all parameters of a given port at one time.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              The group of bits to apply this operation to. Other bits (mask
 *              set to zero) are not changed.
 * \param       dir
 *              Data direction.
 * \param       type
 *              Edge-triggered or level-triggered interrupts.
 * \param       pol
 *              Active-high or active-low polarity.
 * \param       debounc
 *              Debounce signals or not.
 * \param       data
 *              Set the data output to this value.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.

 */
ALT_STATUS_CODE alt_gpio_port_config(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, ALT_GPIO_PIN_DIR_t dir, ALT_GPIO_PIN_TYPE_t type,
        ALT_GPIO_PIN_POL_t pol, ALT_GPIO_PIN_DEBOUNCE_t debounc,
        uint32_t data);

/*! @} */
/******************************************************************************/
/*! \addtogroup ALT_GPIO_INT General-Purpose IO Interrupt Functions
 *
 *  @{
 */
/******************************************************************************/
/*!
 * Enables the specified GPIO data input interrupts.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       config
 *              Individual bit interrupt enables \n
 *              \b 0 - Interrupt disabled. \n
 *              \b 1 - Interrupt enabled.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Bad input argument.
 */
ALT_STATUS_CODE alt_gpio_port_int_enable(ALT_GPIO_PORT_t gpio_pid, uint32_t config);

/******************************************************************************/
/*!
 * Disables the specified GPIO data module interrupt.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       config
 *              Individual bit interrupt enables \n
 *              \b 0 - Interrupt disabled. \n
 *              \b 1 - Interrupt enabled.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Bad input argument.
 */
ALT_STATUS_CODE alt_gpio_port_int_disable(ALT_GPIO_PORT_t gpio_pid, uint32_t config);

/******************************************************************************/
/*!
 *  Returns the current state of the specified GPIO port interrupts enables.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 *
 * \retval      uint32_t
 *              The interrupt enable configuration that was read. Individual bits
 *              are: \n \b 0 = The interrupt for this bit is not enabled. \n \b
 *              1 = The interrupt for this bit is enabled.
 */
uint32_t alt_gpio_port_int_enable_get(ALT_GPIO_PORT_t gpio_pid);


/******************************************************************************/
/*!
 * Masks or unmasks selected interrupt source bits of the data register of
 * the specified GPIO module. Uses a second bit mask to determine which
 * signals may be changed by this call.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       mask
 *              Which bits to change among the port \n \b 0 =
 *              Do not change this bit. \n \b 1 = Allow this bit to change.
 * \param       val
 *              The interrupt mask to write. Individual bits are: \n \b 0 =
 *              Do not mask the interrupt for this bit (default). \n \b 1 =
 *              Mask the interrupt for this bit.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input data.
 */
ALT_STATUS_CODE alt_gpio_port_int_mask_set(ALT_GPIO_PORT_t gpio_pid,
        uint32_t mask, uint32_t val);

/******************************************************************************/
/*!
 * Returns the interrupt mask of the specified GPIO module.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 *
 * \retval      uint32_t
 *              The interrupt mask that was read. Individual bits are: \n
 *              \b 0 = The interrupt for this bit is not masked. \n \b 1 = The
 *              interrupt for this bit is masked.
 *
 */
uint32_t alt_gpio_port_int_mask_get(ALT_GPIO_PORT_t gpio_pid);

/******************************************************************************/
/*!
 * Returns the interrupt pending status of all signals of the specified GPIO
 * register.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.

 * \retval      uint32_t
 *              The current interrupt pending status. Individual bits are: \n
 *              \b 0 - The interrupt for this bit is not pending. \n \b 1 -
 *              The interrupt for this bit is pending.
 *
 */
uint32_t alt_gpio_port_int_status_get(ALT_GPIO_PORT_t gpio_pid);

/******************************************************************************/
/*!
 * Clear the interrupt pending status of selected signals of the
 * specified GPIO register.
 *
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 * \param       clrmask
 *              The interrupt bits to clear. Individual bits are: \n \b 0 -
 *              The interrupt for this bit will not be changed. \n \b 1 -
 *              The interrupt for this bit will be cleared.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input data.
 */
ALT_STATUS_CODE alt_gpio_port_int_status_clear(ALT_GPIO_PORT_t gpio_pid,
        uint32_t clrmask);

/*! @} */

/******************************************************************************/
/*! \addtogroup ALT_GPIO_BITVIEW General-Purpose IO via Bit Index
 *
 * This functional group presents a perspective of the General-Purpose IO
 * signals as individual GPIO and GPI bits spread across a number of signals
 * across several GPIO ports. This allows the programmer the freedom to generally
 * ignore the underlying port and signal structure of the GPIO hardware if
 * desired.
 *
 * @{
 */
/******************************************************************************/
/*!
 * This type definition enumerates the individual bits as one flat array spread
 * across the multiple GPIO ports handled by the GPIO manager. The bit-ordering
 * must match the hardware bit-ordering.
 *
 */
typedef enum ALT_GPIO_1BIT_e
{
    /*! # */
    ALT_GPIO_1BIT_0,
    /*! # */
    ALT_GPIO_1BIT_1,
    /*! # */
    ALT_GPIO_1BIT_2,
    /*! # */
    ALT_GPIO_1BIT_3,
    /*! # */
    ALT_GPIO_1BIT_4,
    /*! # */
    ALT_GPIO_1BIT_5,
    /*! # */
    ALT_GPIO_1BIT_6,
    /*! # */
    ALT_GPIO_1BIT_7,
    /*! # */
    ALT_GPIO_1BIT_8,
    /*! # */
    ALT_GPIO_1BIT_9,
    /*! # */
    ALT_GPIO_1BIT_10,
    /*! # */
    ALT_GPIO_1BIT_11,
    /*! # */
    ALT_GPIO_1BIT_12,
    /*! # */
    ALT_GPIO_1BIT_13,
    /*! # */
    ALT_GPIO_1BIT_14,
    /*! # */
    ALT_GPIO_1BIT_15,
    /*! # */
    ALT_GPIO_1BIT_16,
    /*! # */
    ALT_GPIO_1BIT_17,
    /*! # */
    ALT_GPIO_1BIT_18,
    /*! # */
    ALT_GPIO_1BIT_19,
    /*! # */
    ALT_GPIO_1BIT_20,
    /*! # */
    ALT_GPIO_1BIT_21,
    /*! # */
    ALT_GPIO_1BIT_22,
    /*! # */
    ALT_GPIO_1BIT_23,
    /*! # */
    ALT_GPIO_1BIT_24,
    /*! # */
    ALT_GPIO_1BIT_25,
    /*! # */
    ALT_GPIO_1BIT_26,
    /*! # */
    ALT_GPIO_1BIT_27,
    /*! # */
    ALT_GPIO_1BIT_28,
    /*! # */
    ALT_GPIO_1BIT_29,
    /*! # */
    ALT_GPIO_1BIT_30,
    /*! # */
    ALT_GPIO_1BIT_31,
    /*! # */
    ALT_GPIO_1BIT_32,
    /*! # */
    ALT_GPIO_1BIT_33,
    /*! # */
    ALT_GPIO_1BIT_34,
    /*! # */
    ALT_GPIO_1BIT_35,
    /*! # */
    ALT_GPIO_1BIT_36,
    /*! # */
    ALT_GPIO_1BIT_37,
    /*! # */
    ALT_GPIO_1BIT_38,
    /*! # */
    ALT_GPIO_1BIT_39,
    /*! # */
    ALT_GPIO_1BIT_40,
    /*! # */
    ALT_GPIO_1BIT_41,
    /*! # */
    ALT_GPIO_1BIT_42,
    /*! # */
    ALT_GPIO_1BIT_43,
    /*! # */
    ALT_GPIO_1BIT_44,
    /*! # */
    ALT_GPIO_1BIT_45,
    /*! # */
    ALT_GPIO_1BIT_46,
    /*! # */
    ALT_GPIO_1BIT_47,
    /*! # */
    ALT_GPIO_1BIT_48,
    /*! # */
    ALT_GPIO_1BIT_49,
    /*! # */
    ALT_GPIO_1BIT_50,
    /*! # */
    ALT_GPIO_1BIT_51,
    /*! # */
    ALT_GPIO_1BIT_52,
    /*! # */
    ALT_GPIO_1BIT_53,
    /*! # */
    ALT_GPIO_1BIT_54,
    /*! # */
    ALT_GPIO_1BIT_55,
    /*! # */
    ALT_GPIO_1BIT_56,
    /*! # */
    ALT_GPIO_1BIT_57,
    /*! # */
    ALT_GPIO_1BIT_58,
    /*! # */
    ALT_GPIO_1BIT_59,
    /*! # */
    ALT_GPIO_1BIT_60,
    /*! # */
    ALT_GPIO_1BIT_61,
    /*! # */
    ALT_GPIO_1BIT_62,
    /*! # */
    ALT_GPIO_1BIT_63,
    /*! # */
    ALT_GPIO_1BIT_64,
    /*! # */
    ALT_GPIO_1BIT_65,
    /*! # */
    ALT_GPIO_1BIT_66,
    /*! # */
    ALT_GPIO_1BIT_67,        /* Not bonded out on some versions */
    /*! # */
    ALT_GPIO_1BIT_68,        /* Not bonded out on some versions */
    /*! # */
    ALT_GPIO_1BIT_69,        /* Not bonded out on some versions */

    /*! The last of the input/output bits */
    ALT_GPIO_1BIT_70,        /* Not bonded out on some versions */


    /*! This and the following signals are not present on all SoCs. \n
     * If present, the selection between their use as 14 General-purpose inputs or
     * use as 14 DDR interface signals is made in the IOCSR (IO Configuration Shift
     * Register) and software to make this selection is in the IO Manager API. If
     * they are present, they are restricted to using the same power supply voltage
     * as the SDRAM module.*/
    ALT_HLGPI_0,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_1,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_2,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_3,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_4,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_5,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_6,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_7,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_8,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_9,        /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_10,       /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_11,       /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_12,       /* Not bonded out on some versions */
    /*! # */
    ALT_HLGPI_13,       /* Not bonded out on some versions */

    ALT_HLGPI_14,       /* Not bonded out */

    ALT_HLGPI_15,       /* Not bonded out */

    ALT_GPIO_INVALID,
    ALT_END_OF_GPIO_SIGNALS = -1,
    ALT_LAST_VALID_GPIO_BIT = ALT_HLGPI_15
} ALT_GPIO_1BIT_t;


/******************************************************************************/
/*!
 * This configuration record definition is used for configuring bits and
 * groups of bits of the GPIO interface.
 */
typedef struct ALT_GPIO_CONFIG_RECORD_s
{
    /*!
     * The index number of the signal to configure. */
    ALT_GPIO_1BIT_t             signal_number;
    /*!
     * The data direction of the signal. */
    ALT_GPIO_PIN_DIR_t          direction;
    /*!
     * Edge-triggered or level triggered interrupts. */
    ALT_GPIO_PIN_TYPE_t         type;
    /*!
     * Active-high or active-low trigger for the interrupt. */
    ALT_GPIO_PIN_POL_t          polarity;
    /*!
     * Enable or disable GPIO debounce capability. */
    ALT_GPIO_PIN_DEBOUNCE_t     debounce;
    /*!
     * If the signal is an output, the data value to be output. */
    ALT_GPIO_PIN_DATA_t         data;
} ALT_GPIO_CONFIG_RECORD_t;

/******************************************************************************/
/*!
 * This pin record type definition is comprised of the signal index and
 * associated input or output data.
 */
typedef struct ALT_GPIO_PIN_RECORD_s
{
    /*!
     * The index number of the signal. */
    ALT_GPIO_1BIT_t         signal_number;
    /*!
     * Data - zero or one. */
    ALT_GPIO_PIN_DATA_t     val;
} ALT_GPIO_PIN_RECORD_t;

/*! @} */

/******************************************************************************/
/*! \addtogroup ALT_GPIO_BITVIEW General-Purpose IO via Bit Index
 *
 * @{
 */
/******************************************************************************/
/*!
 * Configures all parameters for one bit (signal) of the GPIO ports.
 *
 * \param       signal_num
 *              The GPIO port signal index.
 * \param       dir
 *              The data direction for this signal.
 * \param       type
 *              Edge-triggered or Level-triggered interrupt for this signal.
 * \param       pol
 *              Active-high or active-low interrupt polarity for this signal.
 * \param       debounce
 *              Enable the debounce flip-flops for this signal or not.
 * \param       data
 *              If the GPIO signal is set to be an output, set it to
 *              this value
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.
 */
ALT_STATUS_CODE alt_gpio_bit_config(ALT_GPIO_1BIT_t signal_num,
        ALT_GPIO_PIN_DIR_t dir, ALT_GPIO_PIN_TYPE_t type,
        ALT_GPIO_PIN_POL_t pol, ALT_GPIO_PIN_DEBOUNCE_t debounce,
        ALT_GPIO_PIN_DATA_t data);

/******************************************************************************/
/*!
 * Returns the configuration parameters of a given GPIO bit.
 *
 * \param       signal_num
 *              The GPIO port signal index.
 * \param       config
 *              Pointer to a single GPIO_CONFIG_RECORD_s configuration record.
 *              The fields of this configuration record are filled in
 *              by the function.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.

 */
ALT_STATUS_CODE alt_gpio_bitconfig_get(ALT_GPIO_1BIT_t signal_num,
        ALT_GPIO_CONFIG_RECORD_t *config);

/******************************************************************************/
/*!
 * Configures a list of GPIO bits. The GPIO bits do not have to be
 * configured the same, as was the case for the mask version of this function,
 * alt_gpio_port_config(). Each bit may be configured differently and bits may
 * be listed in any order.
 *
 * \param       config_array
 *              Pointer to an array of GPIO_CONFIG_RECORD_s configuration
 *              records. These definitions contain all the parameters
 *              needed to set up the listed pins. All or
 *              any subset of the GPIO signals can be configured. Signals do
 *              not have to be listed in numerical order or be unique. If a
 *              signal number is listed multiple times, the last configuration
 *              listed is used. \n Configuration terminates either when \b len
 *              signals have been configured or if the next signal number index
 *              in the array is equal to \b ALT_END_OF_GPIO_SIGNALS (-1).
 *
 * \param       len
 *              Length of array to configure.
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.

 */
ALT_STATUS_CODE alt_gpio_group_config(ALT_GPIO_CONFIG_RECORD_t* config_array,
        uint32_t len);

/******************************************************************************/
/*!
 * Returns a list of the pin signal indices and the associated configuration
 * settings (data direction, interrupt type, polarity, and debounce) of that
 * list of signals.
 *
 * \param       config_array
 *              Pointer to an array of ALT_GPIO_CONFIG_RECORD_t configuration
 *              records. Only the signal indices in the first field of each
 *              configuration record need be filled in. This function will
 *              fill in all the other fields of the configuration record,
 *              returning all configuration parameters in the array.
 *              Signals do not have to be listed in numerical order or be
 *              unique. If a signal number is listed multiple times, the
 *              configuration record will contain multiple entries for
 *              that signal. \n Configuration reading terminates either when
 *              \b len signal configurations have been read or if the next
 *              signal number index in the array is equal to
 *              \b ALT_END_OF_GPIO_SIGNALS (-1).
 * \param       len
 *              Length of configuration array to read and return.
 *
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.

 */
ALT_STATUS_CODE alt_gpio_group_config_get(ALT_GPIO_CONFIG_RECORD_t *config_array,
        uint32_t len);

/******************************************************************************/
/*!
 * Returns a list of the pin signal indices and the associated configuration
 * settings (data direction, interrupt type, polarity, and debounce) of that
 * list of signals. The difference between this version and
 * alt_gpio_group_config_get() is this version follows a separate list of
 * signal indices instead of having the signal list provided in the first
 * field of the configuration records in the array.
 *
 * \param       pinid_array
 *              Pointer to a list of signal index numbers. These indices
 *              are copied to the first field of each configuration record
 *              in the returned array.
 * \param       config_array
 *              Pointer to an array of ALT_GPIO_CONFIG_RECORD_t configuration
 *              records. This function will fill in the fields of the
 *              configuration record, returning all configuration parameters
 *              in the array. Signals do not have to be listed in numerical
 *              order or be unique. If a signal number is listed multiple
 *              times, the configuration record array will contain multiple
 *              identical entries for that signal. \n Configuration reading
 *              terminates either when \b len signal configurations have been
 *              read or if the next signal number index in the array is equal
 *              to \b ALT_END_OF_GPIO_SIGNALS (-1).
 * \param       len
 *              Length of configuration array to read.
 *
 *
 * \retval      ALT_E_SUCCESS   The operation was successful.
 * \retval      ALT_E_ERROR     The operation failed.
 * \retval      ALT_E_BAD_ARG   Invalid input argument.
 *
 */
ALT_STATUS_CODE alt_gpio_group_config_get2(ALT_GPIO_1BIT_t* pinid_array,
        ALT_GPIO_CONFIG_RECORD_t *config_array, uint32_t len);


/*! @} */
/******************************************************************************/
/*! \addtogroup ALT_GPIO_UTILITY General-Purpose IO Utility Functions
 *
 * These are useful utility functions for the general-purpose input & output
 * module.
 *
 * @{ */
/******************************************************************************/
/*!
 * Returns the ID code of the specified GPIO module.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 *
 *
 * \retval      uint32_t    The component code of the module, GPIO_MODULE_IDCODE.
 */
uint32_t alt_gpio_port_idcode_get(ALT_GPIO_PORT_t gpio_pid);

/******************************************************************************/
/*!
 * Returns the version code of the specified GPIO module.
 *
 * \param       gpio_pid
 *              The GPIO port identifier.
 *
 *
 * \retval      uint32_t      The encoded revision number of the module.
 */
uint32_t alt_gpio_port_ver_get(ALT_GPIO_PORT_t gpio_pid);


/******************************************************************************/
/*!
 * Extracts the GPIO port ID from the supplied GPIO Signal Index Number.
 */
ALT_GPIO_PORT_t alt_gpio_bit_to_pid(ALT_GPIO_1BIT_t pin_num);


/******************************************************************************/
/*!
 * Extracts the GPIO signal (pin) offset from the supplied GPIO Signal Index
 * Number.
 *  */
ALT_GPIO_PORTBIT_t alt_gpio_bit_to_port_pin(ALT_GPIO_1BIT_t pin_num);

/******************************************************************************/
/*!
 * Extracts the GPIO Signal Index Number from the supplied GPIO port ID and
 * signal mask. If passed a bitmask composed of more than one signal, the
 * signal number of the lowest bit in the bitmask presented is returned.
 *
 */
ALT_GPIO_1BIT_t alt_gpio_port_pin_to_bit(ALT_GPIO_PORT_t pid,
        uint32_t bitmask);


/*! @} */
/*! @} */

#ifdef __cplusplus
}
#endif  /* __cplusplus */
#endif  /* __ALT_GPIO_H__ */