mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
sensors/bmp180_uorb: support for fixed-point data
support for fixed-point data for bmp180_uorb Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
parent
37981b2b2f
commit
5c3c369dbd
3 changed files with 9 additions and 3 deletions
|
|
@ -293,7 +293,7 @@ void bmp180_read_press_temp(FAR struct bmp180_dev_s *priv)
|
|||
****************************************************************************/
|
||||
|
||||
int bmp180_getpressure(FAR struct bmp180_dev_s *priv,
|
||||
FAR float *temperature)
|
||||
FAR int *temperature)
|
||||
{
|
||||
int32_t x1;
|
||||
int32_t x2;
|
||||
|
|
@ -338,7 +338,9 @@ int bmp180_getpressure(FAR struct bmp180_dev_s *priv,
|
|||
sninfo("Compensated temperature = %" PRId32 "\n", temp);
|
||||
|
||||
if (temperature != NULL)
|
||||
{
|
||||
*temperature = temp;
|
||||
}
|
||||
|
||||
/* Calculate true pressure */
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,6 @@ int bmp180_checkid(FAR struct bmp180_dev_s *priv);
|
|||
void bmp180_updatecaldata(FAR struct bmp180_dev_s *priv);
|
||||
void bmp180_read_press_temp(FAR struct bmp180_dev_s *priv);
|
||||
int bmp180_getpressure(FAR struct bmp180_dev_s *priv,
|
||||
FAR float *temperature);
|
||||
FAR int *temperature);
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_SENSORS_BMP180 */
|
||||
|
|
|
|||
|
|
@ -197,6 +197,8 @@ static void bmp180_worker(FAR void *arg)
|
|||
{
|
||||
FAR struct bmp180_dev_uorb_s *priv = arg;
|
||||
struct sensor_baro baro;
|
||||
int press;
|
||||
int temp;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
|
|
@ -204,7 +206,9 @@ static void bmp180_worker(FAR void *arg)
|
|||
bmp180_worker, priv,
|
||||
priv->interval / USEC_PER_TICK);
|
||||
|
||||
baro.pressure = bmp180_getpressure(&priv->dev, &baro.temperature) / 100.0f;
|
||||
press = bmp180_getpressure(&priv->dev, &temp);
|
||||
baro.temperature = sensor_data_itof(temp);
|
||||
baro.pressure = sensor_data_divi(press, 100);
|
||||
baro.timestamp = sensor_get_timestamp();
|
||||
|
||||
priv->lower.push_event(priv->lower.priv, &baro, sizeof(baro));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue