SAM D21 Power Manager

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the code below, I try to listen for the ready to sleep callback, however the program stops at sleepmgr_register_ready_to_sleep_callback and does not continue to the line. Code works fine if I remove the sleepmgr_register_ready_to_sleep_callback. Anyone has any idea why? Perhaps a sample would be nice.

 

#include <atmel_start.h>

 

void buttonPressed(void);
static void wakeUp(void);
static void readyToSleep(void);

 

static uint8_t idle = 0;

 

int main(void)
{
    
    /* Initializes MCU, drivers and middleware */
    atmel_start_init();
    

    sleepmgr_register_ready_to_sleep_callback(readyToSleep);

    ext_irq_register(PIN15, buttonPressed);
   
    
    sleepmgr_sleep(idle);
    
    
    
    /* Replace with your application code */
    while (1) {
        
    }
}

void buttonPressed(){
    sleepmgr_wakeup(SM_WAKEUP_SOURCE_EXT_IRQ);    
}

void readyToSleep(){
    //Ready to sleep
}

AKA JAX