The firmware of the Grove Node

Dependencies:   BLE_API color_pixels mbed-src-nrf51822 nRF51822

Fork of BLE_LoopbackUART by Bluetooth Low Energy

Revision:
9:84cb66d0375d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/power.c	Thu Nov 06 02:22:01 2014 +0000
@@ -0,0 +1,24 @@
+
+#include "nrf51.h"
+#include "nrf51_bitfields.h"
+
+#define POWER_PIN   8
+
+void power_on()
+{
+    NRF_GPIO->PIN_CNF[POWER_PIN] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                                            | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                                            | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
+                                            | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
+                                            | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
+    NRF_GPIO->OUTSET = (1UL << POWER_PIN);
+}
+
+
+void power_off()
+{
+    NRF_GPIO->OUTCLR = (1UL << POWER_PIN);
+    
+    // Enter system OFF. After wakeup the chip will be reset, and the MCU will run from the top 
+    NRF_POWER->SYSTEMOFF = 1;
+}