Skip to content

Commit

Permalink
drivers: apds9960: allow additional LED current configuration
Browse files Browse the repository at this point in the history
Allow additional proximity LED current configuration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
  • Loading branch information
jfischer-no authored and MaureenHelm committed Jun 5, 2019
1 parent df3796a commit 2204193
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
18 changes: 18 additions & 0 deletions drivers/sensor/apds9960/Kconfig
Expand Up @@ -92,6 +92,24 @@ config APDS9960_PPULSE_LENGTH_32US

endchoice

choice
prompt "Proximity LED boost current"
default APDS9960_PLED_BOOST_100PCT

config APDS9960_PLED_BOOST_300PCT
bool "300%"

config APDS9960_PLED_BOOST_200PCT
bool "200%"

config APDS9960_PLED_BOOST_150PCT
bool "150%"

config APDS9960_PLED_BOOST_100PCT
bool "100%"

endchoice

config APDS9960_PPULSE_COUNT
int "Proximity Pulse Count"
range 1 64
Expand Down
17 changes: 17 additions & 0 deletions drivers/sensor/apds9960/apds9960.c
Expand Up @@ -177,6 +177,14 @@ static int apds9960_proxy_setup(struct device *dev)
return -EIO;
}

if (i2c_reg_update_byte(data->i2c, config->i2c_address,
APDS9960_CONFIG2_REG,
APDS9960_PLED_BOOST_300,
config->pled_boost)) {
LOG_ERR("LED Drive Strength not set");
return -EIO;
}

if (i2c_reg_update_byte(data->i2c, config->i2c_address,
APDS9960_CONTROL_REG, APDS9960_CONTROL_PGAIN,
(config->pgain & APDS9960_PGAIN_8X))) {
Expand Down Expand Up @@ -509,6 +517,15 @@ static const struct apds9960_config apds9960_config = {
.ppcount = APDS9960_PPULSE_LENGTH_4US |
(CONFIG_APDS9960_PPULSE_COUNT - 1),
#endif
#if CONFIG_APDS9960_PLED_BOOST_300PCT
.pled_boost = APDS9960_PLED_BOOST_300,
#elif CONFIG_APDS9960_PLED_BOOST_200PCT
.pled_boost = APDS9960_PLED_BOOST_200,
#elif CONFIG_APDS9960_PLED_BOOST_150PCT
.pled_boost = APDS9960_PLED_BOOST_150,
#else
.pled_boost = APDS9960_PLED_BOOST_100,
#endif
};

static struct apds9960_data apds9960_data;
Expand Down
10 changes: 5 additions & 5 deletions drivers/sensor/apds9960/apds9960.h
Expand Up @@ -64,12 +64,11 @@
#define APDS9960_CONFIG2_REG 0x90
#define APDS9960_CONFIG2_CPSIEN BIT(6)
#define APDS9960_CONFIG2_PSIEN BIT(7)
#define APDS9960_CONFIG2_LEDBOOST (BIT(5) | BIT(4))
/* LED Boost values */
#define APDS9960_GLED_BOOST_100 0
#define APDS9960_GLED_BOOST_150 BIT(4)
#define APDS9960_GLED_BOOST_200 BIT(5)
#define APDS9960_GLED_BOOST_300 (BIT(5) | BIT(4))
#define APDS9960_PLED_BOOST_100 0
#define APDS9960_PLED_BOOST_150 BIT(4)
#define APDS9960_PLED_BOOST_200 BIT(5)
#define APDS9960_PLED_BOOST_300 (BIT(5) | BIT(4))

#define APDS9960_ID_REG 0x92
/* Acceptable device IDs */
Expand Down Expand Up @@ -221,6 +220,7 @@ struct apds9960_config {
u8_t pgain;
u8_t again;
u8_t ppcount;
u8_t pled_boost;
};

struct apds9960_data {
Expand Down

0 comments on commit 2204193

Please sign in to comment.