add s command to disable mcusleep

master
Harald Pichler 2017-09-14 16:15:43 +02:00
parent 31ec8687e4
commit 0b24e047c5
4 changed files with 50 additions and 7 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}
/*---------------------------------------------------------------------------*/

View File

@ -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. */