Changeset 260 for rtos_arduino/trunk/lib
- Timestamp:
- Oct 23, 2016, 8:29:46 PM (8 years ago)
- Location:
- rtos_arduino/trunk/lib
- Files:
-
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
rtos_arduino/trunk/lib/Makefile.r2ca
r224 r260 2 2 # Arduinoã©ã¤ãã©ãªç¨ã®å®ç¾© 3 3 # 4 ARDUINO_LIB_DIR = $(R CA_DIR)/arduino_lib4 ARDUINO_LIB_DIR = $(R2CA_DIR)/arduino_lib 5 5 6 6 # … … 15 15 syscalls.o \ 16 16 17 APPL_CXXOBJS += r ca_lib.o \17 APPL_CXXOBJS += r2ca_lib.o \ 18 18 variant.o \ 19 19 SERCOM.o Uart.o RingBuffer.o Print.o \ … … 30 30 # Ethenet2ã©ã¤ãã©ãª 31 31 # 32 APPL_DIR += $(R CA_DIR)/arduino_lib/libraries/Ethernet2/src/ $(RCA_DIR)/arduino_lib/libraries/Ethernet2/src/utility32 APPL_DIR += $(R2CA_DIR)/arduino_lib/libraries/Ethernet2/src/ $(R2CA_DIR)/arduino_lib/libraries/Ethernet2/src/utility 33 33 APPL_CXXOBJS += Dhcp.o Dns.o Ethernet2.o EthernetClient.o EthernetServer.o EthernetUdp2.o Twitter.o socket.o w5500.o 34 34 APPL_COBJS += … … 40 40 # NCESCANã©ã¤ãã©ãª 41 41 # 42 APPL_DIR += $(R CA_DIR)/arduino_lib/libraries/NcesCan/42 APPL_DIR += $(R2CA_DIR)/arduino_lib/libraries/NcesCan/ 43 43 APPL_CXXOBJS += mcp_can.o 44 44 APPL_COBJS += … … 50 50 # NAxesMotionã©ã¤ãã©ãª 51 51 # 52 APPL_DIR += $(R CA_DIR)/arduino_lib/libraries/NAxesMotion $(RCA_DIR)/arduino_lib/libraries/NAxesMotion/utility52 APPL_DIR += $(R2CA_DIR)/arduino_lib/libraries/NAxesMotion $(R2CA_DIR)/arduino_lib/libraries/NAxesMotion/utility 53 53 APPL_CXXOBJS += NAxisMotion.o 54 54 APPL_COBJS += BNO055.o … … 60 60 # SDã©ã¤ãã©ãª 61 61 # 62 APPL_DIR += $(R CA_DIR)/arduino_lib/libraries/SD/src/ $(RCA_DIR)/arduino_lib/libraries/SD/src/utility62 APPL_DIR += $(R2CA_DIR)/arduino_lib/libraries/SD/src/ $(R2CA_DIR)/arduino_lib/libraries/SD/src/utility 63 63 APPL_CXXOBJS += File.o SD.o Sd2Card.o SdFile.o SdVolume.o 64 64 APPL_COBJS += … … 69 69 # TFTã©ã¤ãã©ãª 70 70 # 71 APPL_DIR += $(R CA_DIR)/arduino_lib/libraries/TFT/src/ $(RCA_DIR)/arduino_lib/libraries/TFT/src/utility71 APPL_DIR += $(R2CA_DIR)/arduino_lib/libraries/TFT/src/ $(R2CA_DIR)/arduino_lib/libraries/TFT/src/utility 72 72 APPL_CXXOBJS += TFT.o Adafruit_GFX.o Adafruit_ST7735.o 73 73 APPL_COBJS += glcdfont.o … … 78 78 # Wireã©ã¤ãã©ãª 79 79 # 80 APPL_DIR += $(R CA_DIR)/arduino_lib/hardware/arduino/samd/libraries/Wire/80 APPL_DIR += $(R2CA_DIR)/arduino_lib/hardware/arduino/samd/libraries/Wire/ 81 81 APPL_CXXOBJS += Wire.o 82 82 APPL_COBJS += … … 87 87 # SPIã©ã¤ãã©ãª 88 88 # 89 APPL_DIR += $(R CA_DIR)/arduino_lib/hardware/arduino/samd/libraries/SPI/89 APPL_DIR += $(R2CA_DIR)/arduino_lib/hardware/arduino/samd/libraries/SPI/ 90 90 APPL_CXXOBJS += SPI.o 91 91 APPL_COBJS += … … 96 96 # RTCã©ã¤ãã©ãª 97 97 # 98 APPL_DIR += $(R CA_DIR)/arduino_lib/libraries/RTC/src/98 APPL_DIR += $(R2CA_DIR)/arduino_lib/libraries/RTC/src/ 99 99 APPL_CXXOBJS += RTCInt.o 100 100 APPL_COBJS += … … 102 102 103 103 104 APPL_DIR += $(R CA_DIR)/lib \104 APPL_DIR += $(R2CA_DIR)/lib \ 105 105 $(ARDUINO_LIB_DIR)/hardware/arduino/samd/cores/arduino/ \ 106 106 $(ARDUINO_LIB_DIR)/hardware/arduino/samd/cores/arduino/avr \ … … 192 192 # ãªãã¸ã§ã¯ããã¡ã¤ã«åã®å®ç¾© 193 193 # 194 OBJNAME = r ca194 OBJNAME = r2ca 195 195 ifdef OBJEXT 196 196 OBJFILE = $(OBJNAME).$(OBJEXT) -
rtos_arduino/trunk/lib/r2ca.h
r136 r260 1 #ifndef _R CA_H_2 #define _R CA_H_1 #ifndef _R2CA_H_ 2 #define _R2CA_H_ 3 3 4 4 #include <kernel.h> … … 6 6 #include <t_stdlib.h> 7 7 8 #include "r ca_lib.h"8 #include "r2ca_lib.h" 9 9 #undef true 10 10 #undef false … … 16 16 17 17 #include "kernel_cfg.h" 18 #include "r ca_app.h"18 #include "r2ca_app.h" 19 19 #endif /* _RCA_H_ */ -
rtos_arduino/trunk/lib/r2ca_lib.cfg
r249 r260 1 #include "r ca_lib.h"1 #include "r2ca_lib.h" 2 2 3 ATT_INI({ TA_NULL, 0, r ca_init });4 CRE_TSK(R CA_MAINTASK, { TA_ACT, 0, rca_maintask, RCA_MAINTASK_SETUP_PRI, RCA_MAINTASK_STACK_SIZE, NULL });3 ATT_INI({ TA_NULL, 0, r2ca_init }); 4 CRE_TSK(R2CA_MAINTASK, { TA_ACT, 0, r2ca_maintask, R2CA_MAINTASK_PRI, R2CA_MAINTASK_STACK_SIZE, NULL }); 5 5 6 //For Setup 7 CRE_SEM(SETUP_SEM, { TA_TPRI, 0, 1 }); 6 #if R2CA_NUM_TASK > 0 7 CRE_TSK(R2CA_TASK1, { TA_ACT, 0, r2ca_task1, R2CA_TASK1_PRI, R2CA_TASK1_STACK_SIZE, NULL }); 8 #endif /* R2CA_NUM_TASK > 0 */ 8 9 9 #if R CA_NUM_TASK > 010 CRE_TSK(R CA_TASK1, { TA_ACT, 0, rca_task1, RCA_TASK1_SETUP_PRI, RCA_TASK1_STACK_SIZE, NULL });11 #endif /* R CA_NUM_TASK > 0*/10 #if R2CA_NUM_TASK > 1 11 CRE_TSK(R2CA_TASK2, { TA_ACT, 0, r2ca_task2, R2CA_TASK2_PRI, R2CA_TASK2_STACK_SIZE, NULL }); 12 #endif /* R2CA_NUM_TASK > 1 */ 12 13 13 #if R CA_NUM_TASK > 114 CRE_TSK(R CA_TASK2, { TA_ACT, 0, rca_task2, RCA_TASK2_SETUP_PRI, RCA_TASK2_STACK_SIZE, NULL });15 #endif /* R CA_NUM_TASK > 1*/14 #if R2CA_NUM_TASK > 2 15 CRE_TSK(R2CA_TASK3, { TA_ACT, 0, r2ca_task3, R2CA_TASK3_PRI, R2CA_TASK3_STACK_SIZE, NULL }); 16 #endif /* R2CA_NUM_TASK > 2 */ 16 17 17 #if R CA_NUM_TASK > 218 CRE_TSK(R CA_TASK3, { TA_ACT, 0, rca_task3, RCA_TASK3_SETUP_PRI, RCA_TASK3_STACK_SIZE, NULL });19 #endif /* R CA_NUM_TASK > 2*/18 #if R2CA_NUM_TASK > 3 19 CRE_TSK(R2CA_TASK4, { TA_ACT, 0, r2ca_task4, R2CA_TASK4_PRI, R2CA_TASK4_STACK_SIZE, NULL }); 20 #endif /* R2CA_NUM_TASK > 3 */ 20 21 21 #if R CA_NUM_TASK > 322 CRE_TSK(R CA_TASK4, { TA_ACT, 0, rca_task4, RCA_TASK4_SETUP_PRI, RCA_TASK4_STACK_SIZE, NULL });23 #endif /* R CA_NUM_TASK > 3*/22 #if R2CA_NUM_TASK > 4 23 CRE_TSK(R2CA_TASK5, { TA_ACT, 0, r2ca_task5, R2CA_TASK5_PRI, R2CA_TASK5_STACK_SIZE, NULL }); 24 #endif /* R2CA_NUM_TASK > 4 */ 24 25 25 #if RCA_NUM_TASK > 4 26 CRE_TSK(RCA_TASK5, { TA_ACT, 0, rca_task5, RCA_TASK5_SETUP_PRI, RCA_TASK5_STACK_SIZE, NULL }); 27 #endif /* RCA_NUM_TASK > 4 */ 28 29 #ifdef RCA_ENABLE_PROFILING 30 CRE_TSK(RCA_IDLE_TASK, { TA_ACT, 0, rca_idle_task, 15, 512, NULL }); 31 #endif /* RCA_ENABLE_PROFILING */ 26 #ifdef R2CA_ENABLE_PROFILING 27 CRE_TSK(R2CA_IDLE_TASK, { TA_ACT, 0, r2ca_idle_task, 15, 512, NULL }); 28 #endif /* R2CA_ENABLE_PROFILING */ 32 29 33 30 //For SysTick 34 CRE_CYC(R CA_CYCHDR, { TA_STA, 0, rca_CycHandler, 1, 1});31 CRE_CYC(R2CA_CYCHDR, { TA_STA, 0, r2ca_CycHandler, 1, 1}); 35 32 36 33 //For USB (ToDo)Naitiveã«å¤æ´ 37 DEF_INH((16+7), { TA_NULL, r ca_USB_Handler });34 DEF_INH((16+7), { TA_NULL, r2ca_USB_Handler }); 38 35 CFG_INT((16+7), { TA_NULL, -1 }); 39 36 40 37 #ifdef TOPPERS_USE_ARDUINO_SERIAL 41 38 //For SERCOM5 42 DEF_INH((16+14), { TA_NULL, r ca_SERCOM5_Handler });39 DEF_INH((16+14), { TA_NULL, r2ca_SERCOM5_Handler }); 43 40 CFG_INT((16+14), { TA_NULL, -1 }); 44 41 #endif /* TOPPERS_USE_ARDUINO_SERIAL */ 45 42 46 43 //For SERCOM0(Serial5) 47 DEF_INH((16+9), { TA_NULL, r ca_SERCOM0_Handler });44 DEF_INH((16+9), { TA_NULL, r2ca_SERCOM0_Handler }); 48 45 CFG_INT((16+9), { TA_NULL, -1 }); 49 46 50 #ifdef R CA_USE_SERIAL347 #ifdef R2CA_USE_SERIAL3 51 48 //For SERCOM2(Serial3) 52 DEF_INH((16+11), { TA_NULL, r ca_SERCOM2_Handler });49 DEF_INH((16+11), { TA_NULL, r2ca_SERCOM2_Handler }); 53 50 CFG_INT((16+11), { TA_NULL, -1 }); 54 #endif /* R CA_USE_SERIAL3 */51 #endif /* R2CA_USE_SERIAL3 */ 55 52 56 53 //For SERCOM3(I2C) 57 DEF_INH((16+12), { TA_NULL, r ca_SERCOM3_Handler });54 DEF_INH((16+12), { TA_NULL, r2ca_SERCOM3_Handler }); 58 55 CFG_INT((16+12), { TA_NULL, -1 }); 59 56 60 57 //For SERCOM4(SPI) 61 DEF_INH((16+13), { TA_NULL, r ca_SERCOM4_Handler });58 DEF_INH((16+13), { TA_NULL, r2ca_SERCOM4_Handler }); 62 59 CFG_INT((16+13), { TA_NULL, -1 }); 63 60 64 61 //For EIC 65 DEF_INH((16+4), { TA_NULL, r ca_EIC_Handler });62 DEF_INH((16+4), { TA_NULL, r2ca_EIC_Handler }); 66 63 CFG_INT((16+4), { TA_NULL, -1 }); 67 64 68 65 //For TC5 69 DEF_INH((16+20), { TA_NULL, r ca_TC5_Handler });66 DEF_INH((16+20), { TA_NULL, r2ca_TC5_Handler }); 70 67 CFG_INT((16+20), { TA_NULL, -1 }); 71 68 72 69 //For RTC 73 DEF_INH((16+3), { TA_NULL, r ca_RTC_Handler });70 DEF_INH((16+3), { TA_NULL, r2ca_RTC_Handler }); 74 71 CFG_INT((16+3), { TA_NULL, -1 }); 75 72 -
rtos_arduino/trunk/lib/r2ca_lib.cpp
r251 r260 1 #include "r ca.h"2 #include "r ca_lib.h"1 #include "r2ca.h" 2 #include "r2ca_lib.h" 3 3 4 4 extern "C" { 5 5 extern void yield(void); 6 extern void r ca_ena_int(uint_t intno);7 extern void r ca_dis_int(uint_t intno);8 } 9 10 #ifdef R CA_ENABLE_PROFILING11 volatile uint32_t r ca_idle_result;12 volatile uint32_t r ca_isr_result;13 volatile uint32_t r ca_dispatch_result;14 volatile uint32_t r ca_timer_isr_result;15 volatile uint32_t r ca_usb_isr_result;16 volatile uint32_t r ca_sercom0_isr_result;17 volatile uint32_t r ca_sercom2_isr_result;18 volatile uint32_t r ca_sercom3_isr_result;19 volatile uint32_t r ca_sercom4_isr_result;20 volatile uint32_t r ca_sercom5_isr_result;21 volatile uint32_t r ca_eic_isr_result;22 volatile uint32_t r ca_tc5_isr_result;23 volatile uint32_t r ca_rtc_isr_result;24 25 static volatile uint32_t r ca_idle_cnt;26 static volatile uint32_t r ca_isr_cnt;27 static volatile uint32_t r ca_dispatch_cnt;28 static volatile uint32_t r ca_timer_isr_cnt;29 static volatile uint32_t r ca_usb_isr_cnt;30 static volatile uint32_t r ca_sercom0_isr_cnt;31 static volatile uint32_t r ca_sercom2_isr_cnt;32 static volatile uint32_t r ca_sercom3_isr_cnt;33 static volatile uint32_t r ca_sercom4_isr_cnt;34 static volatile uint32_t r ca_sercom5_isr_cnt;35 static volatile uint32_t r ca_eic_isr_cnt;36 static volatile uint32_t r ca_tc5_isr_cnt;37 static volatile uint32_t r ca_rtc_isr_cnt;38 static volatile uint32_t r ca_profiling_cyccnt;39 #endif /* R CA_ENABLE_PROFILING */6 extern void r2ca_ena_int(uint_t intno); 7 extern void r2ca_dis_int(uint_t intno); 8 } 9 10 #ifdef R2CA_ENABLE_PROFILING 11 volatile uint32_t r2ca_idle_result; 12 volatile uint32_t r2ca_isr_result; 13 volatile uint32_t r2ca_dispatch_result; 14 volatile uint32_t r2ca_timer_isr_result; 15 volatile uint32_t r2ca_usb_isr_result; 16 volatile uint32_t r2ca_sercom0_isr_result; 17 volatile uint32_t r2ca_sercom2_isr_result; 18 volatile uint32_t r2ca_sercom3_isr_result; 19 volatile uint32_t r2ca_sercom4_isr_result; 20 volatile uint32_t r2ca_sercom5_isr_result; 21 volatile uint32_t r2ca_eic_isr_result; 22 volatile uint32_t r2ca_tc5_isr_result; 23 volatile uint32_t r2ca_rtc_isr_result; 24 25 static volatile uint32_t r2ca_idle_cnt; 26 static volatile uint32_t r2ca_isr_cnt; 27 static volatile uint32_t r2ca_dispatch_cnt; 28 static volatile uint32_t r2ca_timer_isr_cnt; 29 static volatile uint32_t r2ca_usb_isr_cnt; 30 static volatile uint32_t r2ca_sercom0_isr_cnt; 31 static volatile uint32_t r2ca_sercom2_isr_cnt; 32 static volatile uint32_t r2ca_sercom3_isr_cnt; 33 static volatile uint32_t r2ca_sercom4_isr_cnt; 34 static volatile uint32_t r2ca_sercom5_isr_cnt; 35 static volatile uint32_t r2ca_eic_isr_cnt; 36 static volatile uint32_t r2ca_tc5_isr_cnt; 37 static volatile uint32_t r2ca_rtc_isr_cnt; 38 static volatile uint32_t r2ca_profiling_cyccnt; 39 #endif /* R2CA_ENABLE_PROFILING */ 40 40 41 41 Inline void 42 r ca_di(void){42 r2ca_di(void){ 43 43 Asm("cpsid f":::"memory"); 44 44 } … … 48 48 */ 49 49 Inline void 50 r ca_ei(void){50 r2ca_ei(void){ 51 51 Asm("cpsie f":::"memory"); 52 52 } 53 53 54 54 void 55 rca_init(intptr_t exinf) 56 { 57 init(); //wiring.c 58 } 59 60 void 61 rca_ena_int(uint_t intno) { 62 if (ena_int(intno + 16) != E_OK) { 63 while(1); //ToDo 64 } 65 66 } 67 68 void 69 rca_dis_int(uint_t intno) { 70 if (dis_int(intno + 16) != E_OK) { 71 while(1); //ToDo 72 } 55 r2ca_init(intptr_t exinf) 56 { 57 init(); //wiring.c 58 } 59 60 void 61 r2ca_ena_int(uint_t intno) { 62 if (ena_int(intno + 16) != E_OK) { 63 while(1); //ToDo 64 } 65 } 66 67 void 68 r2ca_dis_int(uint_t intno) { 69 if (dis_int(intno + 16) != E_OK) { 70 while(1); //ToDo 71 } 73 72 } 74 73 75 74 extern const DeviceVectors exception_table; 76 75 77 #ifdef RCA_RR_SCHEDULE78 76 static uint32_t time_slice = 0; 79 #endif /* RCA_RR_SCHEDULE */80 77 81 78 /* … … 83 80 */ 84 81 void 85 r ca_CycHandler(intptr_t exinf)82 r2ca_CycHandler(intptr_t exinf) 86 83 { 87 #ifdef RCA_RR_SCHEDULE 88 int i; 89 if (++time_slice == RCA_RR_SCHEDULE_CYCLE) { 90 time_slice = 0; 91 for(i = 1; i < 16; i++){ 92 if (RCA_RR_SCHEDULE & (1 << i)) { 93 irot_rdq(i); 94 } 95 } 96 } 97 #endif /* RCA_RR_SCHEDULE */ 98 #ifdef RCA_ENABLE_PROFILING 99 rca_di(); 100 rca_isr_cnt++; 101 rca_timer_isr_cnt++; 102 rca_profiling_cyccnt++; 103 if(rca_profiling_cyccnt == RCA_PROFILING_CYC_MS){ 104 rca_idle_result= rca_idle_cnt; 105 rca_isr_result= rca_isr_cnt; 106 rca_dispatch_result= rca_dispatch_cnt; 107 rca_timer_isr_result= rca_timer_isr_cnt; 108 rca_usb_isr_result= rca_usb_isr_cnt; 109 rca_sercom0_isr_result= rca_sercom0_isr_cnt; 110 rca_sercom2_isr_result= rca_sercom2_isr_cnt; 111 rca_sercom3_isr_result= rca_sercom3_isr_cnt; 112 rca_sercom4_isr_result= rca_sercom4_isr_cnt; 113 rca_sercom5_isr_result= rca_sercom5_isr_cnt; 114 rca_eic_isr_result= rca_eic_isr_cnt; 115 rca_tc5_isr_result= rca_tc5_isr_cnt; 116 rca_rtc_isr_result= rca_rtc_isr_cnt; 117 rca_idle_cnt = 0; 118 rca_isr_cnt = 0; 119 rca_dispatch_cnt = 0; 120 rca_timer_isr_cnt = 0; 121 rca_usb_isr_cnt = 0; 122 rca_sercom0_isr_cnt = 0; 123 rca_sercom2_isr_cnt = 0; 124 rca_sercom3_isr_cnt = 0; 125 rca_sercom4_isr_cnt = 0; 126 rca_sercom5_isr_cnt = 0; 127 rca_eic_isr_cnt = 0; 128 rca_tc5_isr_cnt = 0; 129 rca_rtc_isr_cnt = 0; 130 rca_profiling_cyccnt = 0; 131 } 132 rca_ei(); 133 #endif /* RCA_ENABLE_PROFILING */ 134 ((void(*)(void))(exception_table.pfnSysTick_Handler))(); 84 int i; 85 if (++time_slice == R2CA_RR_SCHEDULE_CYCLE) { 86 time_slice = 0; 87 for(i = 1; i < 16; i++){ 88 if (R2CA_RR_SCHEDULE_PRI & (1 << i)) { 89 irot_rdq(i); 90 } 91 } 92 } 93 #ifdef R2CA_ENABLE_PROFILING 94 r2ca_di(); 95 r2ca_isr_cnt++; 96 r2ca_timer_isr_cnt++; 97 r2ca_profiling_cyccnt++; 98 if(r2ca_profiling_cyccnt == R2CA_PROFILING_CYC_MS){ 99 r2ca_idle_result= r2ca_idle_cnt; 100 r2ca_isr_result= r2ca_isr_cnt; 101 r2ca_dispatch_result= r2ca_dispatch_cnt; 102 r2ca_timer_isr_result= r2ca_timer_isr_cnt; 103 r2ca_usb_isr_result= r2ca_usb_isr_cnt; 104 r2ca_sercom0_isr_result= r2ca_sercom0_isr_cnt; 105 r2ca_sercom2_isr_result= r2ca_sercom2_isr_cnt; 106 r2ca_sercom3_isr_result= r2ca_sercom3_isr_cnt; 107 r2ca_sercom4_isr_result= r2ca_sercom4_isr_cnt; 108 r2ca_sercom5_isr_result= r2ca_sercom5_isr_cnt; 109 r2ca_eic_isr_result= r2ca_eic_isr_cnt; 110 r2ca_tc5_isr_result= r2ca_tc5_isr_cnt; 111 r2ca_rtc_isr_result= r2ca_rtc_isr_cnt; 112 r2ca_idle_cnt = 0; 113 r2ca_isr_cnt = 0; 114 r2ca_dispatch_cnt = 0; 115 r2ca_timer_isr_cnt = 0; 116 r2ca_usb_isr_cnt = 0; 117 r2ca_sercom0_isr_cnt = 0; 118 r2ca_sercom2_isr_cnt = 0; 119 r2ca_sercom3_isr_cnt = 0; 120 r2ca_sercom4_isr_cnt = 0; 121 r2ca_sercom5_isr_cnt = 0; 122 r2ca_eic_isr_cnt = 0; 123 r2ca_tc5_isr_cnt = 0; 124 r2ca_rtc_isr_cnt = 0; 125 r2ca_profiling_cyccnt = 0; 126 } 127 r2ca_ei(); 128 #endif /* R2CA_ENABLE_PROFILING */ 129 ((void(*)(void))(exception_table.pfnSysTick_Handler))(); 135 130 } 136 131 … … 139 134 */ 140 135 void 141 r ca_USB_Handler(void)142 { 143 #ifdef R CA_ENABLE_PROFILING144 rca_di();145 rca_usb_isr_cnt++;146 rca_isr_cnt++;147 rca_ei();148 #endif /* R CA_ENABLE_PROFILING */149 150 } 151 152 void 153 r ca_SERCOM0_Handler(void)154 { 155 #ifdef R CA_ENABLE_PROFILING156 rca_di();157 rca_sercom0_isr_cnt++;158 rca_isr_cnt++;159 rca_ei();160 #endif /* R CA_ENABLE_PROFILING */161 162 } 163 164 #ifdef R CA_USE_SERIAL3136 r2ca_USB_Handler(void) 137 { 138 #ifdef R2CA_ENABLE_PROFILING 139 r2ca_di(); 140 r2ca_usb_isr_cnt++; 141 r2ca_isr_cnt++; 142 r2ca_ei(); 143 #endif /* R2CA_ENABLE_PROFILING */ 144 ((void(*)(void))(exception_table.pfnUSB_Handler))(); 145 } 146 147 void 148 r2ca_SERCOM0_Handler(void) 149 { 150 #ifdef R2CA_ENABLE_PROFILING 151 r2ca_di(); 152 r2ca_sercom0_isr_cnt++; 153 r2ca_isr_cnt++; 154 r2ca_ei(); 155 #endif /* R2CA_ENABLE_PROFILING */ 156 ((void(*)(void))(exception_table.pfnSERCOM0_Handler))(); 157 } 158 159 #ifdef R2CA_USE_SERIAL3 165 160 #define PIN_SERIAL3_RX 49 /* D5 */ 166 161 #define PIN_SERIAL3_TX 48 /* D4 */ … … 169 164 170 165 void 171 r ca_SERCOM2_Handler(void)172 { 173 #ifdef R CA_ENABLE_PROFILING174 rca_di();175 rca_sercom2_isr_cnt++;176 rca_isr_cnt++;177 rca_ei();178 #endif /* R CA_ENABLE_PROFILING */179 180 } 181 #endif /* R CA_USE_SERIAL3 */182 183 void 184 r ca_SERCOM3_Handler(void)185 { 186 #ifdef R CA_ENABLE_PROFILING187 rca_di();188 rca_sercom3_isr_cnt++;189 rca_isr_cnt++;190 rca_ei();191 #endif /* R CA_ENABLE_PROFILING */192 193 } 194 195 void 196 r ca_SERCOM4_Handler(void)197 { 198 #ifdef R CA_ENABLE_PROFILING199 rca_di();200 rca_sercom4_isr_cnt++;201 rca_isr_cnt++;202 rca_ei();203 #endif /* R CA_ENABLE_PROFILING */204 166 r2ca_SERCOM2_Handler(void) 167 { 168 #ifdef R2CA_ENABLE_PROFILING 169 r2ca_di(); 170 r2ca_sercom2_isr_cnt++; 171 r2ca_isr_cnt++; 172 r2ca_ei(); 173 #endif /* R2CA_ENABLE_PROFILING */ 174 Serial3.IrqHandler(); 175 } 176 #endif /* R2CA_USE_SERIAL3 */ 177 178 void 179 r2ca_SERCOM3_Handler(void) 180 { 181 #ifdef R2CA_ENABLE_PROFILING 182 r2ca_di(); 183 r2ca_sercom3_isr_cnt++; 184 r2ca_isr_cnt++; 185 r2ca_ei(); 186 #endif /* R2CA_ENABLE_PROFILING */ 187 ((void(*)(void))(exception_table.pfnSERCOM3_Handler))(); 188 } 189 190 void 191 r2ca_SERCOM4_Handler(void) 192 { 193 #ifdef R2CA_ENABLE_PROFILING 194 r2ca_di(); 195 r2ca_sercom4_isr_cnt++; 196 r2ca_isr_cnt++; 197 r2ca_ei(); 198 #endif /* R2CA_ENABLE_PROFILING */ 199 ((void(*)(void))(exception_table.pfnSERCOM4_Handler))(); 205 200 } 206 201 207 202 #ifdef TOPPERS_USE_ARDUINO_SERIAL 208 203 void 209 r ca_SERCOM5_Handler(void)210 { 211 #ifdef R CA_ENABLE_PROFILING212 rca_di();213 rca_sercom5_isr_cnt++;214 rca_isr_cnt++;215 rca_ei();216 #endif /* R CA_ENABLE_PROFILING */217 204 r2ca_SERCOM5_Handler(void) 205 { 206 #ifdef R2CA_ENABLE_PROFILING 207 r2ca_di(); 208 r2ca_sercom5_isr_cnt++; 209 r2ca_isr_cnt++; 210 r2ca_ei(); 211 #endif /* R2CA_ENABLE_PROFILING */ 212 ((void(*)(void))(exception_table.pfnSERCOM5_Handler))(); 218 213 } 219 214 #endif /* TOPPERS_USE_ARDUINO_SERIAL */ 220 215 221 216 void 222 r ca_EIC_Handler(void)223 { 224 #ifdef R CA_ENABLE_PROFILING225 rca_di();226 rca_eic_isr_cnt++;227 rca_isr_cnt++;228 rca_ei();229 #endif /* R CA_ENABLE_PROFILING */230 231 } 232 233 void 234 r ca_TC5_Handler(void)235 { 236 #ifdef R CA_ENABLE_PROFILING237 rca_di();238 rca_tc5_isr_cnt++;239 rca_isr_cnt++;240 rca_ei();241 #endif /* R CA_ENABLE_PROFILING */242 243 } 244 245 void 246 r ca_RTC_Handler(void)247 { 248 #ifdef R CA_ENABLE_PROFILING249 rca_di();250 rca_rtc_isr_cnt++;251 rca_isr_cnt++;252 rca_ei();253 #endif /* R CA_ENABLE_PROFILING */254 217 r2ca_EIC_Handler(void) 218 { 219 #ifdef R2CA_ENABLE_PROFILING 220 r2ca_di(); 221 r2ca_eic_isr_cnt++; 222 r2ca_isr_cnt++; 223 r2ca_ei(); 224 #endif /* R2CA_ENABLE_PROFILING */ 225 ((void(*)(void))(exception_table.pfnEIC_Handler))(); 226 } 227 228 void 229 r2ca_TC5_Handler(void) 230 { 231 #ifdef R2CA_ENABLE_PROFILING 232 r2ca_di(); 233 r2ca_tc5_isr_cnt++; 234 r2ca_isr_cnt++; 235 r2ca_ei(); 236 #endif /* R2CA_ENABLE_PROFILING */ 237 ((void(*)(void))(exception_table.pfnTC5_Handler))(); 238 } 239 240 void 241 r2ca_RTC_Handler(void) 242 { 243 #ifdef R2CA_ENABLE_PROFILING 244 r2ca_di(); 245 r2ca_rtc_isr_cnt++; 246 r2ca_isr_cnt++; 247 r2ca_ei(); 248 #endif /* R2CA_ENABLE_PROFILING */ 249 ((void(*)(void))(exception_table.pfnRTC_Handler))(); 255 250 } 256 251 … … 260 255 void 261 256 yield(void){ 262 #ifdef RCA_RR_SCHEDULE 263 time_slice = 0; 264 #endif /* RCA_RR_SCHEDULE */ 265 #ifdef RCA_ENABLE_PROFILING 266 rca_di(); 267 rca_dispatch_cnt++; 268 rca_ei(); 269 #endif /* RCA_ENABLE_PROFILING */ 270 dly_tsk(0); 257 time_slice = 0; 258 #ifdef R2CA_ENABLE_PROFILING 259 r2ca_di(); 260 r2ca_dispatch_cnt++; 261 r2ca_ei(); 262 #endif /* R2CA_ENABLE_PROFILING */ 263 dly_tsk(0); 271 264 } 272 265 … … 274 267 extern void loop(void); 275 268 276 void 277 rca_maintask(intptr_t exinf) 278 { 279 syslog(LOG_NOTICE, "Arduino Main Task start!"); 280 dly_tsk(1); 269 270 const ID task_id[] = { 271 #if R2CA_NUM_TASK > 0 272 R2CA_TASK1, 273 #endif /* R2CA_NUM_TASK > 0 */ 274 #if R2CA_NUM_TASK > 1 275 R2CA_TASK2, 276 #endif /* R2CA_NUM_TASK > 1 */ 277 #if R2CA_NUM_TASK > 2 278 R2CA_TASK3, 279 #endif /* R2CA_NUM_TASK > 2 */ 280 #if R2CA_NUM_TASK > 3 281 R2CA_TASK4, 282 #endif /* R2CA_NUM_TASK > 3 */ 283 #if R2CA_NUM_TASK > 4 284 R2CA_TASK5, 285 #endif /* R2CA_NUM_TASK > 4 */ 286 }; 287 288 void 289 r2ca_maintask(intptr_t exinf) 290 { 291 int i; 292 293 syslog(LOG_NOTICE, "Arduino Main Task start!"); 294 281 295 #ifdef USBCON 282 283 296 USBDevice.init(); 297 USBDevice.attach(); 284 298 #endif /* USBCON */ 285 299 286 300 analogReference(AR_DEFAULT); 287 301 288 302 setup(); 289 303 290 sig_sem(SETUP_SEM); 304 for(i = 0; i < R2CA_NUM_TASK; i++) { 305 act_tsk(task_id[i]); 306 } 291 307 292 chg_pri(0, RCA_MAINTASK_LOOP_PRI); 293 294 while(1){ 295 loop(); 296 if (serialEventRun) serialEventRun(); 297 } 298 } 299 300 #define RCA_TASK_BODY(NUM) \ 301 extern void task##NUM##_setup(void); \ 302 extern void task##NUM##_loop(void); \ 308 while(1){ 309 loop(); 310 if (serialEventRun) serialEventRun(); 311 } 312 } 313 314 #define R2CA_TASK_BODY(NUM) \ 315 extern void loop##NUM(void); \ 303 316 \ 304 317 void \ 305 r ca_task##NUM(intptr_t exinf) \318 r2ca_task##NUM(intptr_t exinf) \ 306 319 { \ 307 wai_sem(SETUP_SEM);\308 task##NUM##_setup(); \309 sig_sem(SETUP_SEM);\310 chg_pri(0, RCA_TASK##NUM##_LOOP_PRI); \311 \312 320 while(1){ \ 313 task##NUM##_loop(); \321 loop##NUM(); \ 314 322 } \ 315 323 } 316 324 317 #if R CA_NUM_TASK > 0318 R CA_TASK_BODY(1)319 #endif /* R CA_NUM_TASK > 0 */320 321 #if R CA_NUM_TASK > 1322 R CA_TASK_BODY(2)323 #endif /* R CA_NUM_TASK > 1 */324 325 #if R CA_NUM_TASK > 2326 R CA_TASK_BODY(3)327 #endif /* R CA_NUM_TASK > 2 */328 329 #if R CA_NUM_TASK > 3330 R CA_TASK_BODY(4)331 #endif /* R CA_NUM_TASK > 3 */332 333 #if R CA_NUM_TASK > 4334 R CA_TASK_BODY(5)335 #endif /* R CA_NUM_TASK > 4 */336 337 #ifdef R CA_ENABLE_PROFILING338 void 339 r ca_idle_task(intptr_t exinf) {340 341 rca_di();342 rca_idle_cnt++;343 rca_ei();344 345 } 346 #endif /* R CA_ENABLE_PROFILING */325 #if R2CA_NUM_TASK > 0 326 R2CA_TASK_BODY(1) 327 #endif /* R2CA_NUM_TASK > 0 */ 328 329 #if R2CA_NUM_TASK > 1 330 R2CA_TASK_BODY(2) 331 #endif /* R2CA_NUM_TASK > 1 */ 332 333 #if R2CA_NUM_TASK > 2 334 R2CA_TASK_BODY(3) 335 #endif /* R2CA_NUM_TASK > 2 */ 336 337 #if R2CA_NUM_TASK > 3 338 R2CA_TASK_BODY(4) 339 #endif /* R2CA_NUM_TASK > 3 */ 340 341 #if R2CA_NUM_TASK > 4 342 R2CA_TASK_BODY(5) 343 #endif /* R2CA_NUM_TASK > 4 */ 344 345 #ifdef R2CA_ENABLE_PROFILING 346 void 347 r2ca_idle_task(intptr_t exinf) { 348 while(1){ 349 r2ca_di(); 350 r2ca_idle_cnt++; 351 r2ca_ei(); 352 } 353 } 354 #endif /* R2CA_ENABLE_PROFILING */ -
rtos_arduino/trunk/lib/r2ca_lib.h
r238 r260 1 #include "r ca_app.h"1 #include "r2ca_app.h" 2 2 3 3 /* 4 4 * Max number of task 5 5 */ 6 #define R CA_NUM_TASK_MAX 56 #define R2CA_NUM_TASK_MAX 5 7 7 8 8 /* 9 9 * Check number of task 10 10 */ 11 #if R CA_NUM_TASK > RCA_NUM_TASK_MAX11 #if R2CA_NUM_TASK > R2CA_NUM_TASK_MAX 12 12 #error The number of Task is over! 13 #endif /* R CA_NUM_TASK > RCA_NUM_TASK_MAX */13 #endif /* R2CA_NUM_TASK > R2CA_NUM_TASK_MAX */ 14 14 15 15 /* … … 25 25 * Priotiry 26 26 */ 27 #ifndef R CA_MAINTASK_SETUP_PRI28 #define R CA_MAINTASK_SETUP_PRI 529 #endif /* R CA_MAINTASK_SETUP_PRI */27 #ifndef R2CA_MAINTASK_PRI 28 #define R2CA_MAINTASK_PRI 5 29 #endif /* R2CA_MAINTASK_SETUP_PRI */ 30 30 31 #ifndef R CA_MAINTASK_LOOP_PRI32 #define R CA_MAINTASK_LOOP_PRI 533 #endif /* R CA_MAINTASK_SETUP_PRI */31 #ifndef R2CA_TASK1_PRI 32 #define R2CA_TASK1_PRI 5 33 #endif /* R2CA_TASK1_SETUP_PRI */ 34 34 35 #ifndef R CA_TASK1_SETUP_PRI36 #define R CA_TASK1_SETUP_PRI 537 #endif /* R CA_TASK1_SETUP_PRI */35 #ifndef R2CA_TASK2_PRI 36 #define R2CA_TASK2_PRI 5 37 #endif /* R2CA_TASK2_SETUP_PRI */ 38 38 39 #ifndef R CA_TASK1_LOOP_PRI40 #define R CA_TASK1_LOOP_PRI 541 #endif /* R CA_TASK1_SETUP_PRI */39 #ifndef R2CA_TASK3_PRI 40 #define R2CA_TASK3_PRI 5 41 #endif /* R2CA_TASK3_SETUP_PRI */ 42 42 43 #ifndef R CA_TASK2_SETUP_PRI44 #define R CA_TASK2_SETUP_PRI 545 #endif /* R CA_TASK2_SETUP_PRI */43 #ifndef R2CA_TASK4_PRI 44 #define R2CA_TASK4_PRI 5 45 #endif /* R2CA_TASK4_SETUP_PRI */ 46 46 47 #ifndef RCA_TASK2_LOOP_PRI 48 #define RCA_TASK2_LOOP_PRI 5 49 #endif /* RCA_TASK2_SETUP_PRI */ 50 51 #ifndef RCA_TASK3_SETUP_PRI 52 #define RCA_TASK3_SETUP_PRI 5 53 #endif /* RCA_TASK3_SETUP_PRI */ 54 55 #ifndef RCA_TASK3_LOOP_PRI 56 #define RCA_TASK3_LOOP_PRI 5 57 #endif /* RCA_TASK3_SETUP_PRI */ 58 59 #ifndef RCA_TASK4_SETUP_PRI 60 #define RCA_TASK4_SETUP_PRI 5 61 #endif /* RCA_TASK4_SETUP_PRI */ 62 63 #ifndef RCA_TASK4_LOOP_PRI 64 #define RCA_TASK4_LOOP_PRI 5 65 #endif /* RCA_TASK4_SETUP_PRI */ 66 67 #ifndef RCA_TASK5_SETUP_PRI 68 #define RCA_TASK5_SETUP_PRI 5 69 #endif /* RCA_TASK5_SETUP_PRI */ 70 71 #ifndef RCA_TASK5_LOOP_PRI 72 #define RCA_TASK5_LOOP_PRI 5 73 #endif /* RCA_TASK3_SETUP_PRI */ 47 #ifndef R2CA_TASK5_PRI 48 #define R2CA_TASK5_PRI 5 49 #endif /* R2CA_TASK3_SETUP_PRI */ 74 50 75 51 /* 76 52 * Stack Size 77 53 */ 78 #ifndef R CA_MAINTASK_STACK_SIZE79 #define R CA_MAINTASK_STACK_SIZE 204880 #endif /* R CA_MAINTASK_STACK_SIZE */54 #ifndef R2CA_MAINTASK_STACK_SIZE 55 #define R2CA_MAINTASK_STACK_SIZE 2048 56 #endif /* R2CA_MAINTASK_STACK_SIZE */ 81 57 82 #ifndef R CA_TASK1_STACK_SIZE83 #define R CA_TASK1_STACK_SIZE 102484 #endif /* R CA_TASK1_STACK_SIZE */58 #ifndef R2CA_TASK1_STACK_SIZE 59 #define R2CA_TASK1_STACK_SIZE 1024 60 #endif /* R2CA_TASK1_STACK_SIZE */ 85 61 86 #ifndef R CA_TASK2_STACK_SIZE87 #define R CA_TASK2_STACK_SIZE 102488 #endif /* R CA_TASK2_STACK_SIZE */62 #ifndef R2CA_TASK2_STACK_SIZE 63 #define R2CA_TASK2_STACK_SIZE 1024 64 #endif /* R2CA_TASK2_STACK_SIZE */ 89 65 90 #ifndef R CA_TASK3_STACK_SIZE91 #define R CA_TASK3_STACK_SIZE 102492 #endif /* R CA_TASK3_STACK_SIZE */66 #ifndef R2CA_TASK3_STACK_SIZE 67 #define R2CA_TASK3_STACK_SIZE 1024 68 #endif /* R2CA_TASK3_STACK_SIZE */ 93 69 94 #ifndef R CA_TASK4_STACK_SIZE95 #define R CA_TASK4_STACK_SIZE 102496 #endif /* R CA_TASK4_STACK_SIZE */70 #ifndef R2CA_TASK4_STACK_SIZE 71 #define R2CA_TASK4_STACK_SIZE 1024 72 #endif /* R2CA_TASK4_STACK_SIZE */ 97 73 98 #ifndef R CA_TASK5_STACK_SIZE99 #define R CA_TASK5_STACK_SIZE 1024100 #endif /* R CA_TASK5_STACK_SIZE */74 #ifndef R2CA_TASK5_STACK_SIZE 75 #define R2CA_TASK5_STACK_SIZE 1024 76 #endif /* R2CA_TASK5_STACK_SIZE */ 101 77 102 78 … … 104 80 * Round Robin Scheduling cycle 105 81 */ 106 #ifndef RCA_RR_SCHEDULE_CYCLE 107 #define RCA_RR_SCHEDULE_CYCLE 1 108 #endif /* RCA_RR_SCHEDULE_CYCLE */ 82 #ifndef R2CA_RR_SCHEDULE_CYCLE 83 #define R2CA_RR_SCHEDULE_CYCLE 1 84 #endif /* R2CA_RR_SCHEDULE_CYCLE */ 85 86 #ifndef R2CA_RR_SCHEDULE_PRI 87 #define R2CA_RR_SCHEDULE_PRI 0x0000 88 #endif /* R2CA_RR_SCHEDULE_PRI */ 109 89 110 90 #ifdef __cplusplus … … 112 92 #endif 113 93 114 extern void r ca_init(intptr_t exinf);115 extern void r ca_maintask(intptr_t exinf);116 extern void r ca_task1(intptr_t exinf);117 extern void r ca_task2(intptr_t exinf);118 extern void r ca_task3(intptr_t exinf);119 extern void r ca_task4(intptr_t exinf);120 extern void r ca_task5(intptr_t exinf);121 extern void r ca_CycHandler(intptr_t exinf);94 extern void r2ca_init(intptr_t exinf); 95 extern void r2ca_maintask(intptr_t exinf); 96 extern void r2ca_task1(intptr_t exinf); 97 extern void r2ca_task2(intptr_t exinf); 98 extern void r2ca_task3(intptr_t exinf); 99 extern void r2ca_task4(intptr_t exinf); 100 extern void r2ca_task5(intptr_t exinf); 101 extern void r2ca_CycHandler(intptr_t exinf); 122 102 123 extern void r ca_USB_Handler(void);124 extern void r ca_SERCOM0_Handler(void);125 extern void r ca_SERCOM2_Handler(void);126 extern void r ca_SERCOM3_Handler(void);127 extern void r ca_SERCOM4_Handler(void);128 extern void r ca_SERCOM5_Handler(void);129 extern void r ca_EIC_Handler(void);130 extern void r ca_TC5_Handler(void);131 extern void r ca_RTC_Handler(void);103 extern void r2ca_USB_Handler(void); 104 extern void r2ca_SERCOM0_Handler(void); 105 extern void r2ca_SERCOM2_Handler(void); 106 extern void r2ca_SERCOM3_Handler(void); 107 extern void r2ca_SERCOM4_Handler(void); 108 extern void r2ca_SERCOM5_Handler(void); 109 extern void r2ca_EIC_Handler(void); 110 extern void r2ca_TC5_Handler(void); 111 extern void r2ca_RTC_Handler(void); 132 112 133 #ifdef R CA_ENABLE_PROFILING134 extern void r ca_idle_task(intptr_t exinf);135 extern volatile uint32_t r ca_idle_result;136 extern volatile uint32_t r ca_isr_result;137 extern volatile uint32_t r ca_dispatch_result;138 extern volatile uint32_t r ca_timer_isr_result;139 extern volatile uint32_t r ca_usb_isr_result;140 extern volatile uint32_t r ca_sercom0_isr_result;141 extern volatile uint32_t r ca_sercom4_isr_result;142 extern volatile uint32_t r ca_sercom5_isr_result;143 extern volatile uint32_t r ca_eic_isr_result;144 extern volatile uint32_t r ca_tc5_isr_result;145 extern volatile uint32_t r ca_rtc_isr_result;113 #ifdef R2CA_ENABLE_PROFILING 114 extern void r2ca_idle_task(intptr_t exinf); 115 extern volatile uint32_t r2ca_idle_result; 116 extern volatile uint32_t r2ca_isr_result; 117 extern volatile uint32_t r2ca_dispatch_result; 118 extern volatile uint32_t r2ca_timer_isr_result; 119 extern volatile uint32_t r2ca_usb_isr_result; 120 extern volatile uint32_t r2ca_sercom0_isr_result; 121 extern volatile uint32_t r2ca_sercom4_isr_result; 122 extern volatile uint32_t r2ca_sercom5_isr_result; 123 extern volatile uint32_t r2ca_eic_isr_result; 124 extern volatile uint32_t r2ca_tc5_isr_result; 125 extern volatile uint32_t r2ca_rtc_isr_result; 146 126 147 #ifdef R CA_USE_SERIAL3148 extern volatile uint32_t r ca_sercom3_isr_result;149 #endif /* R CA_USE_SERIAL3 */127 #ifdef R2CA_USE_SERIAL3 128 extern volatile uint32_t r2ca_sercom3_isr_result; 129 #endif /* R2CA_USE_SERIAL3 */ 150 130 151 #endif /* R CA_ENABLE_PROFILING */131 #endif /* R2CA_ENABLE_PROFILING */ 152 132 153 133 #define WIRE_ENTER_CRITICAL wai_sem(WIRE_SEM);
Note:
See TracChangeset
for help on using the changeset viewer.