source: rtos_arduino/trunk/examples/Profiling/rca_app.cpp@ 137

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

サンプルの追加.

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