bugfix startup dont sleep 5sec.
This commit is contained in:
parent
0b24e047c5
commit
87f433d657
|
@ -58,7 +58,8 @@
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "project-conf.h"
|
#include "project-conf.h"
|
||||||
|
|
||||||
#define DEBUG 0
|
|
||||||
|
#define DEBUG 1
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define PRINTF(...) printf(__VA_ARGS__)
|
#define PRINTF(...) printf(__VA_ARGS__)
|
||||||
|
@ -87,7 +88,7 @@ void
|
||||||
mcu_sleep_init(void)
|
mcu_sleep_init(void)
|
||||||
{
|
{
|
||||||
mcusleepcycleval=mcusleepcycle;
|
mcusleepcycleval=mcusleepcycle;
|
||||||
mcu_sleep_enable();
|
mcu_sleep_disable();
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
mcu_sleep_disable(void)
|
mcu_sleep_disable(void)
|
||||||
|
@ -126,10 +127,13 @@ PROCESS(arduino_sketch, "Arduino Sketch Wrapper");
|
||||||
#ifndef LOOP_INTERVAL
|
#ifndef LOOP_INTERVAL
|
||||||
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
||||||
#endif
|
#endif
|
||||||
|
#define START_MCUSLEEP (5 * CLOCK_SECOND)
|
||||||
|
|
||||||
PROCESS_THREAD(arduino_sketch, ev, data)
|
PROCESS_THREAD(arduino_sketch, ev, data)
|
||||||
{
|
{
|
||||||
static struct etimer loop_periodic_timer;
|
static struct etimer loop_periodic_timer;
|
||||||
|
static struct etimer start_mcusleep_timer;
|
||||||
|
static int a=0;
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
adc_init ();
|
adc_init ();
|
||||||
|
@ -137,6 +141,7 @@ PROCESS_THREAD(arduino_sketch, ev, data)
|
||||||
setup ();
|
setup ();
|
||||||
/* Define application-specific events here. */
|
/* Define application-specific events here. */
|
||||||
etimer_set(&loop_periodic_timer, LOOP_INTERVAL);
|
etimer_set(&loop_periodic_timer, LOOP_INTERVAL);
|
||||||
|
etimer_set(&start_mcusleep_timer, START_MCUSLEEP);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
|
@ -148,6 +153,11 @@ PROCESS_THREAD(arduino_sketch, ev, data)
|
||||||
mcu_sleep_on();
|
mcu_sleep_on();
|
||||||
}
|
}
|
||||||
#endif /* PLATFORM_HAS_BUTTON */
|
#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)) {
|
if(etimer_expired(&loop_periodic_timer)) {
|
||||||
mcu_sleep_off();
|
mcu_sleep_off();
|
||||||
|
|
Loading…
Reference in a new issue