WEB开发网
开发学院手机开发Android 开发 Android 驱动之 jogball 详解 阅读

Android 驱动之 jogball 详解

 2010-03-17 16:15:00 来源:WEB开发网   
核心提示:report)/*时间处理函数*/static enum hrtimer_restart emc_progress_hrtimer_handler_func(struct hrtimer *timer)/*中断处理函数*/static irqreturn_t gpio_axis_irq_handler(int irq,
report)

/*时间处理函数*/

static enum hrtimer_restart emc_progress_hrtimer_handler_func(struct hrtimer *timer)

/*中断处理函数*/

static irqreturn_t gpio_axis_irq_handler(int irq, void *dev_id)

/*给上层的注册回调函数*/

int gpio_event_axis_func(struct input_dev *input_dev, struct gpio_event_info *info, void **data, int func)

5.3 platform代码

例如:/arch/arm/match-msm/board-72×7.c

uint16_t hero_axis_map(struct gpio_event_axis_info *info, uint16_t in)

{

struct hero_axis_info *ai = container_of(info, struct hero_axis_info, info);

uint16_t out = ai->out_state;

if (nav_just_on) {

if (jiffies == nav_on_jiffies || jiffies == nav_on_jiffies + 1)

goto ignore;

nav_just_on = 0;

}

if((ai->in_state ^ in) & 1) /*检测在方向1上有没有数值变化*/

out--;

if((ai->n_state ^ in) & 2) /*检测在方向1相对方向上有没有数值变化*/

out++;

ai->;out_state = out;

ignore:

ai->in_state = in;

if (ai->out_state - ai->temp_state == ai->threshold) {

ai->temp_state++;

ai->out_state = ai->temp_state;

} else if (ai->temp_state - ai-out_state == ai->threshold) {

ai->temp_state--;

ai->out_state = ai->temp_state;

} else if (abs(ai->out_state - ai->;temp_state) > ai->threshold)

ai->temp_state = ai->out_state;

return ai->temp_state;

}

以上函数,是最终的数据解析函数,也就是把硬件中读出来的数据,转化为实际的位置变化的函数。此函数主要做了差错控制,增加

了程序的鲁棒性和可订制性。

static struct hero_axis_info hero_x_axis = {

.threshold = 1,

.info = {

.info.func = gpio_event_axis_func,

上一页  1 2 3 4 5  下一页

Tags:Android 驱动 jogball

编辑录入:coldstar [复制链接] [打 印]
赞助商链接