Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network: Made kconfig to ds18 and moisture sensor #303

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
RocioRojas marked this conversation as resolved.
Show resolved Hide resolved
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
RocioRojas marked this conversation as resolved.
Show resolved Hide resolved
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