You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/02/24 11:55:21 UTC

[GitHub] [incubator-nuttx] Donny9 edited a comment on pull request #2907: sensor driver model update

Donny9 edited a comment on pull request #2907:
URL: https://github.com/apache/incubator-nuttx/pull/2907#issuecomment-785023389


   > Hi @Donny9 yesterday @phfbertoleti asked me about the idea of modifying the bmp180 driver to return pressure and temperature, but I noticed that the register function only will register a single sensor type. Is it possible to use this new sensor subsystem for composite devices like the bmp180?
   
   Yes, we can register composite sensors currently by new sensor driver model, you can refer to the wtgahrs2 driver https://github.com/apache/incubator-nuttx/blob/master/drivers/sensors/wtgahrs2.c.
   
   The following code register accel and gyro in a sensor driver.
     /* Accelerometer register */
   
     tmp = &rtdata->dev[WTGAHRS2_ACCEL_IDX];
     tmp->lower.ops = &g_wtgahrs2_ops;
     tmp->lower.type = SENSOR_TYPE_ACCELEROMETER;
     tmp->lower.buffer_size = sizeof(struct sensor_event_accel);
     ret = sensor_register(&tmp->lower, devno);
     if (ret < 0)
       {
         goto accel_err;
       }
   
     /* Gyroscope register */
   
     tmp = &rtdata->dev[WTGAHRS2_GYRO_IDX];
     tmp->lower.ops = &g_wtgahrs2_ops;
     tmp->lower.type = SENSOR_TYPE_GYROSCOPE;
     tmp->lower.buffer_size = sizeof(struct sensor_event_gyro);
     ret = sensor_register(&tmp->lower, devno);
     if (ret < 0)
       {
         goto gyro_err;
       }


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org