MAX32675 Peripheral Driver API
Peripheral Driver API for the MAX32675
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  *************************************************************************** */
38 
39 /* Define to prevent redundant inclusion */
40 #ifndef _GPIO_H_
41 #define _GPIO_H_
42 
43 /* **** Includes **** */
44 #include "gpio_regs.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
56 /* **** Definitions **** */
65 #define MXC_GPIO_PORT_0 ((uint32_t)(1UL << 0))
66 #define MXC_GPIO_PORT_1 ((uint32_t)(1UL << 1))
67 #define MXC_GPIO_PORT_2 ((uint32_t)(1UL << 2))
68 #define MXC_GPIO_PORT_3 ((uint32_t)(1UL << 3))
69 
75 #define MXC_GPIO_PIN_0 ((uint32_t)(1UL << 0))
76 #define MXC_GPIO_PIN_1 ((uint32_t)(1UL << 1))
77 #define MXC_GPIO_PIN_2 ((uint32_t)(1UL << 2))
78 #define MXC_GPIO_PIN_3 ((uint32_t)(1UL << 3))
79 #define MXC_GPIO_PIN_4 ((uint32_t)(1UL << 4))
80 #define MXC_GPIO_PIN_5 ((uint32_t)(1UL << 5))
81 #define MXC_GPIO_PIN_6 ((uint32_t)(1UL << 6))
82 #define MXC_GPIO_PIN_7 ((uint32_t)(1UL << 7))
83 #define MXC_GPIO_PIN_8 ((uint32_t)(1UL << 8))
84 #define MXC_GPIO_PIN_9 ((uint32_t)(1UL << 9))
85 #define MXC_GPIO_PIN_10 ((uint32_t)(1UL << 10))
86 #define MXC_GPIO_PIN_11 ((uint32_t)(1UL << 11))
87 #define MXC_GPIO_PIN_12 ((uint32_t)(1UL << 12))
88 #define MXC_GPIO_PIN_13 ((uint32_t)(1UL << 13))
89 #define MXC_GPIO_PIN_14 ((uint32_t)(1UL << 14))
90 #define MXC_GPIO_PIN_15 ((uint32_t)(1UL << 15))
91 #define MXC_GPIO_PIN_16 ((uint32_t)(1UL << 16))
92 #define MXC_GPIO_PIN_17 ((uint32_t)(1UL << 17))
93 #define MXC_GPIO_PIN_18 ((uint32_t)(1UL << 18))
94 #define MXC_GPIO_PIN_19 ((uint32_t)(1UL << 19))
95 #define MXC_GPIO_PIN_20 ((uint32_t)(1UL << 20))
96 #define MXC_GPIO_PIN_21 ((uint32_t)(1UL << 21))
97 #define MXC_GPIO_PIN_22 ((uint32_t)(1UL << 22))
98 #define MXC_GPIO_PIN_23 ((uint32_t)(1UL << 23))
99 #define MXC_GPIO_PIN_24 ((uint32_t)(1UL << 24))
100 #define MXC_GPIO_PIN_25 ((uint32_t)(1UL << 25))
101 #define MXC_GPIO_PIN_26 ((uint32_t)(1UL << 26))
102 #define MXC_GPIO_PIN_27 ((uint32_t)(1UL << 27))
103 #define MXC_GPIO_PIN_28 ((uint32_t)(1UL << 28))
104 #define MXC_GPIO_PIN_29 ((uint32_t)(1UL << 29))
105 #define MXC_GPIO_PIN_30 ((uint32_t)(1UL << 30))
106 #define MXC_GPIO_PIN_31 ((uint32_t)(1UL << 31))
107 
113 #define MXC_GPIO_INACCESSIBLE (MXC_GPIO_PIN_2 | MXC_GPIO_PIN_3 | MXC_GPIO_PIN_4 | MXC_GPIO_PIN_5 | \
114  MXC_GPIO_PIN_12 | MXC_GPIO_PIN_20 | MXC_GPIO_PIN_22 | MXC_GPIO_PIN_23 | \
115  MXC_GPIO_PIN_24 | MXC_GPIO_PIN_25 | MXC_GPIO_PIN_26 | MXC_GPIO_PIN_27 | \
116  MXC_GPIO_PIN_28 | MXC_GPIO_PIN_29 | MXC_GPIO_PIN_30)
117 
126 typedef void (*mxc_gpio_callback_fn) (void *cbdata);
127 
131 typedef enum {
139 
143 typedef enum {
147 
151 typedef enum {
156 
160 typedef struct {
162  uint32_t mask;
167 
171 typedef enum {
175 
179 typedef enum {
186 
187 /* **** Function Prototypes **** */
188 
194 int MXC_GPIO_Init (uint32_t portMask);
195 
201 int MXC_GPIO_Shutdown (uint32_t portMask);
202 
208 int MXC_GPIO_Reset (uint32_t portMask);
209 
215 int MXC_GPIO_Config (const mxc_gpio_cfg_t *cfg);
216 
223 uint32_t MXC_GPIO_InGet (mxc_gpio_regs_t* port, uint32_t mask);
224 
230 void MXC_GPIO_OutSet (mxc_gpio_regs_t* port, uint32_t mask);
231 
237 void MXC_GPIO_OutClr (mxc_gpio_regs_t* port, uint32_t mask);
238 
246 uint32_t MXC_GPIO_OutGet (mxc_gpio_regs_t* port, uint32_t mask);
247 
255 void MXC_GPIO_OutPut (mxc_gpio_regs_t* port, uint32_t mask, uint32_t val);
256 
262 void MXC_GPIO_OutToggle (mxc_gpio_regs_t* port, uint32_t mask);
263 
271 
278 void MXC_GPIO_EnableInt (mxc_gpio_regs_t* port, uint32_t mask);
279 
285 void MXC_GPIO_DisableInt (mxc_gpio_regs_t* port, uint32_t mask);
286 
294 uint32_t MXC_GPIO_GetFlags (mxc_gpio_regs_t* port);
295 
302 void MXC_GPIO_ClearFlags (mxc_gpio_regs_t* port, uint32_t flags);
303 
311 void MXC_GPIO_RegisterCallback (const mxc_gpio_cfg_t *cfg, mxc_gpio_callback_fn callback, void *cbdata);
312 
320 void MXC_GPIO_Handler (unsigned int port);
321 
331 int MXC_GPIO_SetVSSEL (mxc_gpio_regs_t* port, mxc_gpio_vssel_t vssel, uint32_t mask);
332 
335 #ifdef __cplusplus
336 }
337 #endif
338 
339 #endif /* _GPIO_H_ */
MXC_GPIO_FUNC_ALT3
@ MXC_GPIO_FUNC_ALT3
Alternate Function Selection.
Definition: gpio.h:136
mxc_gpio_callback_fn
void(* mxc_gpio_callback_fn)(void *cbdata)
Type alias for a GPIO callback function with prototype:
Definition: gpio.h:126
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:171
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
Voltage select.
Definition: gpio.h:165
mxc_gpio_cfg_t::mask
uint32_t mask
Pin mask (multiple pins may be set)
Definition: gpio.h:162
MXC_GPIO_INT_LEVEL
@ MXC_GPIO_INT_LEVEL
Interrupt is level sensitive.
Definition: gpio.h:172
MXC_GPIO_PAD_NONE
@ MXC_GPIO_PAD_NONE
No pull-up or pull-down.
Definition: gpio.h:152
MXC_GPIO_Reset
int MXC_GPIO_Reset(uint32_t portMask)
Reset GPIO.
MXC_GPIO_PAD_PULL_DOWN
@ MXC_GPIO_PAD_PULL_DOWN
Set pad to weak pull-down.
Definition: gpio.h:154
MXC_GPIO_INT_HIGH
@ MXC_GPIO_INT_HIGH
Interrupt triggers when level is high.
Definition: gpio.h:181
mxc_gpio_int_pol_t
mxc_gpio_int_pol_t
Enumeration type for the interrupt polarity.
Definition: gpio.h:179
mxc_gpio_cfg_t::func
mxc_gpio_func_t func
Function type.
Definition: gpio.h:163
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
Interrupt is edge sensitive.
Definition: gpio.h:173
MXC_GPIO_INT_RISING
@ MXC_GPIO_INT_RISING
Interrupt triggers on rising edge.
Definition: gpio.h:182
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
Alternate Function Selection.
Definition: gpio.h:134
MXC_GPIO_FUNC_OUT
@ MXC_GPIO_FUNC_OUT
GPIO Output.
Definition: gpio.h:133
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:131
MXC_GPIO_INT_BOTH
@ MXC_GPIO_INT_BOTH
Interrupt triggers on either edge.
Definition: gpio.h:184
mxc_gpio_cfg_t::port
mxc_gpio_regs_t * port
Pointer to GPIO regs.
Definition: gpio.h:161
MXC_GPIO_PAD_PULL_UP
@ MXC_GPIO_PAD_PULL_UP
Set pad to weak pull-up.
Definition: gpio.h:153
mxc_gpio_cfg_t
Structure type for configuring a GPIO port.
Definition: gpio.h:160
mxc_gpio_pad_t
mxc_gpio_pad_t
Enumeration type for the type of GPIO pad on a given pin.
Definition: gpio.h:151
MXC_GPIO_FUNC_IN
@ MXC_GPIO_FUNC_IN
GPIO Input.
Definition: gpio.h:132
MXC_GPIO_INT_LOW
@ MXC_GPIO_INT_LOW
Interrupt triggers when level is low.
Definition: gpio.h:183
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
Alternate Function Selection.
Definition: gpio.h:137
MXC_GPIO_VSSEL_VDDIO
@ MXC_GPIO_VSSEL_VDDIO
Set pin to VIDDIO voltage.
Definition: gpio.h:144
MXC_GPIO_FUNC_ALT2
@ MXC_GPIO_FUNC_ALT2
Alternate Function Selection.
Definition: gpio.h:135
mxc_gpio_vssel_t
mxc_gpio_vssel_t
Enumeration type for the voltage level on a given pin.
Definition: gpio.h:143
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
Interrupt triggers on falling edge.
Definition: gpio.h:180
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
Set pin to VIDDIOH voltage.
Definition: gpio.h:145
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
Pad type.
Definition: gpio.h:164