123456789101112131415161718192021222324252627282930313233343536373839 |
- /*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2021-08-23 lianzhian first implementation.
- */
- #ifndef __DRV_GPIO_H__
- #define __DRV_GPIO_H__
- #include <rtthread.h>
- #include <rthw.h>
- #include <rtdevice.h>
- #include <board.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define __GD32_PORT(port) GPIO##port
- #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__GD32_PORT(PORTx) - (rt_base_t)GPIO_BASE)/(0x0400UL) )) + PIN)
- #define PIN_NUM(port, no) (((((port) & 0xFu) << 4) | ((no) & 0xFu)))
- #define PIN_PORT(pin) ((uint8_t)(((pin) >> 4) & 0xFu))
- #define PIN_NO(pin) ((uint8_t)((pin) & 0xFu))
- #define PIN_GDPIN(pin) ((uint16_t)(1u << PIN_NO(pin)))
- #ifdef __cplusplus
- }
- #endif
- #endif /* __DRV_GPIO_H__ */
|