to cai
Dependencies: BLE_API nRF51822
Fork of BLE_NODE_TEST by
power.c
- Committer:
- yihui
- Date:
- 2014-11-27
- Revision:
- 11:22480ac31879
- Parent:
- 9:05f0b5a3a70a
File content as of revision 11:22480ac31879:
#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; }