1,增加硬件抽象层(HAL)模块访问linux内核驱动程序
①创建相关文件
1)/home/senrsl/android/source/WORKING_DIRECTORY/hardware/libhardware/include/hardware/senrsl.h
- senrsl@senrsl-ubuntu:~$ cd android/source/WORKING_DIRECTORY/
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$ cd hardware/libhardware/include/hardware/
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/include/hardware$ vi senrsl.h
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/include/hardware$ cd ..
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/include$ cd ..
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware$ cd modules/
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/modules$ mkdir senrsl
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/modules$ cd senrsl/
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/modules/senrsl$ touch senrsl.c
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/modules/senrsl$ gedit senrsl.c
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/modules/senrsl$ touch Android.mk
- senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/hardware/libhardware/modules/senrsl$
- /**
- * 这里按照Android硬件抽象层规范的要求,分别定义模块ID、模块结构体以及硬件接口结构体。在硬件接口结构体中,fd表示设备文件描述符,对应我们 将要处理的设备文件"/dev/senrsl",set_val和get_val为该HAL对上提供的函数接口。
- */
- #ifndef ANDROID_SENRSL_INTERFACE_H
- #define ANDROID_SENRSL_INTERFACE_H
- #include <hardware/hardware.h>
- __BEGIN_DECLS
- /*定义模块ID*/
- #define SENRSL_HARDWARE_MODULE_ID "senrsl"
- /*硬件模块结构体*/
- struct senrsl_module_t {
- struct hw_module_t common;
- };
- /*硬件接口结构体*/
- struct senrsl_device_t {
- struct hw_device_t common;
- int fd;
- int (*set_val)(struct senrsl_device_t* dev, int val);
- int (*get_val)(struct senrsl_device_t* dev, int* val);
- };
- __END_DECLS
没有评论 :
发表评论