drv_gpio.h 1.0 KB
Newer Older
1
/*
mysterywolf's avatar
mysterywolf 已提交
2
 * Copyright (c) 2006-2021, RT-Thread Development Team
3 4 5 6 7
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author            Notes
S
SummerGift 已提交
8
 * 2018-11-06     balanceTWK        first version
T
thread-liu 已提交
9
 * 2020-06-16     thread-liu        add stm32mp1
mysterywolf's avatar
mysterywolf 已提交
10
 * 2020-09-01     thread-liu        add GPIOZ
11
 * 2020-09-18     geniusgogo        optimization design pin-index algorithm
12 13 14 15 16 17
 */

#ifndef __DRV_GPIO_H__
#define __DRV_GPIO_H__

#include <drv_common.h>
18
#include <board.h>
19

20 21 22 23
#ifdef __cplusplus
extern "C" {
#endif

Y
yygg_you 已提交
24
#define __STM32_PORT(port)  GPIO##port##_BASE
25

T
thread-liu 已提交
26
#if defined(SOC_SERIES_STM32MP1)
T
thread-liu 已提交
27
#define GET_PIN(PORTx,PIN) (GPIO##PORTx == GPIOZ) ? (176 + PIN) : ((rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x1000UL) )) + PIN))
T
thread-liu 已提交
28
#else
Y
yygg_you 已提交
29
#define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
T
thread-liu 已提交
30
#endif
31 32 33 34 35 36 37 38 39

struct pin_irq_map
{
    rt_uint16_t pinbit;
    IRQn_Type irqno;
};

int rt_hw_pin_init(void);

40 41 42 43
#ifdef __cplusplus
}
#endif

44 45
#endif /* __DRV_GPIO_H__ */