android硬件驱动提取,自己动手 从android硬件驱动到APP---(2)hal驱动层

本文深入探讨了Android硬件抽象层(HAL)的实现,以hello模块为例,详细解析了hello.h和hello.c文件的内容,包括设备打开、关闭、设置和获取值的函数。通过这个例子,读者可以理解如何将硬件驱动与应用程序进行交互。
摘要由CSDN通过智能技术生成

1:aosp/hardware/libhardware/include/hardware/hello.h

#ifndef ANDROID_HELLO_INTERFACE_H

#define ANDROID_HELLO_INTERFACE_H

#include

__BEGIN_DECLS

#define HELLO_HARDWARE_MODULE_ID "hello"//ID

struct hello_module_t {

struct hw_module_t common;

};//hw_module_t的继承者

struct hello_device_t {

struct hw_device_t common;

int fd;

int (*set_val)(struct hello_device_t* dev, int val);

int (*get_val)(struct hello_device_t* dev, int* val);

};//hw_device_t的继承者

__END_DECLS

#endif

2:aosp/hardware/libhardware/modules/hello/hello.c

#define LOG_TAG "HelloStub"

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值