File tree 2 files changed +30
-4
lines changed
2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -4,22 +4,46 @@ int add(int a, int b) {
4
4
return a + b;
5
5
}
6
6
7
- void setup () {
7
+ int sub (int a, int b) {
8
+ return a - b;
9
+ }
10
+
11
+ void setup () {
12
+ Serial.begin (115200 );
13
+ while (!Serial) {
14
+
15
+ }
16
+
8
17
RPC.begin ();
9
18
RPC.bind (" add" , add);
19
+ RPC.bind (" sub" , sub);
20
+ if (HAL_GetCurrentCPUID () == CM7_CPUID) {
21
+ // Introduce a brief delay to allow the M4 sufficient time
22
+ // to bind remote functions before invoking them.
23
+ delay (100 );
24
+ }
10
25
pinMode (LEDG, OUTPUT);
11
26
}
12
27
13
28
void loop () {
14
29
static size_t loop_count = 0 ;
30
+
15
31
// Blink every 512 iterations
16
- if ((loop_count++ % 512 ) == 0 ) {
32
+ if (HAL_GetCurrentCPUID () == CM4_CPUID && (loop_count++ % 512 ) == 0 ) {
17
33
digitalWrite (LEDG, LOW);
18
34
delay (10 );
19
35
digitalWrite (LEDG, HIGH);
20
36
delay (10 );
21
37
}
38
+
22
39
int res = RPC.call (" add" , 1 , 2 ).as <int >();
23
- RPC.call (" sub" , res, 1 ).as <int >();
40
+ if (HAL_GetCurrentCPUID () == CM7_CPUID) {
41
+ Serial.println (" add(1, 2) = " + String (res));
42
+ }
43
+
44
+ res = RPC.call (" sub" , res, 1 ).as <int >();
45
+ if (HAL_GetCurrentCPUID () == CM7_CPUID) {
46
+ Serial.println (" sub(3, 1) = " + String (res));
47
+ }
24
48
delay (250 );
25
49
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ size_t hash_out_count = 0;
7
7
#ifdef CORE_CM4
8
8
size_t data_buf_size = 0 ;
9
9
#else
10
- size_t data_buf_size = 512 ;
10
+ size_t data_buf_size = 256 ;
11
11
#endif
12
12
13
13
typedef std::vector<byte> vec_t ;
@@ -59,6 +59,8 @@ void setup() {
59
59
#ifdef CORE_CM4
60
60
RPC.bind (" set_buffer_size" , set_buffer_size);
61
61
#else
62
+ // Introduce a brief delay to allow the M4 sufficient time
63
+ // to bind remote functions before invoking them.
62
64
delay (100 );
63
65
auto ret = RPC.call (" set_buffer_size" , data_buf_size).as <size_t >();
64
66
#endif
You can’t perform that action at this time.
0 commit comments