mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 12:08:36 +08:00
driver/sensor: update sensor data structure and state structure
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
24040250f5
commit
e3e59a03b1
4 changed files with 118 additions and 123 deletions
|
@ -58,7 +58,7 @@
|
|||
|
||||
struct sensor_info_s
|
||||
{
|
||||
uint8_t esize;
|
||||
unsigned long esize;
|
||||
FAR char *name;
|
||||
};
|
||||
|
||||
|
@ -82,7 +82,7 @@ struct sensor_user_s
|
|||
* appear in dual role
|
||||
*/
|
||||
|
||||
size_t generation; /* Last generation subscriber has seen */
|
||||
unsigned long generation; /* Last generation subscriber has seen */
|
||||
unsigned long interval; /* The interval for subscriber */
|
||||
unsigned long latency; /* The bactch latency for subscriber */
|
||||
};
|
||||
|
@ -94,9 +94,7 @@ struct sensor_upperhalf_s
|
|||
FAR struct sensor_lowerhalf_s *lower; /* The handle of lower half driver */
|
||||
struct sensor_state_s state; /* The state of sensor device */
|
||||
struct circbuf_s buffer; /* The circular buffer of sensor device */
|
||||
uint8_t esize; /* The element size of circular buffer */
|
||||
sem_t exclsem; /* Manages exclusive access to file operations */
|
||||
size_t generation; /* The current generation count */
|
||||
struct list_node userlist; /* List of users */
|
||||
};
|
||||
|
||||
|
@ -125,39 +123,39 @@ static ssize_t sensor_push_event(FAR void *priv, FAR const void *data,
|
|||
|
||||
static const struct sensor_info_s g_sensor_info[] =
|
||||
{
|
||||
{0, NULL},
|
||||
{sizeof(struct sensor_event_accel), "accel"},
|
||||
{sizeof(struct sensor_event_mag), "mag"},
|
||||
{sizeof(struct sensor_event_gyro), "gyro"},
|
||||
{sizeof(struct sensor_event_light), "light"},
|
||||
{sizeof(struct sensor_event_baro), "baro"},
|
||||
{sizeof(struct sensor_event_prox), "prox"},
|
||||
{sizeof(struct sensor_event_humi), "humi"},
|
||||
{sizeof(struct sensor_event_temp), "temp"},
|
||||
{sizeof(struct sensor_event_rgb), "rgb"},
|
||||
{sizeof(struct sensor_event_hall), "hall"},
|
||||
{sizeof(struct sensor_event_ir), "ir"},
|
||||
{sizeof(struct sensor_event_gps), "gps"},
|
||||
{sizeof(struct sensor_event_uv), "uv"},
|
||||
{sizeof(struct sensor_event_noise), "noise"},
|
||||
{sizeof(struct sensor_event_pm25), "pm25"},
|
||||
{sizeof(struct sensor_event_pm1p0), "pm1p0"},
|
||||
{sizeof(struct sensor_event_pm10), "pm10"},
|
||||
{sizeof(struct sensor_event_co2), "co2"},
|
||||
{sizeof(struct sensor_event_hcho), "hcho"},
|
||||
{sizeof(struct sensor_event_tvoc), "tvoc"},
|
||||
{sizeof(struct sensor_event_ph), "ph"},
|
||||
{sizeof(struct sensor_event_dust), "dust"},
|
||||
{sizeof(struct sensor_event_hrate), "hrate"},
|
||||
{sizeof(struct sensor_event_hbeat), "hbeat"},
|
||||
{sizeof(struct sensor_event_ecg), "ecg"},
|
||||
{sizeof(struct sensor_event_ppgd), "ppgd"},
|
||||
{sizeof(struct sensor_event_ppgq), "ppgq"},
|
||||
{sizeof(struct sensor_event_impd), "impd"},
|
||||
{sizeof(struct sensor_event_ots), "ots"},
|
||||
{sizeof(struct sensor_event_gps_satellite), "gps_satellite"},
|
||||
{sizeof(struct sensor_event_wake_gesture), "wake_gesture"},
|
||||
{sizeof(struct sensor_event_cap), "cap"},
|
||||
{0, NULL},
|
||||
{sizeof(struct sensor_accel), "accel"},
|
||||
{sizeof(struct sensor_mag), "mag"},
|
||||
{sizeof(struct sensor_gyro), "gyro"},
|
||||
{sizeof(struct sensor_light), "light"},
|
||||
{sizeof(struct sensor_baro), "baro"},
|
||||
{sizeof(struct sensor_prox), "prox"},
|
||||
{sizeof(struct sensor_humi), "humi"},
|
||||
{sizeof(struct sensor_temp), "temp"},
|
||||
{sizeof(struct sensor_rgb), "rgb"},
|
||||
{sizeof(struct sensor_hall), "hall"},
|
||||
{sizeof(struct sensor_ir), "ir"},
|
||||
{sizeof(struct sensor_gps), "gps"},
|
||||
{sizeof(struct sensor_uv), "uv"},
|
||||
{sizeof(struct sensor_noise), "noise"},
|
||||
{sizeof(struct sensor_pm25), "pm25"},
|
||||
{sizeof(struct sensor_pm1p0), "pm1p0"},
|
||||
{sizeof(struct sensor_pm10), "pm10"},
|
||||
{sizeof(struct sensor_co2), "co2"},
|
||||
{sizeof(struct sensor_hcho), "hcho"},
|
||||
{sizeof(struct sensor_tvoc), "tvoc"},
|
||||
{sizeof(struct sensor_ph), "ph"},
|
||||
{sizeof(struct sensor_dust), "dust"},
|
||||
{sizeof(struct sensor_hrate), "hrate"},
|
||||
{sizeof(struct sensor_hbeat), "hbeat"},
|
||||
{sizeof(struct sensor_ecg), "ecg"},
|
||||
{sizeof(struct sensor_ppgd), "ppgd"},
|
||||
{sizeof(struct sensor_ppgq), "ppgq"},
|
||||
{sizeof(struct sensor_impd), "impd"},
|
||||
{sizeof(struct sensor_ots), "ots"},
|
||||
{sizeof(struct sensor_gps_satellite), "gps_satellite"},
|
||||
{sizeof(struct sensor_wake_gesture), "wake_gesture"},
|
||||
{sizeof(struct sensor_cap), "cap"},
|
||||
};
|
||||
|
||||
static const struct file_operations g_sensor_fops =
|
||||
|
@ -178,7 +176,8 @@ static const struct file_operations g_sensor_fops =
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static bool sensor_in_range(size_t left, size_t value, size_t right)
|
||||
static bool sensor_in_range(unsigned long left, unsigned long value,
|
||||
unsigned long right)
|
||||
{
|
||||
if (left < right)
|
||||
{
|
||||
|
@ -192,7 +191,8 @@ static bool sensor_in_range(size_t left, size_t value, size_t right)
|
|||
}
|
||||
}
|
||||
|
||||
static bool sensor_is_updated(size_t generation, size_t ugeneration)
|
||||
static bool sensor_is_updated(unsigned long generation,
|
||||
unsigned long ugeneration)
|
||||
{
|
||||
return generation > ugeneration;
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ static int sensor_open(FAR struct file *filep)
|
|||
|
||||
user->interval = ULONG_MAX;
|
||||
user->latency = ULONG_MAX;
|
||||
user->generation = upper->generation;
|
||||
user->generation = upper->state.generation;
|
||||
nxsem_init(&user->buffersem, 0, 0);
|
||||
nxsem_set_protocol(&user->buffersem, SEM_PRIO_NONE);
|
||||
list_add_tail(&upper->userlist, &user->node);
|
||||
|
@ -458,8 +458,8 @@ static ssize_t sensor_read(FAR struct file *filep, FAR char *buffer,
|
|||
FAR struct sensor_upperhalf_s *upper = inode->i_private;
|
||||
FAR struct sensor_lowerhalf_s *lower = upper->lower;
|
||||
FAR struct sensor_user_s *user = filep->f_priv;
|
||||
unsigned long nums;
|
||||
ssize_t ret;
|
||||
size_t nums;
|
||||
|
||||
if (!buffer || !len)
|
||||
{
|
||||
|
@ -534,7 +534,7 @@ static ssize_t sensor_read(FAR struct file *filep, FAR char *buffer,
|
|||
* new data.
|
||||
*/
|
||||
|
||||
if (user->generation == upper->generation)
|
||||
if (user->generation == upper->state.generation)
|
||||
{
|
||||
user->generation--;
|
||||
}
|
||||
|
@ -543,21 +543,22 @@ static ssize_t sensor_read(FAR struct file *filep, FAR char *buffer,
|
|||
* oldest data in circbuffer are returned to the users.
|
||||
*/
|
||||
|
||||
else if (!sensor_in_range(upper->generation - lower->buffer_number,
|
||||
user->generation, upper->generation))
|
||||
else if (!sensor_in_range(upper->state.generation - lower->nbuffer,
|
||||
user->generation, upper->state.generation))
|
||||
|
||||
{
|
||||
user->generation = upper->generation - lower->buffer_number;
|
||||
user->generation = upper->state.generation - lower->nbuffer;
|
||||
}
|
||||
|
||||
nums = upper->generation - user->generation;
|
||||
if (len < nums * upper->esize)
|
||||
nums = upper->state.generation - user->generation;
|
||||
if (len < nums * upper->state.esize)
|
||||
{
|
||||
nums = len / upper->esize;
|
||||
nums = len / upper->state.esize;
|
||||
}
|
||||
|
||||
len = nums * upper->esize;
|
||||
ret = circbuf_peekat(&upper->buffer, user->generation * upper->esize,
|
||||
len = nums * upper->state.esize;
|
||||
ret = circbuf_peekat(&upper->buffer,
|
||||
user->generation * upper->state.esize,
|
||||
buffer, len);
|
||||
user->generation += nums;
|
||||
}
|
||||
|
@ -650,9 +651,9 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
}
|
||||
break;
|
||||
|
||||
case SNIOC_GET_NEVENTBUF:
|
||||
case SNIOC_SET_USERPRIV:
|
||||
{
|
||||
*(FAR uint32_t *)(uintptr_t)arg = lower->buffer_number;
|
||||
upper->state.priv = (FAR void *)(uintptr_t)arg;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -660,9 +661,9 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
if (!circbuf_is_init(&upper->buffer))
|
||||
{
|
||||
if (arg >= lower->buffer_number)
|
||||
if (arg >= lower->nbuffer)
|
||||
{
|
||||
lower->buffer_number = arg;
|
||||
lower->nbuffer = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -742,7 +743,7 @@ static int sensor_poll(FAR struct file *filep,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (sensor_is_updated(upper->generation, user->generation))
|
||||
else if (sensor_is_updated(upper->state.generation, user->generation))
|
||||
{
|
||||
eventset |= (fds->events & POLLIN);
|
||||
}
|
||||
|
@ -774,12 +775,12 @@ static ssize_t sensor_push_event(FAR void *priv, FAR const void *data,
|
|||
FAR struct sensor_upperhalf_s *upper = priv;
|
||||
FAR struct sensor_lowerhalf_s *lower = upper->lower;
|
||||
FAR struct sensor_user_s *user;
|
||||
size_t envcount;
|
||||
unsigned long envcount;
|
||||
int semcount;
|
||||
int ret;
|
||||
|
||||
envcount = bytes / upper->esize;
|
||||
if (!envcount || bytes != envcount * upper->esize)
|
||||
envcount = bytes / upper->state.esize;
|
||||
if (!envcount || bytes != envcount * upper->state.esize)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -794,8 +795,8 @@ static ssize_t sensor_push_event(FAR void *priv, FAR const void *data,
|
|||
{
|
||||
/* Initialize sensor buffer when data is first generated */
|
||||
|
||||
ret = circbuf_init(&upper->buffer, NULL, lower->buffer_number *
|
||||
upper->esize);
|
||||
ret = circbuf_init(&upper->buffer, NULL, lower->nbuffer *
|
||||
upper->state.esize);
|
||||
if (ret < 0)
|
||||
{
|
||||
nxsem_post(&upper->exclsem);
|
||||
|
@ -804,10 +805,10 @@ static ssize_t sensor_push_event(FAR void *priv, FAR const void *data,
|
|||
}
|
||||
|
||||
circbuf_overwrite(&upper->buffer, data, bytes);
|
||||
upper->generation += envcount;
|
||||
upper->state.generation += envcount;
|
||||
list_for_every_entry(&upper->userlist, user, struct sensor_user_s, node)
|
||||
{
|
||||
if (sensor_is_updated(upper->generation, user->generation))
|
||||
if (sensor_is_updated(upper->state.generation, user->generation))
|
||||
{
|
||||
nxsem_get_value(&user->buffersem, &semcount);
|
||||
if (semcount < 1)
|
||||
|
@ -916,7 +917,7 @@ int sensor_register(FAR struct sensor_lowerhalf_s *lower, int devno)
|
|||
****************************************************************************/
|
||||
|
||||
int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR const char *path, uint8_t esize)
|
||||
FAR const char *path, unsigned long esize)
|
||||
{
|
||||
FAR struct sensor_upperhalf_s *upper;
|
||||
int ret = -EINVAL;
|
||||
|
@ -941,9 +942,9 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower,
|
|||
/* Initialize the upper-half data structure */
|
||||
|
||||
upper->lower = lower;
|
||||
upper->esize = esize;
|
||||
|
||||
list_initialize(&upper->userlist);
|
||||
upper->state.esize = esize;
|
||||
upper->state.min_interval = ULONG_MAX;
|
||||
upper->state.min_latency = ULONG_MAX;
|
||||
if (lower->ops->activate)
|
||||
|
@ -959,9 +960,9 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower,
|
|||
|
||||
if (!lower->ops->fetch)
|
||||
{
|
||||
if (!lower->buffer_number)
|
||||
if (!lower->nbuffer)
|
||||
{
|
||||
lower->buffer_number = 1;
|
||||
lower->nbuffer = 1;
|
||||
}
|
||||
|
||||
lower->push_event = sensor_push_event;
|
||||
|
@ -969,9 +970,10 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower,
|
|||
else
|
||||
{
|
||||
lower->notify_event = sensor_notify_event;
|
||||
lower->buffer_number = 0;
|
||||
lower->nbuffer = 0;
|
||||
}
|
||||
|
||||
upper->state.nbuffer = lower->nbuffer;
|
||||
sninfo("Registering %s\n", path);
|
||||
ret = register_driver(path, &g_sensor_fops, 0666, upper);
|
||||
if (ret)
|
||||
|
|
|
@ -104,7 +104,7 @@ static int usensor_register(FAR struct usensor_context_s *usensor,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
lower->driver.buffer_number = info->nqueue;
|
||||
lower->driver.nbuffer = info->nbuffer;
|
||||
lower->driver.ops = &g_usensor_ops;
|
||||
strcpy(lower->path, info->path);
|
||||
ret = sensor_custom_register(&lower->driver, lower->path, info->esize);
|
||||
|
|
|
@ -256,22 +256,12 @@
|
|||
|
||||
#define SNIOC_BATCH _SNIOC(0x0082)
|
||||
|
||||
/* Command: SNIOC_GET_NEVENTBUF
|
||||
* Description: the number of sensor events that sensor buffer of upper half
|
||||
* holds.
|
||||
* Argument: This is the number of events pointer, is output parameter.
|
||||
* Note: Tell the application layer number of sensor events in sensor
|
||||
* buffer.
|
||||
* This buffer is used to solve the problem that the
|
||||
* application layer can't read the sensor event in time.
|
||||
* Recommend the number of sensor events in application layer's
|
||||
* buffer is same as result by call this function.
|
||||
* This is number of sensor events rather than the length of
|
||||
* buffer.
|
||||
* See sensor.h(struct sensor_lower_half_s buffer_bytes).
|
||||
/* Command: SNIOC_SET_USERPRIV
|
||||
* Description: Set the private data of userspace user.
|
||||
* Argument: This is the pointer of private data.
|
||||
*/
|
||||
|
||||
#define SNIOC_GET_NEVENTBUF _SNIOC(0x0083)
|
||||
#define SNIOC_SET_USERPRIV _SNIOC(0x0083)
|
||||
|
||||
/* Command: SNIOC_SET_BUFFER_NUMBER
|
||||
* Description: Set the number of events intermediate circualr buffer can
|
||||
|
|
|
@ -313,7 +313,7 @@ static inline uint64_t sensor_get_timestamp(void)
|
|||
* reported.
|
||||
*/
|
||||
|
||||
struct sensor_event_accel /* Type: Accerometer */
|
||||
struct sensor_accel /* Type: Accerometer */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float x; /* Axis X in m/s^2 */
|
||||
|
@ -322,7 +322,7 @@ struct sensor_event_accel /* Type: Accerometer */
|
|||
float temperature; /* Temperature in degrees celsius */
|
||||
};
|
||||
|
||||
struct sensor_event_gyro /* Type: Gyroscope */
|
||||
struct sensor_gyro /* Type: Gyroscope */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float x; /* Axis X in rad/s */
|
||||
|
@ -331,7 +331,7 @@ struct sensor_event_gyro /* Type: Gyroscope */
|
|||
float temperature; /* Temperature in degrees celsius */
|
||||
};
|
||||
|
||||
struct sensor_event_mag /* Type: Magnetic Field */
|
||||
struct sensor_mag /* Type: Magnetic Field */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float x; /* Axis X in Gauss or micro Tesla (uT) */
|
||||
|
@ -340,38 +340,38 @@ struct sensor_event_mag /* Type: Magnetic Field */
|
|||
float temperature; /* Temperature in degrees celsius */
|
||||
};
|
||||
|
||||
struct sensor_event_baro /* Type: Barometer */
|
||||
struct sensor_baro /* Type: Barometer */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float pressure; /* pressure measurement in millibar or hpa */
|
||||
float temperature; /* Temperature in degrees celsius */
|
||||
};
|
||||
|
||||
struct sensor_event_prox /* Type: proximity */
|
||||
struct sensor_prox /* Type: proximity */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float proximity; /* distance to the nearest object in centimeters */
|
||||
};
|
||||
|
||||
struct sensor_event_light /* Type: Light */
|
||||
struct sensor_light /* Type: Light */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float light; /* in SI lux units */
|
||||
};
|
||||
|
||||
struct sensor_event_humi /* Type: Relative Humidity */
|
||||
struct sensor_humi /* Type: Relative Humidity */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float humidity; /* in percent */
|
||||
};
|
||||
|
||||
struct sensor_event_temp /* Type: Ambient Temperature */
|
||||
struct sensor_temp /* Type: Ambient Temperature */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float temperature; /* Temperature in degrees celsius */
|
||||
};
|
||||
|
||||
struct sensor_event_rgb /* Type: RGB */
|
||||
struct sensor_rgb /* Type: RGB */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float r; /* Units is percent */
|
||||
|
@ -379,19 +379,19 @@ struct sensor_event_rgb /* Type: RGB */
|
|||
float b; /* Units is percent */
|
||||
};
|
||||
|
||||
struct sensor_event_hall /* Type: HALL */
|
||||
struct sensor_hall /* Type: HALL */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
bool hall; /* Boolean type */
|
||||
};
|
||||
|
||||
struct sensor_event_ir /* Type: Infrared Ray */
|
||||
struct sensor_ir /* Type: Infrared Ray */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float ir; /* in SI units lux */
|
||||
};
|
||||
|
||||
struct sensor_event_gps /* Type: Gps */
|
||||
struct sensor_gps /* Type: Gps */
|
||||
{
|
||||
uint64_t timestamp; /* Time since system start, Units is microseconds */
|
||||
|
||||
|
@ -424,85 +424,85 @@ struct sensor_event_gps /* Type: Gps */
|
|||
uint32_t satellites_used; /* Number of satellites used */
|
||||
};
|
||||
|
||||
struct sensor_event_uv /* Type: Ultraviolet Light */
|
||||
struct sensor_uv /* Type: Ultraviolet Light */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float uvi; /* the value range is 0 - 15 */
|
||||
};
|
||||
|
||||
struct sensor_event_noise /* Type: Noise Loudness */
|
||||
struct sensor_noise /* Type: Noise Loudness */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float db; /* in SI units db */
|
||||
};
|
||||
|
||||
struct sensor_event_pm25 /* Type: PM25 */
|
||||
struct sensor_pm25 /* Type: PM25 */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float pm25; /* in SI units ug/m^3 */
|
||||
};
|
||||
|
||||
struct sensor_event_pm10 /* Type: PM10 */
|
||||
struct sensor_pm10 /* Type: PM10 */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float pm10; /* in SI units ug/m^3 */
|
||||
};
|
||||
|
||||
struct sensor_event_pm1p0 /* Type: PM1P0 */
|
||||
struct sensor_pm1p0 /* Type: PM1P0 */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float pm1p0; /* in SI units ug/m^3 */
|
||||
};
|
||||
|
||||
struct sensor_event_co2 /* Type: CO2 */
|
||||
struct sensor_co2 /* Type: CO2 */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float co2; /* in SI units ppm */
|
||||
};
|
||||
|
||||
struct sensor_event_hcho /* Type: HCHO */
|
||||
struct sensor_hcho /* Type: HCHO */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float hcho; /* in SI units ppm */
|
||||
};
|
||||
|
||||
struct sensor_event_tvoc /* Type: TVOC */
|
||||
struct sensor_tvoc /* Type: TVOC */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float tvoc; /* in SI units ppm */
|
||||
};
|
||||
|
||||
struct sensor_event_ph /* Type: PH */
|
||||
struct sensor_ph /* Type: PH */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float ph; /* PH = 7.0 neutral, PH < 7.0 acidic, PH > 7.0 alkaline */
|
||||
};
|
||||
|
||||
struct sensor_event_dust /* Type: DUST */
|
||||
struct sensor_dust /* Type: DUST */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float dust; /* is SI units ug/m^3 */
|
||||
};
|
||||
|
||||
struct sensor_event_hrate /* Type: Heart Rate */
|
||||
struct sensor_hrate /* Type: Heart Rate */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float bpm; /* is SI units BPM */
|
||||
};
|
||||
|
||||
struct sensor_event_hbeat /* Type: Heart Beat */
|
||||
struct sensor_hbeat /* Type: Heart Beat */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
float beat; /* Units is times/minutes */
|
||||
};
|
||||
|
||||
struct sensor_event_ecg /* Type: ECG */
|
||||
struct sensor_ecg /* Type: ECG */
|
||||
{
|
||||
uint64_t timestamp; /* Unit is microseconds */
|
||||
float ecg; /* Unit is μV */
|
||||
};
|
||||
|
||||
struct sensor_event_ppgd /* Type: PPGD */
|
||||
struct sensor_ppgd /* Type: PPGD */
|
||||
{
|
||||
uint64_t timestamp; /* Unit is microseconds */
|
||||
uint32_t ppg[2]; /* PPG from 2 channels. Units are ADC counts. */
|
||||
|
@ -510,7 +510,7 @@ struct sensor_event_ppgd /* Type: PPGD */
|
|||
uint16_t gain[2]; /* ADC gains of channels. Units are V/V or V/A. */
|
||||
};
|
||||
|
||||
struct sensor_event_ppgq /* Type: PPDQ */
|
||||
struct sensor_ppgq /* Type: PPDQ */
|
||||
{
|
||||
uint64_t timestamp; /* Unit is microseconds */
|
||||
uint32_t ppg[4]; /* PPG from 4 channels. Units are ADC counts. */
|
||||
|
@ -518,21 +518,21 @@ struct sensor_event_ppgq /* Type: PPDQ */
|
|||
uint16_t gain[4]; /* ADC gains of channels. Units are V/V or V/A. */
|
||||
};
|
||||
|
||||
struct sensor_event_impd /* Type: Impedance */
|
||||
struct sensor_impd /* Type: Impedance */
|
||||
{
|
||||
uint64_t timestamp; /* Unit is microseconds */
|
||||
float real; /* Real part, unit is Ohm(Ω) */
|
||||
float imag; /* Imaginary part, unit is Ohm(Ω) */
|
||||
};
|
||||
|
||||
struct sensor_event_ots /* Type: OTS */
|
||||
struct sensor_ots /* Type: OTS */
|
||||
{
|
||||
uint64_t timestamp; /* Unit is microseconds */
|
||||
int32_t x; /* Axis X in counts */
|
||||
int32_t y; /* Axis Y in counts */
|
||||
};
|
||||
|
||||
struct sensor_event_gps_satellite
|
||||
struct sensor_gps_satellite
|
||||
{
|
||||
uint64_t timestamp; /* Time since system start, Units is microseconds */
|
||||
uint32_t count; /* Total number of messages of satellites visible */
|
||||
|
@ -561,7 +561,7 @@ struct sensor_event_gps_satellite
|
|||
info[4];
|
||||
};
|
||||
|
||||
struct sensor_event_wake_gesture /* Type: Wake gesture */
|
||||
struct sensor_wake_gesture /* Type: Wake gesture */
|
||||
{
|
||||
uint64_t timestamp; /* Units is microseconds */
|
||||
|
||||
|
@ -572,7 +572,7 @@ struct sensor_event_wake_gesture /* Type: Wake gesture */
|
|||
uint32_t event;
|
||||
};
|
||||
|
||||
struct sensor_event_cap /* Type: Capacitance */
|
||||
struct sensor_cap /* Type: Capacitance */
|
||||
{
|
||||
uint64_t timestamp; /* Unit is microseconds */
|
||||
int32_t status; /* Detection status */
|
||||
|
@ -814,10 +814,10 @@ struct sensor_lowerhalf_s
|
|||
*
|
||||
* If device support batch mode, the number of events that hardware fifo
|
||||
* hold maximum number of samples, must be aligned with size of
|
||||
* struct sensor_event_xxx.
|
||||
* struct sensor_xxx.
|
||||
*/
|
||||
|
||||
uint32_t buffer_number;
|
||||
unsigned long nbuffer;
|
||||
|
||||
/* The uncalibrated use to describe whether the sensor event is
|
||||
* uncalibrated. True is uncalibrated data, false is calibrated data,
|
||||
|
@ -878,11 +878,14 @@ struct sensor_lowerhalf_s
|
|||
|
||||
struct sensor_state_s
|
||||
{
|
||||
unsigned long min_interval; /* The minimum subscription interval for sensor, in us */
|
||||
unsigned long esize; /* The element size of circular buffer */
|
||||
unsigned long nbuffer; /* The number of events that the circular buffer can hold */
|
||||
unsigned long min_latency; /* The minimum batch latency for sensor, in us */
|
||||
unsigned long nsubscribers; /* The number of subcribers, if subsrciber exists,
|
||||
* the sensor deivce is enabled */
|
||||
unsigned long min_interval; /* The minimum subscription interval for sensor, in us */
|
||||
unsigned long nsubscribers; /* The number of subcribers */
|
||||
unsigned long nadvertisers; /* The number of advertisers */
|
||||
unsigned long generation; /* The recent generation of circular buffer */
|
||||
FAR void *priv; /* The pointer to private data of userspace user */
|
||||
};
|
||||
|
||||
/* This structure describes the register info for the user sensor */
|
||||
|
@ -890,9 +893,9 @@ struct sensor_state_s
|
|||
#ifdef CONFIG_USENSOR
|
||||
struct sensor_reginfo_s
|
||||
{
|
||||
FAR const char *path; /* The path of user sensor */
|
||||
uint16_t esize; /* The element size of user sensor */
|
||||
uint32_t nqueue; /* The number of queue buffered elements */
|
||||
FAR const char *path; /* The path of user sensor */
|
||||
unsigned long esize; /* The element size of user sensor */
|
||||
unsigned long nbuffer; /* The number of queue buffered elements */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -966,7 +969,7 @@ int sensor_register(FAR struct sensor_lowerhalf_s *dev, int devno);
|
|||
****************************************************************************/
|
||||
|
||||
int sensor_custom_register(FAR struct sensor_lowerhalf_s *dev,
|
||||
FAR const char *path, uint8_t esize);
|
||||
FAR const char *path, unsigned long esize);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sensor_unregister
|
||||
|
|
Loading…
Reference in a new issue