Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1382 → Rev 1377

/demos/trunk/base/fly.c
18,11 → 18,11
 
/**
------------
CVS : $Id: fly.c,v 1.5 2004-04-18 19:46:29 giacomo Exp $
CVS : $Id: fly.c,v 1.4 2004-04-17 11:36:13 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.5 $
Last update: $Date: 2004-04-18 19:46:29 $
Revision: $Revision: 1.4 $
Last update: $Date: 2004-04-17 11:36:13 $
------------
**/
 
53,8 → 53,11
#include <stdlib.h>
#include <math.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_fb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
76,6 → 79,72
int fly_wcet = 1000; /* task wcet */
PID pid;
 
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
FB26_init();
FB26_open(FRAME_BUFFER_DEVICE);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
return 0;
}
 
int device_drivers_close() {
 
FB26_close(FRAME_BUFFER_DEVICE);
 
KEYB26_close();
 
INPUT26_close();
 
return 0;
 
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_end();
 
return NULL;
 
}
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
/*--------------------------------------------------------------*/
 
void draw_fly(int x, int y, int c)
151,6 → 220,10
int i = 0; /* number of tasks created */
TIME seme; /* used to init the random seed */
 
set_shutdown_task();
 
device_drivers_init();
 
/* The scenario */
grx_rect(XMIN-D-1, YMIN-D-1, XMAX+D+1, YMAX+D+1, 14);
grx_text("Simulation of Random Flies", XMIN, YMENU+10, 13, 0);
176,7 → 249,7
pid = task_create("fly", fly, &m, NULL);
if (pid == NIL) {
sys_shutdown_message("Could not create task <fly>");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
task_activate(pid);
186,7 → 259,7
 
} while (c != ESC);
 
sys_end();
task_activate(shutdown_task_PID);
 
return 0;