@@ -180,48 +180,25 @@ int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off)
180
180
return ret ;
181
181
}
182
182
183
- void __attribute__(( naked )) pm_s2ram_mark_set (void )
183
+ void pm_s2ram_mark_set (void )
184
184
{
185
185
/* empty */
186
- __asm__ volatile ("bx lr\n" );
187
186
}
188
187
189
- bool __attribute__(( naked )) pm_s2ram_mark_check_and_clear (void )
188
+ bool pm_s2ram_mark_check_and_clear (void )
190
189
{
191
- __asm__ volatile (
192
- /* Set return value to 0 */
193
- "mov r0, #0\n"
190
+ bool unretained_wake ;
191
+ bool restore_valid ;
192
+ uint32_t reset_reason = nrf_resetinfo_resetreas_local_get ( NRF_RESETINFO );
194
193
195
- /* Load and check RESETREAS register */
196
- "ldr r3, [%[resetinfo_addr], %[resetreas_offs]]\n"
197
- "cmp r3, %[resetreas_unretained_mask]\n"
198
-
199
- "bne exit\n"
200
-
201
- /* Clear RESETREAS register */
202
- "str r0, [%[resetinfo_addr], %[resetreas_offs]]\n"
203
-
204
- /* Load RESTOREVALID register */
205
- "ldr r3, [%[resetinfo_addr], %[restorevalid_offs]]\n"
206
-
207
- /* Clear RESTOREVALID */
208
- "str r0, [%[resetinfo_addr], %[restorevalid_offs]]\n"
209
-
210
- /* Check RESTOREVALID register */
211
- "cmp r3, %[restorevalid_present_mask]\n"
212
- "bne exit\n"
213
-
214
- /* Set return value to 1 */
215
- "mov r0, #1\n"
194
+ if (reset_reason != NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK ) {
195
+ return false;
196
+ }
197
+ unretained_wake = reset_reason & NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK ;
198
+ nrf_resetinfo_resetreas_local_set (NRF_RESETINFO , 0 );
216
199
217
- "exit:\n"
218
- "bx lr\n"
219
- :
220
- : [resetinfo_addr ] "r" (NRF_RESETINFO ),
221
- [resetreas_offs ] "r" (offsetof(NRF_RESETINFO_Type , RESETREAS .LOCAL )),
222
- [resetreas_unretained_mask ] "r" (NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK ),
223
- [restorevalid_offs ] "r" (offsetof(NRF_RESETINFO_Type , RESTOREVALID )),
224
- [restorevalid_present_mask ] "r" (RESETINFO_RESTOREVALID_RESTOREVALID_Msk )
200
+ restore_valid = nrf_resetinfo_restore_valid_check (NRF_RESETINFO );
201
+ nrf_resetinfo_restore_valid_set (NRF_RESETINFO , false);
225
202
226
- : "r0" , "r1" , "r3" , "r4" , "memory" ) ;
203
+ return ( unretained_wake & restore_valid ) ? true : false ;
227
204
}
0 commit comments