The firmware of the Grove Node
Dependencies: BLE_API color_pixels mbed-src-nrf51822 nRF51822
Fork of BLE_LoopbackUART by
power.c
- Committer:
- yihui
- Date:
- 2015-06-04
- Revision:
- 11:c0885b74a63a
- Parent:
- 9:84cb66d0375d
File content as of revision 11:c0885b74a63a:
#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; }