From 0b24e047c5b1f82f050a0d9470520a06ecefcef1 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 14 Sep 2017 16:15:43 +0200 Subject: [PATCH] add s command to disable mcusleep --- apps/arduino/arduino-process.c | 20 ++++++++++++-- apps/arduino/arduino-process.h | 6 ++++- apps/shell/shell-merkur.c | 27 +++++++++++++++++-- .../arduino-settingsmanager/project-conf.h | 4 +-- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/apps/arduino/arduino-process.c b/apps/arduino/arduino-process.c index 5afefd3c8..de364ee6d 100644 --- a/apps/arduino/arduino-process.c +++ b/apps/arduino/arduino-process.c @@ -79,23 +79,39 @@ extern resource_t res_event, res_separate; #endif /* PLATFORM_HAS_BUTTON */ volatile uint8_t mcusleepcycleval; +/* 0 dont sleep; 1 sleep */ +uint8_t mcusleep; /*-------------- enabled sleep mode ----------------------------------------*/ void mcu_sleep_init(void) { mcusleepcycleval=mcusleepcycle; + mcu_sleep_enable(); +} +void +mcu_sleep_disable(void) +{ + mcusleep=0; + mcu_sleep_off(); +} +void +mcu_sleep_enable(void) +{ + mcusleep=1; } void mcu_sleep_on(void) { - mcusleepcycle= mcusleepcycleval; + if(mcusleep){ + mcusleepcycle= mcusleepcycleval; + } } /*--------------- disable sleep mode ---------------------------------------*/ void mcu_sleep_off(void) { - mcusleepcycle=0; + mcusleepcycle=0; } /*---------------- set duty cycle value ------------------------------------*/ void diff --git a/apps/arduino/arduino-process.h b/apps/arduino/arduino-process.h index 905f9d47c..da27773e8 100644 --- a/apps/arduino/arduino-process.h +++ b/apps/arduino/arduino-process.h @@ -52,8 +52,12 @@ #include "contiki.h" /*--------------- enable sleep mode ---------------------------------------*/ -void mcu_sleep_on(void); +void mcu_sleep_enable(void); /*--------------- disable sleep mode ---------------------------------------*/ +void mcu_sleep_disable(void); +/*--------------- sleep mode on---------------------------------------*/ +void mcu_sleep_on(void); +/*--------------- sleep mode off---------------------------------------*/ void mcu_sleep_off(void); /*---------------- set sleep value ------------------------------------*/ void mcu_sleep_set(uint8_t value); diff --git a/apps/shell/shell-merkur.c b/apps/shell/shell-merkur.c index 7c7c1b07b..10ba783f1 100644 --- a/apps/shell/shell-merkur.c +++ b/apps/shell/shell-merkur.c @@ -43,8 +43,8 @@ #include "sys/cc.h" #include "dev/radio.h" #include "shell-merkur.h" -//#include "extended-rf-api.h" #include "params.h" +#include "arduino-process.h" /*---------------------------------------------------------------------------*/ PROCESS(shell_txpower_process, "txpower"); @@ -77,7 +77,30 @@ SHELL_COMMAND(saverfparam_command, "saverfparam", "saverfparam <> save radio parameters txpower, channel, panid to eeprom settingsmanager", &shell_saverfparam_process); +PROCESS(shell_s_process, "s"); +SHELL_COMMAND(s_command, + "s", + "s disable mcu_sleep", + &shell_s_process); +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(shell_s_process, ev, data) +{ +// radio_value_t value; + const char *newptr; + + PROCESS_BEGIN(); + shell_strtolong(data, &newptr); + + if(newptr == data) { + mcu_sleep_disable(); + shell_output_str(&txpower_command, "disable mcusleep", 0); + } else { + mcu_sleep_enable(); + shell_output_str(&txpower_command, "enable mcusleep", 0); + } + PROCESS_END(); +} /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_txpower_process, ev, data) { @@ -232,6 +255,6 @@ shell_merkur_init(void) shell_register_command(&panid_command); shell_register_command(&macconf_command); shell_register_command(&saverfparam_command); - + shell_register_command(&s_command); } /*---------------------------------------------------------------------------*/ diff --git a/examples/osd/arduino-settingsmanager/project-conf.h b/examples/osd/arduino-settingsmanager/project-conf.h index 6efd21174..fce494ff3 100644 --- a/examples/osd/arduino-settingsmanager/project-conf.h +++ b/examples/osd/arduino-settingsmanager/project-conf.h @@ -45,8 +45,8 @@ //#define RDC_CONF_PT_YIELD_OFF /* For Debug: Dont allow MCU sleeping between channel checks */ -#undef RDC_CONF_MCU_SLEEP -#define RDC_CONF_MCU_SLEEP 0 +//#undef RDC_CONF_MCU_SLEEP +//#define RDC_CONF_MCU_SLEEP 0 /* Disabling RDC for demo purposes. Core updates often require more memory. */ /* For projects, optimize memory and enable RDC again. */