@@ -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
}
0 commit comments