MAX32655 Peripheral Driver API
Peripheral Driver API for the MAX32655
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-08-28 17:03:02 -0500 (Tue, 28 Aug 2018) $
38  * $Revision: 37424 $
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 MXC_GPIO_PORT_0 ((uint32_t)(1UL << 0))
69 #define MXC_GPIO_PORT_1 ((uint32_t)(1UL << 1))
70 #define MXC_GPIO_PORT_2 ((uint32_t)(1UL << 2))
71 #define MXC_GPIO_PORT_3 ((uint32_t)(1UL << 3))
78 #define MXC_GPIO_PIN_0 ((uint32_t)(1UL << 0))
79 #define MXC_GPIO_PIN_1 ((uint32_t)(1UL << 1))
80 #define MXC_GPIO_PIN_2 ((uint32_t)(1UL << 2))
81 #define MXC_GPIO_PIN_3 ((uint32_t)(1UL << 3))
82 #define MXC_GPIO_PIN_4 ((uint32_t)(1UL << 4))
83 #define MXC_GPIO_PIN_5 ((uint32_t)(1UL << 5))
84 #define MXC_GPIO_PIN_6 ((uint32_t)(1UL << 6))
85 #define MXC_GPIO_PIN_7 ((uint32_t)(1UL << 7))
86 #define MXC_GPIO_PIN_8 ((uint32_t)(1UL << 8))
87 #define MXC_GPIO_PIN_9 ((uint32_t)(1UL << 9))
88 #define MXC_GPIO_PIN_10 ((uint32_t)(1UL << 10))
89 #define MXC_GPIO_PIN_11 ((uint32_t)(1UL << 11))
90 #define MXC_GPIO_PIN_12 ((uint32_t)(1UL << 12))
91 #define MXC_GPIO_PIN_13 ((uint32_t)(1UL << 13))
92 #define MXC_GPIO_PIN_14 ((uint32_t)(1UL << 14))
93 #define MXC_GPIO_PIN_15 ((uint32_t)(1UL << 15))
94 #define MXC_GPIO_PIN_16 ((uint32_t)(1UL << 16))
95 #define MXC_GPIO_PIN_17 ((uint32_t)(1UL << 17))
96 #define MXC_GPIO_PIN_18 ((uint32_t)(1UL << 18))
97 #define MXC_GPIO_PIN_19 ((uint32_t)(1UL << 19))
98 #define MXC_GPIO_PIN_20 ((uint32_t)(1UL << 20))
99 #define MXC_GPIO_PIN_21 ((uint32_t)(1UL << 21))
100 #define MXC_GPIO_PIN_22 ((uint32_t)(1UL << 22))
101 #define MXC_GPIO_PIN_23 ((uint32_t)(1UL << 23))
102 #define MXC_GPIO_PIN_24 ((uint32_t)(1UL << 24))
103 #define MXC_GPIO_PIN_25 ((uint32_t)(1UL << 25))
104 #define MXC_GPIO_PIN_26 ((uint32_t)(1UL << 26))
105 #define MXC_GPIO_PIN_27 ((uint32_t)(1UL << 27))
106 #define MXC_GPIO_PIN_28 ((uint32_t)(1UL << 28))
107 #define MXC_GPIO_PIN_29 ((uint32_t)(1UL << 29))
108 #define MXC_GPIO_PIN_30 ((uint32_t)(1UL << 30))
109 #define MXC_GPIO_PIN_31 ((uint32_t)(1UL << 31))
121 typedef void (*mxc_gpio_callback_fn) (void *cbdata);
122 
126 typedef enum {
134 
138 typedef enum {
142 
146 typedef enum {
151 
155 typedef struct {
157  uint32_t mask;
158  mxc_gpio_func_t func;
159  mxc_gpio_pad_t pad;
160  mxc_gpio_vssel_t vssel;
162 
166 typedef enum {
170 
174 typedef enum {
181 
182 /* **** Function Prototypes **** */
183 
189 int MXC_GPIO_Init (uint32_t portMask);
190 
196 int MXC_GPIO_Shutdown (uint32_t portMask);
197 
203 int MXC_GPIO_Reset (uint32_t portMask);
204 
210 int MXC_GPIO_Config (const mxc_gpio_cfg_t *cfg);
211 
218 uint32_t MXC_GPIO_InGet (mxc_gpio_regs_t* port, uint32_t mask);
219 
225 void MXC_GPIO_OutSet (mxc_gpio_regs_t* port, uint32_t mask);
226 
232 void MXC_GPIO_OutClr (mxc_gpio_regs_t* port, uint32_t mask);
233 
241 uint32_t MXC_GPIO_OutGet (mxc_gpio_regs_t* port, uint32_t mask);
242 
250 void MXC_GPIO_OutPut (mxc_gpio_regs_t* port, uint32_t mask, uint32_t val);
251 
257 void MXC_GPIO_OutToggle (mxc_gpio_regs_t* port, uint32_t mask);
258 
265 int MXC_GPIO_IntConfig (const mxc_gpio_cfg_t *cfg, mxc_gpio_int_pol_t pol);
266 
273 void MXC_GPIO_EnableInt (mxc_gpio_regs_t* port, uint32_t mask);
274 
280 void MXC_GPIO_DisableInt (mxc_gpio_regs_t* port, uint32_t mask);
281 
289 uint32_t MXC_GPIO_GetFlags (mxc_gpio_regs_t* port);
290 
297 void MXC_GPIO_ClearFlags (mxc_gpio_regs_t* port, uint32_t flags);
298 
306 void MXC_GPIO_RegisterCallback (const mxc_gpio_cfg_t *cfg, mxc_gpio_callback_fn callback, void *cbdata);
307 
315 void MXC_GPIO_Handler (unsigned int port);
316 
324 int MXC_GPIO_SetVSSEL (mxc_gpio_regs_t* port, mxc_gpio_vssel_t vssel, uint32_t mask);
325 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #endif /* _GPIO_H_ */
mxc_gpio_regs_t * port
Definition: gpio.h:156
Structure type for configuring a GPIO port.
Definition: gpio.h:155
uint32_t MXC_GPIO_InGet(mxc_gpio_regs_t *port, uint32_t mask)
Gets the pin(s) input state.
int MXC_GPIO_SetVSSEL(mxc_gpio_regs_t *port, mxc_gpio_vssel_t vssel, uint32_t mask)
Set Voltage select for pins to VDDIO or VDDIOH.
int MXC_GPIO_Init(uint32_t portMask)
Initialize GPIO.
int MXC_GPIO_Shutdown(uint32_t portMask)
Shutdown GPIO.
mxc_gpio_vssel_t
Enumeration type for the voltage level on a given pin.
Definition: gpio.h:138
Definition: gpio_regs.h:88
Definition: gpio.h:167
uint32_t MXC_GPIO_OutGet(mxc_gpio_regs_t *port, uint32_t mask)
Gets the pin(s) output state.
void MXC_GPIO_OutSet(mxc_gpio_regs_t *port, uint32_t mask)
Sets the pin(s) to a high level output.
Definition: gpio.h:149
Definition: gpio.h:176
Definition: gpio.h:147
int MXC_GPIO_IntConfig(const mxc_gpio_cfg_t *cfg, mxc_gpio_int_pol_t pol)
Configure GPIO interrupt(s)
void MXC_GPIO_RegisterCallback(const mxc_gpio_cfg_t *cfg, mxc_gpio_callback_fn callback, void *cbdata)
Registers a callback for the interrupt on a given port and pin.
Definition: gpio.h:168
mxc_gpio_vssel_t vssel
Definition: gpio.h:160
mxc_gpio_func_t func
Definition: gpio.h:158
Definition: gpio.h:177
void MXC_GPIO_ClearFlags(mxc_gpio_regs_t *port, uint32_t flags)
Gets the interrupt(s) status on a GPIO port.
Definition: gpio.h:128
void(* mxc_gpio_callback_fn)(void *cbdata)
Type alias for a GPIO callback function with prototype:
Definition: gpio.h:121
Definition: gpio.h:129
mxc_gpio_int_mode_t
Enumeration type for the interrupt modes.
Definition: gpio.h:166
Definition: gpio.h:148
void MXC_GPIO_OutClr(mxc_gpio_regs_t *port, uint32_t mask)
Clears the pin(s) to a low level output.
void MXC_GPIO_Handler(unsigned int port)
GPIO IRQ Handler.
mxc_gpio_func_t
Enumeration type for the GPIO Function Type.
Definition: gpio.h:126
void MXC_GPIO_OutToggle(mxc_gpio_regs_t *port, uint32_t mask)
Toggles the the pin(s) output level.
mxc_gpio_pad_t
Enumeration type for the type of GPIO pad on a given pin.
Definition: gpio.h:146
mxc_gpio_pad_t pad
Definition: gpio.h:159
Definition: gpio.h:179
void MXC_GPIO_EnableInt(mxc_gpio_regs_t *port, uint32_t mask)
Enables the specified GPIO interrupt.
Definition: gpio.h:127
Definition: gpio.h:178
int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
Configure GPIO pin(s).
mxc_gpio_int_pol_t
Enumeration type for the interrupt polarity.
Definition: gpio.h:174
Definition: gpio.h:139
Definition: gpio.h:130
Definition: gpio.h:132
int MXC_GPIO_Reset(uint32_t portMask)
Reset GPIO.
Definition: gpio.h:140
uint32_t mask
Definition: gpio.h:157
void MXC_GPIO_DisableInt(mxc_gpio_regs_t *port, uint32_t mask)
Disables the specified GPIO interrupt.
Definition: gpio.h:131
void MXC_GPIO_OutPut(mxc_gpio_regs_t *port, uint32_t mask, uint32_t val)
Write the pin(s) to a desired output level.
Definition: gpio.h:175
uint32_t MXC_GPIO_GetFlags(mxc_gpio_regs_t *port)
Gets the interrupt(s) status on a GPIO port.