diff --git a/drivers/sensors/bmp280.c b/drivers/sensors/bmp280.c index ff557ccc69..fb0ea491a1 100644 --- a/drivers/sensors/bmp280.c +++ b/drivers/sensors/bmp280.c @@ -548,6 +548,33 @@ static uint32_t bmp280_getpressure(FAR struct bmp280_dev_s *priv) return press; } +/**************************************************************************** + * Name: bmp280_gettemp + * + * Description: + * Read temperature only + * + ****************************************************************************/ + +static uint32_t bmp280_gettemp(FAR struct bmp280_dev_s *priv) +{ + uint8_t buf[3]; + int32_t temp; + + bmp280_getregs(priv, BMP280_TEMP_MSB, buf, 3); + + temp = COMBINE(buf); + + sninfo("temp = %d\n", temp); + + if (priv->compensated == ENABLE_COMPENSATED) + { + temp = bmp280_compensate_temp(priv, temp); + } + + return temp; +} + /**************************************************************************** * Name: bmp280_open * @@ -641,6 +668,9 @@ static int bmp280_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ret = bmp280_set_standby(priv, arg); break; + case SNIOC_GET_TEMP: + *(uint32_t*)arg = bmp280_gettemp(priv); + default: snerr("Unrecognized cmd: %d\n", cmd); ret = - ENOTTY; diff --git a/include/nuttx/sensors/bmp280.h b/include/nuttx/sensors/bmp280.h index 44da0432b9..7c74987e02 100644 --- a/include/nuttx/sensors/bmp280.h +++ b/include/nuttx/sensors/bmp280.h @@ -112,6 +112,13 @@ extern "C" #define SNIOC_SETSTB _SNIOC(0x0003) +/* Get temperature value + * + * Arg: Pointer to uint32_t (raw value) + */ + +#define SNIOC_GET_TEMP _SNIOC(0x0004) + struct bmp280_press_adj_s { uint16_t dig_p1; /* calibration P1 data */