Android HAL 例 蓝牙模块

本文详细介绍了Android系统中硬件模块的加载过程,包括通过hw_get_module函数获取模块信息,利用模块的open方法打开设备,以及如何访问设备的私有方法等关键技术细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,hw module

设备模块类型定义:

/hardware/libhardware/include/hardware/hardware.h


打开hw module

hardware.c

int hw_get_module(const char *id, const struct hw_module_t **module)

通过id获得module信息块--hmi

io和so名称匹配及so存放路径查找原则参考该函数实现。


2,打开设备

通过hmi的open方法打开设备

err = module->methods->open(module, id, &abstraction);

3,设备私有方法访问

使用前downcast到具体的设备模块类型:

           bluetooth_module_t* btStack = (bluetooth_module_t *)abstraction;

调用模块自己的方法:

         sBluetoothInterface = btStack->get_bluetooth_interface();

4,设备模块实现:

/external/bluetooth/bluedroid/btif/src/bluetooth.c


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值