26
26
27
27
#include <assert.h>
28
28
#include "py/mpconfig.h"
29
- #include "mutex_extra .h"
29
+ #include "py/mpthread .h"
30
30
#include "pendsv.h"
31
31
32
32
#if PICO_RP2040
@@ -47,21 +47,21 @@ void PendSV_Handler(void);
47
47
48
48
// Using the nowait variant here as softtimer updates PendSV from the loop of mp_wfe_or_timeout(),
49
49
// where we don't want the CPU event bit to be set.
50
- static recursive_mutex_nowait_t pendsv_mutex ;
50
+ static mp_thread_recursive_mutex_t pendsv_mutex ;
51
51
52
52
void pendsv_init (void ) {
53
- recursive_mutex_nowait_init (& pendsv_mutex );
53
+ mp_thread_recursive_mutex_init (& pendsv_mutex );
54
54
}
55
55
56
56
void pendsv_suspend (void ) {
57
57
// Recursive Mutex here as either core may call pendsv_suspend() and expect
58
58
// both mutual exclusion (other core can't enter pendsv_suspend() at the
59
59
// same time), and that no PendSV handler will run.
60
- recursive_mutex_nowait_enter_blocking (& pendsv_mutex );
60
+ mp_thread_recursive_mutex_lock (& pendsv_mutex , 1 );
61
61
}
62
62
63
63
void pendsv_resume (void ) {
64
- recursive_mutex_nowait_exit (& pendsv_mutex );
64
+ mp_thread_recursive_mutex_unlock (& pendsv_mutex );
65
65
66
66
// Run pendsv if needed. Find an entry with a dispatch and call pendsv dispatch
67
67
// with it. If pendsv runs it will service all slots.
@@ -97,7 +97,7 @@ void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f) {
97
97
// PendSV interrupt handler to perform background processing.
98
98
void PendSV_Handler (void ) {
99
99
100
- if (!recursive_mutex_nowait_try_enter (& pendsv_mutex , NULL )) {
100
+ if (!mp_thread_recursive_mutex_lock (& pendsv_mutex , 0 )) {
101
101
// Failure here means core 1 holds pendsv_mutex. ISR will
102
102
// run again after core 1 calls pendsv_resume().
103
103
return ;
@@ -117,5 +117,5 @@ void PendSV_Handler(void) {
117
117
}
118
118
}
119
119
120
- recursive_mutex_nowait_exit (& pendsv_mutex );
120
+ mp_thread_recursive_mutex_unlock (& pendsv_mutex );
121
121
}
0 commit comments