Altera HWLIB  16.0
The Altera HW Manager API Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
alt_generalpurpose_io.h
Go to the documentation of this file.
1 
5 /******************************************************************************
6 *
7 * Copyright 2013 Altera Corporation. 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 copyright holder nor the names of its contributors
20 * may 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  * $Id: //depot/embedded/rel/15.0/ip/hps/altera_hps/hwlib/include/alt_generalpurpose_io.h#1 $
39  */
40 
41 #ifndef __ALT_GPIO_H__
42 #define __ALT_GPIO_H__
43 
44 #include <stdint.h>
45 #include "hwlib.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif /* __cplusplus */
50 
51 #define ALT_GPIO_BITMASK 0x1FFFFFFF
52 
53 /* If the GPIO special test mode flag was not defined in the makefile, */
54  /* set the ALT_GPIO_DATAREAD_TEST_MODE flag to false to specify that */
55  /* the production code version of alt_gpio_port_data_read() is included. */
56  /* If the flag is defined as true in the makefile, then the test version */
57  /* located in the test code file is substituted instead of the version */
58  /* in this file. */
59 #ifndef ALT_GPIO_DATAREAD_TEST_MODE
60 #define ALT_GPIO_DATAREAD_TEST_MODE false
61 #endif
62 
63 /******************************************************************************/
81 /******************************************************************************/
107 /******************************************************************************/
113 typedef enum ALT_GPIO_PIN_DIR_e
114 {
120 
121 /******************************************************************************/
128 {
134 
135 /******************************************************************************/
142 typedef enum ALT_GPIO_PIN_POL_e
143 {
147 
152 
153 /******************************************************************************/
163 {
169 
170 /******************************************************************************/
179 {
185 
186 /******************************************************************************/
192 {
198 
199 
200 /******************************************************************************/
206 typedef enum ALT_GPIO_PORT_e
207 {
212 
217 
226 
232 
233 
234 /******************************************************************************/
246 typedef enum ALT_GPIO_PORTBIT_e
247 {
249  ALT_GPIO_BIT0 = ALT_TWO_TO_POW0,
251  ALT_GPIO_BIT1 = ALT_TWO_TO_POW1,
253  ALT_GPIO_BIT2 = ALT_TWO_TO_POW2,
255  ALT_GPIO_BIT3 = ALT_TWO_TO_POW3,
257  ALT_GPIO_BIT4 = ALT_TWO_TO_POW4,
259  ALT_GPIO_BIT5 = ALT_TWO_TO_POW5,
261  ALT_GPIO_BIT6 = ALT_TWO_TO_POW6,
263  ALT_GPIO_BIT7 = ALT_TWO_TO_POW7,
265  ALT_GPIO_BIT8 = ALT_TWO_TO_POW8,
267  ALT_GPIO_BIT9 = ALT_TWO_TO_POW9,
269  ALT_GPIO_BIT10 = ALT_TWO_TO_POW10,
271  ALT_GPIO_BIT11 = ALT_TWO_TO_POW11,
273  ALT_GPIO_BIT12 = ALT_TWO_TO_POW12,
275  ALT_GPIO_BIT13 = ALT_TWO_TO_POW13,
277  ALT_GPIO_BIT14 = ALT_TWO_TO_POW14,
279  ALT_GPIO_BIT15 = ALT_TWO_TO_POW15,
281  ALT_GPIO_BIT16 = ALT_TWO_TO_POW16,
283  ALT_GPIO_BIT17 = ALT_TWO_TO_POW17,
285  ALT_GPIO_BIT18 = ALT_TWO_TO_POW18,
287  ALT_GPIO_BIT19 = ALT_TWO_TO_POW19,
289  ALT_GPIO_BIT20 = ALT_TWO_TO_POW20,
291  ALT_GPIO_BIT21 = ALT_TWO_TO_POW21,
293  ALT_GPIO_BIT22 = ALT_TWO_TO_POW22,
295  ALT_GPIO_BIT23 = ALT_TWO_TO_POW23,
297  ALT_GPIO_BIT24 = ALT_TWO_TO_POW24,
299  ALT_GPIO_BIT25 = ALT_TWO_TO_POW25,
301  ALT_GPIO_BIT26 = ALT_TWO_TO_POW26,
303  ALT_GPIO_BIT27 = ALT_TWO_TO_POW27,
305  ALT_GPIO_BIT28 = ALT_TWO_TO_POW28,
306  ALT_GPIO_BIT29 = ALT_TWO_TO_POW29, /* Not currently used */
307  ALT_GPIO_BIT30 = ALT_TWO_TO_POW30, /* Not currently used */
308  ALT_GPIO_BIT31 = (int32_t) (1UL<<31), /* Not currently used */
309 
310  ALT_GPIO_BITNUM_MAX = (28),
311  ALT_GPIO_BIT_MAX = (1 << ALT_GPIO_BITNUM_MAX),
312  ALT_END_OF_GPIO_PORT_SIGNALS = (32)
314 
315 
316 
317 /******************************************************************************/
324 ALT_STATUS_CODE alt_gpio_init(void);
325 
326 /******************************************************************************/
333 ALT_STATUS_CODE alt_gpio_uninit(void);
334 
335 /******************************************************************************/
357 ALT_STATUS_CODE alt_gpio_port_datadir_set(ALT_GPIO_PORT_t gpio_pid,
358  uint32_t mask, uint32_t config);
359 
360 /******************************************************************************/
379  uint32_t mask);
380 
381 /******************************************************************************/
401 ALT_STATUS_CODE alt_gpio_port_data_write(ALT_GPIO_PORT_t gpio_pid,
402  uint32_t mask, uint32_t val);
403 
404 /******************************************************************************/
421 uint32_t alt_gpio_port_data_read(ALT_GPIO_PORT_t gpio_pid, uint32_t mask);
422 
423 
425 /******************************************************************************/
433 /******************************************************************************/
456 ALT_STATUS_CODE alt_gpio_port_int_type_set(ALT_GPIO_PORT_t gpio_pid,
457  uint32_t mask, uint32_t config);
458 
459 /******************************************************************************/
479  uint32_t mask);
480 
481 /******************************************************************************/
503 ALT_STATUS_CODE alt_gpio_port_int_pol_set(ALT_GPIO_PORT_t gpio_pid,
504  uint32_t mask, uint32_t config);
505 
506 /******************************************************************************/
528  uint32_t mask);
529 
530 
532 /******************************************************************************/
537 /******************************************************************************/
561 ALT_STATUS_CODE alt_gpio_port_debounce_set(ALT_GPIO_PORT_t gpio_pid,
562  uint32_t mask, uint32_t config);
563 
564 /******************************************************************************/
585  uint32_t mask);
586 
587 /******************************************************************************/
605 ALT_STATUS_CODE alt_gpio_port_sync_set(ALT_GPIO_PORT_t gpio_pid,
606  uint32_t config);
607 
608 /******************************************************************************/
626 ALT_STATUS_CODE alt_gpio_port_sync_get(ALT_GPIO_PORT_t gpio_pid);
627 
628 /******************************************************************************/
654 ALT_STATUS_CODE alt_gpio_port_config(ALT_GPIO_PORT_t gpio_pid,
655  uint32_t mask, ALT_GPIO_PIN_DIR_t dir, ALT_GPIO_PIN_TYPE_t type,
657  uint32_t data);
658 
660 /******************************************************************************/
665 /******************************************************************************/
681 ALT_STATUS_CODE alt_gpio_port_int_enable(ALT_GPIO_PORT_t gpio_pid, uint32_t config);
682 
683 /******************************************************************************/
699 ALT_STATUS_CODE alt_gpio_port_int_disable(ALT_GPIO_PORT_t gpio_pid, uint32_t config);
700 
701 /******************************************************************************/
714 
715 
716 /******************************************************************************/
737 ALT_STATUS_CODE alt_gpio_port_int_mask_set(ALT_GPIO_PORT_t gpio_pid,
738  uint32_t mask, uint32_t val);
739 
740 /******************************************************************************/
755 
756 /******************************************************************************/
772 
773 /******************************************************************************/
790 ALT_STATUS_CODE alt_gpio_port_int_status_clear(ALT_GPIO_PORT_t gpio_pid,
791  uint32_t clrmask);
792 
795 /******************************************************************************/
806 /******************************************************************************/
813 typedef enum ALT_GPIO_1BIT_e
814 {
950  ALT_GPIO_1BIT_67, /* Not bonded out on some versions */
952  ALT_GPIO_1BIT_68, /* Not bonded out on some versions */
954  ALT_GPIO_1BIT_69, /* Not bonded out on some versions */
955 
957  ALT_GPIO_1BIT_70, /* Not bonded out on some versions */
958 
959 
966  ALT_HLGPI_0, /* Not bonded out on some versions */
968  ALT_HLGPI_1, /* Not bonded out on some versions */
970  ALT_HLGPI_2, /* Not bonded out on some versions */
972  ALT_HLGPI_3, /* Not bonded out on some versions */
974  ALT_HLGPI_4, /* Not bonded out on some versions */
976  ALT_HLGPI_5, /* Not bonded out on some versions */
978  ALT_HLGPI_6, /* Not bonded out on some versions */
980  ALT_HLGPI_7, /* Not bonded out on some versions */
982  ALT_HLGPI_8, /* Not bonded out on some versions */
984  ALT_HLGPI_9, /* Not bonded out on some versions */
986  ALT_HLGPI_10, /* Not bonded out on some versions */
988  ALT_HLGPI_11, /* Not bonded out on some versions */
990  ALT_HLGPI_12, /* Not bonded out on some versions */
992  ALT_HLGPI_13, /* Not bonded out on some versions */
993 
994  ALT_HLGPI_14, /* Not bonded out */
995 
996  ALT_HLGPI_15, /* Not bonded out */
997 
998  ALT_GPIO_INVALID,
999  ALT_END_OF_GPIO_SIGNALS = -1,
1000  ALT_LAST_VALID_GPIO_BIT = ALT_HLGPI_15
1001 } ALT_GPIO_1BIT_t;
1002 
1003 
1004 /******************************************************************************/
1010 {
1030 
1031 /******************************************************************************/
1037 {
1045 
1048 /******************************************************************************/
1053 /******************************************************************************/
1075 ALT_STATUS_CODE alt_gpio_bit_config(ALT_GPIO_1BIT_t signal_num,
1078  ALT_GPIO_PIN_DATA_t data);
1079 
1080 /******************************************************************************/
1096 ALT_STATUS_CODE alt_gpio_bitconfig_get(ALT_GPIO_1BIT_t signal_num,
1097  ALT_GPIO_CONFIG_RECORD_t *config);
1098 
1099 /******************************************************************************/
1125 ALT_STATUS_CODE alt_gpio_group_config(ALT_GPIO_CONFIG_RECORD_t* config_array,
1126  uint32_t len);
1127 
1128 /******************************************************************************/
1156 ALT_STATUS_CODE alt_gpio_group_config_get(ALT_GPIO_CONFIG_RECORD_t *config_array,
1157  uint32_t len);
1158 
1159 /******************************************************************************/
1192 ALT_STATUS_CODE alt_gpio_group_config_get2(ALT_GPIO_1BIT_t* pinid_array,
1193  ALT_GPIO_CONFIG_RECORD_t *config_array, uint32_t len);
1194 
1195 
1197 /******************************************************************************/
1204 /******************************************************************************/
1214 uint32_t alt_gpio_port_idcode_get(ALT_GPIO_PORT_t gpio_pid);
1215 
1216 /******************************************************************************/
1226 uint32_t alt_gpio_port_ver_get(ALT_GPIO_PORT_t gpio_pid);
1227 
1228 
1229 /******************************************************************************/
1234 
1235 
1236 /******************************************************************************/
1242 
1243 /******************************************************************************/
1251  uint32_t bitmask);
1252 
1253 
1257 #ifdef __cplusplus
1258 }
1259 #endif /* __cplusplus */
1260 #endif /* __ALT_GPIO_H__ */