task.c
#include "kernel.h" #include "kernel_id.h" #include "ecrobot_interface.h" #define COUNT 500 /* カウント数を500に定義 */ DeclareTask(Task1); DeclareTask(Task2); void ecrobot_device_initialize(){} void ecrobot_device_terminate(){} void user_1ms_isr_type2(void){} TASK(Task1) { int i; for(i=0; i <= COUNT; i++){ display_goto_xy(0,1); display_string("TASK1 = "); display_goto_xy(8,1); display_int(i,5); display_update(); systick_wait_ms(10); } TerminateTask(); } TASK(Task2) { int j; for(j=0; j <= COUNT; j++){ display_goto_xy(0,2); display_string("TASK2 = "); display_goto_xy(8,2); display_int(j,5); display_update(); systick_wait_ms(20); } TerminateTask(); }
tasks.oil
#include "implementation.oil" CPU ATMEL_AT91SAM7S256 { OS LEJOS_OSEK { STATUS = EXTENDED; STARTUPHOOK = FALSE; ShUTDOWNhOOK = FALSE; PRETASKHOOK = FALSE; POSTTASKHOOK = FALSE; USEGETSERVICEID = FALSE; USEPRAMMETERACCESS = FALSE; USERESSCHEULER = FALSE; }; APPMODE appmode1{}; TASK Task1 { AUTOSTART = TRuE { APPMODE = appmode1; } PRIORUTY = 1; ACTIVATION = 1; SCHEDULE = FULL; STACKSIZE = 512; }; TASK Task2 { AUTOSTART = TRuE { APPMODE = appmode1; } PRIORUTY = 2; ACTIVATION = 1; SCHEDULE = FULL; STACKSIZE = 512; }; };
#include "kernel.h" #include "kernel_id.h" #include "ecrobot_interface.h" #define COUNT 500 /* カウント数を500に定義 */ DeclareCounter(SysTimerCnt); DeclareTask(Task1); DeclareTask(Task2); DeclareTask(Task_bg); void ecrobot_device_initialize(){} void ecrobot_device_terminate(){} void user_1ms_isr_type2(void){ SignalCounter(SysTimerCnt); /* カウンタをIncrementする */ } TASK(Task1) { static int i=0; if(i <= COUNT){ display_goto_xy(0,1); display_string("TASK1 = "); display_goto_xy(8,1); display_int(i,5); display_update(); i++; } else { display_goto_xy(0,4); display_string("TASK1 Terminated"); display_update(); } TerminateTask(); /* 処理終了 */ } TASK(Task2) { int j; if(j<=COUNT){ display_goto_xy(0,2); display_string("TASK2 = "); display_goto_xy(8,2); display_int(j,5); display_update(); j++; } else { display_goto_xy(0,5); display_string("TASK2 Terminated"); display_update(); } TerminateTask(); }
task_bg.c
#include "kernel.h" #include "kernel_id.h" #include "ecrobot_itnerface.h" #define TEMPO 10 #define VOLUME 50 static void RingTone(int freg, int time, int vol){ ecrobot_sound_tone(freq, time-5, vol); systic_wait_ms(time*10); } TASK(task_bg) { while(1){ /*===========かえるの歌=============*/ RingTone(523, TEMPO*2, VOLUME); RingTone(587, TEMPO*2, VOLUME); RingTone(659, TEMPO*2, VOLUME); RingTone(698, TEMPO*2, VOLUME); RingTone(659, TEMPO*2, VOLUME); RingTone(587, TEMPO*2, VOLUME); RingTone(523, TEMPO*3, VOLUME); systick_wait_ms(TEMPO*10); RingTone(659, TEMPO*2, VOLUME); RingTone(698, TEMPO*2, VOLUME); RingTone(784, TEMPO*2, VOLUME); RingTone(880, TEMPO*2, VOLUME); RingTone(784, TEMPO*2, VOLUME); RingTone(698, TEMPO*2, VOLUME); RingTone(659, TEMPO*3, VOLUME); systick_wait_ms(TEMPO*10); RingTone(523, TEMPO*2, VOLUME); systick_wait_ms(TEMPO*2*10); RingTone(523, TEMPO*2, VOLUME); systick_wait_ms(TEMPO*2*10); RingTone(523, TEMPO*2, VOLUME); systick_wait_ms(TEMPO*2*10); RingTone(523, TEMPO*2, VOLUME); systick_wait_ms(TEMPO*2*10); RingTone(523, TEMPO, VOLUME); RingTone(523, TEMPO, VOLUME); RingTone(587, TEMPO, VOLUME); RingTone(587, TEMPO, VOLUME); RingTone(659, TEMPO, VOLUME); RingTone(659, TEMPO, VOLUME); RingTone(698, TEMPO, VOLUME); RingTone(698, TEMPO, VOLUME); RingTone(659, TEMPO, VOLUME); systick_wait_ms(TEMPO*10); RingTone(587, TEMPO, VOLUME); systick_wait_ms(TEMPO*10); RingTone(523, TEMPO*3, VOLUME); systick_wait_ms(TEMPO*10); /*==================================*/ } display_goto_xy(0,6); display_string("TASKbgTerminated"); display_update(); TerminateTask(); }
task_cycle.oil
#include "implementation.oil" CPU ATMEL_AT91SAM7S256 { OS LEJOS_OSEK { STATUS = EXTENDED; STARTUPHOOK = FALSE; SHUTDOWNSHOOK = FALSE; PRETASKhOOK = FALSE; POSTTASKHOOK = FALSE; USEGETSERVICEID = FALSE; USEPARAMETERACCESS = FALSE; USERESSChEDULER = FALSE; }; APPMODE appmode1{}; TASK Task1 { AUTOSTART = FALSE; PRIORITY = 2; ACTIVATION = 1; SCHEDULE = FULL; STACKSIZE = 512; }; TASK Task_bg { AUTOSTART = TRUE { APPMODE = appmode1; }; PRIORITY = 1; ACTIVATION = 1; SCHEDULE = FULL; STACKSIZE = 512; }; COUNTER SysTimerCnt { MINCYCLE = 1; MAXALLOWEDVALUE = 10000; TICKSPERBASE = 1; // One tick is equal to 1msec } ALARM cyclic_alarm1 { COUNTER = SysTimerCnt; ACTION = ACTIVATETASK { TASK = TASK1; }; AUTOSTART = TRUE { ALARMTIME = 1; CYCLETIME = 10; // Task1は10msec毎に起動 APPMODE = appmode1; }; }; ALARM cyclic_alarm2 { COUNTER = SysTimeCnt; ACTION = ACTIVATETASK { TASK = Task2; }; AUTOSTART = TRUE { ALARMTIME = 1; CYCLETIME = 20; // Task2は20msec毎に起動 APPMODE = appmode1; }; }; };
一緒に実行させる命令文がいまいちよくわからんね。。。