driver/sensor: change nbuffer and sensor event structure type

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-03-25 18:10:24 +08:00 committed by Xiang Xiao
parent e3e59a03b1
commit 01aa0c2d46
7 changed files with 54 additions and 54 deletions

View File

@ -602,7 +602,7 @@ static int bmp280_fetch(FAR struct sensor_lowerhalf_s *lower,
int32_t temp;
int ret;
struct timespec ts;
struct sensor_event_baro baro_data;
struct sensor_baro baro_data;
if (buflen != sizeof(baro_data))
{

View File

@ -571,12 +571,12 @@ static void ds18b20_notify(FAR struct ds18b20_dev_s *dev,
FAR struct ds18b20_sensor_data_s *data)
{
FAR struct ds18b20_sensor_s *sensor = &dev->sensor;
struct sensor_event_temp temp;
struct sensor_temp temp;
temp.temperature = ds18b20_temp(data->spad);
temp.timestamp = data->timestamp;
sensor->lower.push_event(sensor->lower.priv, &temp,
sizeof(struct sensor_event_temp));
sizeof(struct sensor_temp));
}
#endif
@ -640,18 +640,18 @@ static int ds18b20_fetch(FAR struct sensor_lowerhalf_s *lower,
/* Check if the user is reading the right size */
if (buflen != sizeof(struct sensor_event_temp))
if (buflen != sizeof(struct sensor_temp))
{
snerr("ERROR: You need to read %d bytes from this sensor!\n",
sizeof(struct sensor_event_temp));
sizeof(struct sensor_temp));
return -EINVAL;
}
ret = ds18b20_measure_read(priv, &data);
if (!ret)
{
FAR struct sensor_event_temp *temp =
(FAR struct sensor_event_temp *)buffer;
FAR struct sensor_temp *temp =
(FAR struct sensor_temp *)buffer;
temp->temperature = ds18b20_temp(data.spad);
temp->timestamp = data.timestamp;
}
@ -952,7 +952,7 @@ int ds18b20_register(int devno, FAR struct onewire_master_s *onewire,
tmp->lower.ops = &g_ds18b20_ops;
tmp->lower.type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
tmp->lower.uncalibrated = false;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{

View File

@ -133,7 +133,7 @@ static int fakesensor_read_csv_header(FAR struct fakesensor_s *sensor)
static inline void fakesensor_read_accel(FAR struct fakesensor_s *sensor)
{
struct sensor_event_accel accel;
struct sensor_accel accel;
char raw[50];
fakesensor_read_csv_line(
&sensor->data, raw, sizeof(raw), sensor->raw_start);
@ -141,12 +141,12 @@ static inline void fakesensor_read_accel(FAR struct fakesensor_s *sensor)
accel.temperature = NAN;
accel.timestamp = sensor_get_timestamp();
sensor->lower.push_event(sensor->lower.priv, &accel,
sizeof(struct sensor_event_accel));
sizeof(struct sensor_accel));
}
static inline void fakesensor_read_mag(FAR struct fakesensor_s *sensor)
{
struct sensor_event_mag mag;
struct sensor_mag mag;
char raw[50];
fakesensor_read_csv_line(
&sensor->data, raw, sizeof(raw), sensor->raw_start);
@ -154,12 +154,12 @@ static inline void fakesensor_read_mag(FAR struct fakesensor_s *sensor)
mag.temperature = NAN;
mag.timestamp = sensor_get_timestamp();
sensor->lower.push_event(sensor->lower.priv, &mag,
sizeof(struct sensor_event_mag));
sizeof(struct sensor_mag));
}
static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor)
{
struct sensor_event_gyro gyro;
struct sensor_gyro gyro;
char raw[50];
fakesensor_read_csv_line(
&sensor->data, raw, sizeof(raw), sensor->raw_start);
@ -167,12 +167,12 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor)
gyro.temperature = NAN;
gyro.timestamp = sensor_get_timestamp();
sensor->lower.push_event(sensor->lower.priv, &gyro,
sizeof(struct sensor_event_gyro));
sizeof(struct sensor_gyro));
}
static inline void fakesensor_read_gps(FAR struct fakesensor_s *sensor)
{
struct sensor_event_gps gps;
struct sensor_gps gps;
float time;
char latitude;
char longitude;
@ -181,7 +181,7 @@ static inline void fakesensor_read_gps(FAR struct fakesensor_s *sensor)
float hoop;
float altitude;
char raw[150];
memset(&gps, 0, sizeof(struct sensor_event_gps));
memset(&gps, 0, sizeof(struct sensor_gps));
read:
fakesensor_read_csv_line(
&sensor->data, raw, sizeof(raw), sensor->raw_start);
@ -210,7 +210,7 @@ static inline void fakesensor_read_gps(FAR struct fakesensor_s *sensor)
gps.altitude = altitude;
sensor->lower.push_event(sensor->lower.priv, &gps,
sizeof(struct sensor_event_gps));
sizeof(struct sensor_gps));
}
static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower, bool sw)
@ -247,7 +247,7 @@ static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower,
{
FAR struct fakesensor_s *sensor = container_of(lower,
struct fakesensor_s, lower);
unsigned long max_latency = sensor->lower.buffer_number * sensor->interval;
unsigned long max_latency = sensor->lower.nbuffer * sensor->interval;
if (*latency_us > max_latency)
{
*latency_us = max_latency;
@ -392,7 +392,7 @@ int fakesensor_init(int type, FAR const char *file_name,
sensor->lower.type = type;
sensor->lower.ops = &g_fakesensor_ops;
sensor->lower.buffer_number = batch_number;
sensor->lower.nbuffer = batch_number;
sensor->file_path = file_name;
nxsem_init(&sensor->wakeup, 0, 0);

View File

@ -152,7 +152,7 @@ static const struct sensor_ops_s g_hyt271_ops =
****************************************************************************/
static void hyt271_humi_from_rawdata(FAR struct hyt271_sensor_data_s *data,
FAR struct sensor_event_humi *humi)
FAR struct sensor_humi *humi)
{
humi->timestamp = data->timestamp;
humi->humidity = HYT271_HUMIDATA(data->data);
@ -169,7 +169,7 @@ static void hyt271_humi_from_rawdata(FAR struct hyt271_sensor_data_s *data,
****************************************************************************/
static void hyt271_temp_from_rawdata(FAR struct hyt271_sensor_data_s *data,
FAR struct sensor_event_temp *temp)
FAR struct sensor_temp *temp)
{
temp->timestamp = data->timestamp;
temp->temperature = HYT271_TEMPDATA(data->data);
@ -635,14 +635,14 @@ static int hyt271_fetch(FAR struct sensor_lowerhalf_s *lower,
{
case SENSOR_TYPE_AMBIENT_TEMPERATURE:
{
struct sensor_event_temp temp;
struct sensor_temp temp;
hyt271_temp_from_rawdata(&data, &temp);
memcpy(buffer, &temp, sizeof(temp));
}
break;
case SENSOR_TYPE_RELATIVE_HUMIDITY:
{
struct sensor_event_humi humi;
struct sensor_humi humi;
hyt271_humi_from_rawdata(&data, &humi);
memcpy(buffer, &humi, sizeof(humi));
}
@ -812,19 +812,19 @@ static int hyt271_thread(int argc, char** argv)
if (priv->initial_read == false || (hsensor->enabled == true &&
!HYT271_HUMIRAWEQUAL(orawdata, data.data)))
{
struct sensor_event_humi humi;
struct sensor_humi humi;
hyt271_humi_from_rawdata(&data, &humi);
hsensor->lower.push_event(hsensor->lower.priv, &humi,
sizeof(struct sensor_event_humi));
sizeof(struct sensor_humi));
}
if (priv->initial_read == false || (tsensor->enabled == true &&
!HYT271_TEMPRAWEQUAL(orawdata, data.data)))
{
struct sensor_event_temp temp;
struct sensor_temp temp;
hyt271_temp_from_rawdata(&data, &temp);
tsensor->lower.push_event(tsensor->lower.priv, &temp,
sizeof(struct sensor_event_temp));
sizeof(struct sensor_temp));
}
if (priv->initial_read == false)
@ -917,11 +917,11 @@ int hyt271_register(int devno, FAR struct i2c_master_s *i2c, uint8_t addr,
#ifdef CONFIG_SENSORS_HYT271_POLL
tmp->enabled = false;
#endif
tmp->buffer_size = sizeof(struct sensor_event_humi);
tmp->buffer_size = sizeof(struct sensor_humi);
tmp->lower.ops = &g_hyt271_ops;
tmp->lower.type = SENSOR_TYPE_RELATIVE_HUMIDITY;
tmp->lower.uncalibrated = false;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{
@ -935,11 +935,11 @@ int hyt271_register(int devno, FAR struct i2c_master_s *i2c, uint8_t addr,
#ifdef CONFIG_SENSORS_HYT271_POLL
tmp->enabled = false;
#endif
tmp->buffer_size = sizeof(struct sensor_event_temp);
tmp->buffer_size = sizeof(struct sensor_temp);
tmp->lower.ops = &g_hyt271_ops;
tmp->lower.type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
tmp->lower.uncalibrated = false;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{

View File

@ -82,7 +82,7 @@ static void l3gd20_write_register(FAR struct l3gd20_dev_s *dev,
uint8_t const reg_data);
static void l3gd20_reset(FAR struct l3gd20_dev_s *dev);
static void l3gd20_read_measurement_data(FAR struct l3gd20_dev_s *dev,
FAR struct sensor_event_gyro *data);
FAR struct sensor_gyro *data);
static void l3gd20_read_gyroscope_data(FAR struct l3gd20_dev_s *dev,
uint16_t *x_gyr, uint16_t *y_gyr,
uint16_t *z_gyr);
@ -217,7 +217,7 @@ static void l3gd20_reset(FAR struct l3gd20_dev_s *dev)
****************************************************************************/
static void l3gd20_read_measurement_data(FAR struct l3gd20_dev_s *dev,
FAR struct sensor_event_gyro *data)
FAR struct sensor_gyro *data)
{
uint16_t x_gyr = 0;
uint16_t y_gyr = 0;
@ -381,7 +381,7 @@ static int l3gd20_interrupt_handler(int irq, FAR void *context,
static void l3gd20_worker(FAR void *arg)
{
struct sensor_event_gyro temp;
struct sensor_gyro temp;
FAR struct l3gd20_dev_s *priv = (FAR struct l3gd20_dev_s *)(arg);
DEBUGASSERT(priv != NULL);
@ -393,7 +393,7 @@ static void l3gd20_worker(FAR void *arg)
/* push data to upper half driver */
priv->lower.push_event(priv->lower.priv, &temp,
sizeof(struct sensor_event_gyro));
sizeof(struct sensor_gyro));
}
#else
@ -409,16 +409,16 @@ static int l3gd20_fetch(FAR struct sensor_lowerhalf_s *lower,
FAR struct l3gd20_dev_s,
lower);
if (buflen != sizeof(struct sensor_event_gyro))
if (buflen != sizeof(struct sensor_gyro))
return 0;
DEBUGASSERT(priv != NULL);
/* Read out the latest sensor data */
l3gd20_read_measurement_data(priv, (FAR struct sensor_event_gyro *)buffer);
l3gd20_read_measurement_data(priv, (FAR struct sensor_gyro *)buffer);
return sizeof(struct sensor_event_gyro);
return sizeof(struct sensor_gyro);
}
#endif
@ -432,7 +432,7 @@ static int l3gd20_activate(FAR struct sensor_lowerhalf_s *lower,
FAR struct l3gd20_dev_s *priv = container_of(lower,
FAR struct l3gd20_dev_s,
lower);
struct sensor_event_gyro temp;
struct sensor_gyro temp;
#ifdef CONFIG_DEBUG_SENSORS_INFO
uint8_t reg_content;
@ -559,7 +559,7 @@ int l3gd20_register(int devno, FAR struct spi_dev_s *spi,
priv->timestamp = 0;
priv->lower.type = SENSOR_TYPE_GYROSCOPE;
priv->lower.buffer_number = CONFIG_SENSORS_L3GD20_BUFFER_SIZE;
priv->lower.nbuffer = CONFIG_SENSORS_L3GD20_BUFFER_SIZE;
priv->lower.ops = &g_l2gd20_ops;
priv->lower.uncalibrated = true;

View File

@ -250,7 +250,7 @@ static int ms5611_read24(FAR struct ms5611_dev_s *priv, uint8_t *regval)
}
static inline void baro_measure_read(FAR struct ms5611_dev_s *priv,
FAR struct sensor_event_baro *baro)
FAR struct sensor_baro *baro)
{
uint32_t press;
uint32_t temp;
@ -370,7 +370,7 @@ static int ms5611_thread(int argc, char **argv)
FAR struct ms5611_dev_s *priv = (FAR struct ms5611_dev_s *)
((uintptr_t)strtoul(argv[1], NULL, 0));
struct sensor_event_baro baro_data;
struct sensor_baro baro_data;
while (true)
{
@ -390,7 +390,7 @@ static int ms5611_thread(int argc, char **argv)
baro_measure_read(priv, &baro_data);
priv->sensor_lower.push_event(priv->sensor_lower.priv, &baro_data,
sizeof(struct sensor_event_baro));
sizeof(struct sensor_baro));
/* Sleeping thread before fetching the next sensor data */
@ -596,7 +596,7 @@ static int ms5611_fetch(FAR struct sensor_lowerhalf_s *lower,
FAR struct ms5611_dev_s *priv = container_of(lower,
FAR struct ms5611_dev_s,
sensor_lower);
struct sensor_event_baro baro_data;
struct sensor_baro baro_data;
if (buflen != sizeof(baro_data))
{

View File

@ -83,7 +83,7 @@ struct wtgahrs2_dev_s
struct wtgahrs2_sensor_s dev[WTGAHRS2_MAX_IDX];
struct file file;
struct sensor_event_gps gps;
struct sensor_gps gps;
unsigned char gps_mask;
};
@ -186,7 +186,7 @@ static void wtgahrs2_accel_data(FAR struct wtgahrs2_dev_s *rtdata,
FAR struct wtgahrs2_sensor_s *dev = &rtdata->dev[WTGAHRS2_ACCEL_IDX];
FAR struct sensor_lowerhalf_s *lower = &dev->lower;
uint64_t now = sensor_get_timestamp();
struct sensor_event_accel accel;
struct sensor_accel accel;
if (!dev->enable || now - dev->last_update < dev->interval)
{
@ -212,7 +212,7 @@ static void wtgahrs2_gyro_data(FAR struct wtgahrs2_dev_s *rtdata,
FAR struct wtgahrs2_sensor_s *dev = &rtdata->dev[WTGAHRS2_GYRO_IDX];
FAR struct sensor_lowerhalf_s *lower = &dev->lower;
uint64_t now = sensor_get_timestamp();
struct sensor_event_gyro gyro;
struct sensor_gyro gyro;
if (!dev->enable || now - dev->last_update < dev->interval)
{
@ -238,7 +238,7 @@ static void wtgahrs2_mag_data(FAR struct wtgahrs2_dev_s *rtdata,
FAR struct wtgahrs2_sensor_s *dev = &rtdata->dev[WTGAHRS2_MAG_IDX];
FAR struct sensor_lowerhalf_s *lower = &dev->lower;
uint64_t now = sensor_get_timestamp();
struct sensor_event_mag mag;
struct sensor_mag mag;
if (!dev->enable || now - dev->last_update < dev->interval)
{
@ -264,7 +264,7 @@ static void wtgahrs2_baro_data(FAR struct wtgahrs2_dev_s *rtdata,
FAR struct wtgahrs2_sensor_s *dev = &rtdata->dev[WTGAHRS2_BARO_IDX];
FAR struct sensor_lowerhalf_s *lower = &dev->lower;
uint64_t now = sensor_get_timestamp();
struct sensor_event_baro baro;
struct sensor_baro baro;
if (!dev->enable || now - dev->last_update < dev->interval)
{
@ -471,7 +471,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
tmp = &rtdata->dev[WTGAHRS2_ACCEL_IDX];
tmp->lower.ops = &g_wtgahrs2_ops;
tmp->lower.type = SENSOR_TYPE_ACCELEROMETER;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{
@ -483,7 +483,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
tmp = &rtdata->dev[WTGAHRS2_GYRO_IDX];
tmp->lower.ops = &g_wtgahrs2_ops;
tmp->lower.type = SENSOR_TYPE_GYROSCOPE;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{
@ -495,7 +495,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
tmp = &rtdata->dev[WTGAHRS2_MAG_IDX];
tmp->lower.ops = &g_wtgahrs2_ops;
tmp->lower.type = SENSOR_TYPE_MAGNETIC_FIELD;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{
@ -507,7 +507,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
tmp = &rtdata->dev[WTGAHRS2_BARO_IDX];
tmp->lower.ops = &g_wtgahrs2_ops;
tmp->lower.type = SENSOR_TYPE_BAROMETER;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{
@ -519,7 +519,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
tmp = &rtdata->dev[WTGAHRS2_GPS_IDX];
tmp->lower.ops = &g_wtgahrs2_ops;
tmp->lower.type = SENSOR_TYPE_GPS;
tmp->lower.buffer_number = 1;
tmp->lower.nbuffer = 1;
ret = sensor_register(&tmp->lower, devno);
if (ret < 0)
{