Skip to content

Commit

Permalink
Network: Made kconfig ds18 and moisture sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocio committed Jul 12, 2022
1 parent 18768df commit 45351e4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 18 deletions.
1 change: 1 addition & 0 deletions examples/moisture_sensor_hw390/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsource "../../firmware/peripherals/moisture_sensor/Kconfig"
2 changes: 1 addition & 1 deletion examples/moisture_sensor_hw390/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "periph/adc.h"
#include "ztimer.h"

#define RES ADC_RES_10BIT
#define RES CONFIG_ADC_RES
#define DELAY_MS 5000U

int main (void) {
Expand Down
9 changes: 2 additions & 7 deletions firmware/peripherals/Kconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
menu "Peripherals"
menu "Hardware Periph Setup"
if BOARD_M4A_24G
rsource "../../boards/m4a-24g/Kconfig.periph"
endif
endmenu
rsource "ds18_sensor/Kconfig"
rsource "moisture_sensor/Kconfig"
rsource "ds18_sensor/Kconfig"
rsource "moisture_sensor/Kconfig"
endmenu
11 changes: 3 additions & 8 deletions firmware/peripherals/ds18_sensor/Kconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
menu "ds18 for soil"
# Set if the ds18 for soil is connected
config DS18_SOIL_CONNECTED
bool "Set if it's connected"
default y
# Set the GPIO where it's connected
config DS18_SOIL_GPIO
int "GPIO where the ds18 is attached"
default 0
config PIN_TEMP_SENSOR
int "Pin to connect temperature sensor"
default 5
endmenu
31 changes: 31 additions & 0 deletions firmware/peripherals/moisture_sensor/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
menu "Moisture sensor setup"
choice ADC_RES
prompt "ADC_BITS_RESOLUTION"
default ADC_RES_10BIT

config ADC_RES_6BIT
bool "ADC resolution: 6 bit"

config ADC_RES_8BIT
bool "ADC resolution: 8 bit"

config ADC_RES_10BIT
bool "ADC resolution: 10 bit"

config ADC_RES_12BIT
bool "ADC resolution: 12 bit"

config ADC_RES_14BIT
bool "ADC resolution: 14 bit"

config ADC_RES_1B6IT
bool "ADC resolution: 16 bit"
endchoice

config ADC_RES
int

default 255 if ADC_RES_6BIT
default 48 if ADC_RES_8BIT
default 32 if ADC_RES_10BIT
default 0 if ADC_RES_12BIT
default 254 if ADC_RES_14BIT
default 253 if ADC_RES_16BIT
endmenu
2 changes: 1 addition & 1 deletion firmware/peripherals/moisture_sensor/moisture_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define DEFAULT_MIN 356
#define DEFAULT_MAX 880
#define RES ADC_RES_10BIT
#define RES (CONFIG_ADC_RES)

int init_moisture (void)
{
Expand Down
1 change: 1 addition & 0 deletions tests/ds18/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsource "../../firmware/peripherals/ds18_sensor/Kconfig"
2 changes: 1 addition & 1 deletion tests/ds18/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "ds18_sensor.h"

void test_init_ds18(void) {
int err = init_temperature_sensor(5);
int err = init_temperature_sensor(CONFIG_PIN_TEMP_SENSOR);

TEST_ASSERT_EQUAL_INT(0, err);
}
Expand Down

0 comments on commit 45351e4

Please sign in to comment.