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_${SERIES/GPIO_IP}_GPIO_H__
19#define __HAL_DRIVER_${SERIES/GPIO_IP}_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/*\note Refer to template/README.md for usage cases.
35 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
36 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
37 * For emulated drivers, **** No reimplementation ****.
38 *
39 * Usually, there is no IPCore driver for GPIO.
40 */
41
42/*\note Includes CAN ONLY be put here. */
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/*============================ MACROS ========================================*/
49
50// HW
51/*\note hw GPIO driver can reimplement following types:
52 * To enable reimplementation, please enable macro below:
53 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE for vsf_gpio_mode_t
54 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG for vsf_gpio_cfg_t
55 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CTRL for vsf_gpio_ctrl_t
56 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_gpio_capability_t
57 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
58 * *** DO NOT reimplement these in emulated drivers. ***
59 */
60
61#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE ENABLED
62#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG ENABLED
63#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
64#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
65// HW end
66
67/*============================ MACROFIED FUNCTIONS ===========================*/
68/*============================ TYPES =========================================*/
69
70// HW/IPCore
71/*\note To redefine these two macros, vsf_gpio_pin_mask_t type must be defined according to actual situation,
72 * and macro with the same name must be defined.
73 */
74 #if (VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG == ENABLED) || (VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED)
76 #define vsf_gpio_pin_mask_t vsf_gpio_pin_mask_t
77 #endif
78
79/*\note If the default uint16_t is not sufficient, we can redefine the type vsf_gpio_alternate_function_t,
80 * for example as uint32_t, and define a macro with the same name.
81 */
82//#ifndef vsf_gpio_alternate_function_t
83//typedef uint32_t vsf_gpio_alternate_function_t;
84//# define vsf_gpio_alternate_function_t vsf_gpio_alternate_function_t
85//#endif
86// HW/IPCore end
87
88// HW/IPCore, not for emulated drivers
89#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE == ENABLED
90typedef enum vsf_gpio_mode_t {
91 VSF_GPIO_INPUT = (0 << 0),
92 VSF_GPIO_ANALOG = (1 << 0),
95 VSF_GPIO_EXTI = (4 << 0),
96 VSF_GPIO_AF = (5 << 0),
97
99 VSF_GPIO_PULL_UP = (1 << 4),
101
109#endif
110
111#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
112typedef struct vsf_gpio_t vsf_gpio_t;
113typedef void vsf_gpio_exti_isr_handler_t(void *target_ptr, vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask);
114typedef struct vsf_gpio_exti_irq_cfg_t {
116 void *target_ptr;
119typedef struct vsf_gpio_cfg_t {
123#endif
124
125#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
126typedef struct vsf_gpio_capability_t {
127#if VSF_GPIO_CFG_INHERIT_HAL_CAPABILITY == ENABLED
129#endif
130 uint8_t is_async : 1;
139#endif
140
141#if VSF_GPIO_CFG_REIMPLEMENT_TYPE_CTRL == ENABLED
142typedef enum vsf_gpio_ctrl_t {
145#endif
146// HW/IPCore end
147
148/*============================ INCLUDES ======================================*/
149/*============================ PROTOTYPES ====================================*/
150
151#ifdef __cplusplus
152}
153#endif
154
155#endif // VSF_HAL_USE_GPIO
156#endif // __HAL_DRIVER_${SERIES/GPIO_IP}_GPIO_H__
157/* 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
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:135
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:71
struct vsf_gpio_cfg_t vsf_gpio_cfg_t
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:696
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:731
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:773
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:761
uint8_t can_read_in_alternate_mode
Indicates whether vsf_gpio_read is valid in alternate function mode. When set, reading pin state is s...
Definition vsf_template_gpio.h:751
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:791
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:698
uint8_t can_read_in_gpio_output_mode
Indicates whether vsf_gpio_read is valid when configured as GPIO output mode. When set,...
Definition vsf_template_gpio.h:741
gpio configuration
Definition vsf_template_gpio.h:665
vsf_gpio_alternate_function_t alternate_function
alternate function is only valid in GPIO_AF mode
Definition vsf_template_gpio.h:668
vsf_gpio_mode_t mode
Definition vsf_template_gpio.h:666
Definition vsf_template_gpio.h:658
vsf_gpio_exti_isr_handler_t * handler_fn
Definition vsf_template_gpio.h:659
vsf_arch_prio_t prio
Definition vsf_template_gpio.h:661
void * target_ptr
Definition vsf_template_gpio.h:660
Definition vsf_template_gpio.h:844
Definition vsf_template_hal_driver.h:204
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:113
vsf_gpio_ctrl_t
Definition gpio.h:142
@ __VSF_GPIO_CTRL_DUMMY
Definition gpio.h:143
vsf_gpio_ctrl_t
GPIO control commands for hardware-specific operations.
Definition vsf_template_gpio.h:804
uint32_t vsf_gpio_pin_mask_t
Definition vsf_template_gpio.h:350
Generated from commit: vsfteam/vsf@b2e9e8a