Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

#define PI

#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/rr.h"

#ifndef PI
#include "modules/rrsoft.h"
#endif

#include "modules/dummy.h"

#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
#include "modules/pi.h"
#include "modules/pc.h"
#include "modules/srp.h"
#include "modules/npp.h"
#include "modules/nop.h"

#include "drivers/keyb.h"
#include "drivers/glib.h"

/*+ system tick in us +*/
#define TICK 1000

/*+ RR tick in us +*/
#define RRTICK 10000
//#define RRTICK 3000

TIME __kernel_register_levels__(void *arg)
{
  struct multiboot_info *mb = (struct multiboot_info *)arg;

#ifdef PI
  EDF_register_level(EDF_ENABLE_WCET_CHECK);
  CBS_register_level(0,0); //CBS_ENABLE_ALL, 0);
#else
  RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT);
  RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs
#endif

  RR_register_level(RRTICK, RR_MAIN_YES, mb);
  dummy_register_level();


  SEM_register_module();

  CABS_register_module();

  PI_register_module();
  NOP_register_module();

  return TICK;
}

TASK __init__(void *arg)
{
  struct multiboot_info *mb = (struct multiboot_info *)arg;

  HARTPORT_init();
  
  kern_printf("TIME=%d\n",sys_gettime(NULL));
  KEYB_init(NULL);
  kern_printf("TIME=%d\n",sys_gettime(NULL));
  grx_init();
  __call_main__(mb);

  return (void *)0;
}


#ifdef PI
void app_mutex_init(mutex_t *m)
{
  PI_mutexattr_t attr;

  PI_mutexattr_default(attr);

  mutex_init(m, &attr);
}
#else
void app_mutex_init(mutex_t *m)
{
  NOP_mutexattr_t attr;

  NOP_mutexattr_default(attr);

  mutex_init(m, &attr);
}
#endif

E_WCET_CHECK);
  CBS_register_level(0,0); //CBS_ENABLE_ALL, 0);
#else
  RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT);
  RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs
#endif

  RR_register_level(RRTICK, RR_MAIN_YES, mb
  B cab1, cab2;
extern struct Parametri prm;

void app_mutex_init(mutex_t *);

int da_motor(float v);
float v2x(float v);
float v2theta(float v);
float bass1(float u);
float bass2(float u);
float bass3(float u);
float bass4(float u);
float  dx(float u);
float  dth(float u);








/* scenario */
#define SCENARIO_NLABEL 16


/*
 * Global Stuffs 
 */

/* graphic mutex... */
extern mutex_t mutex;

/* useful colors... */
int white;
int black;
int red;
int gray;
int green;
int blue;

void init_jetcontrol();

void init_framegrabber();

/*
 *
 * JETCONTROL stuffs
 *
 */

#define JET_NTASK   13
#define JET_Y_NAME  480  //500

#define DUMMY_PID    1

#define JET_DUMMY_WIDTH    210
#define JET_DUMMY_HEIGHT    40

/* the point (x, y) is the top left corner */
#define JET_DUMMY_X        60
#define JET_DUMMY_Y        514

#define JET_SLIDE_WIDTH     50
#define JET_SLIDE_X        (384+200)


/*
 *
 * FRAMEGRABBER stuffs
 *
 */

// if defined... object black on a white background
#ifndef __BLACK_ON_WHITE
#define __BLACK_ON_WHITE
#endif

#define ABS_NUM(a) ((a >= 0) ? a : -a)
#define MIN_NUM(a, b) ((a < b) ? a : b)
#define MAX_NUM(a, b) ((a > b) ? a : b)


// Cols and rows  of the framegrabber image
#define N_COL     384 //   384
#define N_ROW        288
#define N_BPS        8   // Bits per pixel
#define N_GRIGI     256

#define N_FRAMES    20 //  100

/* pixel of the video image */
#define IMG_COL 230    //  230 //256
#define IMG_ROW 160   // 160 //192

/* position of the video image */
#define IMG_X   500  //   644  // 384
#define IMG_Y   32   // 200     // 32

// I singoli pixel sono caratteri a 8 bit
typedef unsigned char TPixel;

typedef struct {
  int x1, y1;
  int x2, y2;
  int xb, yb;
  TIME time_stamp;
} TDataObj;

typedef struct {
  int found;
  int top_frame;
  int vx,vy;
  int predx;
  int predy;
  TDataObj current;
} TTracking;


float distance(unsigned int x1, unsigned int y1,
               unsigned int x2, unsigned int y2);

char scan_all_frame(TDataObj *data, TPixel *in_frame);

char scan_window_frame(TDataObj *data, TPixel *in_frame,  \
                unsigned int xc, unsigned int yc, int border, int border_y);
void threshold_up_function(KEY_EVT key);
void threshold_down_function(KEY_EVT key);
void border_up_function(KEY_EVT key);
void border_down_function(KEY_EVT key);
void tracking(int top_frame, int *track_x, int *track_y, int *int_vx, int *int_vy, int time_to);
TASK elab_image_TASK(void);