From f50708b24c89e95b7e38ca0fe395cf730c440401 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 6 Apr 2017 15:45:51 +0700 Subject: [PATCH] add sleep() as wrapper for __wfe() --- cores/nRF5/wiring.h | 5 +++++ .../Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cores/nRF5/wiring.h b/cores/nRF5/wiring.h index ac87c7b3..bf802e4c 100644 --- a/cores/nRF5/wiring.h +++ b/cores/nRF5/wiring.h @@ -24,6 +24,11 @@ extern "C" { extern void init(void); +static inline void sleep(void) +{ + __WFE(); +} + extern void enterSerialDfu(void); extern void enterOTADfu(void); diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino b/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino index 6d13bf1c..ff1d4b8f 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino @@ -87,7 +87,7 @@ void loop() } // forward from Serial to BLEUART - if (Serial.available()) + while (Serial.available()) { // delay to get enough inputs, since we have limited number of transmission buffer delay(2); @@ -98,12 +98,14 @@ void loop() } // forward from BLEUART to Serial - if ( bleuart.available() ) + while ( bleuart.available() ) { uint8_t ch; ch = (uint8_t) bleuart.read(); Serial.write(ch); } + + sleep(); } void connect_callback(void)