apq8053 Androidthings 底层硬件接口分析

//Androidthings 传感器流程
注册 SensorManager.DynamicSensorCallback
注册驱动服务 ProximityService

ProximityService中注册 Vcnl4200SensorDriver
Vcnl4200SensorDriver注册 UserDriverManager
UserDriverManager 调用 UserSensorReading
UserSensorReading调用readLight 真正的读取设备数据
在使能函数中做设备初始化。

//命令获取到的硬件接口
adb shell pio list uart

msm8x53_som:/ # pio list
gpio GPIO_0
gpio GPIO_1
gpio GPIO_117
gpio GPIO_127
gpio GPIO_13
gpio GPIO_140
gpio GPIO_35
gpio GPIO_42
gpio GPIO_43
gpio GPIO_44
gpio GPIO_45
gpio GPIO_46
gpio GPIO_48
gpio GPIO_65
gpio GPIO_68
gpio GPIO_85
gpio GPIO_86
gpio GPIO_87
gpio GPIO_98
gpio GPIO_99
i2c I2C1
i2c I2C2
uart UART6

接口配置
./msm8x53/somconfig/hardware_capabilities.xml

//在命令行测定GPIO
msm8x53_som:/ # pio gpio GPIO_85 read
1

系统中调用的是:
/etc/somconfig/default_configuration.pb
配置了需要的接口

在/device/qcom/msm8x53/msm8x53.mk中

P I/O HAL and SOM config for 8x53

202 PRODUCT_PACKAGES +=
203 default_configuration.pb
204 peripheral_io.msm8x53
205
206 # Camera
207 include device/qcom/msm8x53/camera.mk
208
209 # Keymaster

//映射函数
./qcom/msm8x53/pio_hal/pio_hal.cpp:98: // GPIO_1019 is a special-case, virtual GPIO that reflects the state of
./qcom/msm8x53/pio_hal/pio_hal.cpp:104: callbacks->register_sysfs_hidden_gpio(“GPIO_1019”, 1019);
//注册函数RegisterPeripherals

//从底层中取到节点然后注册 这个是example,更能直观的看出接口获取
// Initialization callback from PIO to register all known I/O. Called once
// on PIO daemon startup.
static int RegisterPeripherals(const pio_module_v1_t* /module/,
const pio_registration_callbacks_t* callbacks) {
// Register all the pins first.
for (const PioPin* pin : GetPins()) {
callbacks->register_pin(pin->hal_pin());
}

// Now link functions to their sysfs paths so PIO knows where to find them.
// Sysfs paths are just made up for this example HAL.

// GPIOs: /sys/class/gpio/gpio
callbacks->register_sysfs_gpio(“GPIO_A0”, 0);
callbacks->register_sysfs_gpio(“GPIO_A1”, 1);
callbacks->register_sysfs_gpio(“GPIO_A2”, 2);
callbacks->register_sysfs_gpio(“GPIO_A3”, 3);
callbacks->register_sysfs_gpio(“GPIO_B0”, 8);
callbacks->register_sysfs_gpio(“GPIO_B1”, 9);
callbacks->register_sysfs_gpio(“GPIO_B2”, 10);
callbacks->register_sysfs_gpio(“GPIO_B3”, 11);
callbacks->register_sysfs_gpio(“GPIO_B4”, 12);
callbacks->register_sysfs_gpio(“GPIO_B5”, 13);
callbacks->register_sysfs_gpio(“GPIO_B6”, 14);
callbacks->register_sysfs_gpio(“GPIO_B7”, 15);

// I2C0: /dev/i2c-4
callbacks->register_sysfs_i2c(“I2C0”, 4);

// PWM0: /sys/class/pwm/pwmchip0/pwm0
// PWM1: /sys/class/pwm/pwmchip1/pwm2
callbacks->register_sysfs_pwm(“PWM0”, 0, 0);
callbacks->register_sysfs_pwm(“PWM1”, 1, 2);

// SPI0.0: /dev/spidev1.0
// SPI0.1: /dev/spidev1.15
// SPI0.2: /dev/spidev1.32767
pio_sysfs_spi_chip_select_t chip_selects[] = {{0, 0}, {1, 15}, {2, 32767}};
callbacks->register_sysfs_spi(
“SPI0”, 1, chip_selects, arraysize(chip_selects));

// UART0: /dev/ttyS4
callbacks->register_sysfs_uart(“UART0”, “/dev/ttyS4”);

return 0;
}

系统中跑了一个peripheralman进程
peripheralman.rc
service peripheralman /system/bin/peripheralman
class main
user root
# Some UARTs are shared with Bluetooth, so give peripheralman access to the
# bluetooth group rather than giving everyone rw access to those devices.
# See b/78327678 and b/112380556.
group system bluetooth
onrestart restart zygote

msm8x53_som:/ # ps -A |grep peripheralman
root 517 1 38500 12516 SyS_epoll_wait 0 S peripheralman

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值