Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf51 system off /on after specific duration of time for ble central

hello , i am trying to imblement system off or system on  in one of the ble central example 'ble_app_blinky_c' , i tried to refer to this example 'ble_app_template' but if i understand the code correctly it seems like it utilize all the bsp buttons , also i want to add a timer where the nrf51 goes into system off after let`s say 5 mins 

thank you 

Parents
  • Hello,

    The BSP module is not required for configuring the GPIOs, you can access the GPIOs directly as well (GPIO abstraction).

    e.g., 

    void enter_sys_off()
    {
        /*Pins that are not needed in system OFF should be configured to reset state
        to avoid leakage currents and unexpected wakeups.*/
        nrf_gpio_cfg_default(PIN_x);
        nrf_gpio_cfg_default(PIN_y);
        ...
            
        /* Configure wakeup pin*/
        nrf_gpio_cfg_sense_input(WAKE_UP_PIN,
                                 NRF_GPIO_PIN_x, // configure pull-up or pull-down according to button schematic.
                                 NRF_GPIO_PIN_SENSE_x); // Active low or active high
        sd_power_system_off(); // NOTE: chip will enter emulated system OFF if chip is in debug interface mode. 
    }

    "enter_sys_off()" can be called from your timer interrupt. Alternatively, set the scanner timeout to 5 minutes, and enter system off when scanner timeout occurs: 

        #define SCAN_TIMEOUT    5*60  //Scanner timeout in seconds
        
        static void on_ble_evt(const ble_evt_t * const p_ble_evt)
        {
            ..
            
            switch (p_ble_evt->header.evt_id)
            {
                case BLE_GAP_EVT_TIMEOUT:
                if (p_ble_evt->evt.gap_evt.params.timeout.src != BLE_GAP_TIMEOUT_SRC_SCAN)
                {
                    enter_sys_off();
                }
            }
            
            ..

     

Reply Children
No Data
Related