diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 118522416f71bcddc7796d772ffad3913616c2ff..84071d042c85643dfc181549f038e46c9c4b354a 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -133,8 +133,8 @@ typedef _Bool bool; #define API_MAX30001_ENABLE 0xf0 #define API_MAX30001_DISABLE 0xf1 -#define API_MAX86150_ENABLE 0x0100 -#define API_MAX86150_DISABLE 0x0101 +#define API_MAX86150_ENABLE 0x0100 +#define API_MAX86150_DISABLE 0x0101 #define API_USB_SHUTDOWN 0x110 #define API_USB_STORAGE 0x111 @@ -897,8 +897,6 @@ struct max86150_sensor_config { * Possible values are 10, 20, 50, 84, 100, 200. */ uint16_t ppg_sample_rate; - /** Always zero. Reserved for future parameters. */ - uint8_t _padding[10]; }; /** @@ -920,26 +918,25 @@ struct max86150_sensor_data { * data from the sensor. You can then retrieve the samples using * :c:func:`epic_stream_read`. * + * :param max86150_sensor_config* config: Configuration for this sensor. + * :param size_t config_size: Size of ``config``. * :returns: A sensor descriptor which can be used with * :c:func:`epic_stream_read` or a negative error value: * - * - ``-EBUSY``: The MAX86150 driver or I2C bus are currently busy with other tasks - * and could not be acquired for enabling a sensor. * - ``-ENOMEM``: The MAX86150 driver failed to create a stream queue. - * - ``-ENODEV``: The MAX86150 driver failed due to physical connectivity problem (broken wire, unpowered, etc). - * - ``-EINVAL``: config->ppg_sample_rate is not one of 10, 20, 50, 84, 100, 200. + * - ``-ENODEV``: The MAX86150 driver failed due to physical connectivity problem + * (broken wire, unpowered, etc). + * - ``-EINVAL``: config->ppg_sample_rate is not one of 10, 20, 50, 84, 100, 200 + * or config_size is not size of config. * * .. versionadded:: 1.13 */ -API(API_MAX86150_ENABLE, int epic_max86150_enable_sensor(struct max86150_sensor_config *config)); +API(API_MAX86150_ENABLE, int epic_max86150_enable_sensor(struct max86150_sensor_config *config, size_t config_size)); /** * Disable the MAX86150 sensor. * - * :returns: 0 in case of success or a negative error value: - * - * - ``-EBUSY``: The MAX86150 driver or I2C bus are currently busy with other tasks and - * could not be acquired for enabling a sensor. + * :returns: 0 in case of success or forward negative error value from stream_deregister. * * .. versionadded:: 1.13 */ diff --git a/epicardium/modules/max86150.c b/epicardium/modules/max86150.c index f853783bc8833c2391e7cc3fa526f2a31a09f87c..3c8ab807fdd315808da13c4d1d250ce0d94c3e03 100644 --- a/epicardium/modules/max86150.c +++ b/epicardium/modules/max86150.c @@ -32,10 +32,15 @@ static struct stream_info max86150_stream; /* Active */ static bool max86150_sensor_active = false; -int epic_max86150_enable_sensor(struct max86150_sensor_config *config) -{ +int epic_max86150_enable_sensor( + struct max86150_sensor_config *config, size_t config_size +) { int result = 0; + // if (sizeof(struct max86150_sensor_config) != config_size) { + // return -EINVAL; + // } + mutex_lock(&max86150_mutex); hwlock_acquire(HWLOCK_I2C);