From b2f7f066dbeed346e6d70414593cad2d918c2bd4 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 12 Jul 2018 15:24:36 +0200 Subject: Add arch.idle() command --- src/arch/arduino-nano/arch.cc | 8 ++++++++ src/arch/esp8266/arch.cc | 4 ++++ src/arch/msp430fr5969lp/arch.cc | 11 +++++++++++ src/arch/posix/arch.cc | 4 ++++ 4 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/arch/arduino-nano/arch.cc b/src/arch/arduino-nano/arch.cc index 16d09fb..fda518c 100644 --- a/src/arch/arduino-nano/arch.cc +++ b/src/arch/arduino-nano/arch.cc @@ -55,6 +55,14 @@ void Arch::idle_loop(void) } } +void Arch::idle(void) +{ + SMCR = _BV(SE); + asm("sleep"); + SMCR = 0; + asm("wdr"); +} + void Arch::delay_us(unsigned char const us) { __builtin_avr_delay_cycles(1600); diff --git a/src/arch/esp8266/arch.cc b/src/arch/esp8266/arch.cc index f5d1c91..3490ffe 100644 --- a/src/arch/esp8266/arch.cc +++ b/src/arch/esp8266/arch.cc @@ -57,6 +57,10 @@ void Arch::idle_loop(void) { } +void ArcH::idle(void) +{ +} + extern "C" void user_init(void) { system_init_done_cb(jump_to_main); diff --git a/src/arch/msp430fr5969lp/arch.cc b/src/arch/msp430fr5969lp/arch.cc index aee46f3..3016842 100644 --- a/src/arch/msp430fr5969lp/arch.cc +++ b/src/arch/msp430fr5969lp/arch.cc @@ -91,6 +91,17 @@ void Arch::idle_loop(void) } } +void Arch::idle(void) +{ + __eint(); + asm volatile("nop"); + __bis_SR_register(LPM2_bits); + asm volatile("nop"); +#ifdef WITH_WAKEUP + wakeup(); +#endif +} + Arch arch; #if defined(WITH_LOOP) || defined(TIMER_S) diff --git a/src/arch/posix/arch.cc b/src/arch/posix/arch.cc index efcf90e..54ee8e1 100644 --- a/src/arch/posix/arch.cc +++ b/src/arch/posix/arch.cc @@ -10,4 +10,8 @@ void Arch::idle_loop(void) } } +void Arch::idle(void) +{ +} + Arch arch; -- cgit v1.2.3