raiden00pl commented on code in PR #15573: URL: https://github.com/apache/nuttx/pull/15573#discussion_r1918081645
########## drivers/sensors/sht4x_uorb.c: ########## @@ -153,68 +162,58 @@ static const uint8_t g_crc_lookup[] = static const uint16_t g_measurement_times[] = { - [SHT4X_PREC_LOW] = 1600, - [SHT4X_PREC_MED] = 4500, - [SHT4X_PREC_HIGH] = 8300, + [SHT4X_PREC_LOW] = 1600, + [SHT4X_PREC_MED] = 4500, + [SHT4X_PREC_HIGH] = 8300, }; /* Commands for the various heating options. */ static const uint8_t g_heat_cmds[] = { - [SHT4X_HEATER_200MW_1] = SHT4X_HEAT_200_1, - [SHT4X_HEATER_200MW_01] = SHT4X_HEAT_200_P1, - [SHT4X_HEATER_110MW_1] = SHT4X_HEAT_110_1, - [SHT4X_HEATER_110MW_01] = SHT4X_HEAT_110_P1, - [SHT4X_HEATER_20MW_1] = SHT4X_HEAT_20_1, - [SHT4X_HEATER_20MW_01] = SHT4X_HEAT_20_P1, + [SHT4X_HEATER_200MW_1] = SHT4X_HEAT_200_1, + [SHT4X_HEATER_200MW_01] = SHT4X_HEAT_200_P1, + [SHT4X_HEATER_110MW_1] = SHT4X_HEAT_110_1, + [SHT4X_HEATER_110MW_01] = SHT4X_HEAT_110_P1, + [SHT4X_HEATER_20MW_1] = SHT4X_HEAT_20_1, + [SHT4X_HEATER_20MW_01] = SHT4X_HEAT_20_P1, }; /* Timeouts for the various heating options in microseconds. */ static const uint32_t g_heat_times[] = { - [SHT4X_HEATER_200MW_1] = 1000000, [SHT4X_HEATER_200MW_01] = 100000, - [SHT4X_HEATER_110MW_1] = 1000000, [SHT4X_HEATER_110MW_01] = 100000, - [SHT4X_HEATER_20MW_1] = 1000000, [SHT4X_HEATER_20MW_01] = 100000, + [SHT4X_HEATER_200MW_1] = 1000000, [SHT4X_HEATER_200MW_01] = 100000, + [SHT4X_HEATER_110MW_1] = 1000000, [SHT4X_HEATER_110MW_01] = 100000, + [SHT4X_HEATER_20MW_1] = 1000000, [SHT4X_HEATER_20MW_01] = 100000, }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static int sht4x_open(FAR struct file *filep); -static int sht4x_close(FAR struct file *filep); -static ssize_t sht4x_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); -static ssize_t sht4x_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); -static int sht4x_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -static int sht4x_unlink(FAR struct inode *inode); +static int sht4x_set_interval(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, + FAR uint32_t *period_us); +static int sht4x_activate(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, bool enable); +static int sht4x_get_info(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, + FAR struct sensor_device_info_s *info); +static int sht4x_control(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, int cmd, unsigned long arg); /**************************************************************************** * Private Data ****************************************************************************/ -static const struct file_operations g_sht4xfops = +static const struct sensor_ops_s g_sensor_ops = { -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - .open = sht4x_open, - .close = sht4x_close, -#else - .open = NULL, - .close = NULL, -#endif - .read = sht4x_read, - .write = sht4x_write, - .seek = NULL, - .ioctl = sht4x_ioctl, - .mmap = NULL, - .truncate = NULL, - .poll = NULL, -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - .unlink = sht4x_unlink, -#endif + .activate = sht4x_activate, + .fetch = NULL, Review Comment: if your application don't need constant polling of sensor data, but you prefer to control when sensor is read from your application code, then you can implement `fetch()` interface. Then the driver behaves more like "legacy" implementation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org