summaryrefslogtreecommitdiff
path: root/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_gpio.h
blob: 99b204041166a005b1763d647642036d16a93999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2006-2026, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Date           Author            Notes
 * 2026-05-17     swtblue           add interrupt operation function
 */

#ifndef __DRV_GPIO_H__
#define __DRV_GPIO_H__

#include <rtdevice.h>
#include "gpio.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct
{
    GPIO_TypeDef *port;
    GPIO_PinNum pin;
} rt_pin_info_t;

#define PIN_NUM(...)        get_pin_num(__VA_ARGS__)
#define PIN_PORT(pin)       get_port_index_by_num(pin)
#define PIN_NO(pin)         get_pin_index_by_num(pin)

const rt_pin_info_t *get_pin_info(int pin_num);
int get_pin_num(GPIO_TypeDef *port, GPIO_PinNum pin);
uint8_t get_port_index(GPIO_TypeDef *port);
uint8_t get_pin_index(uint16_t pin);
uint8_t get_port_index_by_num(int pin_num);
uint8_t get_pin_index_by_num(int pin_num);

int rt_hw_pin_init(void);

#ifdef __cplusplus
}
#endif

#endif /* __DRV_GPIO_H__ */