18
18
#include <hal/nrf_gpio.h>
19
19
#if CONFIG_SOC_NRF54H20_CPUAPP
20
20
#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>
21
30
#endif
22
31
23
32
#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);
29
38
static const uint32_t port_sw1 = DT_PROP (DT_GPIO_CTLR_BY_IDX (DT_ALIAS (sw1 ), gpios , 0 ), port );
30
39
#endif
31
40
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
+
32
63
int main (void )
33
64
{
34
65
int rc ;
@@ -48,6 +79,13 @@ int main(void)
48
79
49
80
printf ("\n%s system off demo\n" , CONFIG_BOARD );
50
81
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
+
51
89
if (IS_ENABLED (CONFIG_APP_USE_RETAINED_MEM )) {
52
90
bool retained_ok = retained_validate ();
53
91
@@ -116,11 +154,17 @@ int main(void)
116
154
retained_update ();
117
155
}
118
156
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
+
119
162
if (do_poweroff ) {
120
163
#if CONFIG_SOC_NRF54H20_CPUAPP
121
164
/* Local RAM0 (TCM) is currently not used so retention can be disabled. */
122
165
nrf_memconf_ramblock_ret_mask_enable_set (NRF_MEMCONF , 0 , RAMBLOCK_RET_MASK , false);
123
166
nrf_memconf_ramblock_ret_mask_enable_set (NRF_MEMCONF , 1 , RAMBLOCK_RET_MASK , false);
167
+ //nrfs_backend_close_connection();
124
168
#endif
125
169
sys_poweroff ();
126
170
} else {
0 commit comments