From 87f433d65727edaf949730944235c72e53923270 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 14 Sep 2017 17:19:53 +0200 Subject: [PATCH] bugfix startup dont sleep 5sec. --- apps/arduino/arduino-process.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/arduino/arduino-process.c b/apps/arduino/arduino-process.c index de364ee6d..1ad5ce548 100644 --- a/apps/arduino/arduino-process.c +++ b/apps/arduino/arduino-process.c @@ -58,7 +58,8 @@ #include "contiki.h" #include "project-conf.h" -#define DEBUG 0 + +#define DEBUG 1 #if DEBUG #include #define PRINTF(...) printf(__VA_ARGS__) @@ -87,7 +88,7 @@ void mcu_sleep_init(void) { mcusleepcycleval=mcusleepcycle; - mcu_sleep_enable(); + mcu_sleep_disable(); } void mcu_sleep_disable(void) @@ -126,10 +127,13 @@ PROCESS(arduino_sketch, "Arduino Sketch Wrapper"); #ifndef LOOP_INTERVAL #define LOOP_INTERVAL (1 * CLOCK_SECOND) #endif +#define START_MCUSLEEP (5 * CLOCK_SECOND) PROCESS_THREAD(arduino_sketch, ev, data) { static struct etimer loop_periodic_timer; + static struct etimer start_mcusleep_timer; + static int a=0; PROCESS_BEGIN(); adc_init (); @@ -137,6 +141,7 @@ PROCESS_THREAD(arduino_sketch, ev, data) setup (); /* Define application-specific events here. */ etimer_set(&loop_periodic_timer, LOOP_INTERVAL); + etimer_set(&start_mcusleep_timer, START_MCUSLEEP); while (1) { PROCESS_WAIT_EVENT(); @@ -148,6 +153,11 @@ PROCESS_THREAD(arduino_sketch, ev, data) mcu_sleep_on(); } #endif /* PLATFORM_HAS_BUTTON */ + if(etimer_expired(&start_mcusleep_timer) && a == 0) { + PRINTF("mcusleep_timer %d",a); + mcu_sleep_enable(); + a++; + } if(etimer_expired(&loop_periodic_timer)) { mcu_sleep_off();