Skip to content
Permalink
Browse files

drivers: apds9960: allow additional LED current configuration

Allow additional proximity LED current configuration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
  • Loading branch information...
jfischer-phytec-iot authored and MaureenHelm committed May 13, 2019
1 parent df3796a commit 2204193bdb572728c8d6b68881164c5488c3d4bf
Showing with 40 additions and 5 deletions.
  1. +18 −0 drivers/sensor/apds9960/Kconfig
  2. +17 −0 drivers/sensor/apds9960/apds9960.c
  3. +5 −5 drivers/sensor/apds9960/apds9960.h
@@ -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
@@ -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))) {
@@ -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;
@@ -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 */
@@ -221,6 +220,7 @@ struct apds9960_config {
u8_t pgain;
u8_t again;
u8_t ppcount;
u8_t pled_boost;
};

struct apds9960_data {

0 comments on commit 2204193

Please sign in to comment.
You can’t perform that action at this time.