bmp280: support getting temperature via ioctl()
This commit is contained in:
parent
7ce175b614
commit
6c333d7cbf
|
@ -548,6 +548,33 @@ static uint32_t bmp280_getpressure(FAR struct bmp280_dev_s *priv)
|
||||||
return press;
|
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
|
* 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);
|
ret = bmp280_set_standby(priv, arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SNIOC_GET_TEMP:
|
||||||
|
*(uint32_t*)arg = bmp280_gettemp(priv);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snerr("Unrecognized cmd: %d\n", cmd);
|
snerr("Unrecognized cmd: %d\n", cmd);
|
||||||
ret = - ENOTTY;
|
ret = - ENOTTY;
|
||||||
|
|
|
@ -112,6 +112,13 @@ extern "C"
|
||||||
|
|
||||||
#define SNIOC_SETSTB _SNIOC(0x0003)
|
#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
|
struct bmp280_press_adj_s
|
||||||
{
|
{
|
||||||
uint16_t dig_p1; /* calibration P1 data */
|
uint16_t dig_p1; /* calibration P1 data */
|
||||||
|
|
Loading…
Reference in New Issue