/* public functions ========================================================= */ int speed_init(void) { if (running) { goto err_running; } if ((ostream = fopen("speed", "w")) == NULL) { goto err_ostream; } rt_intr_create(&intr, NULL, 81, 0); rt_intr_enable(&intr); rt_mutex_create(&mutex_instant, NULL); rt_mutex_create(&mutex_average, NULL); rt_queue_create(&queue, "irq81", QUEUE_SIZE, Q_UNLIMITED, Q_FIFO); rt_task_spawn(&task_soft, NULL, 0, 80, 0, task_soft_routine, NULL); rt_task_spawn(&task_hard, NULL, 0, 90, 0, task_hard_routine, NULL); instant = 0; average = 0; running = 1; return 0; err_ostream: err_running: return -1; }
static int space_invader(void) { int err; printk("Start space_invader\n"); // Création de la tâche gérant le menu err = rt_task_create (&menu_task, "menu", STACK_SIZE, 50, 0); if (err != 0) { printk("menu task creation failed: %d\n", err); goto fail; } printk("Task created\n"); err = rt_task_start(&menu_task, menu, 0); if (err != 0) { printk("menu task start failed: %d\n", err); goto fail; } printk("Task started\n"); err = rt_intr_enable(&isrDesc); printk("Intr enable\n"); if (err != 0) { printk("rt-app: Could not enable I2C ISR\n"); goto fail; } printk("rt-app: Enabled ISR\n"); printk("End space_invader\n"); return 0; fail: cleanup_module(); return -1; }
void irq_server (void *cookie) { int fd ,iomask=0x00; if (rt_intr_enable(&intr_desc) != 0) { printf("Error : enabling IT\n"); return; } if ((fd = open(INTERRUPT_OUTPUT_DEV, O_RDWR))<0) { printf("Open error on /dev/gpio/portD\n"); return; } for (;;) { /* Wait for the next interrupt. */ if (rt_intr_wait(&intr_desc,TM_INFINITE) > 0) { write(fd,&iomask,sizeof(iomask)); iomask^=1; } } }
/*! \brief Fonction de création de l'application * * Fonction appelée lorsque l'initialisation de l'I2C est faite par le module_init * (point d'entrée de l'application) */ static int space_invader(void) { int err; err = rt_intr_enable(&isrDesc); if (err != 0) { printk("rt-app: Could not enable I2C ISR\n"); goto fail; } printk("rt-app: Enabled ISR\n"); err = rt_heap_create(&heap, "rt_heap", 240*320*2, 0); if(err != 0){ printk("rt-app: Could not create the rt heap\n"); goto fail; }else{ heap_created = 1; } printk("rt-app: RT-Heap created\n"); // On essaie de créer le tas pour le double buffering err = rt_heap_alloc(&heap, 240*320*2, TM_NONBLOCK, &fb_mem_rt); if(err != 0){ printk("rt-app: Could not allocate the rt heap\n"); goto fail; }else{ heap_allocated = 1; } printk("rt-app: RT-Heap allocated\n"); // On crée la tâche pour les invaders if(invaders_task_start() != 0){ goto fail; } // On crée la tâche pour les collisions if(hit_task_start() != 0){ goto fail; } // On crée la tâche pour la gestion des entrées/sorties if(io_task_start() != 0){ goto fail; } // On crée la tâche pour la gestion du frame buffer if(fb_task_start() != 0){ goto fail; } // On crée la tâche pour le vaisseau if(ship_task_start() != 0){ goto fail; } return 0; // En cas d'échec de création de l'ISR ou d'une tâche fail: cleanup_module(); return -1; }