Enter Low Power mode not to use sd_power_system_off() subroutine

Dependents:   BLE_EddystoneBeacon_w_ACC_TY51822 BLE_LoopbackUART_low_pwr_w_RTC1 BLE_Paired_Server BLE_Paired_Client

Revision:
0:9ddf14df689c
Child:
1:4c3f4f1e154e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF51_lowpwr.h	Wed Jun 01 10:55:02 2016 +0000
@@ -0,0 +1,74 @@
+/*
+ * mbed library program
+ *  Set low power condition only for nRF51822 BLE chip
+ *
+ *  Copyright (c) 2016 Kenji Arai / JH1PJL
+ *  http://www.page.sannet.ne.jp/kenjia/index.html
+ *  http://mbed.org/users/kenjiArai/
+ *      Started:    April     30th, 2016
+ *      Revised:    June       1st, 2016
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+ * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef NRF51_LOWPWR_H
+#define NRF51_LOWPWR_H
+
+#include "mbed.h"
+
+ 
+ ////////////// DATA TYPE DEFINITION ///////////////////////
+typedef struct {
+    bool    std_printf_function;
+    bool    serial_function;
+    bool    i2c_function;
+    bool    spi_function;
+    bool    spi_slave_function;
+    bool    pwm_functions;
+    bool    analog_function;
+} nRF51_LOWPWR_TypeDef;
+
+/** Set low power condition only for nRF51822 BLE chip
+ *
+ * @code
+ * #include    "mbed.h"
+ * #include    "BLE.h"
+ * #include    "nRF51_lowpwr.h"
+ *
+ * const nRF51_LOWPWR_TypeDef  lowpwr_table = 
+ *                       {
+ *                           false,
+ *                           false,
+ *                           true,
+ *                           false,
+ *                           false,
+ *                           false,
+ *                           false
+ *                       };
+ *
+ * int main() {
+ *     LowPwr set_lowpwr(&lowpwr_table);
+ *     while(1) {
+ *          ble.waitForEvent();
+ *     }
+ * }
+ * @endcode
+ */
+
+class LowPwr{
+public:
+    /** Configure data pin
+      * @param parameters table for Enable/Disable peripheral functions
+      */
+    LowPwr(const nRF51_LOWPWR_TypeDef *param);   
+};
+
+#ifndef TARGET_NRF51822
+#error  "Only for TY51822r3 (If your chip is nRF51822, it should work(I haven't tested)."
+#endif
+
+#endif  // NRF51_LOWPWR_H