drivers: sensors: lis2dh: added full high-pass filter capabilities
The lis2dh driver has the ability to enable the hp filter. However it was only possible to set the first 2 bits of the hp register. These bits indicate wether the hp filter is enabled for the interrupts. This commit moves lis2dh_acc_hp_filter_set to lis2dh. It also removes the mask so that all bits are able to be set. Signed-off-by: Maarten Nieuwenhuize <maarten.nieuwenhuize@picoo.nl>
This commit is contained in:
parent
e7e6cb9def
commit
86a7e29b50
3 changed files with 20 additions and 23 deletions
|
|
@ -271,6 +271,21 @@ static int lis2dh_acc_range_set(const struct device *dev, int32_t range)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIS2DH_ACCEL_HP_FILTERS
|
||||
static int lis2dh_acc_hp_filter_set(const struct device *dev, int32_t val)
|
||||
{
|
||||
struct lis2dh_data *lis2dh = dev->data;
|
||||
int status;
|
||||
|
||||
status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL2, val);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to set high pass filters");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int lis2dh_acc_config(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
|
|
|
|||
|
|
@ -87,9 +87,12 @@
|
|||
#define LIS2DH_REG_CTRL2 0x21
|
||||
#define LIS2DH_HPIS1_EN_BIT BIT(0)
|
||||
#define LIS2DH_HPIS2_EN_BIT BIT(1)
|
||||
#define LIS2DH_HPCLICK_EN_BIT BIT(2)
|
||||
#define LIS2DH_FDS_EN_BIT BIT(3)
|
||||
|
||||
#define LIS2DH_HPIS_EN_MASK BIT_MASK(2)
|
||||
#define LIS2DH_HPCF0_EN_BIT BIT(4)
|
||||
#define LIS2DH_HPCF1_EN_BIT BIT(5)
|
||||
#define LIS2DH_HPM0_EN_BIT BIT(6)
|
||||
#define LIS2DH_HPM1_EN_BIT BIT(7)
|
||||
|
||||
#define LIS2DH_REG_CTRL3 0x22
|
||||
#define LIS2DH_EN_CLICK_INT1 BIT(7)
|
||||
|
|
@ -305,11 +308,6 @@ int lis2dh_acc_slope_config(const struct device *dev,
|
|||
const struct sensor_value *val);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIS2DH_ACCEL_HP_FILTERS
|
||||
int lis2dh_acc_hp_filter_set(const struct device *dev,
|
||||
int32_t val);
|
||||
#endif
|
||||
|
||||
int lis2dh_spi_init(const struct device *dev);
|
||||
int lis2dh_i2c_init(const struct device *dev);
|
||||
|
||||
|
|
|
|||
|
|
@ -361,22 +361,6 @@ int lis2dh_acc_slope_config(const struct device *dev,
|
|||
return status;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIS2DH_ACCEL_HP_FILTERS
|
||||
int lis2dh_acc_hp_filter_set(const struct device *dev, int32_t val)
|
||||
{
|
||||
struct lis2dh_data *lis2dh = dev->data;
|
||||
int status;
|
||||
|
||||
status = lis2dh->hw_tf->update_reg(dev, LIS2DH_REG_CTRL2,
|
||||
LIS2DH_HPIS_EN_MASK, val);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to set high pass filters");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void lis2dh_gpio_int1_callback(const struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue