1818#include <hal/nrf_gpio.h>
1919#if CONFIG_SOC_NRF54H20_CPUAPP
2020#include <hal/nrf_memconf.h>
21+ #include <internal/nrfs_backend.h>
22+ #include <nrfs_backend_ipc_service.h>
23+ #include <nrfs_mram.h>
24+ #include <nrfs_temp.h>
25+ #include <nrfs_pmic.h>
26+ #include <nrfs_usb.h>
27+ #include <nrfs_clock.h>
28+ #include <nrfs_gdpwr.h>
29+ #include <nrfs_gdfs.h>
2130#endif
2231
2332#if IS_ENABLED (CONFIG_GRTC_WAKEUP_ENABLE )
@@ -29,6 +38,28 @@ static const struct gpio_dt_spec sw1 = GPIO_DT_SPEC_GET(DT_ALIAS(sw1), gpios);
2938static const uint32_t port_sw1 = DT_PROP (DT_GPIO_CTLR_BY_IDX (DT_ALIAS (sw1 ), gpios , 0 ), port );
3039#endif
3140
41+ void temp_handler (nrfs_temp_evt_t const * p_evt , void * context )
42+ {
43+ int32_t temp ;
44+
45+ switch (p_evt -> type ) {
46+ case NRFS_TEMP_EVT_MEASURE_DONE :
47+ temp = nrfs_temp_from_raw (p_evt -> raw_temp );
48+ printk ("TEMP Measurement done: %d.%d [C]\n" , temp / 100 , temp % 100 );
49+ break ;
50+ case NRFS_TEMP_EVT_CHANGE :
51+ temp = nrfs_temp_from_raw (p_evt -> raw_temp );
52+ printk ("TEMP exceeded limit: %d.%d [C]\n" , temp / 100 , temp % 100 );
53+ break ;
54+ case NRFS_TEMP_EVT_REJECT :
55+ printk ("TEMP handler - request rejected\n" );
56+ break ;
57+ default :
58+ printk ("TEMP handler - unexpected event: 0x%x\n" , p_evt -> type );
59+ break ;
60+ }
61+ }
62+
3263int main (void )
3364{
3465 int rc ;
@@ -48,6 +79,13 @@ int main(void)
4879
4980 printf ("\n%s system off demo\n" , CONFIG_BOARD );
5081
82+ int status = nrfs_temp_init (temp_handler );
83+ if (status != NRFS_SUCCESS ) {
84+ printk ("TEMP service init failed: %d\n" , status );
85+ } else {
86+ printk ("Local TEMP init done\n" );
87+ }
88+
5189 if (IS_ENABLED (CONFIG_APP_USE_RETAINED_MEM )) {
5290 bool retained_ok = retained_validate ();
5391
@@ -116,11 +154,17 @@ int main(void)
116154 retained_update ();
117155 }
118156
157+ status = nrfs_temp_subscribe (5000 , nrfs_temp_to_raw (4000 ), nrfs_temp_to_raw (8000 ),
158+ (void * )NULL );
159+
160+ k_msleep (1000 );
161+
119162 if (do_poweroff ) {
120163#if CONFIG_SOC_NRF54H20_CPUAPP
121164 /* Local RAM0 (TCM) is currently not used so retention can be disabled. */
122165 nrf_memconf_ramblock_ret_mask_enable_set (NRF_MEMCONF , 0 , RAMBLOCK_RET_MASK , false);
123166 nrf_memconf_ramblock_ret_mask_enable_set (NRF_MEMCONF , 1 , RAMBLOCK_RET_MASK , false);
167+ //nrfs_backend_close_connection();
124168#endif
125169 sys_poweroff ();
126170 } else {
0 commit comments