VSF Documented
gpio.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __HAL_DRIVER_NATIONS_N32H76X_N32H78X_GPIO_H__
19#define __HAL_DRIVER_NATIONS_N32H76X_N32H78X_GPIO_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_GPIO == ENABLED
26
27// HW/IPCore
32// HW/IPCore end
33
34#include "../../__device.h"
35
36/*\note Refer to template/README.md for usage cases.
37 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
38 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
39 * For emulated drivers, **** No reimplementation ****.
40 *
41 * Usually, there is no IPCore driver for GPIO.
42 */
43
44/*\note Includes CAN ONLY be put here. */
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*============================ MACROS ========================================*/
51
52// HW
53/*\note hw GPIO driver can reimplement following types:
54 * To enable reimplementation, please enable macro below:
55 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE for vsf_gpio_mode_t
56 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG for vsf_gpio_cfg_t
57 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_gpio_capability_t
58 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
59 * *** DO NOT reimplement these in emulated drivers. ***
60 */
61
62#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE ENABLED
63#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG DISABLED
64#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
65// HW end
66
67// HW/IPCore
68/*\note To redefine these two macros, vsf_gpio_pin_mask_t type must be defined according to actual situation,
69 * and macro with the same name must be defined.
70 */
71#if (VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG == ENABLED) || (VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED)
73#define vsf_gpio_pin_mask_t vsf_gpio_pin_mask_t
74#endif
75// HW/IPCore end
76
77/*============================ MACROFIED FUNCTIONS ===========================*/
78/*============================ TYPES =========================================*/
79
80// HW/IPCore, not for emulated drivers
81#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE == ENABLED
82typedef enum vsf_gpio_mode_t {
83 // 0..1, GPIO_PMODE: INPUT(0)/OUTPUT(1)/AF(2)/ANALOG(3)
84 // 2: GPIO_POTYPE: PUSHPULL(0)/OPENDRAIN(1)
85 VSF_GPIO_INPUT = (0 << 0),
86 VSF_GPIO_ANALOG = (3 << 0),
87 VSF_GPIO_OUTPUT_PUSH_PULL = (1 << 0) | (0 << 2),
88 VSF_GPIO_OUTPUT_OPEN_DRAIN = (1 << 0) | (1 << 2),
89 VSF_GPIO_AF = (2 << 0),
90 VSF_GPIO_AF_PUSH_PULL = (2 << 0) | (0 << 2),
91 VSF_GPIO_AF_OPEN_DRAIN = (2 << 0) | (1 << 2),
93
94 // 3..4, GPIO_PUPD: FLOATING(0)/PULLUP(1)/PULLDOWN(2)
96 VSF_GPIO_PULL_UP = (1 << 3),
97 VSF_GPIO_PULL_DOWN = (2 << 3),
98
99 // 5, GPIO_SR: FAST(0)/SLOW(1)
104#define VSF_GPIO_SPEED_LOW VSF_GPIO_SPEED_LOW
105#define VSF_GPIO_SPEED_HIGH VSF_GPIO_SPEED_HIGH
106#define VSF_GPIO_SPEED_MASK VSF_GPIO_SPEED_MASK
107
108 // 6..7: GPIO_DS: LOW(0), MEDIUM(2), HIGH(1), VERY_HIGH(3)
119
120 // TODO: add exti support
127
130#endif
131
132#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
133typedef struct vsf_gpio_t vsf_gpio_t;
134typedef void vsf_gpio_exti_isr_handler_t(void *target_ptr, vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask);
135typedef struct vsf_gpio_exti_irq_cfg_t {
137 void *target_ptr;
140typedef struct vsf_gpio_cfg_t {
144#endif
145
146#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
147typedef struct vsf_gpio_capability_t {
148#if VSF_GPIO_CFG_INHERIT_HAL_CAPABILITY == ENABLED
150#endif
151 uint8_t is_async : 1;
158#endif
159// HW/IPCore end
160
161/*============================ INCLUDES ======================================*/
162/*============================ PROTOTYPES ====================================*/
163
164#ifdef __cplusplus
165}
166#endif
167
168#endif // VSF_HAL_USE_GPIO
169#endif // __HAL_DRIVER_NATIONS_N32H76X_N32H78X_GPIO_H__
170/* EOF */
vsf_gpio_mode_t
Definition gpio.h:31
@ VSF_GPIO_NO_PULL_UP_DOWN
Definition gpio.h:39
@ VSF_GPIO_EXTI_MODE_HIGH_LEVEL
Definition gpio.h:50
@ VSF_GPIO_OUTPUT_PUSH_PULL
Definition gpio.h:43
@ VSF_GPIO_EXTI
Definition gpio.h:45
@ VSF_GPIO_EXTI_MODE_LOW_LEVEL
Definition gpio.h:49
@ VSF_GPIO_EXTI_MODE_NONE
Definition gpio.h:48
@ VSF_GPIO_EXTI_MODE_RISING
Definition gpio.h:51
@ VSF_GPIO_EXTI_MODE_RISING_FALLING
Definition gpio.h:53
@ VSF_GPIO_PULL_UP
Definition gpio.h:37
@ VSF_GPIO_AF
Definition gpio.h:46
@ VSF_GPIO_INPUT
Definition gpio.h:41
@ VSF_GPIO_ANALOG
Definition gpio.h:44
@ VSF_GPIO_EXTI_MODE_FALLING
Definition gpio.h:52
@ VSF_GPIO_OUTPUT_OPEN_DRAIN
Definition gpio.h:42
@ VSF_GPIO_PULL_DOWN
Definition gpio.h:38
#define VSF_GPIO_SPEED_HIGH
Definition gpio.h:84
#define VSF_GPIO_SPEED_MASK
Definition gpio.h:86
@ __VSF_HW_GPIO_MODE_ALL_BITS
Definition gpio.h:98
@ VSF_GPIO_AF_PUSH_PULL
enable output push-pull mode
Definition gpio.h:67
@ VSF_GPIO_AF_OPEN_DRAIN
enable output open-drain mode
Definition gpio.h:68
#define VSF_GPIO_SPEED_LOW
Definition gpio.h:82
#define VSF_GPIO_DRIVE_STRENGTH_MEDIUM
Definition gpio.h:115
void vsf_gpio_exti_isr_handler_t(void *target_ptr, vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
Definition gpio.h:134
#define VSF_GPIO_HIGH_DRIVE_STRENGTH_MASK
Definition gpio.h:118
#define VSF_GPIO_DRIVE_STRENGTH_HIGH
Definition gpio.h:116
#define VSF_GPIO_DRIVE_STRENGTH_VERY_HIGH
Definition gpio.h:117
struct vsf_gpio_capability_t vsf_gpio_capability_t
struct vsf_gpio_exti_irq_cfg_t vsf_gpio_exti_irq_cfg_t
#define vsf_gpio_pin_mask_t
Definition gpio.h:73
struct vsf_gpio_cfg_t vsf_gpio_cfg_t
#define VSF_GPIO_DRIVE_STRENGTH_LOW
Definition gpio.h:114
@ VSF_GPIO_HIGH_DRIVE_STRENGTH_LOW
Definition gpio.h:109
@ VSF_GPIO_HIGH_DRIVE_STRENGTH_HIGH
Definition gpio.h:111
@ VSF_GPIO_HIGH_DRIVE_STRENGTH_MEDIUM
Definition gpio.h:110
@ VSF_GPIO_HIGH_DRIVE_STRENGTH_VERY_HIGH
Definition gpio.h:112
vsf_arch_prio_t
Definition cortex_a_generic.h:88
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_gpio.h:628
uint8_t support_output_and_clear
Support for atomic output and clear operations. Prevents signal glitches when switching from input to...
Definition vsf_template_gpio.h:663
uint8_t pin_count
Total number of pins in hardware. Includes all pins, even those that cannot be configured as GPIO....
Definition vsf_template_gpio.h:685
uint8_t support_interrupt
Support for external interrupt functionality. When set, the GPIO pins can be configured to generate i...
Definition vsf_template_gpio.h:673
vsf_gpio_pin_mask_t pin_mask
Available pin mask indicating which pins can be used as GPIO. Common bit patterns include:
Definition vsf_template_gpio.h:703
inherit(vsf_peripheral_capability_t) uint8_t is_async uint8_t support_output_and_set
Flag indicating if GPIO operations are asynchronous. When set, operations are only guaranteed to be s...
Definition vsf_template_gpio.h:630
gpio channel configuration
Definition vsf_template_gpio.h:600
uint16_t alternate_function
alternate function is only valid in GPIO_AF mode
Definition vsf_template_gpio.h:603
vsf_gpio_mode_t mode
Definition vsf_template_gpio.h:601
Definition vsf_template_gpio.h:593
vsf_gpio_exti_isr_handler_t * handler_fn
Definition vsf_template_gpio.h:594
vsf_arch_prio_t prio
Definition vsf_template_gpio.h:596
void * target_ptr
Definition vsf_template_gpio.h:595
Definition vsf_template_gpio.h:725
Definition vsf_template_hal_driver.h:203
void vsf_gpio_exti_isr_handler_t(void *target_ptr, vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
Definition gpio.h:105
uint32_t vsf_gpio_pin_mask_t
Definition vsf_template_gpio.h:304
Generated from commit: vsfteam/vsf@cfd571b