to cai

Dependencies:   BLE_API nRF51822

Fork of BLE_NODE_TEST by Yihui Xiong

Committer:
yihui
Date:
Wed Oct 29 06:23:47 2014 +0000
Revision:
9:05f0b5a3a70a
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 9:05f0b5a3a70a 1
yihui 9:05f0b5a3a70a 2 #include "nrf51.h"
yihui 9:05f0b5a3a70a 3 #include "nrf51_bitfields.h"
yihui 9:05f0b5a3a70a 4
yihui 9:05f0b5a3a70a 5 #define POWER_PIN 8
yihui 9:05f0b5a3a70a 6
yihui 9:05f0b5a3a70a 7 void power_on()
yihui 9:05f0b5a3a70a 8 {
yihui 9:05f0b5a3a70a 9 NRF_GPIO->PIN_CNF[POWER_PIN] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
yihui 9:05f0b5a3a70a 10 | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
yihui 9:05f0b5a3a70a 11 | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
yihui 9:05f0b5a3a70a 12 | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
yihui 9:05f0b5a3a70a 13 | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
yihui 9:05f0b5a3a70a 14 NRF_GPIO->OUTSET = (1UL << POWER_PIN);
yihui 9:05f0b5a3a70a 15 }
yihui 9:05f0b5a3a70a 16
yihui 9:05f0b5a3a70a 17
yihui 9:05f0b5a3a70a 18 void power_off()
yihui 9:05f0b5a3a70a 19 {
yihui 9:05f0b5a3a70a 20 NRF_GPIO->OUTCLR = (1UL << POWER_PIN);
yihui 9:05f0b5a3a70a 21
yihui 9:05f0b5a3a70a 22 // Enter system OFF. After wakeup the chip will be reset, and the MCU will run from the top
yihui 9:05f0b5a3a70a 23 NRF_POWER->SYSTEMOFF = 1;
yihui 9:05f0b5a3a70a 24 }