[Armadeus-commitlog] SF.net SVN: armadeus:[1131] trunk/target/linux/modules/fpga/ wishbone_example
Brought to you by:
sszy
|
From: <Fa...@us...> - 2009-03-09 10:32:51
|
Revision: 1131
http://armadeus.svn.sourceforge.net/armadeus/?rev=1131&view=rev
Author: FabM
Date: 2009-03-09 10:32:47 +0000 (Mon, 09 Mar 2009)
Log Message:
-----------
[LINUX] Updating test programs for led and button in wishbone_example
Modified Paths:
--------------
trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c
trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c
Added Paths:
-----------
trunk/target/linux/modules/fpga/wishbone_example/push-led.c
Added: trunk/target/linux/modules/fpga/wishbone_example/push-led.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/push-led.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/push-led.c 2009-03-09 10:32:47 UTC (rev 1131)
@@ -0,0 +1,103 @@
+/* Enable or disable led when button is pressed
+ * Fabien Marteau <fab...@ar...>
+ * 9 mars 2009
+ * fpgaaccess.h
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ *
+ * A simple driver for reading and writing on
+ * fpga throught a character file /dev/fpgaaccess
+ *
+ * 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>
+
+/* file management */
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/* as name said */
+#include <signal.h>
+
+/* sleep */
+#include <unistd.h>
+
+int fbutton;
+int fled;
+
+void quit(int pouet){
+ close(fbutton);
+ close(fled);
+ exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned short i,j;
+
+ /* quit when Ctrl-C pressed */
+ signal(SIGINT, quit);
+
+ j=0;
+
+ printf( "Blink a led pushing button\n" );
+
+ if(argc < 3){
+ perror("invalid arguments number\npush-led <button_filename> <led_filename>\n");
+ exit(EXIT_FAILURE);
+ }
+
+ fbutton=open(argv[1],O_RDWR);
+ if(fbutton<0){
+ perror("can't open button file\n");
+ exit(EXIT_FAILURE);
+ }
+
+ while(1){
+
+ /* read button value */
+ if(read(fbutton,&j,1)<0){
+ perror("read error\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(lseek(fbutton,0,SEEK_SET)<0){
+ perror("lseek error\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* write led value */
+ fled=open(argv[2],O_RDWR);
+ if(fbutton<0){
+ perror("can't open led file\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(write(fled,&j,2)<=0){
+ perror("LED write error\n");
+ exit(EXIT_FAILURE);
+ }
+ close(fled);
+ }
+
+ close(fbutton);
+ close(fled);
+ exit(0);
+}
+
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c 2009-03-09 09:52:44 UTC (rev 1130)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c 2009-03-09 10:32:47 UTC (rev 1131)
@@ -1,4 +1,4 @@
-/* a program to write/read values on fpga address map
+/* a program to test button driver
* Fabien Marteau <fab...@ar...>
* 7 april 2008
* fpgaaccess.h
@@ -38,10 +38,10 @@
/* sleep */
#include <unistd.h>
-int fled;
+int fbutton;
void quit(int pouet){
- close(fled);
+ close(fbutton);
exit(0);
}
@@ -57,12 +57,12 @@
printf( "Testing button driver\n" );
if(argc < 2){
- perror("invalide arguments number\ntestled <button_filename>\n");
+ perror("invalide arguments number\ntestbutton <button_filename>\n");
exit(EXIT_FAILURE);
}
- fled=open(argv[1],O_RDWR);
- if(fled<0){
+ fbutton=open(argv[1],O_RDWR);
+ if(fbutton<0){
perror("can't open file\n");
exit(EXIT_FAILURE);
}
@@ -72,19 +72,19 @@
fflush(stdout);
/* read value */
- if(read(fled,&j,1)<0){
+ if(read(fbutton,&j,1)<0){
perror("read error\n");
exit(EXIT_FAILURE);
}
printf("Read %d\n",j);
- if(lseek(fled,0,SEEK_SET)<0){
+ if(lseek(fbutton,0,SEEK_SET)<0){
perror("lseek error\n");
exit(EXIT_FAILURE);
}
}
- close(fled);
+ close(fbutton);
exit(0);
}
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c 2009-03-09 09:52:44 UTC (rev 1130)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c 2009-03-09 10:32:47 UTC (rev 1131)
@@ -1,4 +1,4 @@
-/* a program to write/read values on fpga address map
+/* a program to test led driver
* Fabien Marteau <fab...@ar...>
* 7 april 2008
* fpgaaccess.h
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|