gpio有关函数

本文详细介绍了S3C系列微控制器中GPIO配置的相关结构体和函数,包括配置寄存器、设置输入输出模式、设置上拉下拉电阻等操作,并对比了Linux内核中的通用GPIO接口函数。

1.gpio-cfg.h

 

struct s3c_gpio_cfg {
 unsigned int cfg_eint;

 s3c_gpio_pull_t (*get_pull)(struct s3c_gpio_chip *chip, unsigned offs);
 int  (*set_pull)(struct s3c_gpio_chip *chip, unsigned offs,
        s3c_gpio_pull_t pull);

 int  (*set_pin)(struct s3c_gpio_chip *chip, unsigned offs,
        s3c_gpio_pull_t level);

 unsigned (*get_config)(struct s3c_gpio_chip *chip, unsigned offs);
 int  (*set_config)(struct s3c_gpio_chip *chip, unsigned offs,
          unsigned config);
};

 

/* Defines for generic pin configurations */
#define S3C_GPIO_INPUT (S3C_GPIO_SPECIAL(0))
#define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1))
#define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x))             //S3C_GPIO_SFN(oxf)   在S5PV210平台为外部中断模式 EXIT_MODE;

#define s3c_gpio_is_cfg_special(_cfg) \
 (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK)

 

extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to);

extern unsigned s3c_gpio_getcfg(unsigned int pin);

 

#define S3C_GPIO_PULL_NONE ((__force s3c_gpio_pull_t)0x00)
#define S3C_GPIO_PULL_DOWN ((__force s3c_gpio_pull_t)0x01)
#define S3C_GPIO_PULL_UP ((__force s3c_gpio_pull_t)0x02)

extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull);

extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin);

#define S5P_GPIO_DRVSTR_LV1 ((__force s5p_gpio_drvstr_t)0x00)
#define S5P_GPIO_DRVSTR_LV2 ((__force s5p_gpio_drvstr_t)0x01)
#define S5P_GPIO_DRVSTR_LV3 ((__force s5p_gpio_drvstr_t)0x10)
#define S5P_GPIO_DRVSTR_LV4 ((__force s5p_gpio_drvstr_t)0x11)

extern s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin);

extern int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr);

2.linux/gpio.h

static inline int gpio_is_valid(int number)
static inline int gpio_request(unsigned gpio, const char *label)
static inline void gpio_free(unsigned gpio)
static inline int gpio_direction_input(unsigned gpio)
static inline int gpio_direction_output(unsigned gpio, int value)
static inline int gpio_get_value(unsigned gpio)
static inline void gpio_set_value(unsigned gpio, int value)
static inline int gpio_cansleep(unsigned gpio)
static inline int gpio_get_value_cansleep(unsigned gpio)
static inline void gpio_set_value_cansleep(unsigned gpio, int value)
static inline int gpio_export(unsigned gpio, bool direction_may_change)
static inline int gpio_export_link(struct device *dev, const char *name,  unsigned gpio)
static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
static inline void gpio_unexport(unsigned gpio)
static inline int gpio_to_irq(unsigned gpio)
static inline int irq_to_gpio(unsigned irq)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值