@@ -714,532 +714,274 @@ lis2ds12_get_power_mode(struct sensor_itf *itf, uint8_t *mode)
}

/**
* Set Wake Up Threshold configuration
* Sets the self test mode of the sensor
*
* @param The sensor interface
* @param self test mode
*
* @param the sensor interface
* @param wake_up_ths value to set
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_wake_up_ths(struct sensor_itf *itf, uint8_t val)
int
lis2ds12_set_self_test(struct sensor_itf *itf, uint8_t mode)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
goto err;
}

reg &= ~LIS2DS12_WAKE_THS_THS;
reg |= val & LIS2DS12_WAKE_THS_THS;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_THS, reg);
}

/**
* Get Wake Up Threshold config
*
* @param the sensor interface
* @param ptr to store wake_up_ths value
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_wake_up_ths(struct sensor_itf *itf, uint8_t *val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
reg &= ~LIS2DS12_CTRL_REG3_ST_MODE;
reg |= (mode & LIS2DS12_CTRL_REG3_ST_MODE);

rc = lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);
if (rc) {
return rc;
goto err;
}

*val = reg & LIS2DS12_WAKE_THS_THS;
return 0;
err:
return rc;
}

/**
* Set whether sleep on inactivity is enabled
* Gets the self test mode of the sensor
*
* @param the sensor interface
* @param value to set (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_inactivity_sleep_en(struct sensor_itf *itf, uint8_t en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_THS_SLEEP_ON;
reg |= en ? LIS2DS12_WAKE_THS_SLEEP_ON : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_THS, reg);
}

/**
* Get whether sleep on inactivity is enabled
* @param The sensor interface
* @param ptr to self test mode read from sensor
*
* @param the sensor interface
* @param ptr to store read state (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_inactivity_sleep_en(struct sensor_itf *itf, uint8_t *en)
int
lis2ds12_get_self_test(struct sensor_itf *itf, uint8_t *mode)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
goto err;
}

*en = (reg & LIS2DS12_WAKE_THS_SLEEP_ON) ? 1 : 0;
return 0;
*mode = reg & LIS2DS12_CTRL_REG3_ST_MODE;

return 0;
err:
return rc;
}

/**
* Set whether double tap event is enabled
* Sets the interrupt push-pull/open-drain selection
*
* @param The sensor interface
* @param interrupt setting (0 = push-pull, 1 = open-drain)
*
* @param the sensor interface
* @param value to set (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_double_tap_event_en(struct sensor_itf *itf, uint8_t en)
int
lis2ds12_set_int_pp_od(struct sensor_itf *itf, uint8_t mode)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_THS_SINGLE_DOUBLE_TAP;
reg |= en ? LIS2DS12_WAKE_THS_SINGLE_DOUBLE_TAP : en;
reg &= ~LIS2DS12_CTRL_REG3_PP_OD;
reg |= mode ? LIS2DS12_CTRL_REG3_PP_OD : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_THS, reg);
return lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);
}

/**
* Get whether double tap event is enabled
* Gets the interrupt push-pull/open-drain selection
*
* @param The sensor interface
* @param ptr to store setting (0 = push-pull, 1 = open-drain)
*
* @param the sensor interface
* @param ptr to store read state (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_double_tap_event_en(struct sensor_itf *itf, uint8_t *en)
int
lis2ds12_get_int_pp_od(struct sensor_itf *itf, uint8_t *mode)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

*en = (reg & LIS2DS12_WAKE_THS_SINGLE_DOUBLE_TAP) ? 1 : 0;
*mode = (reg & LIS2DS12_CTRL_REG3_PP_OD) ? 1 : 0;

return 0;
}

/**
* Set Wake Up Duration
* Sets whether latched interrupts are enabled
*
* @param The sensor interface
* @param value to set (0 = not latched, 1 = latched)
*
* @param the sensor interface
* @param value to set
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_wake_up_dur(struct sensor_itf *itf, uint8_t val)
int
lis2ds12_set_latched_int(struct sensor_itf *itf, uint8_t en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_DUR_DUR;
reg |= (val & LIS2DS12_WAKE_DUR_DUR) << 5;
reg &= ~LIS2DS12_CTRL_REG3_LIR;
reg |= en ? LIS2DS12_CTRL_REG3_LIR : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_DUR, reg);
}

/**
* Get Wake Up Duration
* Gets whether latched interrupts are enabled
*
* @param The sensor interface
* @param ptr to store value (0 = not latched, 1 = latched)
*
* @param the sensor interface
* @param ptr to store wake_up_dur value
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_wake_up_dur(struct sensor_itf *itf, uint8_t *val)
int
lis2ds12_get_latched_int(struct sensor_itf *itf, uint8_t *en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

*val = (reg & LIS2DS12_WAKE_DUR_DUR) >> 5;
*en = (reg & LIS2DS12_CTRL_REG3_LIR) ? 1 : 0;

return 0;
}

/**
* Set Sleep Duration
* Sets whether interrupts are active high or low
*
* @param The sensor interface
* @param value to set (0 = active high, 1 = active low)
*
* @param the sensor interface
* @param value to set
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_sleep_dur(struct sensor_itf *itf, uint8_t val)
int
lis2ds12_set_int_active_low(struct sensor_itf *itf, uint8_t low)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_DUR_SLEEP_DUR;
reg |= (val & LIS2DS12_WAKE_DUR_SLEEP_DUR);
reg &= ~LIS2DS12_CTRL_REG3_H_LACTIVE;
reg |= low ? LIS2DS12_CTRL_REG3_H_LACTIVE : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_DUR, reg);
}

/**
* Get Sleep Duration
* Gets whether interrupts are active high or low
*
* @param The sensor interface
* @param ptr to store value (0 = active high, 1 = active low)
*
* @param the sensor interface
* @param ptr to store sleep_dur value
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_sleep_dur(struct sensor_itf *itf, uint8_t *val)
int
lis2ds12_get_int_active_low(struct sensor_itf *itf, uint8_t *low)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

*val = reg & LIS2DS12_WAKE_DUR_SLEEP_DUR;
return 0;
}
*low = (reg & LIS2DS12_CTRL_REG3_H_LACTIVE) ? 1 : 0;

/**
* Get Wake Up Source
*
* @param the sensor interface
* @param pointer to return wake_up_src in
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_wake_up_src(struct sensor_itf *itf, uint8_t *status)
{
return lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_SRC, status);
}
return 0;

/**
* Get Tap Source
*
* @param the sensor interface
* @param pointer to return tap_src in
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_tap_src(struct sensor_itf *itf, uint8_t *status)
{
return lis2ds12_read8(itf, LIS2DS12_REG_TAP_SRC, status);
}

/**
* Get 6D Source
* Set filter config
*
* @param the sensor interface
* @param pointer to return sixd_src in
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_sixd_src(struct sensor_itf *itf, uint8_t *status)
{
return lis2ds12_read8(itf, LIS2DS12_REG_6D_SRC, status);
}


/**
* Sets the self test mode of the sensor
*
* @param The sensor interface
* @param self test mode
*
* @param filter type (1 = high pass, 0 = low pass)
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_set_self_test(struct sensor_itf *itf, uint8_t mode)
lis2ds12_set_filter_cfg(struct sensor_itf *itf, uint8_t type)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG2, &reg);
if (rc) {
goto err;
}

reg &= ~LIS2DS12_CTRL_REG3_ST_MODE;
reg |= (mode & LIS2DS12_CTRL_REG3_ST_MODE);

rc = lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);
reg &= ~LIS2DS12_CTRL_REG2_FDS_SLOPE;
if (type) {
reg |= LIS2DS12_CTRL_REG2_FDS_SLOPE;
}

rc = lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG2, reg);
if (rc) {
goto err;
}

return 0;
err:
return rc;

}

/**
* Gets the self test mode of the sensor
*
* @param The sensor interface
* @param ptr to self test mode read from sensor
* Get filter config
*
* @param the sensor interface
* @param ptr to filter type (1 = high pass, 0 = low pass)
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_get_self_test(struct sensor_itf *itf, uint8_t *mode)
lis2ds12_get_filter_cfg(struct sensor_itf *itf, uint8_t *type)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG2, &reg);
if (rc) {
goto err;
}

*mode = reg & LIS2DS12_CTRL_REG3_ST_MODE;
*type = (reg & LIS2DS12_CTRL_REG2_FDS_SLOPE) > 0;

return 0;
err:
return rc;
}

/**
* Sets the interrupt push-pull/open-drain selection
*
* @param The sensor interface
* @param interrupt setting (0 = push-pull, 1 = open-drain)
*
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_set_int_pp_od(struct sensor_itf *itf, uint8_t mode)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_CTRL_REG3_PP_OD;
reg |= mode ? LIS2DS12_CTRL_REG3_PP_OD : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);
}

/**
* Gets the interrupt push-pull/open-drain selection
*
* @param The sensor interface
* @param ptr to store setting (0 = push-pull, 1 = open-drain)
*
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_get_int_pp_od(struct sensor_itf *itf, uint8_t *mode)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

*mode = (reg & LIS2DS12_CTRL_REG3_PP_OD) ? 1 : 0;

return 0;
}

/**
* Sets whether latched interrupts are enabled
*
* @param The sensor interface
* @param value to set (0 = not latched, 1 = latched)
*
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_set_latched_int(struct sensor_itf *itf, uint8_t en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_CTRL_REG3_LIR;
reg |= en ? LIS2DS12_CTRL_REG3_LIR : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);

}

/**
* Gets whether latched interrupts are enabled
*
* @param The sensor interface
* @param ptr to store value (0 = not latched, 1 = latched)
*
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_get_latched_int(struct sensor_itf *itf, uint8_t *en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

*en = (reg & LIS2DS12_CTRL_REG3_LIR) ? 1 : 0;

return 0;
}

/**
* Sets whether interrupts are active high or low
*
* @param The sensor interface
* @param value to set (0 = active high, 1 = active low)
*
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_set_int_active_low(struct sensor_itf *itf, uint8_t low)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_CTRL_REG3_H_LACTIVE;
reg |= low ? LIS2DS12_CTRL_REG3_H_LACTIVE : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG3, reg);

}

/**
* Gets whether interrupts are active high or low
*
* @param The sensor interface
* @param ptr to store value (0 = active high, 1 = active low)
*
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_get_int_active_low(struct sensor_itf *itf, uint8_t *low)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG3, &reg);
if (rc) {
return rc;
}

*low = (reg & LIS2DS12_CTRL_REG3_H_LACTIVE) ? 1 : 0;

return 0;

}

/**
* Set filter config
*
* @param the sensor interface
* @param filter type (1 = high pass, 0 = low pass)
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_set_filter_cfg(struct sensor_itf *itf, uint8_t type)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG2, &reg);
if (rc) {
goto err;
}

reg &= ~LIS2DS12_CTRL_REG2_FDS_SLOPE;
if (type) {
reg |= LIS2DS12_CTRL_REG2_FDS_SLOPE;
}

rc = lis2ds12_write8(itf, LIS2DS12_REG_CTRL_REG2, reg);
if (rc) {
goto err;
}

return 0;
err:
return rc;

}

/**
* Get filter config
*
* @param the sensor interface
* @param ptr to filter type (1 = high pass, 0 = low pass)
* @return 0 on success, non-zero on failure
*/
int
lis2ds12_get_filter_cfg(struct sensor_itf *itf, uint8_t *type)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_CTRL_REG2, &reg);
if (rc) {
goto err;
}

*type = (reg & LIS2DS12_CTRL_REG2_FDS_SLOPE) > 0;

return 0;
err:
return rc;
}

/**
* Set tap detection configuration
* Set tap detection configuration
*
* @param the sensor interface
* @param the tap settings
@@ -1555,6 +1297,228 @@ lis2ds12_set_int2_pin_cfg(struct sensor_itf *itf, uint8_t cfg)
return rc;
}


/**
* Set Wake Up Threshold configuration
*
* @param the sensor interface
* @param wake_up_ths value to set
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_wake_up_ths(struct sensor_itf *itf, uint8_t val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_THS_THS;
reg |= val & LIS2DS12_WAKE_THS_THS;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_THS, reg);
}

/**
* Get Wake Up Threshold config
*
* @param the sensor interface
* @param ptr to store wake_up_ths value
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_wake_up_ths(struct sensor_itf *itf, uint8_t *val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

*val = reg & LIS2DS12_WAKE_THS_THS;
return 0;
}

/**
* Set whether sleep on inactivity is enabled
*
* @param the sensor interface
* @param value to set (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_inactivity_sleep_en(struct sensor_itf *itf, uint8_t en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_THS_SLEEP_ON;
reg |= en ? LIS2DS12_WAKE_THS_SLEEP_ON : 0;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_THS, reg);
}

/**
* Get whether sleep on inactivity is enabled
*
* @param the sensor interface
* @param ptr to store read state (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_inactivity_sleep_en(struct sensor_itf *itf, uint8_t *en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

*en = (reg & LIS2DS12_WAKE_THS_SLEEP_ON) ? 1 : 0;
return 0;

}

/**
* Set whether double tap event is enabled
*
* @param the sensor interface
* @param value to set (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_double_tap_event_en(struct sensor_itf *itf, uint8_t en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_THS_SINGLE_DOUBLE_TAP;
reg |= en ? LIS2DS12_WAKE_THS_SINGLE_DOUBLE_TAP : en;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_THS, reg);
}

/**
* Get whether double tap event is enabled
*
* @param the sensor interface
* @param ptr to store read state (0 = disabled, 1 = enabled)
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_double_tap_event_en(struct sensor_itf *itf, uint8_t *en)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_THS, &reg);
if (rc) {
return rc;
}

*en = (reg & LIS2DS12_WAKE_THS_SINGLE_DOUBLE_TAP) ? 1 : 0;
return 0;
}

/**
* Set Wake Up Duration
*
* @param the sensor interface
* @param value to set
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_wake_up_dur(struct sensor_itf *itf, uint8_t val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_DUR_DUR;
reg |= (val & LIS2DS12_WAKE_DUR_DUR) << 5;

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_DUR, reg);
}

/**
* Get Wake Up Duration
*
* @param the sensor interface
* @param ptr to store wake_up_dur value
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_wake_up_dur(struct sensor_itf *itf, uint8_t *val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
if (rc) {
return rc;
}

*val = (reg & LIS2DS12_WAKE_DUR_DUR) >> 5;
return 0;
}

/**
* Set Sleep Duration
*
* @param the sensor interface
* @param value to set
* @return 0 on success, non-zero on failure
*/
int lis2ds12_set_sleep_dur(struct sensor_itf *itf, uint8_t val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
if (rc) {
return rc;
}

reg &= ~LIS2DS12_WAKE_DUR_SLEEP_DUR;
reg |= (val & LIS2DS12_WAKE_DUR_SLEEP_DUR);

return lis2ds12_write8(itf, LIS2DS12_REG_WAKE_UP_DUR, reg);
}

/**
* Get Sleep Duration
*
* @param the sensor interface
* @param ptr to store sleep_dur value
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_sleep_dur(struct sensor_itf *itf, uint8_t *val)
{
int rc;
uint8_t reg;

rc = lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_DUR, &reg);
if (rc) {
return rc;
}

*val = reg & LIS2DS12_WAKE_DUR_SLEEP_DUR;
return 0;
}

/**
* Clear interrupt 1
*
@@ -1578,6 +1542,42 @@ int lis2ds12_get_int_status(struct sensor_itf *itf, uint8_t *status)
return lis2ds12_read8(itf, LIS2DS12_REG_STATUS, status);
}

/**
* Get Wake Up Source
*
* @param the sensor interface
* @param pointer to return wake_up_src in
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_wake_up_src(struct sensor_itf *itf, uint8_t *status)
{
return lis2ds12_read8(itf, LIS2DS12_REG_WAKE_UP_SRC, status);
}

/**
* Get Tap Source
*
* @param the sensor interface
* @param pointer to return tap_src in
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_tap_src(struct sensor_itf *itf, uint8_t *status)
{
return lis2ds12_read8(itf, LIS2DS12_REG_TAP_SRC, status);
}

/**
* Get 6D Source
*
* @param the sensor interface
* @param pointer to return sixd_src in
* @return 0 on success, non-zero on failure
*/
int lis2ds12_get_sixd_src(struct sensor_itf *itf, uint8_t *status)
{
return lis2ds12_read8(itf, LIS2DS12_REG_6D_SRC, status);
}

/**
* Set whether interrupt 1 signals is mapped onto interrupt 2 pin
*