你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux下S3C6410的GPIO操作

[日期:2012-05-13] 来源:Linux社区  作者:tianxiawuzhei [字体:大 中 小]

源码如下:注意看注释,讲的很明白。

/**
 * struct s3c_gpio_cfg GPIO configuration
 * @cfg_eint: Configuration setting when used for external interrupt source外部中断
 * @get_pull: Read the current pull configuration for the GPIO
 * @set_pull: Set the current pull configuraiton for the GPIO
 * @set_config: Set the current configuration for the GPIO
 * @get_config: Read the current configuration for the GPIO
 *
 * Each chip can have more than one type of GPIO bank available and some
 * have different capabilites even when they have the same control register
 * layouts. Provide an point to vector control routine and provide any
 * per-bank configuration information that other systems such as the
 * external interrupt code will need.

 */ 指向具体端口的函数调转表
struct s3c_gpio_cfg {
unsigned intcfg_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);


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


那么上的这三个有什么不同呢?看下面这段就可知道了:



/* GPIO bank summary:
 *
 * BankGPIO端口GPIOs数目Style类型控制位数目SlpCon端口A 睡眠模式配置寄存ExtInt Group外部中断
 * A8 4BitYes1
 * B7 4BitYes1
 * C8 4BitYes2
 * D5 4BitYes3
 * E5 4BitYesNone
 * F16 2BitYes4 [1]
 * G7 4BitYes5
 * H10 4Bit[2]Yes6
 * I16 2BitYesNone
 * J12 2BitYesNone
 * K16 4Bit[2]NoNone
 * L15 4Bit[2] NoNone
 * M6 4BitNoIRQ_EINT
 * N16 2BitNoIRQ_EINT
 * O16 2BitYes7
 * P15 2BitYes8
 * Q9 2BitYes9
 *
 * [1] BANKF pins 14,15 do not form part of the external interrupt sources
 * [2] BANK has two control registers, GPxCON0 and GPxCON1
 */

对照下图应该明白了上面的


下面这个图对应gpio_4bit


下面这两个图对应gpio_4bit2,4为控制,2个控制寄存器


下面这两个图对应gpio_2bit,两位控制



注:体会一下,s3c_gpio_chip和gpio_chip两个结构体的不同指出。

linux
相关资讯       S3C6410 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款