Re-orginized led and nvram related code, for generic target.
authoretisserant
Thu, 18 May 2006 21:54:24 +0200
changeset 15 e930a0e817de
parent 14 1fbdf88163b3
child 16 1684806cf7e1
Re-orginized led and nvram related code, for generic target.
configure
drivers/Makefile.in
drivers/can_virtual/Makefile.in
drivers/can_virtual/led_virtual.c
drivers/generic/Makefile.in
drivers/led_stdout/Makefile.in
drivers/led_stdout/led_stdout.c
examples/TestMasterSlave/Makefile.in
include/can_driver.h
include/led_driver.h
include/nvram_driver.h
--- a/configure	Thu May 18 16:26:59 2006 +0200
+++ b/configure	Thu May 18 21:54:24 2006 +0200
@@ -94,6 +94,8 @@
 	--prefix=*)	SUB_PREFIX=$optarg;;
 	--target=*)	SUB_TARGET=$optarg;;
 	--can=*)	SUB_CAN_DRIVER=$optarg;;
+	--led=*)	SUB_LED_DRIVER=$optarg;;
+	--nvram=*)	SUB_NVRAM_DRIVER=$optarg;;
 	--timers=*)	SUB_TIMERS_DRIVER=$optarg;;
 	--disable-Ox)	DISABLE_OPT=1;
 			echo "On user request: Won't optimize with \"-Ox\"";;
@@ -105,10 +107,6 @@
 			echo "Debug messages (PDO) enabled !!";;
 	--enable-lss)	SUB_LSS_ENABLE=YES;
 			echo "On user request: Will enable Auto Baudrate detect Feature";;
-	--enable-led)	SUB_LED_ENABLE=YES;
-			echo "On user request: Will enable diagnostic LED feature";;
-	--enable-nvram)	SUB_NVRAM_ENABLE=YES;
-			echo "On user request: Will enable Non Volatile RAM Feature";;
 	--desable-timers)	SUB_TIMERS_ENABLE=NO;
 			echo "On user request: Will enable built-in timer dispatch Feature";;
 	--MAX_CAN_BUS_ID=*)	MAX_CAN_BUS_ID=$1;;
@@ -131,15 +129,13 @@
 		echo	"		\"ecos_lpc2138_sja1000\" for eCOS + Philips ARM LPC21381 + Philips SJA1000" 
 		echo 	" --can=foo	Use 'foo' as CAN driver (can be either 'peak' or 'virtual')"
 		echo 	" --timers=foo	Use 'foo' as TIMERS driver (can be either 'unix' or 'xenomai')"
+		echo	" --led=foo	Use 'foo' as DS-305 LED driver (use 'none' to disable or 'stdout')"
+		echo	" --nvram=foo	Use 'foo' as NVRAM driver (use 'none' to disable or 'file')"
 		echo	" --disable-Ox	Disable gcc \"-Ox\" optimizations."
 		echo	" --enable-jaxe	Enable \"jaxe\" installation."
 		echo	" --debug	Enable debug messages."
 		echo	" --debugPDO	Enable debug messages, using PDO."
 		echo	" --enable-lss	Enable Auto Baudrate detect Feature"
-		echo	" --enable-led	Enable DS-305 LED diagnistic Feature"
-		echo	" --enable-nvram Enable Non-volatile RAM managment Feature"
-		echo	" --enable-timers Enable built-in schuduler Feature"
-		echo	" --enable-	Enable  Feature"
 		echo
 		echo	"Stack compilation constants"
 		echo	" --MAX_CAN_BUS_ID [=1] Number of can bus to use"
@@ -185,6 +181,16 @@
 	fi
 fi
 
+if [ "$SUB_TARGET" = "generic" -a "$SUB_LED_DRIVER" = "" ]; then
+	echo "Choosing stdout LED driver."
+	SUB_LED_DRIVER=stdout
+fi
+
+if [ "$SUB_TARGET" = "generic" -a "$SUB_NVRAM_DRIVER" = "" ]; then
+	echo "Choosing binary file NVRAM driver. -- not implemented --"
+#	SUB_NVRAM_DRIVER=file
+fi
+
 # If target generic, try to gess timers
 if [ "$SUB_TARGET" = "generic" -a "$SUB_TIMERS_DRIVER" = "" ]; then
 	echo "Choosing unix timers driver."
@@ -415,9 +421,6 @@
 	SUB_NVRAM_ENABLE=YES
 	# ecos driver implement its own timers
 	SUB_TIMERS_ENABLE=NO
-#	SUB_TIMERS_DRIVER=ecos
-#	SUB_CAN_DRIVER=ecos_lpc2138_sja1000
-
 fi
 
 
@@ -427,17 +430,8 @@
 	SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lpcan
 fi
 
-if [ "$SUB_CAN_DRIVER" = "ecos_lpc2138_sja1000" ]; then
-	SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ 
-fi
-
-
 #### TIMERS_DRIVER ####
 
-if [ "$SUB_TIMERS_DRIVER" = "ecos" ]; then
-	SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -llpthread
-fi
-
 if [ "$SUB_TIMERS_DRIVER" = "unix" ]; then
 	SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lpthread
 fi
@@ -448,6 +442,36 @@
 	SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ `$XENO_CONFIG --xeno-cflags`
 fi
 
+#### LED_DRIVER ####
+#enable led support if a led driver have been selected.
+if [ "$SUB_LED_DRIVER" != "" ]; then
+	SUB_LED_ENABLE=YES
+fi
+#if "none" driver is selected led feature is enabled but driver not compiled
+if [ "$SUB_LED_DRIVER" = "none" ]; then
+	SUB_LED_DRIVER=
+fi
+#if "disable" driver is selected led feature is disabled
+if [ "$SUB_LED_DRIVER" = "disable" ]; then
+	SUB_LED_ENABLE=
+	SUB_LED_DRIVER=
+fi
+
+#### NVRAM_DRIVER ####
+#enable nvram support if a nvram driver have been selected.
+if [ "$SUB_NVRAM_DRIVER" != "" ]; then
+	SUB_NVRAM_ENABLE=YES
+fi
+#if "none" driver is selected nvram feature is enabled but driver not compiled
+if [ "$SUB_NVRAM_DRIVER" = "none" ]; then
+	SUB_NVRAM_DRIVER=
+fi
+#if "disable" driver is selected nvram feature is disabled
+if [ "$SUB_NVRAM_DRIVER" = "disable" ]; then
+	SUB_NVRAM_ENABLE=
+	SUB_NVRAM_DRIVER=
+fi
+
 ###########################################################################
 #                              GUESS COMPILER                             #
 ###########################################################################
@@ -605,6 +629,16 @@
 \	drivers/can_$SUB_CAN_DRIVER/Makefile.in
 fi
 
+if [ "$SUB_LED_DRIVER" != "" ]; then
+	MAKEFILES=$MAKEFILES\
+\	drivers/led_$SUB_LED_DRIVER/Makefile.in
+fi
+
+if [ "$SUB_NVRAM_DRIVER" != "" ]; then
+	MAKEFILES=$MAKEFILES\
+\	drivers/nvram_$SUB_NVRAM_DRIVER/Makefile.in
+fi
+
 if [ "$SUB_TARGET" = "generic" ]; then
 	MAKEFILES=$MAKEFILES\
 \	drivers/generic/Makefile.in\
@@ -639,6 +673,8 @@
 	s:SUB_TIMERS_ENABLE:${SUB_TIMERS_ENABLE}:
 	s:SUB_TIMERS_DRIVER:timers_${SUB_TIMERS_DRIVER}:
 	s:SUB_CAN_DRIVER:can_${SUB_CAN_DRIVER}:
+	s:SUB_LED_DRIVER:led_${SUB_LED_DRIVER}:
+	s:SUB_NVRAM_DRIVER:nvram_${SUB_NVRAM_DRIVER}:
 	" > $makefile
 done
 
--- a/drivers/Makefile.in	Thu May 18 16:26:59 2006 +0200
+++ b/drivers/Makefile.in	Thu May 18 21:54:24 2006 +0200
@@ -24,11 +24,20 @@
 TARGET = SUB_TARGET
 CAN_DRIVER = SUB_CAN_DRIVER
 TIMERS_DRIVER = SUB_TIMERS_DRIVER
-LED_ENABLE = SUB_LED_ENABLE
+LED_DRIVER = SUB_LED_DRIVER
+NVRAM_DRIVER = SUB_NVRAM_DRIVER
 
 all: driver
 
 driver:
+ifneq ($(LED_DRIVER),led_)
+	$(MAKE) -C $(LED_DRIVER) $@
+endif
+
+ifneq ($(NVRAM_DRIVER),nvram_)
+	$(MAKE) -C $(NVRAM_DRIVER) $@
+endif
+
 ifneq ($(TIMERS_DRIVER),timers_)
 	$(MAKE) -C $(TIMERS_DRIVER) $@
 endif
@@ -39,6 +48,14 @@
 	$(MAKE) -C $(TARGET) $@
 
 install:
+ifneq ($(LED_DRIVER),led_)
+	$(MAKE) -C $(LED_DRIVER) $@
+endif
+
+ifneq ($(NVRAM_DRIVER),nvram_)
+	$(MAKE) -C $(NVRAM_DRIVER) $@
+endif
+
 ifneq ($(TIMERS_DRIVER),timers_)
 	$(MAKE) -C $(TIMERS_DRIVER) $@
 endif
@@ -49,6 +66,14 @@
 	$(MAKE) -C $(TARGET) $@
 
 uninstall:
+ifneq ($(LED_DRIVER),led_)
+	$(MAKE) -C $(LED_DRIVER) $@
+endif
+
+ifneq ($(NVRAM_DRIVER),nvram_)
+	$(MAKE) -C $(NVRAM_DRIVER) $@
+endif
+
 ifneq ($(TIMERS_DRIVER),timers_)
 	$(MAKE) -C $(TIMERS_DRIVER) $@
 endif
@@ -59,6 +84,14 @@
 	$(MAKE) -C $(TARGET) $@
 
 clean:
+ifneq ($(LED_DRIVER),led_)
+	$(MAKE) -C $(LED_DRIVER) $@
+endif
+
+ifneq ($(NVRAM_DRIVER),nvram_)
+	$(MAKE) -C $(NVRAM_DRIVER) $@
+endif
+
 ifneq ($(TIMERS_DRIVER),timers_)
 	$(MAKE) -C $(TIMERS_DRIVER) $@
 endif
@@ -69,6 +102,14 @@
 	$(MAKE) -C $(TARGET) $@
 
 mrproper: clean
+ifneq ($(LED_DRIVER),led_)
+	$(MAKE) -C $(LED_DRIVER) $@
+endif
+
+ifneq ($(NVRAM_DRIVER),nvram_)
+	$(MAKE) -C $(NVRAM_DRIVER) $@
+endif
+
 ifneq ($(TIMERS_DRIVER),timers_)
 	$(MAKE) -C $(TIMERS_DRIVER) $@
 endif
--- a/drivers/can_virtual/Makefile.in	Thu May 18 16:26:59 2006 +0200
+++ b/drivers/can_virtual/Makefile.in	Thu May 18 21:54:24 2006 +0200
@@ -37,18 +37,12 @@
 
 INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(CAN_DRIVER) -I../../include/$(TIMERS_DRIVER)
 
-
 OBJS = $(CAN_DRIVER).o
 
 SRC_HFILES = ../../include/$(CAN_DRIVER)/cancfg.h
 
 TARGET_HFILES = $(PREFIX)/include/canfestival/cancfg.h
 
-ifeq ($(LED_ENABLE),YES)
-OBJS += led_virtual.o
-SRC_HFILES += ../include/led.h
-endif
-
 all: driver
 
 driver: $(OBJS)
--- a/drivers/can_virtual/led_virtual.c	Thu May 18 16:26:59 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/***************************************************************************/
-#include <data.h>
-#include <led.h>
-
-void led_set_redgreen(CO_Data *d, unsigned char state)
-{
-        if (state & 0x01)
-                printf("\e[41m ERROR LED ON \e[m          ");
-        else
-                printf("\e[31m error led off \e[m         ");
-
-        if (state & 0x02)
-                printf("\e[34;42m RUN LED ON \e[m\n");
-        else
-                printf("\e[32m run led off \e[m\n");
-}
-
-
--- a/drivers/generic/Makefile.in	Thu May 18 16:26:59 2006 +0200
+++ b/drivers/generic/Makefile.in	Thu May 18 21:54:24 2006 +0200
@@ -33,21 +33,33 @@
 TARGET = SUB_TARGET
 CAN_DRIVER = SUB_CAN_DRIVER
 TIMERS_DRIVER = SUB_TIMERS_DRIVER
+LED_DRIVER = SUB_LED_DRIVER
+NVRAM_DRIVER = SUB_NVRAM_DRIVER
 
 INCLUDES = -I../../include -I../../include/generic
 
 OBJS = 
 
 # add timers driver if any
-ifneq ($(TIMERS_DRIVER),)
+ifneq ($(TIMERS_DRIVER),timers_)
 OBJS += ../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o
 endif
 
 # add can driver if any
-ifneq ($(CAN_DRIVER),)
+ifneq ($(CAN_DRIVER),can_)
 OBJS += ../$(CAN_DRIVER)/$(CAN_DRIVER).o
 endif
 
+# add led driver if any
+ifneq ($(LED_DRIVER),led_)
+OBJS += ../$(LED_DRIVER)/$(LED_DRIVER).o
+endif
+
+# add nvram driver if any
+ifneq ($(NVRAM_DRIVER),nvram_)
+OBJS += ../$(NVRAM_DRIVER)/$(NVRAM_DRIVER).o
+endif
+
 SRC_HFILES = ../../include/$(TARGET)/applicfg.h
 
 TARGET_HFILES = $(PREFIX)/include/$(TARGET)/applicfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/led_stdout/Makefile.in	Thu May 18 21:54:24 2006 +0200
@@ -0,0 +1,59 @@
+#! gmake
+
+#
+# Copyright (C) 2006 Laurent Bessard
+# 
+# This file is part of canfestival, a library implementing the canopen
+# stack
+# 
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+# 
+# This library 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
+# Lesser General Public License for more details.
+# 
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# 
+
+CC = SUB_CC
+OPT_CFLAGS = -O2
+CFLAGS = SUB_OPT_CFLAGS
+PROG_CFLAGS = SUB_PROG_CFLAGS
+LIBS = -lm
+SHAREDLIBOPT = -shared
+OS_NAME = SUB_OS_NAME
+ARCH_NAME = SUB_ARCH_NAME
+PREFIX = SUB_PREFIX
+TARGET = SUB_TARGET
+TIMERS_DRIVER = SUB_TIMERS_DRIVER
+CAN_DRIVER = SUB_CAN_DRIVER
+LED_DRIVER = SUB_LED_DRIVER
+NVRAM_DRIVER = SUB_NVRAM_DRIVER
+
+INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(CAN_DRIVER) -I../../include/$(TIMERS_DRIVER)
+
+OBJS = $(LED_DRIVER).o
+
+all: driver
+
+driver: $(OBJS)
+
+%o: %c
+	$(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
+
+install:
+
+uninstall:
+
+clean:
+	-\rm $(OBJS)
+
+mrproper: clean
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/led_stdout/led_stdout.c	Thu May 18 21:54:24 2006 +0200
@@ -0,0 +1,18 @@
+/***************************************************************************/
+#include <data.h>
+#include <led.h>
+
+void led_set_redgreen(CO_Data *d, unsigned char state)
+{
+        if (state & 0x01)
+                printf("\e[41m ERROR LED ON \e[m          ");
+        else
+                printf("\e[31m error led off \e[m         ");
+
+        if (state & 0x02)
+                printf("\e[34;42m RUN LED ON \e[m\n");
+        else
+                printf("\e[32m run led off \e[m\n");
+}
+
+
--- a/examples/TestMasterSlave/Makefile.in	Thu May 18 16:26:59 2006 +0200
+++ b/examples/TestMasterSlave/Makefile.in	Thu May 18 21:54:24 2006 +0200
@@ -34,22 +34,16 @@
 TIMERS_DRIVER = SUB_TIMERS_DRIVER
 LED_ENABLE = SUB_LED_ENABLE
 
-INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(CAN_DRIVER) -I../../include/$(TIMERS_DRIVER)
+INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(CAN_DRIVER) -I../../include/$(TIMERS_DRIVER) -I../../include/$(LED_DRIVER) -I../../include/$(NVRAM_DRIVER)
 
 MASTER_OBJS = TestSlave.o TestMaster.o TestMasterSlave.o Slave.o Master.o
 
-OBJS = $(MASTER_OBJS) ../../drivers/$(TARGET)/libcanfestival_$(TARGET).a  ../../src/libcanfestival.a
+OBJS = $(MASTER_OBJS) ../../src/libcanfestival.a ../../drivers/$(TARGET)/libcanfestival_$(TARGET).a
 
 ifeq ($(TIMERS_DRIVER),timers_xeno)
 	PROGDEFINES = -DUSE_XENO
 endif
 
-ifeq ($(LED_ENABLE),YES)
-OBJS += ../../drivers/can_virtual/led_virtual.o 
-PROG_CFLAGS += -DLED_ENABLE
-endif
-
-
 all: TestMasterSlave
 
 ../../drivers/$(TARGET)/libcanfestival_$(TARGET).a:
--- a/include/can_driver.h	Thu May 18 16:26:59 2006 +0200
+++ b/include/can_driver.h	Thu May 18 21:54:24 2006 +0200
@@ -39,13 +39,6 @@
 
 #include "data.h"
 
-void led_set_redgreen(CO_Data *d, unsigned char bits);
-
-int nvram_open(void);
-void nvram_close(void);
-char nvram_write(int type, int access_attr, void *data);
-char nvram_read(int type, int access_attr, void *data);
-
 struct struct_s_BOARD {
   char * busname;
   int baudrate;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/led_driver.h	Thu May 18 21:54:24 2006 +0200
@@ -0,0 +1,30 @@
+/*
+This file is part of CanFestival, a library implementing CanOpen Stack. 
+
+Copyright (C): Edouard TISSERANT and Francis DUPIN
+
+See COPYING file for copyrights details.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef __led_driver_h__
+#define __led_driver_h__
+
+#include "data.h"
+
+void led_set_redgreen(CO_Data *d, unsigned char bits);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/nvram_driver.h	Thu May 18 21:54:24 2006 +0200
@@ -0,0 +1,33 @@
+/*
+This file is part of CanFestival, a library implementing CanOpen Stack. 
+
+Copyright (C): Edouard TISSERANT and Francis DUPIN
+
+See COPYING file for copyrights details.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef __nvram_driver_h__
+#define __nvram_driver_h__
+
+#include "data.h"
+
+int nvram_open(void);
+void nvram_close(void);
+char nvram_write(int type, int access_attr, void *data);
+char nvram_read(int type, int access_attr, void *data);
+
+#endif