OK210开发板(Cortex-A8)Android4.0.4加速度传感器的移植 - 在线问答 - 电子技术论坛 - 最好最受欢迎电子论坛!

OK210开发板(Cortex-A8)Android4.0.4加速度传感器的移植

栾新科 ( 楼主 ) 2015-5-20 16:55:58  只看该作者 倒序浏览
本帖最后由 forlinx 于 2015-5-20 17:06 编辑

加速度传感器在android系统中是一个比较有意思的硬件设备,飞凌嵌入式公司的OK210开发板(Cortex-A8 S5PV210)中安装了加速度传感器,下边我简单说一下这个硬件的过程。
Android中的加速度传感器分层结构如下:
  
  
  
首先是 硬件上采用i2c接口的芯片连接到飞凌公司的嵌入式开发板OK210开发板上的i2c总线上,之后在开发板软件包的./drivers/input/misc/mma7660.c是驱动程序所在的路径。
static int __devinit mma7660_probe(struct i2c_client *client,
       const struct i2c_device_id *id)
{
}
函数为驱动初始化部分。
static void report_abs(void)
{
input_report_abs(mma7660_idev->input, ABS_X, x);
input_report_abs(mma7660_idev->input, ABS_Y, y);
input_report_abs(mma7660_idev->input, ABS_Z, z);
input_sync(mma7660_idev->input);//同步发送了
}
驱动程序从硬件读取数据,向操作系统的节点上报刚才读取的数据到应用层。
Android层加速度传感器的hal层部分:
hardware/libhardware/include/sensors.h
device/samsung/common/s5p/libsensors/sensors.cpp
device/samsung/common/s5p/libsensors/sensors.h
android jni层部分
device/samsung/common/s5p/libsensors/AccelSensor.cpp
修改此文件3处
#include "./../../../../../config/config.h"//bs
#ifdef  CONFIG_OK210_BOARD
#define ACCEL_PATH "/sys/bus/i2c/drivers/mma7660/0-004c/"
#define ACCEL_NAME "event4"
#else
#define ACCEL_PATH "/sys/bus/i2c/drivers/mma7660/1-004c/"
#define ACCEL_NAME "event3"
#endif
#ifdef  CONFIG_OK210_BOARD
        strcpy(input_sysfs_path, "/sys/devices/platform/s3c2440-i2c.0/i2c-0/0-004c/input/");
        strcat(input_sysfs_path, "input4");//"input_name");//bs
#else  
        strcpy(input_sysfs_path, "/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-004c/input/");
        strcat(input_sysfs_path, "input3");//"input_name");//bs
#endif
修改权限
geany ./system/core/rootdir/init.rc
    chmod 0666 /dev/input/event4
chmod 0666 /sys/devices/platform/s3c2440-i2c.0/i2c-0/0-004c/input/input4/poll
以上就是针对飞凌嵌入式 三星S5PV210(Cortex-A8开发板的操作。
  

0个回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则


关闭

站长推荐上一条 /6 下一条

小黑屋|手机版|Archiver|电子发烧友 ( 湘ICP备2023018690号 )

GMT+8, 2024-9-28 19:46 , Processed in 0.629395 second(s), Total 56, Slave 40 queries .

Powered by 电子发烧友网

© 2015 bbs.elecfans.com

微信扫描
快速回复 返回顶部 返回列表