Hardware Libraries  20.1
Stratix 10 SoC Hardware Manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
alt_generalpurpose_io.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright 2013-2017 Altera Corporation. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************/
32 
33 /*
34  * $Id: //acds/main/embedded/ip/hps/armv8/hwlib/include/alt_generalpurpose_io.h#1 $
35  */
36 
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 /* Valid Bits for the I/O Port on s10 */
52 #define ALT_GPIO_BITMASK 0xFFFFFF
53 
54 /* If the GPIO special test mode flag was not defined in the makefile, */
55 /* set the ALT_GPIO_DATAREAD_TEST_MODE flag to false to specify that */
56 /* the production code version of alt_gpio_port_data_read() is included. */
57 /* If the flag is defined as true in the makefile, then the test version */
58 /* located in the test code file is substituted instead of the version */
59 /* in this file. */
60 #ifndef ALT_GPIO_DATAREAD_TEST_MODE
61 #define ALT_GPIO_DATAREAD_TEST_MODE false
62 #endif
63 
64 /******************************************************************************/
82 /******************************************************************************/
108 /******************************************************************************/
114 typedef enum ALT_GPIO_PIN_DIR_e
115 {
121 
122 /******************************************************************************/
129 {
135 
136 /******************************************************************************/
143 typedef enum ALT_GPIO_PIN_POL_e
144 {
148 
153 
154 /******************************************************************************/
164 {
170 
171 /******************************************************************************/
180 {
186 
187 /******************************************************************************/
193 {
199 
200 
201 /******************************************************************************/
207 typedef enum ALT_GPIO_PORT_e
208 {
213 
218 
224 
225 
226 /******************************************************************************/
238 typedef enum ALT_GPIO_PORTBIT_e
239 {
241  ALT_GPIO_BIT0 = ALT_TWO_TO_POW(0),
243  ALT_GPIO_BIT1 = ALT_TWO_TO_POW(1),
245  ALT_GPIO_BIT2 = ALT_TWO_TO_POW(2),
247  ALT_GPIO_BIT3 = ALT_TWO_TO_POW(3),
249  ALT_GPIO_BIT4 = ALT_TWO_TO_POW(4),
251  ALT_GPIO_BIT5 = ALT_TWO_TO_POW(5),
253  ALT_GPIO_BIT6 = ALT_TWO_TO_POW(6),
255  ALT_GPIO_BIT7 = ALT_TWO_TO_POW(7),
257  ALT_GPIO_BIT8 = ALT_TWO_TO_POW(8),
259  ALT_GPIO_BIT9 = ALT_TWO_TO_POW(9),
261  ALT_GPIO_BIT10 = ALT_TWO_TO_POW(10),
263  ALT_GPIO_BIT11 = ALT_TWO_TO_POW(11),
265  ALT_GPIO_BIT12 = ALT_TWO_TO_POW(12),
267  ALT_GPIO_BIT13 = ALT_TWO_TO_POW(13),
269  ALT_GPIO_BIT14 = ALT_TWO_TO_POW(14),
271  ALT_GPIO_BIT15 = ALT_TWO_TO_POW(15),
273  ALT_GPIO_BIT16 = ALT_TWO_TO_POW(16),
275  ALT_GPIO_BIT17 = ALT_TWO_TO_POW(17),
277  ALT_GPIO_BIT18 = ALT_TWO_TO_POW(18),
279  ALT_GPIO_BIT19 = ALT_TWO_TO_POW(19),
281  ALT_GPIO_BIT20 = ALT_TWO_TO_POW(20),
283  ALT_GPIO_BIT21 = ALT_TWO_TO_POW(21),
285  ALT_GPIO_BIT22 = ALT_TWO_TO_POW(22),
287  ALT_GPIO_BIT23 = ALT_TWO_TO_POW(23),
288  ALT_GPIO_BIT24 = ALT_TWO_TO_POW(24), /* Not currently used for s10 */
289  ALT_GPIO_BIT25 = ALT_TWO_TO_POW(25), /* Not currently used for s10 */
290  ALT_GPIO_BIT26 = ALT_TWO_TO_POW(26), /* Not currently used for s10 */
291  ALT_GPIO_BIT27 = ALT_TWO_TO_POW(27), /* Not currently used for s10 */
292  ALT_GPIO_BIT28 = ALT_TWO_TO_POW(28), /* Not currently used for s10 */
293  ALT_GPIO_BIT29 = ALT_TWO_TO_POW(29), /* Not currently used for s10 */
294  ALT_GPIO_BIT30 = ALT_TWO_TO_POW(30), /* Not currently used for s10 */
295  ALT_GPIO_BIT31 = (int32_t)ALT_TWO_TO_POW(31), /* Not currently used for s10 */
296 
297  /* It is the biggest bit number of a GPIO port ( bit 0, bit 1, ..., bit ALT_GPIO_BITNUM_MAX)
298  * instead of the number of bits on a GPIO port (which is 24 for s10) */
299  ALT_GPIO_BITNUM_MAX = (23),
300 
301  ALT_GPIO_BIT_MAX = (1 << ALT_GPIO_BITNUM_MAX),
302  ALT_END_OF_GPIO_PORT_SIGNALS = (32)
304 
305 
306 
307 /******************************************************************************/
314 ALT_STATUS_CODE alt_gpio_init(void);
315 
316 /******************************************************************************/
323 ALT_STATUS_CODE alt_gpio_uninit(void);
324 
325 /******************************************************************************/
347 ALT_STATUS_CODE alt_gpio_port_datadir_set(ALT_GPIO_PORT_t gpio_pid,
348  uint32_t mask, uint32_t config);
349 
350 /******************************************************************************/
369  uint32_t mask);
370 
371 /******************************************************************************/
391 ALT_STATUS_CODE alt_gpio_port_data_write(ALT_GPIO_PORT_t gpio_pid,
392  uint32_t mask, uint32_t val);
393 
394 /******************************************************************************/
411 uint32_t alt_gpio_port_data_read(ALT_GPIO_PORT_t gpio_pid, uint32_t mask);
412 
413 
415 /******************************************************************************/
423 /******************************************************************************/
446 ALT_STATUS_CODE alt_gpio_port_int_type_set(ALT_GPIO_PORT_t gpio_pid,
447  uint32_t mask, uint32_t config);
448 
449 /******************************************************************************/
469  uint32_t mask);
470 
471 /******************************************************************************/
493 ALT_STATUS_CODE alt_gpio_port_int_pol_set(ALT_GPIO_PORT_t gpio_pid,
494  uint32_t mask, uint32_t config);
495 
496 /******************************************************************************/
518  uint32_t mask);
519 
520 
522 /******************************************************************************/
527 /******************************************************************************/
551 ALT_STATUS_CODE alt_gpio_port_debounce_set(ALT_GPIO_PORT_t gpio_pid,
552  uint32_t mask, uint32_t config);
553 
554 /******************************************************************************/
575  uint32_t mask);
576 
577 /******************************************************************************/
595 ALT_STATUS_CODE alt_gpio_port_sync_set(ALT_GPIO_PORT_t gpio_pid,
596  uint32_t config);
597 
598 /******************************************************************************/
616 ALT_STATUS_CODE alt_gpio_port_sync_get(ALT_GPIO_PORT_t gpio_pid);
617 
618 /******************************************************************************/
644 ALT_STATUS_CODE alt_gpio_port_config(ALT_GPIO_PORT_t gpio_pid,
645  uint32_t mask, ALT_GPIO_PIN_DIR_t dir, ALT_GPIO_PIN_TYPE_t type,
647  uint32_t data);
648 
650 /******************************************************************************/
655 /******************************************************************************/
671 ALT_STATUS_CODE alt_gpio_port_int_enable(ALT_GPIO_PORT_t gpio_pid, uint32_t config);
672 
673 /******************************************************************************/
689 ALT_STATUS_CODE alt_gpio_port_int_disable(ALT_GPIO_PORT_t gpio_pid, uint32_t config);
690 
691 /******************************************************************************/
704 
705 
706 /******************************************************************************/
727 ALT_STATUS_CODE alt_gpio_port_int_mask_set(ALT_GPIO_PORT_t gpio_pid,
728  uint32_t mask, uint32_t val);
729 
730 /******************************************************************************/
745 
746 /******************************************************************************/
762 
763 /******************************************************************************/
780 ALT_STATUS_CODE alt_gpio_port_int_status_clear(ALT_GPIO_PORT_t gpio_pid,
781  uint32_t clrmask);
782 
785 /******************************************************************************/
796 /******************************************************************************/
803 typedef enum ALT_GPIO_1BIT_e
804 {
901 
902  ALT_GPIO_INVALID,
903  ALT_END_OF_GPIO_SIGNALS = -1,
904  ALT_LAST_VALID_GPIO_BIT = ALT_GPIO_1BIT_47
906 
907 
908 /******************************************************************************/
914 {
934 
935 /******************************************************************************/
940 typedef struct ALT_GPIO_PIN_RECORD_s
941 {
949 
952 /******************************************************************************/
957 /******************************************************************************/
979 ALT_STATUS_CODE alt_gpio_bit_config(ALT_GPIO_1BIT_t signal_num,
982  ALT_GPIO_PIN_DATA_t data);
983 
984 /******************************************************************************/
1000 ALT_STATUS_CODE alt_gpio_bitconfig_get(ALT_GPIO_1BIT_t signal_num,
1001  ALT_GPIO_CONFIG_RECORD_t *config);
1002 
1003 /******************************************************************************/
1029 ALT_STATUS_CODE alt_gpio_group_config(ALT_GPIO_CONFIG_RECORD_t* config_array,
1030  uint32_t len);
1031 
1032 /******************************************************************************/
1060 ALT_STATUS_CODE alt_gpio_group_config_get(ALT_GPIO_CONFIG_RECORD_t *config_array,
1061  uint32_t len);
1062 
1063 /******************************************************************************/
1096 ALT_STATUS_CODE alt_gpio_group_config_given_pinid_list_get(ALT_GPIO_1BIT_t* pinid_array,
1097  ALT_GPIO_CONFIG_RECORD_t *config_array, uint32_t len);
1098 
1099 
1101 /******************************************************************************/
1108 /******************************************************************************/
1118 uint32_t alt_gpio_port_idcode_get(ALT_GPIO_PORT_t gpio_pid);
1119 
1120 /******************************************************************************/
1130 uint32_t alt_gpio_port_ver_get(ALT_GPIO_PORT_t gpio_pid);
1131 
1132 
1133 /******************************************************************************/
1138 
1139 
1140 /******************************************************************************/
1146 
1147 /******************************************************************************/
1155  uint32_t bitmask);
1156 
1157 
1161 #ifdef __cplusplus
1162 }
1163 #endif /* __cplusplus */
1164 #endif /* __ALT_GPIO_H__ */