source: rtos_arduino/trunk/examples/Profiling/r2ca_app.cpp@ 260

Last change on this file since 260 was 260, checked in by ertl-honda, 8 years ago

マクロ名を更新.
実行モデルを変更.

File size: 1.8 KB
Line 
1#include "r2ca.h"
2
3void task1_setup();
4
5void setup(){
6 Serial.begin(115200);
7}
8
9void loop(){
10 Serial.print("idle : ");
11 Serial.println(r2ca_idle_result);
12 Serial.print("isr : ");
13 Serial.println(r2ca_isr_result);
14 Serial.print("dispatch : ");
15 Serial.println(r2ca_dispatch_result);
16 delay(1000);
17
18 task1_setup();
19}
20
21#define PSERIAL SerialUSB
22
23bool processing_connected = false;
24
25void establishContact() {
26 while (!PSERIAL.available()) {
27 PSERIAL.print('A'); // send a capital A
28 delay(300);
29 }
30 Serial.println("Processing Task : Connect!");
31 processing_connected = true;
32}
33
34void task1_setup()
35{
36 PSERIAL.begin(115200);
37 while(!PSERIAL){
38 delay(1);
39 }
40 Serial.print("Processing Task : Start!");
41}
42
43int inByte = 0;
44int last_connect = 0;
45
46#define TIMEOUT_MS 3000
47
48void loop1()
49{
50 if(!processing_connected){
51 establishContact();
52 }else{
53 if((millis() - last_connect) > TIMEOUT_MS){
54 processing_connected = false;
55 Serial.println("Processing Task : Disconnect!");
56 }
57 }
58
59 uint16_t load;
60 uint16_t isr_cnt;
61 uint16_t dispatch_cnt;
62
63 load = 100 - map(r2ca_idle_result, 0, IDLE_TASK_IDLE_LOOP_10MS/10, 0, 100);
64 isr_cnt = (r2ca_isr_result > 0xffff)? 0xffff : r2ca_isr_result;
65 dispatch_cnt = (r2ca_dispatch_result > 0xffff)? 0xffff : r2ca_dispatch_result;
66
67 if (PSERIAL.available()){
68 inByte = PSERIAL.read();
69 last_connect = millis();
70
71 PSERIAL.write((uint8_t)(load >> 8));
72 PSERIAL.write((uint8_t)load);
73 PSERIAL.write((uint8_t)(isr_cnt >> 8));
74 PSERIAL.write((uint8_t)isr_cnt);
75 PSERIAL.write((uint8_t)(dispatch_cnt >> 8));
76 PSERIAL.write((uint8_t)dispatch_cnt);
77 }
78 delay(1);
79}
Note: See TracBrowser for help on using the repository browser.