MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
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: 2019-10-24 16:10:14 -0500 (Thu, 24 Oct 2019) $
38  * $Revision: 48075 $
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))
77 #define MXC_GPIO_PIN_0 ((uint32_t)(1UL << 0))
78 #define MXC_GPIO_PIN_1 ((uint32_t)(1UL << 1))
79 #define MXC_GPIO_PIN_2 ((uint32_t)(1UL << 2))
80 #define MXC_GPIO_PIN_3 ((uint32_t)(1UL << 3))
81 #define MXC_GPIO_PIN_4 ((uint32_t)(1UL << 4))
82 #define MXC_GPIO_PIN_5 ((uint32_t)(1UL << 5))
83 #define MXC_GPIO_PIN_6 ((uint32_t)(1UL << 6))
84 #define MXC_GPIO_PIN_7 ((uint32_t)(1UL << 7))
85 #define MXC_GPIO_PIN_8 ((uint32_t)(1UL << 8))
86 #define MXC_GPIO_PIN_9 ((uint32_t)(1UL << 9))
87 #define MXC_GPIO_PIN_10 ((uint32_t)(1UL << 10))
88 #define MXC_GPIO_PIN_11 ((uint32_t)(1UL << 11))
89 #define MXC_GPIO_PIN_12 ((uint32_t)(1UL << 12))
90 #define MXC_GPIO_PIN_13 ((uint32_t)(1UL << 13))
91 #define MXC_GPIO_PIN_14 ((uint32_t)(1UL << 14))
92 #define MXC_GPIO_PIN_15 ((uint32_t)(1UL << 15))
93 #define MXC_GPIO_PIN_16 ((uint32_t)(1UL << 16))
94 #define MXC_GPIO_PIN_17 ((uint32_t)(1UL << 17))
95 #define MXC_GPIO_PIN_18 ((uint32_t)(1UL << 18))
96 #define MXC_GPIO_PIN_19 ((uint32_t)(1UL << 19))
97 #define MXC_GPIO_PIN_20 ((uint32_t)(1UL << 20))
98 #define MXC_GPIO_PIN_21 ((uint32_t)(1UL << 21))
99 #define MXC_GPIO_PIN_22 ((uint32_t)(1UL << 22))
100 #define MXC_GPIO_PIN_23 ((uint32_t)(1UL << 23))
101 #define MXC_GPIO_PIN_24 ((uint32_t)(1UL << 24))
102 #define MXC_GPIO_PIN_25 ((uint32_t)(1UL << 25))
103 #define MXC_GPIO_PIN_26 ((uint32_t)(1UL << 26))
104 #define MXC_GPIO_PIN_27 ((uint32_t)(1UL << 27))
105 #define MXC_GPIO_PIN_28 ((uint32_t)(1UL << 28))
106 #define MXC_GPIO_PIN_29 ((uint32_t)(1UL << 29))
107 #define MXC_GPIO_PIN_30 ((uint32_t)(1UL << 30))
108 #define MXC_GPIO_PIN_31 ((uint32_t)(1UL << 31))
120 typedef void (*mxc_gpio_callback_fn) (void *cbdata);
121 
125 typedef enum {
133 
137 typedef enum {
141 
145 typedef enum {
150 
154 typedef struct {
156  uint32_t mask;
161 
165 typedef enum {
169 
173 typedef enum {
180 
181 /* **** Function Prototypes **** */
182 
188 int MXC_GPIO_Init (uint32_t portMask);
189 
195 int MXC_GPIO_Shutdown (uint32_t portMask);
196 
202 int MXC_GPIO_Reset (uint32_t portMask);
203 
210 
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 
233 void MXC_GPIO_OutClr (mxc_gpio_regs_t* port, uint32_t mask);
234 
243 uint32_t MXC_GPIO_OutGet (mxc_gpio_regs_t* port, uint32_t mask);
244 
252 void MXC_GPIO_OutPut (mxc_gpio_regs_t* port, uint32_t mask, uint32_t val);
253 
259 void MXC_GPIO_OutToggle (mxc_gpio_regs_t* port, uint32_t mask);
260 
268 
274 void MXC_GPIO_EnableInt (mxc_gpio_regs_t* port, uint32_t mask);
275 
281 void MXC_GPIO_DisableInt (mxc_gpio_regs_t* port, uint32_t mask);
282 
291 
298 void MXC_GPIO_ClearFlags (mxc_gpio_regs_t* port, uint32_t flags);
299 
307 void MXC_GPIO_RegisterCallback (const mxc_gpio_cfg_t *cfg, mxc_gpio_callback_fn callback, void *cbdata);
308 
316 void MXC_GPIO_Handler (unsigned int port);
317 
327 int MXC_GPIO_SetVSSEL (mxc_gpio_regs_t* port, mxc_gpio_vssel_t vssel, uint32_t mask);
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif /* _GPIO_H_ */
MXC_GPIO_FUNC_ALT3
@ MXC_GPIO_FUNC_ALT3
Definition: gpio.h:130
mxc_gpio_callback_fn
void(* mxc_gpio_callback_fn)(void *cbdata)
Type alias for a GPIO callback function with prototype:
Definition: gpio.h:120
MXC_GPIO_OutGet
uint32_t MXC_GPIO_OutGet(mxc_gpio_regs_t *port, uint32_t mask)
Gets the pin(s) output state.
MXC_GPIO_SetVSSEL
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.
MXC_GPIO_RegisterCallback
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.
MXC_GPIO_GetFlags
uint32_t MXC_GPIO_GetFlags(mxc_gpio_regs_t *port)
Gets the interrupt(s) status on a GPIO port.
mxc_gpio_int_mode_t
mxc_gpio_int_mode_t
Enumeration type for the interrupt modes.
Definition: gpio.h:165
MXC_GPIO_OutSet
void MXC_GPIO_OutSet(mxc_gpio_regs_t *port, uint32_t mask)
Sets the pin(s) to a high level output.
mxc_gpio_cfg_t::vssel
mxc_gpio_vssel_t vssel
Definition: gpio.h:159
mxc_gpio_cfg_t::mask
uint32_t mask
Definition: gpio.h:156
MXC_GPIO_INT_LEVEL
@ MXC_GPIO_INT_LEVEL
Definition: gpio.h:166
MXC_GPIO_PAD_NONE
@ MXC_GPIO_PAD_NONE
Definition: gpio.h:146
MXC_GPIO_Reset
int MXC_GPIO_Reset(uint32_t portMask)
Reset GPIO.
MXC_GPIO_PAD_PULL_DOWN
@ MXC_GPIO_PAD_PULL_DOWN
Definition: gpio.h:148
MXC_GPIO_INT_HIGH
@ MXC_GPIO_INT_HIGH
Definition: gpio.h:175
mxc_gpio_int_pol_t
mxc_gpio_int_pol_t
Enumeration type for the interrupt polarity.
Definition: gpio.h:173
mxc_gpio_cfg_t::func
mxc_gpio_func_t func
Definition: gpio.h:157
MXC_GPIO_OutToggle
void MXC_GPIO_OutToggle(mxc_gpio_regs_t *port, uint32_t mask)
Toggles the the pin(s) output level.
MXC_GPIO_INT_EDGE
@ MXC_GPIO_INT_EDGE
Definition: gpio.h:167
MXC_GPIO_INT_RISING
@ MXC_GPIO_INT_RISING
Definition: gpio.h:176
MXC_GPIO_ClearFlags
void MXC_GPIO_ClearFlags(mxc_gpio_regs_t *port, uint32_t flags)
Gets the interrupt(s) status on a GPIO port.
MXC_GPIO_Handler
void MXC_GPIO_Handler(unsigned int port)
GPIO IRQ Handler.
MXC_GPIO_OutPut
void MXC_GPIO_OutPut(mxc_gpio_regs_t *port, uint32_t mask, uint32_t val)
Write the pin(s) to a desired output level.
MXC_GPIO_FUNC_ALT1
@ MXC_GPIO_FUNC_ALT1
Definition: gpio.h:128
MXC_GPIO_FUNC_OUT
@ MXC_GPIO_FUNC_OUT
Definition: gpio.h:127
MXC_GPIO_InGet
uint32_t MXC_GPIO_InGet(mxc_gpio_regs_t *port, uint32_t mask)
Gets the pin(s) input state.
MXC_GPIO_Init
int MXC_GPIO_Init(uint32_t portMask)
Initialize GPIO.
mxc_gpio_func_t
mxc_gpio_func_t
Enumeration type for the GPIO Function Type.
Definition: gpio.h:125
MXC_GPIO_INT_BOTH
@ MXC_GPIO_INT_BOTH
Definition: gpio.h:178
mxc_gpio_cfg_t::port
mxc_gpio_regs_t * port
Definition: gpio.h:155
MXC_GPIO_PAD_PULL_UP
@ MXC_GPIO_PAD_PULL_UP
Definition: gpio.h:147
mxc_gpio_cfg_t
Structure type for configuring a GPIO port.
Definition: gpio.h:154
mxc_gpio_pad_t
mxc_gpio_pad_t
Enumeration type for the type of GPIO pad on a given pin.
Definition: gpio.h:145
MXC_GPIO_FUNC_IN
@ MXC_GPIO_FUNC_IN
Definition: gpio.h:126
MXC_GPIO_INT_LOW
@ MXC_GPIO_INT_LOW
Definition: gpio.h:177
MXC_GPIO_Config
int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
Configure GPIO pin(s).
mxc_gpio_regs_t
Definition: gpio_regs.h:88
MXC_GPIO_Shutdown
int MXC_GPIO_Shutdown(uint32_t portMask)
Shutdown GPIO.
MXC_GPIO_FUNC_ALT4
@ MXC_GPIO_FUNC_ALT4
Definition: gpio.h:131
MXC_GPIO_VSSEL_VDDIO
@ MXC_GPIO_VSSEL_VDDIO
Definition: gpio.h:138
MXC_GPIO_FUNC_ALT2
@ MXC_GPIO_FUNC_ALT2
Definition: gpio.h:129
mxc_gpio_vssel_t
mxc_gpio_vssel_t
Enumeration type for the voltage level on a given pin.
Definition: gpio.h:137
MXC_GPIO_EnableInt
void MXC_GPIO_EnableInt(mxc_gpio_regs_t *port, uint32_t mask)
Enables the specified GPIO interrupt.
MXC_GPIO_INT_FALLING
@ MXC_GPIO_INT_FALLING
Definition: gpio.h:174
MXC_GPIO_IntConfig
int MXC_GPIO_IntConfig(const mxc_gpio_cfg_t *cfg, mxc_gpio_int_pol_t pol)
Configure GPIO interrupt(s)
MXC_GPIO_OutClr
void MXC_GPIO_OutClr(mxc_gpio_regs_t *port, uint32_t mask)
Clears the pin(s) to a low level output.
MXC_GPIO_VSSEL_VDDIOH
@ MXC_GPIO_VSSEL_VDDIOH
Definition: gpio.h:139
MXC_GPIO_DisableInt
void MXC_GPIO_DisableInt(mxc_gpio_regs_t *port, uint32_t mask)
Disables the specified GPIO interrupt.
mxc_gpio_cfg_t::pad
mxc_gpio_pad_t pad
Definition: gpio.h:158