1struct rt_sensor_config2{3 struct rt_sensor_intf intf; /* sensor interface config */4 struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notification read data */5 rt_uint8_t mode; /* sensor work mode */6 rt_uint8_t power; /* sensor power ...
1#define irq_pin GET_PIN(B, 0)2 3int lps22hb_port(void) 4{ 5 struct rt_sensor_config cfg; 6 7 cfg.intf.dev_name = "i2c1"; 8 cfg.intf.user_data = (void *)0x55; 9 cfg.irq_pin.pin = irq_pin;10 cfg.irq_pin.mode = PIN_MODE_INPUT_PULLDOWN;11 rt_hw_xxx_init("xxx",...
Sensor 驱动框架抽象出了一些公共的配置选项,这些可配置的选项置于 struct rt_sensor_config 里, 成员如下: 1struct rt_sensor_config 2{ 3 struct rt_sensor_intf intf; /* sensor interface config */ 4 struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notificati...
staticstructrt_sensor_opssensor_ops= { ina226_fetch_data, ina226_control }; intrt_hw_ina226_init(constchar*name,structrt_sensor_config*cfg) { rt_err_tret=RT_EOK; rt_memset(&device,0,sizeof(struct_rt_ina226_device_t)); if(cfg->intf.user_data) ...
bh1750 sensor driver package, support: ambient light:选择使用 BH1750FVI 传感器软件包;Version:配置...
cfg.intf.dev_name=CCS811_I2C_BUS_NAME; rt_hw_ccs811_init("cs8",&cfg); returnRT_EOK; } INIT_COMPONENT_EXPORT(rt_hw_ccs811_port); 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 实际上,这一步在 sensor_ccs811_sample.c 示例中已经有了。因此,我们不用敲一行代码!
struct rt_sensor_config cfg; cfg.intf.dev_name = ISL29035_I2C_BUS; rt_hw_isl29035_init("isl29035", &cfg);returnRT_EOK; } INIT_ENV_EXPORT(rt_hw_isl29035_port); 可能默认使用的JLink-v7.50版本会下载失败,可以修改为6.80版本的JLink再尝试下载。
1intrt_hw_ds18b20_init(constchar*name,structrt_sensor_config *cfg)2{3rt_int8_t result;4rt_sensor_t sensor_temp =RT_NULL;56if(!ds18b20_init((rt_base_t)cfg->intf.user_data))7{8/*temperature sensor register*/9sensor_temp = rt_calloc(1,sizeof(structrt_sensor_device));10if(sensor...
Register the corresponding sensor device and complete the registration of aht10 device; #include"sensor_asair_aht10.h"#defineAHT10_I2C_BUS"i2c4"intrt_hw_aht10_port(void) {structrt_sensor_configcfg;cfg.intf.dev_name=AHT10_I2C_BUS;cfg.intf.user_data=(void*)AHT10_I2C_ADDR;rt_hw_aht10_...
测试命令 sensor_polling eco2_zmo ,验证能否读取 eCO2 数据。运行效果如下:msh />sensor_polling iaq_zmod [309438] I/sensor.zmod4410: Warmup! [311432] I/sensor.cmd: num: 0, IAQ: 1.0 , timestamp:946684800 [311740] I/sensor.zmod4410: Warmup! [313735] I/sensor.cmd: num: 1, IAQ: 1....