GPIO wake-up and sleep

Dear Dialog Support,

I am testing the example ble_app_peripheral in SDK_6.0.18.1182.1. I want to realize the following function:

Once DA14531 is powered on, it enters into the extended sleep mode. When the button is pressed down once, DA14531 wakes up and the functions of the original example ble_app_peripheral can normally perform. And when the button is pressed down once again, DA14531 enters into the extended sleep mode again, and so on.

Could you please show me how to achieve this. Thanks a lot!

Parents
  • Hi Nick,

    Thank you for posting your question online.
    Please find attached the ble_app_peripheral_wakeup.zip file. 
    I worked on SDK v6.0.18 with the DA14531MOD and the Dev Kit Pro.
    I configured the P0_11 as my button and whenever I press the button I get into Extended sleep mode or exit Extended Sleep Mode.
    Please refer to this project for your implementation.

    Best Regards,
    OV_Renesas
    ble_app_peripheral_wakeup.zip

  • Dear OV,

    Thank you so much for your kindly help. Could you please tell me which part you modified in the example ble_app_peripheral, so that I could learn from it. Thanks.

  • Dear Nick,

    Thank you for the reply.

    Could you please tell me which part you modified in the example ble_app_peripheral, so that I could learn from it

    I worked based on the implementation on the prox_reporter example.
    On user_peripheral.c file the main changes are:

    /**
     ****************************************************************************************
     * @brief Button press callback function. Registered in WKUPCT driver.
     ****************************************************************************************
     */
    static void app_button_press_cb(void)
    {
    	//GO into active mode without extended sleep mode
        arch_set_sleep_mode(ARCH_SLEEP_OFF);
    // configure the wake-up controller for P0_11 
        app_button_enable2();
    }
    
    void app_button_enable(void)
    {
    	//Set the wake-up controller callback to leave Extended Sleep
        wkupct_register_callback(app_button_press_cb);
    
    
            wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
                              WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
                              1, // 1 event
                              0); // debouncing time = 0
        
    }
    
    
    static void go_to_sleep(void)
    {
    // Go to extended sleep without OTP copy
    	arch_set_extended_sleep(false);
    //Initialize the Wake-up contoller to trigger an interrupt on P0_11
        app_button_enable();
    }
    
    //Configure the Wake-Up controller for button (P0_11) interrupt and trigger the wake-up controller callback to go into Extended Sleep.
    void app_button_enable2(void)
    {
      //Set the wake-up controller callback to go to extended sleep
        wkupct_register_callback(go_to_sleep);
    
    
            wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
                              WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
                              1, // 1 event
                              0); // debouncing time = 0
        
    }

    The initial call to configure the Wake Up controller is on user_app_init custom callback function.

    Also, on the user_periph_setup.h/c files I configured the P0_11 as a Button.


    Best Regards,
    OV_Renesas

Reply
  • Dear Nick,

    Thank you for the reply.

    Could you please tell me which part you modified in the example ble_app_peripheral, so that I could learn from it

    I worked based on the implementation on the prox_reporter example.
    On user_peripheral.c file the main changes are:

    /**
     ****************************************************************************************
     * @brief Button press callback function. Registered in WKUPCT driver.
     ****************************************************************************************
     */
    static void app_button_press_cb(void)
    {
    	//GO into active mode without extended sleep mode
        arch_set_sleep_mode(ARCH_SLEEP_OFF);
    // configure the wake-up controller for P0_11 
        app_button_enable2();
    }
    
    void app_button_enable(void)
    {
    	//Set the wake-up controller callback to leave Extended Sleep
        wkupct_register_callback(app_button_press_cb);
    
    
            wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
                              WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
                              1, // 1 event
                              0); // debouncing time = 0
        
    }
    
    
    static void go_to_sleep(void)
    {
    // Go to extended sleep without OTP copy
    	arch_set_extended_sleep(false);
    //Initialize the Wake-up contoller to trigger an interrupt on P0_11
        app_button_enable();
    }
    
    //Configure the Wake-Up controller for button (P0_11) interrupt and trigger the wake-up controller callback to go into Extended Sleep.
    void app_button_enable2(void)
    {
      //Set the wake-up controller callback to go to extended sleep
        wkupct_register_callback(go_to_sleep);
    
    
            wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
                              WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
                              1, // 1 event
                              0); // debouncing time = 0
        
    }

    The initial call to configure the Wake Up controller is on user_app_init custom callback function.

    Also, on the user_periph_setup.h/c files I configured the P0_11 as a Button.


    Best Regards,
    OV_Renesas

Children
No Data