52
Application Examples
6
init () _task_ INIT { /* program execution starts here
*/
serial_init (); /* initialize the serial interface
*/
os_create_task (CLOCK); /* start clock task
*/
os_create_task (COMMAND); /* start command task
*/
os_create_task (LIGHTS); /* start lights task
*/
os_create_task (KEYREAD); /* start keyread task
*/
os_delete_task (INIT); /* stop init task (no longer needed)
*/
}
bit display_time = 0; /* flag: signal cmd state display_time
*/
/*****************************************************************************
*/
/* Task 2 'clock'
*/
/*****************************************************************************
*/
clock () _task_ CLOCK {
while (1) { /* clock is an endless loop
*/
if (++ctime.sec == 60) { /* calculate the second
*/
ctime.sec = 0;
if (++ctime.min == 60) { /* calculate the minute
*/
ctime.min = 0;
if (++ctime.hour == 24) { /* calculate the hour
*/
ctime.hour = 0;
}
}
}
if (display_time) { /* if command_status == display_time
*/
os_send_signal (COMMAND); /* signal to task command: time changed
*/
}
os_wait (K_IVL, 100, 0); /* wait interval: 1 second
*/
}
}
struct time rtime; /* temporary storage for entry time
*/
/*****************************************************************************
*/
/* readtime: convert line input to time values & store in rtime
*/
/*****************************************************************************
*/
bit readtime (char idata *buffer) {
Содержание RTX51
Страница 4: ......
Страница 6: ......
Страница 20: ......
Страница 24: ......
Страница 39: ...RTX Tiny 39 4...
Страница 40: ......
Страница 44: ...44 RTX51 Tiny Specifications 5...
Страница 68: ...RTX51 TINY REAL TIME OPERATING SYSTEM User s Guide 2 95...