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#include "../../__device.h"
28
29/*\note Refer to template/README.md for usage cases.
30 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
31 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
32 * For emulated drivers, **** No reimplementation ****.
33 *
34 * Usually, there is no IPCore driver for GPIO.
35 */
36
37/*\note Includes CAN ONLY be put here. */
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/*============================ MACROS ========================================*/
44
45// HW
46/*\note hw GPIO driver can reimplement vsf_gpio_mode_t/vsf_gpio_interrupt_mode_t.
47 * To enable reimplementation, please enable macro below:
48 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE for vsf_gpio_mode_t, mutually exclusive with VSF_GPIO_USE_IO_MODE_TYPE
49 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG for vsf_gpio_cfg_t
50 * VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_gpio_capability_t
51 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
52 * *** DO NOT reimplement these in emulated drivers. ***
53 */
54
55#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE ENABLED
56//#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG ENABLED
57//#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
58// HW end
59
60/*============================ MACROFIED FUNCTIONS ===========================*/
61/*============================ TYPES =========================================*/
62
63// HW, not for emulated drivers
64typedef enum vsf_gpio_mode_t {
65 VSF_GPIO_INPUT = (0 << 0),
66 VSF_GPIO_ANALOG = (1 << 0),
69 VSF_GPIO_EXTI = (4 << 0),
70 VSF_GPIO_AF = (5 << 0),
71
73 VSF_GPIO_PULL_UP = (1 << 4),
75
82
83 // more vendor specified modes can be added here
85// HW end
86
87/*============================ INCLUDES ======================================*/
88/*============================ PROTOTYPES ====================================*/
89
90#ifdef __cplusplus
91}
92#endif
93
94#endif // VSF_HAL_USE_GPIO
95#endif // __HAL_DRIVER_${SERIES/GPIO_IP}_GPIO_H__
96/* 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