File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed 
samples/boards/nordic/system_off Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -21,4 +21,10 @@ config APP_USE_RETAINED_MEM
2121
2222endchoice
2323
24+ config GRTC_WAKEUP_ENABLE
25+ 	bool "Use GRTC to wake up device from system off"
26+ 	default n
27+ 	help
28+ 	  Switch wake up source from pressing sw0 button to GRTC
29+ 
2430source "Kconfig.zephyr"
Original file line number Diff line number Diff line change 2929    extra_configs :
3030      - CONFIG_APP_USE_RETAINED_MEM=y 
3131      - CONFIG_RETAINED_MEM=y 
32+   sample.boards.nrf.system_off.grtc_wakeup :
33+     build_only : true 
34+     platform_allow :
35+       - nrf54l15dk/nrf54l15/cpuapp 
36+     extra_configs :
37+       - CONFIG_GRTC_WAKEUP_ENABLE=y 
Original file line number Diff line number Diff line change 1616#include  <zephyr/sys/poweroff.h> 
1717#include  <zephyr/sys/util.h> 
1818
19+ #if  IS_ENABLED (CONFIG_GRTC_WAKEUP_ENABLE )
20+ #include  <zephyr/drivers/timer/nrf_grtc_timer.h> 
21+ #define  DEEP_SLEEP_TIME_S  2
22+ #else 
1923static  const  struct  gpio_dt_spec  sw0  =  GPIO_DT_SPEC_GET (DT_ALIAS (sw0 ), gpios );
24+ #endif 
2025
2126int  main (void )
2227{
@@ -45,6 +50,15 @@ int main(void)
4550		printf ("Retained data not supported\n" );
4651	}
4752
53+ #if  IS_ENABLED (CONFIG_GRTC_WAKEUP_ENABLE )
54+ 	int  err  =  z_nrf_grtc_wakeup_prepare (DEEP_SLEEP_TIME_S  *  USEC_PER_SEC );
55+ 
56+ 	if  (err  <  0 ) {
57+ 		printk ("Unable to prepare GRTC as a wake up source (err = %d).\n" , err );
58+ 	} else  {
59+ 		printk ("Entering system off; wait %u seconds to restart\n" , DEEP_SLEEP_TIME_S );
60+ 	}
61+ #else 
4862	/* configure sw0 as input, interrupt as level active to allow wake-up */ 
4963	rc  =  gpio_pin_configure_dt (& sw0 , GPIO_INPUT );
5064	if  (rc  <  0 ) {
@@ -59,7 +73,7 @@ int main(void)
5973	}
6074
6175	printf ("Entering system off; press sw0 to restart\n" );
62- 
76+ #endif 
6377	rc  =  pm_device_action_run (cons , PM_DEVICE_ACTION_SUSPEND );
6478	if  (rc  <  0 ) {
6579		printf ("Could not suspend console (%d)\n" , rc );
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments