1、基于 ARM9 的三轴加速度传感器动作识别装置设计摘 要 :该装置以 ARM9 为核心,采用 linux 操作系统,驱动飞思卡尔的三轴陀螺仪mma7660fc 传感器采集外部动作的数据。加以算法分析处理,即可得到方向的角度变化、震动、敲击的外部信息。该装置可用于 MP3、PDA、MID、智能手机等各种手持电子设备的人性化智能控制。关键字:三轴加速度传感器、linux 操作系统、ARM9ARM9-based three-axis acceleration sensor device designed to identify the actionAbstract: The device to AR
2、M9 core, using linux operating system, drivers of three-axis gyroscope mma7660fc Freescale sensor data acquisition external action. To algorithm analysis and processing, can be obtained by changing the angle of orientation, vibration, percussion external information. The device can be used for MP3,
3、PDA, MID, smart phones and other handheld electronic devices, human intelligent control.Keywords: three-axis accelerometer, linux operating system, ARM90 引言随着电子消费品性能和功能的不断发展,消费者对产品的各种人性化的操作的需求也不断提高,因此,在手持设备等便携电子产品上使用各种智能传感器采集外部各种信息,并用于完善设备本身功能的控制,使其更加人性化,具有现实意义。1 装置概述该装置由 ARM9 处理器结合 linux 操作系统,通过 i2
4、c 总线驱动,获取ma7660fc 采集外部动作:设备被转动方向的变化和角度的大小,和速度的快慢,震动或被敲击的数据,并进行适当的算法处理,提取出有用的控制信息。其硬件原理图如图 1 所示,其软件系统结构如图 2 所示。图 1 I2C connection to MCU3 软件设计3.1 驱动核心代码分析static struct timer_list *sensor_timer;static struct work_struct sensor_work_q;/定时器中断服务程序static void sensor_timer_handler(unsigned long data)/调度工作队
5、列if (schedule_work(/注册一个内核定时器static void sensor_timer_registertimer(struct timer_list* ptimer, unsigned int timeover )init_timer(ptimer);ptimer-expires = jiffies+msecs_to_jiffies(timeover);ptimer-data = (unsigned long)NULL;ptimer-function = sensor_timer_handler;add_timer(ptimer);/定时器中断底半部处理函数static
6、void sensor_fetch_thread(struct work_struct *work)mma7660_sensor_get_accel();sensor_timer_registertimer( sensor_timer, sensor_duration ); int _init tcc_sensor_init(void)/初始化工作队列并将工作队列与处理函数绑定INIT_WORK( return 0;3.2 测试应用程序分析#include#includeint main(int argc, char * argv)/打开设备文件fd = open(/dev/sensor,O_
7、RDWR);/读数据 xyz 数据ret = read(fd,/读取加速度数据ioctl(fd,IOCTL_SENSOR_GET_DATA_ACCEL,/设置采样时间ioctl(fd,IOCTL_SENSOR_SET_DELAY_ACCEL,/读取驱动状态标志位ioctl(fd,IOCTL_SENSOR_GET_STATE_ACCEL,/设置加速度值ioctl(fd,IOCTL_SENSOR_SET_CALIB_ACCEL,/设置状态标志位ioctl(fd,IOCTL_SENSOR_SET_STATE_ACCEL,clienti2c 设备驱动 i2c_devI2C 核心AlgorithmI2C 适配器与 s3c2440 适配器硬件相关的代码应用程序I2c 适配器Mma7660fc图 2 Linux I2C 体系结构参考文献:【1】 宋宝华 设备驱动开发详解(第二版)【2】 Linux 设备驱动程序 (第三版)【3】 3-Axis Orientation/Motion Detection Sensor data sheetsheet of Freescale Semiconductor