The firmware of the Grove Node

Dependencies:   BLE_API color_pixels mbed-src-nrf51822 nRF51822

Fork of BLE_LoopbackUART by Bluetooth Low Energy

Committer:
yihui
Date:
Thu Jun 04 12:39:32 2015 +0000
Revision:
11:c0885b74a63a
Parent:
9:84cb66d0375d
fixed direct control bug

Who changed what in which revision?

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