MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
gpio.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  * $Date: 2018-11-08 15:08:58 -0600 (Thu, 08 Nov 2018) $
38  * $Revision: 39056 $
39  *
40  *************************************************************************** */
41 
42 /* Define to prevent redundant inclusion */
43 #ifndef _GPIO_H_
44 #define _GPIO_H_
45 
46 /* **** Includes **** */
47 #include "gpio_regs.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
59 /* **** Definitions **** */
68 #define PORT_0 ((uint32_t)(0UL))
69 #define PORT_1 ((uint32_t)(1UL))
70 #define PORT_2 ((uint32_t)(2UL))
71 #define PORT_3 ((uint32_t)(3UL))
72 #define PORT_4 ((uint32_t)(4UL))
79 #define PIN_0 ((uint32_t)(1UL << 0))
80 #define PIN_1 ((uint32_t)(1UL << 1))
81 #define PIN_2 ((uint32_t)(1UL << 2))
82 #define PIN_3 ((uint32_t)(1UL << 3))
83 #define PIN_4 ((uint32_t)(1UL << 4))
84 #define PIN_5 ((uint32_t)(1UL << 5))
85 #define PIN_6 ((uint32_t)(1UL << 6))
86 #define PIN_7 ((uint32_t)(1UL << 7))
87 #define PIN_8 ((uint32_t)(1UL << 8))
88 #define PIN_9 ((uint32_t)(1UL << 9))
89 #define PIN_10 ((uint32_t)(1UL << 10))
90 #define PIN_11 ((uint32_t)(1UL << 11))
91 #define PIN_12 ((uint32_t)(1UL << 12))
92 #define PIN_13 ((uint32_t)(1UL << 13))
93 #define PIN_14 ((uint32_t)(1UL << 14))
94 #define PIN_15 ((uint32_t)(1UL << 15))
95 #define PIN_16 ((uint32_t)(1UL << 16))
96 #define PIN_17 ((uint32_t)(1UL << 17))
97 #define PIN_18 ((uint32_t)(1UL << 18))
98 #define PIN_19 ((uint32_t)(1UL << 19))
99 #define PIN_20 ((uint32_t)(1UL << 20))
100 #define PIN_21 ((uint32_t)(1UL << 21))
101 #define PIN_22 ((uint32_t)(1UL << 22))
102 #define PIN_23 ((uint32_t)(1UL << 23))
103 #define PIN_24 ((uint32_t)(1UL << 24))
104 #define PIN_25 ((uint32_t)(1UL << 25))
105 #define PIN_26 ((uint32_t)(1UL << 26))
106 #define PIN_27 ((uint32_t)(1UL << 27))
107 #define PIN_28 ((uint32_t)(1UL << 28))
108 #define PIN_29 ((uint32_t)(1UL << 29))
109 #define PIN_30 ((uint32_t)(1UL << 30))
110 #define PIN_31 ((uint32_t)(1UL << 31))
117 typedef enum {
124 } gpio_func_t;
125 
129 typedef enum {
133 } gpio_pad_t;
134 
138 typedef struct {
139  uint32_t port;
140  uint32_t mask;
143 } gpio_cfg_t;
144 
148 typedef enum {
152 
156 typedef enum {
163 
164 /* **** Function Prototypes **** */
165 
170 int GPIO_Init(void);
171 
177 int GPIO_Config(const gpio_cfg_t *cfg);
178 
184 uint32_t GPIO_InGet(const gpio_cfg_t *cfg);
185 
191 void GPIO_OutSet(const gpio_cfg_t *cfg);
192 
198 void GPIO_OutClr(const gpio_cfg_t *cfg);
199 
207 uint32_t GPIO_OutGet(const gpio_cfg_t *cfg);
208 
215 void GPIO_OutPut(const gpio_cfg_t *cfg, uint32_t val);
216 
222 void GPIO_OutToggle(const gpio_cfg_t *cfg);
223 
231 int GPIO_IntConfig(const gpio_cfg_t *cfg, gpio_int_mode_t mode, gpio_int_pol_t pol);
232 
238 void GPIO_IntEnable(const gpio_cfg_t *cfg);
239 
244 void GPIO_IntDisable(const gpio_cfg_t *cfg);
245 
252 uint32_t GPIO_IntStatus(const gpio_cfg_t *cfg);
253 
259 void GPIO_IntClr(const gpio_cfg_t *cfg);
260 
269 typedef void (*gpio_callback_fn)(void *cbdata);
270 
278 void GPIO_RegisterCallback(const gpio_cfg_t *cfg, gpio_callback_fn callback, void *cbdata);
279 
287 void GPIO_Handler(unsigned int port);
288 
291 #ifdef __cplusplus
292 }
293 #endif
294 
295 #endif /* _GPIO_H_ */
uint32_t mask
Pin mask (multiple pins may be set)
Definition: gpio.h:140
void GPIO_Handler(unsigned int port)
GPIO IRQ Handler.
int GPIO_Config(const gpio_cfg_t *cfg)
Configure GPIO pin(s).
Structure type for configuring a GPIO port.
Definition: gpio.h:138
void(* gpio_callback_fn)(void *cbdata)
Type alias for a GPIO callback function with prototype:
Definition: gpio.h:269
void GPIO_IntEnable(const gpio_cfg_t *cfg)
Enables the specified GPIO interrupt.
gpio_int_pol_t
Enumeration type for the interrupt polarity.
Definition: gpio.h:156
uint32_t GPIO_IntStatus(const gpio_cfg_t *cfg)
Gets the interrupt(s) status on a GPIO pin.
uint32_t GPIO_OutGet(const gpio_cfg_t *cfg)
Gets the pin(s) output state.
void GPIO_OutSet(const gpio_cfg_t *cfg)
Sets the pin(s) to a high level output.
int GPIO_Init(void)
Initialize GPIO.
Interrupt triggers on rising edge.
Definition: gpio.h:159
Interrupt triggers on either edge.
Definition: gpio.h:161
gpio_int_mode_t
Enumeration type for the interrupt modes.
Definition: gpio.h:148
No pull-up or pull-down.
Definition: gpio.h:130
Interrupt triggers when level is high.
Definition: gpio.h:158
Alternate Function Selection.
Definition: gpio.h:121
Set pad to weak pull-up.
Definition: gpio.h:131
void GPIO_OutClr(const gpio_cfg_t *cfg)
Clears the pin(s) to a low level output.
Alternate Function Selection.
Definition: gpio.h:123
GPIO Output.
Definition: gpio.h:119
void GPIO_IntDisable(const gpio_cfg_t *cfg)
Disables the specified GPIO interrupt.
Interrupt is level sensitive.
Definition: gpio.h:149
void GPIO_RegisterCallback(const gpio_cfg_t *cfg, gpio_callback_fn callback, void *cbdata)
Registers a callback for the interrupt on a given port and pin.
Alternate Function Selection.
Definition: gpio.h:122
gpio_pad_t pad
Pad type.
Definition: gpio.h:142
Alternate Function Selection.
Definition: gpio.h:120
Interrupt triggers when level is low.
Definition: gpio.h:160
Set pad to weak pull-down.
Definition: gpio.h:132
GPIO Input.
Definition: gpio.h:118
Interrupt is edge sensitive.
Definition: gpio.h:150
Interrupt triggers on falling edge.
Definition: gpio.h:157
void GPIO_OutPut(const gpio_cfg_t *cfg, uint32_t val)
Write the pin(s) to a desired output level.
uint32_t GPIO_InGet(const gpio_cfg_t *cfg)
Gets the pin(s) input state.
void GPIO_OutToggle(const gpio_cfg_t *cfg)
Toggles the the pin(s) output level.
int GPIO_IntConfig(const gpio_cfg_t *cfg, gpio_int_mode_t mode, gpio_int_pol_t pol)
Configure GPIO interrupt(s)
void GPIO_IntClr(const gpio_cfg_t *cfg)
Clears the interrupt(s) status on a GPIO pin.
uint32_t port
Index of GPIO port.
Definition: gpio.h:139
gpio_pad_t
Enumeration type for the type of GPIO pad on a given pin.
Definition: gpio.h:129
gpio_func_t
Enumeration type for the GPIO Function Type.
Definition: gpio.h:117
gpio_func_t func
Function type.
Definition: gpio.h:141