Skip to content

Commit

Permalink
Merge pull request #13966 from akshaim/Kconfig_sps30
Browse files Browse the repository at this point in the history
drivers/sps30 : Expose Configurations to Kconfig
  • Loading branch information
leandrolanzieri authored Apr 28, 2020
2 parents a0a4091 + 817370c commit bb66845
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions drivers/Kconfig.net
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ rsource "hdc1000/Kconfig"
rsource "mag3110/Kconfig"
rsource "mma8x5x/Kconfig"
rsource "opt3001/Kconfig"
rsource "sps30/Kconfig"
endmenu # Sensor Device Drivers
4 changes: 2 additions & 2 deletions drivers/include/sps30.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ typedef enum {
* suboptimal wiring.
*
*/
#ifndef SPS30_ERROR_RETRY
#define SPS30_ERROR_RETRY (500U)
#ifndef CONFIG_SPS30_ERROR_RETRY
#define CONFIG_SPS30_ERROR_RETRY (500U)
#endif
/** @} */

Expand Down
24 changes: 24 additions & 0 deletions drivers/sps30/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2020 Freie Universitaet Berlin
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
menuconfig KCONFIG_MODULE_SPS30
bool "Configure SPS30 driver"
depends on MODULE_SPS30
help
Configure the SPS30 driver using Kconfig.

if KCONFIG_MODULE_SPS30

config SPS30_ERROR_RETRY
int "Maximum number of error retries"
default 500
help
Maximum number of automatic retries on communication errors.
Change this to 0 if more fine-grained feedback is required.
The value may be increased if the device is connected over
suboptimal wiring.

endif # KCONFIG_MODULE_SPS30
2 changes: 1 addition & 1 deletion drivers/sps30/sps30.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int _rx_tx_data(const sps30_t *dev, uint16_t ptr_addr,
uint8_t *data, size_t len, bool read)
{
int res = 0;
unsigned retr = SPS30_ERROR_RETRY;
unsigned retr = CONFIG_SPS30_ERROR_RETRY;

if (i2c_acquire(dev->p.i2c_dev) != 0) {
LOG_ERROR("could not acquire I2C bus %d\n", dev->p.i2c_dev);
Expand Down

0 comments on commit bb66845

Please sign in to comment.