VSF Documented
io.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_GIGADEVICE_GD32H7XX_IO_H__
19#define __HAL_DRIVER_GIGADEVICE_GD32H7XX_IO_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_IO == 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 IO.
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 IO driver can reimplement vsf_io_mode_t.
47 * To enable reimplementation, please enable macro below:
48 * VSF_IO_CFG_REIMPLEMENT_TYPE_MODE for vsf_io_mode_t
49 * Reimplementation is used for optimization hw drivers, reimplement the bit mask according to hw registers.
50 * *** DO NOT reimplement these in emulated drivers. ***
51 */
52
53#define VSF_IO_CFG_REIMPLEMENT_TYPE_MODE ENABLED
54// HW end
55
56/*============================ MACROFIED FUNCTIONS ===========================*/
57/*============================ TYPES =========================================*/
58
59// HW, not for emulated drivers
60typedef enum vsf_io_mode_t {
61 // 0..1, GPIOx_MODER: INPUT(0)/OUTPUT(1)/AF(2)/ANALOG(3)
62 // 2: GPIOx_OTYPER: PUSHPULL(0)/OPENDRAIN(1)
63 VSF_IO_INPUT = (0 << 0),
64 VSF_IO_ANALOG = (3 << 0),
65 VSF_IO_OUTPUT_PUSH_PULL = (1 << 0) | (0 << 2),
66 VSF_IO_OUTPUT_OPEN_DRAIN = (1 << 0) | (1 << 2),
67 VSF_IO_AF = (2 << 0),
68 VSF_IO_AF_PUSH_PULL = (2 << 0) | (0 << 2),
69 VSF_IO_AF_OPEN_DRAIN = (2 << 0) | (1 << 2),
71
72 // 3..4, GPIOx_PUPDR: FLOATING(0)/PULLUP(1)/PULLDOWN(2)
74 VSF_IO_PULL_UP = (1 << 3),
75 VSF_IO_PULL_DOWN = (2 << 3),
76
77 // 5..6, GPIOx_OSPEEDR: LOW(0)/MEDIUM(1)/HIGH(2)/VERY_HIGH(3)
78 VSF_IO_SPEED_LOW = (0 << 5),
88
89 // TODO: add input fileter modes
90
91
94// HW end
95
96/*============================ PROTOTYPES ====================================*/
97/*============================ INCLUDES ======================================*/
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif // VSF_HAL_USE_IO
104#endif // __HAL_DRIVER_GIGADEVICE_GD32H7XX_IO_H__
105/* EOF */
vsf_io_mode_t
Definition io.h:44
@ VSF_IO_PULL_UP
Definition io.h:46
@ VSF_IO_PULL_DOWN
Definition io.h:47
@ VSF_IO_INPUT
Definition io.h:49
@ VSF_IO_ANALOG
Definition io.h:51
@ VSF_IO_OUTPUT_PUSH_PULL
enable output push-pull mode
Definition io.h:65
@ VSF_IO_OUTPUT_OPEN_DRAIN
enable output open-drain mode
Definition io.h:66
@ VSF_IO_EXTI
Definition io.h:70
@ __VSF_HW_IO_MODE_ALL_BITS
Definition io.h:92
@ VSF_IO_NO_PULL_UP_DOWN
enable floating
Definition io.h:73
@ VSF_IO_AF
enable AF mode
Definition io.h:67
@ VSF_IO_AF_PUSH_PULL
enable output push-pull mode
Definition io.h:68
@ VSF_IO_AF_OPEN_DRAIN
enable output open-drain mode
Definition io.h:69
#define VSF_IO_SPEED_MEDIUM
Definition io.h:84
#define VSF_IO_SPEED_VERY_HIGH
Definition io.h:86
#define VSF_IO_SPEED_LOW
Definition io.h:83
#define VSF_IO_SPEED_HIGH
Definition io.h:85
#define VSF_IO_SPEED_MASK
Definition io.h:87