summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2020-04-27 21:14:54 +0200
committerFlorian Baumann <derflob@derflob.de>2020-04-27 21:14:54 +0200
commit427560fdd8e0f0cce9b590f416c2b10856dafe1d (patch)
treea27dc424d86dad1e126f71c45e41d3df825baf73
parentb0efb955ab4f5566a99cd8ae53f41605e3241fe0 (diff)
downloadULPSoilMonitor-427560fdd8e0f0cce9b590f416c2b10856dafe1d.tar.gz
ULPSoilMonitor-427560fdd8e0f0cce9b590f416c2b10856dafe1d.tar.bz2
toggle GPIO25/RTC_GPIO06 to enable moisture sensors
-rw-r--r--ULPSoilMonitor.ino12
-rw-r--r--ulp_soil.s13
2 files changed, 20 insertions, 5 deletions
diff --git a/ULPSoilMonitor.ino b/ULPSoilMonitor.ino
index d8ebfc7..d91fd3d 100644
--- a/ULPSoilMonitor.ino
+++ b/ULPSoilMonitor.ino
@@ -69,11 +69,13 @@ static void init_ulp_program()
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_ulp_enable();
- /*
- adc2_config_channel_atten(ADC2_CHANNEL_9, ADC_ATTEN_DB_0);
- adc2_config_width(ADC_WIDTH_BIT_12);
- adc2_ulp_enable()
- */
+ gpio_deep_sleep_hold_en();
+
+ rtc_gpio_init(GPIO_NUM_25);
+ rtc_gpio_set_direction(GPIO_NUM_25, RTC_GPIO_MODE_OUTPUT_ONLY);
+ rtc_gpio_pullup_en(GPIO_NUM_25);
+ rtc_gpio_set_level(GPIO_NUM_25, 1);
+ rtc_gpio_hold_en(GPIO_NUM_25);
/* Set ULP wake up period to 1000ms */
ulp_set_wakeup_period(0, 10000 * 1000);
diff --git a/ulp_soil.s b/ulp_soil.s
index e5b0689..75e49d2 100644
--- a/ulp_soil.s
+++ b/ulp_soil.s
@@ -13,6 +13,7 @@
and C macros may be used in these files
*/
#include "soc/rtc_cntl_reg.h"
+#include "soc/rtc_io_reg.h"
#include "soc/soc_ulp.h"
/* Configure the number of ADC samples to average on each measurement.
@@ -80,6 +81,13 @@ soil5_shadow:
.text
.global entry
entry:
+
+ /* set GPIO25/RTC_GPIO06 low to enable moisture sensors */
+enable_sensors:
+ WRITE_RTC_REG(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_HOLD_S, 1, 0)
+ WRITE_RTC_REG(RTC_GPIO_OUT_W1TC_REG, RTC_GPIO_OUT_DATA_W1TC_S + 6, 1, 1)
+ WRITE_RTC_REG(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_HOLD_S, 1, 1)
+
/* r2: adc_soilx maps soil sensor to adc channel */
/* r3: after measurement return to store soilx value to its shadow value */
measure_soil0:
@@ -143,6 +151,11 @@ save_soil5:
move r2, soil5_shadow
st r0, r2, 0
+ /* set GPIO25/RTC_GPIO06 high to disable moisture sensors */
+disable_sensors:
+ WRITE_RTC_REG(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_HOLD_S, 1, 0)
+ WRITE_RTC_REG(RTC_GPIO_OUT_W1TS_REG, RTC_GPIO_OUT_DATA_W1TS_S + 6, 1, 1)
+ WRITE_RTC_REG(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_HOLD_S, 1, 1)
/* get maximum change in soil value compared to last sent */
calc_max_diff:
/* reset max_diff, r0, r1 to zero */