From 9ded554952a605bc65420a572f098bb1c5cb8488 Mon Sep 17 00:00:00 2001 From: SmejkalJakub Date: Tue, 31 Oct 2023 12:26:37 +0100 Subject: [PATCH] Add option for third flood detector to be connected to the sensor module --- twr/inc/twr_flood_detector.h | 3 ++- twr/src/twr_flood_detector.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/twr/inc/twr_flood_detector.h b/twr/inc/twr_flood_detector.h index 9cf43a37..de96ce01 100644 --- a/twr/inc/twr_flood_detector.h +++ b/twr/inc/twr_flood_detector.h @@ -15,7 +15,8 @@ typedef enum { TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_A, - TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_B + TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_B, + TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_C } twr_flood_detector_type_t; diff --git a/twr/src/twr_flood_detector.c b/twr/src/twr_flood_detector.c index 5494ece8..95bb536f 100644 --- a/twr/src/twr_flood_detector.c +++ b/twr/src/twr_flood_detector.c @@ -109,6 +109,17 @@ static void _twr_flood_task_measure(void *param) twr_gpio_set_mode(TWR_GPIO_P5, TWR_GPIO_MODE_INPUT); break; } + case TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_C: + { + if (!twr_module_sensor_init()) + { + goto start; + } + twr_module_sensor_set_vdd(true); + twr_gpio_init(TWR_GPIO_P7); + twr_gpio_set_mode(TWR_GPIO_P7, TWR_GPIO_MODE_INPUT); + break; + } default: { goto start; @@ -147,6 +158,11 @@ static void _twr_flood_task_measure(void *param) twr_scheduler_plan_current_from_now(5); break; } + case TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_C: + { + twr_scheduler_plan_current_from_now(5); + break; + } default: { goto start; @@ -182,6 +198,11 @@ static void _twr_flood_task_measure(void *param) } break; } + case TWR_FLOOD_DETECTOR_TYPE_LD_81_SENSOR_MODULE_CHANNEL_C: + { + self->_alarm = twr_gpio_get_input(TWR_GPIO_P7) == 1; + break; + } default: { goto start;