1 路径:

drivers/staging/android/timed_gpio.c

drivers/staging/android/timed_output.c

drivers/staging/android/timed_output.h

drivers/staging/android/timed_gpio.h


2 代码分析:

实现一个设备的驱动,大概需要几个部分的数据:最基础的设备结构体,设备数据结构体和platform data等。


19 struct timed_output_dev {
20 const char *name;
21
22 /* enable the output and set the timer */
23 void (*enable)(struct timed_output_dev *sdev, int timeout);
24
25 /* returns the current number of milliseconds remaining on the timer */
26 int (*get_time)(struct timed_output_dev *sdev);
27
28 /* private data */
29 struct device *dev;
30 int index;
31 int state;
32 };

此处是设备结构体;他表示一个Timed GPIO设备,

首先,name代表对应的Timed GPIO设备名称。

enable用来设置定时器的过期时间,并使GPIO能输出指定的电平(在timed_gpio中,它最终是指向gpio_enable)

get_time函数则用来获得定时器的剩余时间,即离过期还有多长时间(在timed_GPIO中,它最终是指gpio_get_time)。

dev指向该Timed GPIO设备的设备结构体(struct device)对象,在linux2.6中,内核设备模型把每个设备用一个struct device来表示。

index则是区分同一名称的多个设备(这些设备由同一个驱动管理)

state则表示设备的当前状态。

更多相关文章

  1. Android 5.1源代码与Nexus设备工厂镜像下载
  2. ubuntu 64 adb 识别android设备
  3. Android获取设备ID、型号及其它信息
  4. Android 源码结构
  5. Android体系结构

随机推荐

  1. Android Fragment 生命周期onCreatView、
  2. Android帧缓冲区(Frame Buffer)硬件抽象层(H
  3. android gradle 3.0.0 中依赖指令impleme
  4. Android开发指南 —— Multimedia and Ca
  5. Android的Task和Activity(二)
  6. 如何在EditText中设置固定图片——Androi
  7. 关于修改Android系统默认语言
  8. Android(安卓)SparseArray的用法
  9. Android使double保留两位小数的多方法 ja
  10. 如何使用eclipse和emulator debug Androi