-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpico_thread.cc
39 lines (26 loc) · 1.07 KB
/
pico_thread.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//---------------------------------------------------------------------------
#include "javelin/thread.h"
#include <pico/multicore.h>
//---------------------------------------------------------------------------
void RunParallel(void (*func1)(void *context), void *context1,
void (*func2)(void *context), void *context2) {
multicore_fifo_push_blocking((uint32_t)func1);
multicore_fifo_push_blocking((uint32_t)context1);
(*func2)(context2);
multicore_fifo_pop_blocking();
}
//---------------------------------------------------------------------------
static void MultiCoreEntryPoint() {
while (1) {
void (*func)(void *) = (void (*)(void *))multicore_fifo_pop_blocking();
void *context = (void *)multicore_fifo_pop_blocking();
(*func)(context);
multicore_fifo_push_blocking(0);
}
}
//---------------------------------------------------------------------------
void InitMulticore() {
multicore_reset_core1();
multicore_launch_core1(MultiCoreEntryPoint);
}
//---------------------------------------------------------------------------