Enter Low Power mode not to use sd_power_system_off() subroutine

Dependents:   BLE_EddystoneBeacon_w_ACC_TY51822 BLE_LoopbackUART_low_pwr_w_RTC1 BLE_Paired_Server BLE_Paired_Client

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nRF51_lowpwr.h Source File

nRF51_lowpwr.h

00001 /*
00002  * mbed library program
00003  *  Set low power condition only for nRF51822 BLE chip
00004  *
00005  *  Copyright (c) 2016 Kenji Arai / JH1PJL
00006  *  http://www.page.sannet.ne.jp/kenjia/index.html
00007  *  http://mbed.org/users/kenjiArai/
00008  *      Started:    April     30th, 2016
00009  *      Revised:    June      11th, 2016
00010  *
00011  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
00012  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
00013  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00014  * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00015  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00016  */
00017 
00018 #ifndef NRF51_LOWPWR_H
00019 #define NRF51_LOWPWR_H
00020 
00021 #include "mbed.h"
00022 
00023  
00024  ////////////// DATA TYPE DEFINITION ///////////////////////
00025 typedef struct {
00026     bool    std_printf_function;
00027     bool    serial_function;
00028     bool    i2c_function;
00029     bool    spi_function;
00030     bool    spi_slave_function;
00031     bool    pwm_functions;
00032     bool    analog_function;
00033 } nRF51_LOWPWR_TypeDef;
00034 
00035 /** Set low power condition only for nRF51822 BLE chip
00036  *
00037  * @code
00038  * #include    "mbed.h"
00039  * #include    "BLE.h"
00040  * #include    "nRF51_lowpwr.h"
00041  *
00042  * const nRF51_LOWPWR_TypeDef  lowpwr_table = 
00043  *                       {
00044  *                           false, // VCOM
00045  *                           false, // UART
00046  *                           true,  // I2C
00047  *                           false, // SPI
00048  *                           false, // SPI Slave
00049  *                           false, // PWM
00050  *                           false  // ADC
00051  *                       };
00052  *
00053  * int main() {
00054  *     LowPwr set_lowpwr(&lowpwr_table);
00055  *     while(1) {
00056  *          ble.waitForEvent();
00057  *     }
00058  * }
00059  * @endcode
00060  */
00061 
00062 class LowPwr{
00063 public:
00064     /** Configure data pin
00065       * @param parameters table for Enable/Disable peripheral functions
00066       */
00067     LowPwr(const nRF51_LOWPWR_TypeDef *param);   
00068 };
00069 
00070 #ifndef TARGET_NRF51822
00071 #error  "Only for TY51822r3 (If your chip is nRF51822, it should work(I haven't tested)."
00072 #endif
00073 
00074 #endif  // NRF51_LOWPWR_H