[Armadeus-commitlog] SF.net SVN: armadeus:[1188] trunk/target/demos
Brought to you by:
sszy
|
From: <gwe...@us...> - 2009-03-24 14:08:04
|
Revision: 1188
http://armadeus.svn.sourceforge.net/armadeus/?rev=1188&view=rev
Author: gwenhael
Date: 2009-03-24 14:07:40 +0000 (Tue, 24 Mar 2009)
Log Message:
-----------
[DEMOS] Adding a complete set of xenomai usage examples
Added Paths:
-----------
trunk/target/demos/real_time/
trunk/target/demos/real_time/Makefile.in
trunk/target/demos/real_time/fractal/
trunk/target/demos/real_time/fractal/Makefile
trunk/target/demos/real_time/fractal/README
trunk/target/demos/real_time/fractal/lcd.c
trunk/target/demos/real_time/fractal/lcd.h
trunk/target/demos/real_time/fractal/main.c
trunk/target/demos/real_time/fractal/newton.c
trunk/target/demos/real_time/fractal/newton.h
trunk/target/demos/real_time/interrupt/
trunk/target/demos/real_time/interrupt/linux/
trunk/target/demos/real_time/interrupt/linux/kernel/
trunk/target/demos/real_time/interrupt/linux/kernel/Makefile
trunk/target/demos/real_time/interrupt/linux/kernel/interrupt_linux_kernel.c
trunk/target/demos/real_time/interrupt/linux/user_space/
trunk/target/demos/real_time/interrupt/linux/user_space/Makefile
trunk/target/demos/real_time/interrupt/linux/user_space/interrupt_linux_us.c
trunk/target/demos/real_time/interrupt/xenomai/
trunk/target/demos/real_time/interrupt/xenomai/kernel/
trunk/target/demos/real_time/interrupt/xenomai/kernel/Makefile
trunk/target/demos/real_time/interrupt/xenomai/kernel/interrupt_xeno_kernel.c
trunk/target/demos/real_time/interrupt/xenomai/user_space/
trunk/target/demos/real_time/interrupt/xenomai/user_space/Makefile
trunk/target/demos/real_time/interrupt/xenomai/user_space/interrupt_xeno_userspace.c
trunk/target/demos/real_time/pulse/
trunk/target/demos/real_time/pulse/linux/
trunk/target/demos/real_time/pulse/linux/kernel/
trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/
trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/Makefile
trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/pulse_linux_kernel_sleep.c
trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/
trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/Makefile
trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/pulse_linux_kernel_timer.c
trunk/target/demos/real_time/pulse/linux/user_space/
trunk/target/demos/real_time/pulse/linux/user_space/sleep/
trunk/target/demos/real_time/pulse/linux/user_space/sleep/Makefile
trunk/target/demos/real_time/pulse/linux/user_space/sleep/pulse_linux_userspace_sleep.c
trunk/target/demos/real_time/pulse/linux/user_space/timer/
trunk/target/demos/real_time/pulse/linux/user_space/timer/Makefile
trunk/target/demos/real_time/pulse/linux/user_space/timer/pulse_linux_userspace_timer.c
trunk/target/demos/real_time/pulse/xenomai/
trunk/target/demos/real_time/pulse/xenomai/kernel/
trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/
trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/Makefile
trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/pulse_xeno_kernel_rt_timer.c
trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/
trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/Makefile
trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/pulse_xeno_kernel_timer.c
trunk/target/demos/real_time/pulse/xenomai/user_space/
trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/
trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/Makefile
trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/pulse_xeno_userspace_sleep.c
trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/
trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/Makefile
trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/pulse_xeno_userspace_timer.c
Added: trunk/target/demos/real_time/Makefile.in
===================================================================
--- trunk/target/demos/real_time/Makefile.in (rev 0)
+++ trunk/target/demos/real_time/Makefile.in 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,65 @@
+###### CONFIGURATION ######
+DEST_DIR=/tftpboot/local/bin
+ARMADEUS_BASE_DIR=/home/gwe/armadeus/armadeus/
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
+XENO=$(ARMADEUS_ROOTFS_DIR)/usr/xenomai
+XENOCONFIG=$(shell PATH=$(XENO):$(XENO)/bin:$(PATH) which xeno-config 2>/dev/null)
+
+CC= arm-linux-gcc
+LD= arm-linux-ld
+CXX= arm-linux-g++
+AS= arm-linux-as
+NM= arm-linux-nm
+AR= arm-linux-ar
+SIZE= arm-linux-size
+OBJCOPY= arm-linux-objcopy
+
+
+EXEC=$(APPLICATIONS)
+
+
+ifneq ($(APPLICATIONS),)
+SRC= $(wildcard *.c)
+OBJ= $(SRC:.c=.o)
+EXEC= $(APPLICATIONS)
+CFLAGS=-g -W -Wall -I$(XENO)/include -I$(XENO)/include/native -I$(XENO)/include/rtdm -D_GNU_SOURCE -D_REENTRANT
+LDFLAGS=-L$(XENO)/lib -Xlinker -rpath $(XENO)/lib -Xlinker $(XENO)/lib/libnative.a $(XENO)/lib/librtdm.a -lpthread -lnative -lrtdm
+$(EXEC) : $(OBJ)
+ $(CC) -o $@ $^ $(LDFLAGS)
+$(OBJ): $(SRC)
+ $(CC) $(CFLAGS) -o $@ -c $<
+endif
+
+ifneq ($(MODULES),)
+EXEC=$(MODULES).ko
+
+KSRC=$(ARMADEUS_LINUX_DIR)
+#$(LOCALDIR)/linux-2.6.27.13
+KDIR=$(KSRC)
+OBJ := ${patsubst %, %.o, $(MODULES)}
+CLEANMOD := ${patsubst %, .%*, $(MODULES)}
+PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+obj-m := $(OBJ)
+EXTRA_CFLAGS=-I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/posix -I$(KSRC)/arch/arm/mach-imx/include/mach/
+CLEAN_MOD= modules.order *.ko *.mod.c *.mod.o *.symvers $(CLEANMOD) .tmp_versions
+$(EXEC):
+ $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules
+
+
+endif
+.PHONY: all
+all: $(EXEC)
+.PHONY: clean
+clean:
+ rm -rf $(OBJ) $(CLEAN_MOD)
+ rm -f $(EXEC)
+ rm -f *.c~ *.h~ Makefile~
+.PHONY: install
+install: $(EXEC)
+ cp $(EXEC) $(DEST_DIR)/$(EXEC)
+
+.PHONY: mrproper
+mrproper: clean
+ rm -f $(DEST_DIR)/$(EXEC)
+
Added: trunk/target/demos/real_time/fractal/Makefile
===================================================================
--- trunk/target/demos/real_time/fractal/Makefile (rev 0)
+++ trunk/target/demos/real_time/fractal/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,24 @@
+CC=arm-linux-gcc
+CFLAGS=-g -W -Wall
+LDFLAGS=
+EXEC=newton
+SRC= $(wildcard *.c)
+OBJ= $(SRC:.c=.o)
+
+all: $(EXEC)
+
+newton: $(OBJ)
+ $(CC) -o $@ $^ $(LDFLAGS)
+
+%.o: %.c
+ $(CC) -o $@ -c $< $(CFLAGS)
+
+.PHONY: clean install
+
+clean:
+ rm -rf *.o
+ rm -f $(EXEC)
+ rm -f *.c~ *.h~ Makefile~
+install: all
+ cp -f $(EXEC) /tftpboot/local/bin
+
Added: trunk/target/demos/real_time/fractal/README
===================================================================
--- trunk/target/demos/real_time/fractal/README (rev 0)
+++ trunk/target/demos/real_time/fractal/README 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,6 @@
+** Distributed computing for overloading processor **
+
+Calculation and displays a fractal newton distributed.
+Master : creates processus with fork, distributes parts and displays the result.
+10 slaves : computes parts of the picture.
+10 esclaves qui font le calcul d'une partie de l'image.
Added: trunk/target/demos/real_time/fractal/lcd.c
===================================================================
--- trunk/target/demos/real_time/fractal/lcd.c (rev 0)
+++ trunk/target/demos/real_time/fractal/lcd.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,92 @@
+#include <errno.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+
+
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <linux/fb.h>
+#include <sys/mman.h>
+
+#include "lcd.h"
+
+#define RMAX 2.
+#define RMIN -3.
+#define IMAX 2.5
+#define IMIN -2.5
+
+char *fbp = 0;
+
+
+struct fb_var_screeninfo vinfo;
+struct fb_fix_screeninfo finfo;
+long int screensize = 0;
+
+
+int init_lcd(){
+ // Open the file for reading and writing
+ int fbfd = open("/dev/fb0", O_RDWR);
+ if (!fbfd) {
+ printf("Error: cannot open framebuffer device.\n");
+ return -1;
+ }
+ printf("The framebuffer device was opened successfully.\n");
+
+ // Get fixed screen information
+ if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
+ printf("Error reading fixed information.\n");
+ return -1;
+ }
+
+ // Get variable screen information
+ if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
+ printf("Error reading variable information.\n");
+ return -1;
+ }
+
+ printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );
+
+ // Figure out the size of the screen in bytes
+ screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
+
+ // Map the device to memory
+ fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fbfd, 0);
+ if ((int)fbp == -1) {
+ printf("Error: failed to map framebuffer device to memory.\n");
+ return -1;
+ }
+ printf("The framebuffer device was mapped to memory successfully.\n");
+ return fbfd;
+ }
+
+void close_LCD(int fbfd){
+ munmap(fbp, screensize);
+ close(fbfd);
+ }
+
+
+void print_pix(int x, int y, int r, int g, int b){
+ long int location = 0;
+ if(x>=320)x=319;
+ if(y>=240)x=239;
+ if(x<0)x=0;
+ if(y<0)x=0;
+ location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
+ (y+vinfo.yoffset) * finfo.line_length;
+
+ unsigned short int t = ((r&0xf8)>>3)<<11 | ((g&0xfc)>>2) << 5 | ((b&0xf8)>>3);
+ *((unsigned short int*)(fbp + location)) = t;
+}
+
Added: trunk/target/demos/real_time/fractal/lcd.h
===================================================================
--- trunk/target/demos/real_time/fractal/lcd.h (rev 0)
+++ trunk/target/demos/real_time/fractal/lcd.h 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,15 @@
+#ifndef LCD_H
+#define LCD_H
+
+#define POINTSX 320.
+#define POINTSY 242.
+#define RMAX 2.
+#define RMIN -3.
+#define IMAX 2.5
+#define IMIN -2.5
+
+int init_lcd ();
+void close_LCD(int fbfd);
+void print_pix(int x, int y, int r, int g, int b);
+
+#endif /* LCD_H */
Added: trunk/target/demos/real_time/fractal/main.c
===================================================================
--- trunk/target/demos/real_time/fractal/main.c (rev 0)
+++ trunk/target/demos/real_time/fractal/main.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,199 @@
+/*
+* Calculation and displays a fractal newton distributed.
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "newton.h"
+#include "lcd.h"
+
+#define LECTURE 0
+#define ECRITURE 1
+
+
+#define NB_CHILD 10
+
+typedef struct str_color {
+ int r;
+ int g;
+ int b;
+} colour;
+
+typedef struct elem_pict {
+ float ii;
+ int x;
+ int y;
+ int height;
+ int width;
+ int numFils;
+ colour ligne[24][320];
+} elemPict;
+
+
+/* methode utilisee pour le fils pour
+ * faire son calcul
+ */
+void workChildren(elemPict *ep) {
+ float ii,ri,r,i;
+ int yy = 0,y=0;
+ int totaliter=0;
+ int x=0,maxiter=0, iter=0;//, yy = ep->y;
+ float fin = (RMAX-RMIN)/POINTSX;
+ float finY = (IMAX-IMIN)/POINTSY;
+ float yDeb = IMIN+(finY*ep->y);
+
+
+ for (ii=yDeb;ii<IMAX;ii+=(IMAX-IMIN)/POINTSY){ // terminal : 105x54
+ for (ri=RMIN;ri<RMAX;ri+=(RMAX-RMIN)/POINTSX) {
+ iter=0;
+ r=ri; i=ii;
+ do {
+ newton(&r,&i);
+ iter++;
+ }while ((module(r,i)<0.999) || (module(r,i)>1.001));
+ if (iter>maxiter)
+ maxiter=iter;
+ totaliter+=iter;
+ if (y >= (ep->height)) return;
+ ep->ligne[y][x].r = ep->ligne[y][x].g = ep->ligne[y][x].b = 0;
+ if (r>0){
+ ep->ligne[y][x].r = 255;
+ } else{
+ if (i>0){
+ ep->ligne[y][x].g = 255;
+ } else{
+ ep->ligne[y][x].b = 255;
+ }
+ }
+ x++;
+ }
+ y++;x=0;
+ }
+}
+
+
+/* Travail fait par le maitre */
+void workMaster(int *tabChildPipe, int global) {
+ int nbChild = NB_CHILD;
+ int i,lignDeb;
+ // Envoi de la commande de traitement
+ elemPict ep;
+ for (i=0,lignDeb=0;i<NB_CHILD;i++,lignDeb+=24) {
+ ep.x=0;
+ ep.y=lignDeb;
+ ep.height=24;
+ ep.numFils=i;
+ write(tabChildPipe[i],&ep,sizeof(elemPict));
+ }
+
+ // Mise en attente de l'ensemble des calculs
+ do {
+ int size = read(global,&ep,sizeof(elemPict)+1);
+ printf("recu de %d debut %d fin %d\n",ep.numFils,ep.y,ep.height+ep.numFils);
+ if (size != sizeof(elemPict)) {
+ printf("bizarre\n");
+ continue;
+ }
+ nbChild --;
+ int yy,x,y;
+ for (yy=0,y=ep.y;yy<24;y++,yy++) {
+ for (x=0;x<POINTSX;x++){
+ print_pix(x,y,ep.ligne[yy][x].r,ep.ligne[yy][x].g,ep.ligne[yy][x].b);
+ }
+ }
+ } while (nbChild >0);
+}
+
+void prepareChild(int *reception, int *versMaster) {
+ close(versMaster[LECTURE]);
+ close(reception[ECRITURE]);
+ elemPict ep;
+ read(reception[LECTURE], &ep, sizeof(elemPict));
+ workChildren(&ep);
+ write(versMaster[1],&ep,sizeof(elemPict));
+ close(versMaster[ECRITURE]);
+ close(reception[LECTURE]);
+}
+
+/* pipe : 0 => lecture dans le pipe , 1 => ecriture dans le pipe */
+
+int main(int argc, char **argv) {
+ int global[2];
+ int tabChildPipe[NB_CHILD];
+ int pidChildPipe[NB_CHILD];
+ /* Preparation de la pipe commune
+ * enfant vers pere
+ */
+ if (pipe(global) == -1) {
+ perror("pipeToMaster");
+ return(EXIT_FAILURE);
+ }
+ /* Création de tous les processus fils */
+ int pos;
+ int receptionFils[2];
+ for (pos = 0; pos < NB_CHILD; pos ++ ) {
+ if (pipe(receptionFils) == -1){
+ perror("pipeToMaster");
+ return(EXIT_FAILURE);
+ }
+ int pid = fork();
+ switch (pid) {
+ case -1:
+ printf("ca merde\n");
+ return -1;
+ break;
+ case 0: // Fiston
+ prepareChild(receptionFils, global);
+ return EXIT_SUCCESS;
+ break;
+ default: // C'est le pere
+ // Fermeture de la lecture
+ close(receptionFils[LECTURE]);
+ tabChildPipe[pos] = receptionFils[ECRITURE];
+ pidChildPipe[pos] = pid;
+ break;
+ }
+ }
+ // C'est plus que le code du pere
+ close(global[ECRITURE]);
+ int fbfd = init_lcd();
+ workMaster(tabChildPipe,global[LECTURE]);
+ close(global[LECTURE]); // Fermeture du pipe d'ecoute
+ // Fermeture des pipes des enfants
+ for (pos = 0; pos < 1; pos++) {
+ close (tabChildPipe[pos]);
+ }
+ // Fermeture du framebuffer
+ close(fbfd);
+ // Mise en attente de la fin des autres
+ for (pos = 0; pos<1;pos ++) {
+ waitpid(pidChildPipe[pos],NULL,0);
+ }
+ return EXIT_SUCCESS;
+}
Added: trunk/target/demos/real_time/fractal/newton.c
===================================================================
--- trunk/target/demos/real_time/fractal/newton.c (rev 0)
+++ trunk/target/demos/real_time/fractal/newton.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,52 @@
+// Dynamical systems and fractals
+// K.-H. Becker & M. D\"orfler
+// Cambridge University Press (1990), chapter.4
+#include <errno.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include "newton.h"
+
+void multiplie(float *r1,float *i1,float *r2,float *i2) {
+ float tmp;
+ tmp=((*r1) * (*r2)-(*i1) * (*i2));
+ *i1=((*i1)*(*r2)+(*i2)*(*r1));
+ *r1=tmp;
+}
+
+void addition(float *r1,float *i1,float *r2,float *i2) {
+ *r1=((*r1)+(*r2));
+ *i1=((*i1)+(*i2));
+}
+
+void division(float *r1,float *i1,float *r2,float *i2) {
+ float tmp;
+ tmp=((*r1) * (*r2)+(*i1) * (*i2)) / ((*r2)*(*r2)+(*i2)*(*i2));
+ *i1=((*i1) * (*r2)-(*r1) * (*i2)) / ((*r2)*(*r2)+(*i2)*(*i2));
+ *r1=tmp;
+}
+
+void newton(float *ri,float *ii) {
+ float r,i,r2,i2;
+ r2=*ri; i2=*ii;
+ r=*ri; i=*ii;
+ multiplie(&r2,&i2,&r,&i); // z -> z^2 dans (r2,i2)
+ multiplie(&r,&i,&r2,&i2); // z -> z^3 dans (r ,i )
+ r=r-1.; // z^3-1
+ r2=r2*3;
+ i2=i2*3;
+ division(&r,&i,&r2,&i2); // (z^3-1)/(2*z^2)
+ *ri=*ri-r;
+ *ii=*ii-i; // z-(z^3-1)/(2*z^2)
+}
+
+inline float module(float r,float i){
+ return(r*r+i*i);
+}
Added: trunk/target/demos/real_time/fractal/newton.h
===================================================================
--- trunk/target/demos/real_time/fractal/newton.h (rev 0)
+++ trunk/target/demos/real_time/fractal/newton.h 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,10 @@
+#ifndef NEWTON_H
+#define NEWTON_H
+
+void multiplie(float *r1,float *i1,float *r2,float *i2);
+void addition(float *r1,float *i1,float *r2,float *i2);
+void division(float *r1,float *i1,float *r2,float *i2);
+void newton(float *ri,float *ii);
+inline float module(float r,float i);
+
+#endif /* NEWTON_H */
Added: trunk/target/demos/real_time/interrupt/linux/kernel/Makefile
===================================================================
--- trunk/target/demos/real_time/interrupt/linux/kernel/Makefile (rev 0)
+++ trunk/target/demos/real_time/interrupt/linux/kernel/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,4 @@
+###### CONFIGURATION ######
+MODULES=irq_linux_kernel
+
+include /home/gwe/armadeus/stage/devel/Makefile.in
Added: trunk/target/demos/real_time/interrupt/linux/kernel/interrupt_linux_kernel.c
===================================================================
--- trunk/target/demos/real_time/interrupt/linux/kernel/interrupt_linux_kernel.c (rev 0)
+++ trunk/target/demos/real_time/interrupt/linux/kernel/interrupt_linux_kernel.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,80 @@
+/*
+* Small linux kernel driver for handling interrupt
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <linux/module.h>
+#include <asm/irq.h>
+#include <linux/irq.h>
+#include <asm/signal.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <gpio.h>
+
+#define IRQ_NB IRQ_GPIOA(6)
+
+MODULE_AUTHOR("Gwenhael GOAVEC MEROU");
+MODULE_DESCRIPTION("irq kernel test");
+MODULE_SUPPORTED_DEVICE("none");
+MODULE_LICENSE("GPL");
+
+/* irq handler */
+irqreturn_t interrupt_handler (int irqn, void *dev){
+ printk("toto plop\n");
+ return IRQ_HANDLED;
+}
+
+/* loading (insmod) */
+static int __init irq_init(void) {
+ int err;
+ printk("irq init\n");
+ err =request_irq(IRQ_NB, interrupt_handler, 0/*IRQF_SHARED*/,"test irq", NULL);
+ if (err!=0){
+ printk(KERN_INFO "erreur de request_irq\n");
+ switch (err) {
+ case -EINVAL:
+ printk("EINVAL\n");
+ break;
+ case -ENOMEM:
+ printk("ENOMEM\n");
+ break;
+ case -EBUSY:
+ printk("EBUSY\n");
+ break;
+ case -ENXIO:
+ printk("ENXIO\n");
+ break;
+ }
+ return err;
+ }
+ set_irq_type( IRQ_NB, IRQF_TRIGGER_FALLING ); //pour changer le front
+ return 0;
+}
+
+/* unloading (rmmod) */
+void __exit irq_exit(void) {
+ printk(KERN_INFO "irq_exit\n");
+ free_irq(IRQ_NB,NULL);
+}
+
+/* Api Linux devices */
+module_init(irq_init);
+module_exit(irq_exit);
Added: trunk/target/demos/real_time/interrupt/linux/user_space/Makefile
===================================================================
--- trunk/target/demos/real_time/interrupt/linux/user_space/Makefile (rev 0)
+++ trunk/target/demos/real_time/interrupt/linux/user_space/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,4 @@
+###### CONFIGURATION ######
+APPLICATIONS=irq_linux_us
+
+include /home/gwe/armadeus/stage/devel/Makefile.in
Added: trunk/target/demos/real_time/interrupt/linux/user_space/interrupt_linux_us.c
===================================================================
--- trunk/target/demos/real_time/interrupt/linux/user_space/interrupt_linux_us.c (rev 0)
+++ trunk/target/demos/real_time/interrupt/linux/user_space/interrupt_linux_us.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+
+
+#define FALSE 0
+#define TRUE 1
+volatile int STOP=FALSE;
+int wait_flag=TRUE;
+void
+action (int signo, siginfo_t * si, void *data)
+{
+ printf (" -------------- Got the %d signal ------------\n", signo);
+}
+
+int
+main (int argc, char **argv)
+{
+ int fd, res, oflags, retval = 0;
+ unsigned int buffer;
+char buf[255];
+//struct sigaction oa;
+// struct sigaction sa;
+ // sa.sa_sigaction = action;
+ //sa.sa_flags = 0;
+ //sa.sa_restorer = NULL;
+ //sigemptyset(&sa.sa_mask);
+
+ //sigaction (SIGIO, &sa, &oa);
+
+ // Open gpio file device for communication;
+ fd = open ("/dev/gpio/PA6", O_RDONLY);
+ if (fd < 0)
+ {
+ printf ("Open Failed\n");
+ exit (EXIT_FAILURE);
+ }
+
+ // set this process as owner of device file
+ retval = fcntl (fd, F_SETOWN, getpid ());
+ if (retval < 0)
+ {
+ printf ("F_SETOWN fails \n");
+ }
+ //retval = 0;
+ // enable the gpio async notifications
+ //oflags = fcntl (fd, F_GETFL);
+ //retval = fcntl (fd, F_SETFL, oflags | FASYNC);
+ /*if (retval < 0)
+ {
+ printf ("F_SETFL Fails \n");
+ }*/
+ while (STOP == FALSE)
+ {
+ usleep (100000);
+ res = read (fd, buf, 255);
+ printf(".\n");
+ buf[res] = 0;
+ printf ("%d:%x:%d\n", (int)buf[6],buf, res);
+ }
+ close (fd);
+ exit (EXIT_SUCCESS);
+}
Added: trunk/target/demos/real_time/interrupt/xenomai/kernel/Makefile
===================================================================
--- trunk/target/demos/real_time/interrupt/xenomai/kernel/Makefile (rev 0)
+++ trunk/target/demos/real_time/interrupt/xenomai/kernel/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,4 @@
+### List of modules to be build
+MODULES= interrupt_xeno_kernel
+
+include /home/gwe/armadeus/stage/devel/Makefile.in
Added: trunk/target/demos/real_time/interrupt/xenomai/kernel/interrupt_xeno_kernel.c
===================================================================
--- trunk/target/demos/real_time/interrupt/xenomai/kernel/interrupt_xeno_kernel.c (rev 0)
+++ trunk/target/demos/real_time/interrupt/xenomai/kernel/interrupt_xeno_kernel.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,71 @@
+/*
+* Small xenomai kernel driver for handling interrupt
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <linux/module.h>
+#include <native/task.h>
+#include <native/timer.h>
+#include <rtdm/rtdm_driver.h>
+#include <mach/hardware.h>
+#include <native/intr.h>
+
+
+MODULE_LICENSE("GPL");
+
+
+#define IRQ_NUMBER 70 /* Intercept interrupt #7 */
+#define TASK_PRIO 99 /* Highest RT priority */
+#define TASK_MODE 0 /* No flags */
+#define TASK_STKSZ 0 /* Stack size (use default one) */
+
+RT_INTR intr_desc;
+
+static int irq_server (xnintr_t *intr) {
+ printk("IT !\n");
+ return RT_INTR_HANDLED;
+}
+
+static int __init irq_init(void) {
+ int err;
+
+ /* Version With 6 param only on kernel space */
+ err = rt_intr_create(&intr_desc,"MyIrq", IRQ_NUMBER, irq_server, NULL, 0);
+ if (err !=0){
+ printk("rt_intr_create : error\n");
+ return err;
+ }
+
+ err = rt_intr_enable(&intr_desc);
+ if (err != 0)
+ printk("rt_intr_enable : error\n");
+ else
+ printk("rt_intr_create : ok\n");
+ return err;
+}
+
+void __init irq_exit(void) {
+ rt_intr_delete(&intr_desc);
+}
+
+module_init(irq_init);
+module_exit(irq_exit);
+
Added: trunk/target/demos/real_time/interrupt/xenomai/user_space/Makefile
===================================================================
--- trunk/target/demos/real_time/interrupt/xenomai/user_space/Makefile (rev 0)
+++ trunk/target/demos/real_time/interrupt/xenomai/user_space/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,5 @@
+### List of applications to be build
+APPLICATIONS = interrupt_xeno_userspace
+### Set of compilation instructions
+include ../../../Makefile.in
+
Added: trunk/target/demos/real_time/interrupt/xenomai/user_space/interrupt_xeno_userspace.c
===================================================================
--- trunk/target/demos/real_time/interrupt/xenomai/user_space/interrupt_xeno_userspace.c (rev 0)
+++ trunk/target/demos/real_time/interrupt/xenomai/user_space/interrupt_xeno_userspace.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,86 @@
+/*
+* Small xenomai user space for handling interrupt
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <sys/mman.h>
+#include <native/task.h>
+#include <native/intr.h>
+
+#define IRQ_NUMBER 70 /* Intercept interrupt #7 */
+#define TASK_PRIO 99 /* Highest RT priority */
+#define TASK_MODE 0 /* No flags */
+#define TASK_STKSZ 0 /* Stack size (use default one) */
+
+RT_INTR intr_desc;
+
+RT_TASK server_desc;
+void cleanup(void);
+
+void irq_server (void *cookie) {
+ int err;
+ if (rt_intr_enable(&intr_desc) != 0) {
+ printf("erreur pour enable\n");
+ return;
+ }
+ for (;;) {
+ /* Wait for the next interrupt on channel #7. */
+ err = rt_intr_wait(&intr_desc,TM_INFINITE);
+ printf("tata plop\n");
+ if (err > 0) {
+ printf("interrupt retrouvee %d\n",err);
+ }
+ }
+}
+
+int main (int argc, char *argv[]) {
+ int err;
+
+ mlockall(MCL_CURRENT|MCL_FUTURE);
+
+ /* Version With 4 param only on userSpace */
+ err = rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,0);
+ if (err != 0){
+ printf("rt_intr_create : error\n");
+ return 1;
+ } else
+ printf("rt_intr_create : ok\n");
+
+ err = rt_task_create(&server_desc,
+ "MyIrqServer",
+ TASK_STKSZ,
+ TASK_PRIO,
+ TASK_MODE);
+ if (err == 0)
+ rt_task_start(&server_desc,&irq_server,NULL);
+ else{
+ printf("rt_task_start : error\n");
+ return 1;
+ }
+ getchar();
+ cleanup();
+ return 0;
+}
+
+void cleanup (void) {
+ rt_intr_delete(&intr_desc);
+ rt_task_delete(&server_desc);
+}
Added: trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,3 @@
+###### CONFIGURATION ######
+MODULES=pulse_linux_kernel_sleep
+include ../../../../Makefile.in
Added: trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/pulse_linux_kernel_sleep.c
===================================================================
--- trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/pulse_linux_kernel_sleep.c (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/kernel/sleep_kernel/pulse_linux_kernel_sleep.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,46 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <gpio.h>
+
+#define TIMESLEEP 10
+#define MINOR_PORT 4
+
+MODULE_AUTHOR("Gwenhael GOAVEC MEROU");
+MODULE_DESCRIPTION("sleep kernel test");
+MODULE_SUPPORTED_DEVICE("none");
+MODULE_LICENSE("GPL");
+
+struct task_struct *th;
+
+/* thread fonction */
+int fct_thread_sleep(void *data) {
+ int iomask=1;
+ do {
+ imx_gpio_set_value(MINOR_PORT, iomask);
+ iomask^=1;
+ msleep(TIMESLEEP);
+ }while (!kthread_should_stop());
+ return 0;
+}
+
+/* loading (insmod) */
+static int __init blink_init(void) {
+ th = kthread_create(fct_thread_sleep,NULL,"pulse_linux_kernel_thread_sleep");
+ wake_up_process(th);
+ return 0;
+}
+
+
+/* unloading (rmmod) */
+static void __init blink_exit(void) {
+ printk(KERN_INFO "blink_exit\n");
+ kthread_stop(th);
+}
+
+/* API Linux devices */
+module_init(blink_init);
+module_exit(blink_exit);
Added: trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,4 @@
+###### CONFIGURATION ######
+#LOCALDIR=/home/gwe/armadeus/armadeus/buildroot/project_build_armv4t/apf9328
+MODULES=pulse_linux_kernel_timer
+include ../../../../Makefile.in
Added: trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/pulse_linux_kernel_timer.c
===================================================================
--- trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/pulse_linux_kernel_timer.c (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/kernel/timer_kernel/pulse_linux_kernel_timer.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,56 @@
+/***********************************
+ * Pulse generator
+ *
+ * author : Gwenhael GOAVEC-MEROU
+ *
+ ***********************************/
+
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <gpio.h>
+
+#define TIMESLEEP HZ/100
+#define MINOR_PORT 4
+
+MODULE_AUTHOR("Gwenhael GOAVEC MEROU");
+MODULE_DESCRIPTION("sleep kernel test");
+MODULE_SUPPORTED_DEVICE("none");
+MODULE_LICENSE("GPL");
+
+static int iomask = 0x00;
+static struct timer_list mt;
+
+/* timer callback*/
+void fonctionTimer(unsigned long arg) {
+ imx_gpio_set_value(MINOR_PORT, iomask);
+ iomask^=1;
+ mt.expires = jiffies+TIMESLEEP;
+ add_timer(&mt);
+}
+
+/* loading (insmod) */
+static int __init blink_init(void) {
+ current->state = TASK_INTERRUPTIBLE;
+ init_timer(&mt);
+ mt.expires = jiffies + TIMESLEEP;
+ mt.data = (unsigned long) current;
+ mt.function = fonctionTimer;
+ add_timer(&mt);
+ printk(KERN_INFO "blink_init\n");
+ return 0;
+}
+
+/* unloading (rmmod) */
+static void __init blink_exit(void) {
+ printk(KERN_INFO "blink_exit\n");
+ del_timer(&mt);
+}
+
+/* Api Linux devices */
+module_init(blink_init);
+module_exit(blink_exit);
Added: trunk/target/demos/real_time/pulse/linux/user_space/sleep/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/linux/user_space/sleep/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/user_space/sleep/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,3 @@
+APPLICATIONS=pulse_linux_userspace_sleep
+
+include ../../../../Makefile.in
Added: trunk/target/demos/real_time/pulse/linux/user_space/sleep/pulse_linux_userspace_sleep.c
===================================================================
--- trunk/target/demos/real_time/pulse/linux/user_space/sleep/pulse_linux_userspace_sleep.c (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/user_space/sleep/pulse_linux_userspace_sleep.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+int main(int argc, char **argv) {
+
+ int fd;
+ int iomask;
+ if ((fd = open("/dev/gpio/PA4", O_RDWR))<0) {
+ printf("Open error on /dev/gpio/PA4\n");
+ exit(0);
+ }
+ iomask=0x00;
+ printf("Opened on /dev/gpio/PA4\n");
+ while(1){
+ iomask^=1;
+ write(fd,&iomask,sizeof(iomask));
+ usleep(10000);
+ }
+ close(fd);
+ exit(0);
+}
Added: trunk/target/demos/real_time/pulse/linux/user_space/timer/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/linux/user_space/timer/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/user_space/timer/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,3 @@
+APPLICATIONS=pulse_linux_userspace_timer
+include ../../../../Makefile.in
+
Added: trunk/target/demos/real_time/pulse/linux/user_space/timer/pulse_linux_userspace_timer.c
===================================================================
--- trunk/target/demos/real_time/pulse/linux/user_space/timer/pulse_linux_userspace_timer.c (rev 0)
+++ trunk/target/demos/real_time/pulse/linux/user_space/timer/pulse_linux_userspace_timer.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define TIMESLEEP 1
+#define PORT "/dev/gpio/PA4"
+
+int fd;
+int iomask;
+void test() {
+ printf("hello world\n");
+ write(fd, &iomask, sizeof(iomask));
+ iomask ^=1;
+}
+
+int main(int argc, char **argv) {
+ printf("**** G\xE9n\xE9rateur d'impulsions avec timer en mode utilisateur ****\n");
+
+ fd = open(PORT,O_RDWR);
+ if (fd < 0) {
+ printf("erreur\n");
+ return 1;
+ }
+ iomask = 1;
+ do {
+ signal(SIGALRM,test);
+ alarm(TIMESLEEP);
+ pause();
+ } while(1);
+ return 0;
+}
Added: trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,4 @@
+### List of modules to be build
+MODULES = pulse_xeno_kernel_rt_timer
+
+include /home/gwe/armadeus/stage/devel/Makefile.in
Added: trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/pulse_xeno_kernel_rt_timer.c
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/pulse_xeno_kernel_rt_timer.c (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/kernel/rt_timer/pulse_xeno_kernel_rt_timer.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,93 @@
+/*
+* Xenomai kernel driver for generating pulses
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <linux/module.h>
+#include <native/task.h>
+#include <native/timer.h>
+#include <native/sem.h>
+#include <mach/hardware.h>
+#include <nucleus/types.h>
+#include <gpio.h>
+
+MODULE_LICENSE("GPL");
+
+RT_TASK blink_task;
+static int end = 0;
+
+#define TIMESLEEP 10000000llu
+#define MINOR_PORT 4
+#define GPIOWRDIRECTION _IOW(PP_IOCTL, 0xF1, int)
+#define MXC_DR(x) (0x1c + ((x) << 8))
+#define VA_GPIO_BASE IO_ADDRESS(IMX_GPIO_BASE)
+#define PORT_ADDR VA_GPIO_BASE + MXC_DR(0)
+
+void blink(void *arg){
+ int err, iomask;
+ printk(KERN_INFO "entrering blink\n");
+
+ if (imx_gpio_request(GPIO_PORTA | MINOR_PORT, "blink") < 0) {
+ gpio_free(MINOR_PORT);
+ return ;
+ }
+ imx_gpio_direction_output(GPIO_PORTA | MINOR_PORT,1);
+
+ if ((err = rt_task_set_periodic(NULL, TM_NOW,rt_timer_ns2ticks(TIMESLEEP)))){
+ printk("rt task set periodic failed \n");
+ return;
+ }
+ iomask=0;
+
+ while(!end){
+ rt_task_wait_period(NULL);
+ imx_gpio_set_value(GPIO_PORTA | MINOR_PORT, iomask);
+ iomask^=1;
+ }
+ printk("fin\n");
+}
+
+
+static int __init blink_init(void) {
+ printk(KERN_INFO "blink_init\n");
+ if (rt_task_create(&blink_task, "blink", 0, 99, 0)) {
+ printk("task create error\n");
+ return -EBUSY;
+ }
+ if (rt_task_start(&blink_task, &blink, NULL)) {
+ printk("task start error\n");
+ return -EBUSY;
+ }
+ return 0;
+}
+
+/* Fin de la tache (rmmod) */
+static void __init blink_exit(void) {
+ end = 1;
+ printk(KERN_INFO "blink_exit\n");
+ rt_task_delete(&blink_task);
+ rt_timer_stop();
+ gpio_free(MINOR_PORT);
+}
+
+/* Points d'entrée API modules Linux */
+module_init(blink_init);
+module_exit(blink_exit);
Added: trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,3 @@
+### List of modules to be build
+MODULES = pulse_xeno_kernel_timer
+include /home/gwe/armadeus/stage/devel/Makefile.in
Added: trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/pulse_xeno_kernel_timer.c
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/pulse_xeno_kernel_timer.c (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/kernel/timer_kernel/pulse_xeno_kernel_timer.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,79 @@
+/*
+* Xenomai kernel driver for generating pulse with timer
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+
+#include <linux/module.h>
+#include <native/task.h>
+#include <native/timer.h>
+#include <rtdm/rtdm_driver.h>
+#include <mach/hardware.h>
+#include <gpio.h>
+
+MODULE_LICENSE("GPL");
+
+static rtdm_task_t blink_task;
+static int end = 0;
+
+#define TIMESLEEP 5000000
+#define MINOR_PORT 4
+#define GPIOWRDIRECTION _IOW(PP_IOCTL, 0xF1, int)
+#define MXC_DR(x) (0x1c + ((x) << 8))
+#define VA_GPIO_BASE IO_ADDRESS(IMX_GPIO_BASE)
+#define PORT_ADDR VA_GPIO_BASE + MXC_DR(0)
+
+void blink(void *arg){
+ int iomask;
+ printk(KERN_INFO "entrering blink\n");
+ iomask=0;
+ while(!end){
+ rtdm_task_wait_period();
+ gpio_set_value(MINOR_PORT, iomask);
+ iomask^=1;
+ }
+ printk("fin\n");
+}
+
+
+static int __init blink_init(void) {
+ printk(KERN_INFO "blink_init\n");
+ if (gpio_request(MINOR_PORT, "blink") < 0) {
+ gpio_free(MINOR_PORT);
+ return -EBUSY;
+ }
+ gpio_direction_output(MINOR_PORT,1);
+
+ return rtdm_task_init(&blink_task, "blink", blink, NULL,
+ 99, TIMESLEEP);
+}
+
+/* Fin de la tache (rmmod) */
+static void __init blink_exit(void) {
+ end = 1;
+ printk(KERN_INFO "blink_exit\n");
+ rtdm_task_join_nrt(&blink_task,100);
+ gpio_free(MINOR_PORT);
+}
+
+/* Points d'entrée API modules Linux */
+module_init(blink_init);
+module_exit(blink_exit);
Added: trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,5 @@
+### List of applications to be build
+APPLICATIONS = pulse_xeno_userspace_timer
+
+include ../../../../Makefile.in
+
Added: trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/pulse_xeno_userspace_sleep.c
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/pulse_xeno_userspace_sleep.c (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_sleep/pulse_xeno_userspace_sleep.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,90 @@
+/*
+* Small xenomai userspace apps for generating signal
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <linux/ppdev.h>
+#include <signal.h>
+#include <sys/mman.h>
+
+#include <native/task.h>
+#include <native/timer.h>
+#include <rtdm/rtdm.h>
+
+RT_TASK blink_task;
+int write_fd = -1;
+
+#define TIMESLEEP 10000000
+#define WRITE_FILE "gpio/PA4"
+
+#define GPIOWRDIRECTION _IOW(PP_IOCTL, 0xF1, int)
+
+void blink(void *arg){
+ int iomask;
+ struct timespec tim = {0,TIMESLEEP};
+
+ iomask=0x00;
+
+ while(1){
+ rt_dev_write(write_fd,&iomask,sizeof(iomask));
+ iomask^=1;
+ if (nanosleep(&tim,NULL) != 0) {
+ printf("erreur de usleep\n");
+ return;
+ }
+ }
+}
+
+
+void catch_signal(int sig){}
+
+int main(int argc, char **argv) {
+
+ signal(SIGTERM, catch_signal);
+ signal(SIGINT, catch_signal);
+
+
+ /* Avoid memory swapping for this program */
+ mlockall(MCL_CURRENT|MCL_FUTURE);
+
+
+ /* Ouverture du descripteur de fichier */
+ if ((write_fd = rt_dev_open(WRITE_FILE, 0)) < 0) {
+ printf("Cannot open /dev/%s\n",WRITE_FILE);
+ return 1;
+ }
+
+ rt_task_create(&blink_task, "blinkLed", 0, 99, 0);
+ rt_task_start(&blink_task, &blink, NULL);
+
+ pause();
+
+ rt_task_delete(&blink_task);
+ rt_dev_close(write_fd);
+ return 0;
+}
Added: trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/Makefile
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/Makefile (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/Makefile 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,5 @@
+### List of applications to be build
+APPLICATIONS = pulse_xeno_userspace_timer
+
+include ../../../../Makefile.in
+
Added: trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/pulse_xeno_userspace_timer.c
===================================================================
--- trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/pulse_xeno_userspace_timer.c (rev 0)
+++ trunk/target/demos/real_time/pulse/xenomai/user_space/pulse_timer/pulse_xeno_userspace_timer.c 2009-03-24 14:07:40 UTC (rev 1188)
@@ -0,0 +1,91 @@
+/*
+* Small xenomai userspace apps for generating signal
+*
+* Copyright (C) 2009 <gwe...@ar...>
+* Armadeus Project / Armadeus Systems
+*
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <linux/ppdev.h>
+#include <signal.h>
+#include <sys/mman.h>
+
+#include <native/task.h>
+#include <native/timer.h>
+
+RT_TASK blink_task;
+
+#define TIMESLEEP 10000000
+#define GPIOWRDIRECTION _IOW(PP_IOCTL, 0xF1, int)
+
+/* Revoir en se basant sur cross-link.c */
+
+void blink(void *arg){
+ int fd, iomask;
+ if ((fd = open("/dev/gpio/PA4", O_RDWR))<0) {
+ printf("Open error on /dev/gpio/portD\n");
+ exit(0);
+ }
+ iomask=0x00;
+
+ rt_task_set_periodic(NULL, TM_NOW, TIMESLEEP);
+
+ while(1){
+ rt_task_wait_period(NULL);
+ write(fd,&iomask,sizeof(iomask));
+ iomask^=1;
+ }
+ close(fd);
+}
+
+void catch_signal() {}
+
+int main(int argc, char **argv) {
+
+ signal(SIGTERM, catch_signal);
+ signal(SIGINT, catch_signal);
+
+ /* Avoids memory swapping for this program */
+ mlockall(MCL_CURRENT|MCL_FUTURE);
+
+ /*
+ * Arguments: &task,
+ * name,
+ * stack size (0=default),
+ * priority,
+ * mode (FPU, start suspended, ...)
+ */
+ rt_task_create(&blink_task, "blinkLed", 0, 99, 0);
+
+ /*
+ * Arguments: &task,
+ * task function,
+ * function argument
+ */
+ rt_task_start(&blink_task, &blink, NULL);
+ pause();
+ rt_task_delete(&blink_task);
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|