remove s command from shell, add if typing disable mcusleep

This commit is contained in:
Harald Pichler 2017-09-19 11:35:45 +02:00
parent 927c0b8eac
commit 25d38eba2c
3 changed files with 22 additions and 17 deletions

View file

@ -59,7 +59,7 @@
#include "project-conf.h" #include "project-conf.h"
#define DEBUG 1 #define DEBUG 0
#if DEBUG #if DEBUG
#include <stdio.h> #include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__) #define PRINTF(...) printf(__VA_ARGS__)
@ -88,23 +88,23 @@ void
mcu_sleep_init(void) mcu_sleep_init(void)
{ {
mcusleepcycleval=mcusleepcycle; mcusleepcycleval=mcusleepcycle;
mcu_sleep_disable(); mcu_sleep_disable(); // if a shell is active we can type
} }
void void
mcu_sleep_disable(void) mcu_sleep_disable(void)
{ {
mcusleep=0; mcusleep=2;
mcu_sleep_off(); mcu_sleep_off();
} }
void void
mcu_sleep_enable(void) mcu_sleep_enable(void)
{ {
mcusleep=1; mcusleep=0;
} }
void void
mcu_sleep_on(void) mcu_sleep_on(void)
{ {
if(mcusleep){ if(mcusleep == 0){
mcusleepcycle= mcusleepcycleval; mcusleepcycle= mcusleepcycleval;
} }
} }
@ -127,13 +127,12 @@ 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) #define START_MCUSLEEP (10 * 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 struct etimer start_mcusleep_timer;
static int a=0;
PROCESS_BEGIN(); PROCESS_BEGIN();
adc_init (); adc_init ();
@ -153,10 +152,17 @@ 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) { if(etimer_expired(&start_mcusleep_timer)) {
PRINTF("mcusleep_timer %d",a); PRINTF("mcusleep_timer %d\n",mcusleep);
mcu_sleep_enable(); if(mcusleep == 1){
a++; PRINTF("mcu sleep on\n");
mcu_sleep_enable();
mcu_sleep_on();
}
if (mcusleep > 0) {
mcusleep--;
}
etimer_reset(&start_mcusleep_timer);
} }
if(etimer_expired(&loop_periodic_timer)) { if(etimer_expired(&loop_periodic_timer)) {

View file

@ -49,7 +49,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "arduino-process.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(serial_shell_process, "Contiki serial shell"); PROCESS(serial_shell_process, "Contiki serial shell");
@ -59,7 +59,7 @@ shell_default_output(const char *text1, int len1, const char *text2, int len2)
{ {
int i; int i;
mcu_sleep_off(); mcu_sleep_disable();
if(text1 == NULL) { if(text1 == NULL) {
text1 = ""; text1 = "";
len1 = 0; len1 = 0;
@ -78,7 +78,6 @@ shell_default_output(const char *text1, int len1, const char *text2, int len2)
printf("%c", text2[i]); printf("%c", text2[i]);
} }
printf("\r\n"); printf("\r\n");
mcu_sleep_on();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
@ -92,6 +91,7 @@ void
shell_exit(void) shell_exit(void)
{ {
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(serial_shell_process, ev, data) PROCESS_THREAD(serial_shell_process, ev, data)
{ {
@ -101,9 +101,8 @@ PROCESS_THREAD(serial_shell_process, ev, data)
while(1) { while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == serial_line_event_message && data != NULL); PROCESS_WAIT_EVENT_UNTIL(ev == serial_line_event_message && data != NULL);
mcu_sleep_off(); mcu_sleep_disable();
shell_input(data, strlen(data)); shell_input(data, strlen(data));
mcu_sleep_on();
} }
PROCESS_END(); PROCESS_END();

View file

@ -255,6 +255,6 @@ shell_merkur_init(void)
shell_register_command(&panid_command); shell_register_command(&panid_command);
shell_register_command(&macconf_command); shell_register_command(&macconf_command);
shell_register_command(&saverfparam_command); shell_register_command(&saverfparam_command);
shell_register_command(&s_command); // shell_register_command(&s_command);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/