# HG changeset patch # User etisserant # Date 1148671457 -7200 # Node ID a9543d2ccd5605513af0f79776236d41e56b2362 # Parent 6a5cdca4de01e67b8f24dc6e1eb87faa0e78e734 Linux and BSD now use "unix" target. Generic is for driverless compilation. diff -r 6a5cdca4de01 -r a9543d2ccd56 configure --- a/configure Tue May 23 01:15:22 2006 +0200 +++ b/configure Fri May 26 21:24:17 2006 +0200 @@ -47,6 +47,11 @@ MAX_NB_TIMER=32 +# Generic timers declaration defaults +US_TO_TIMEVAL_FACTOR= +TIMEVAL= +TIMEVAL_MAX= + # Default to little-endian CANOPEN_LITTLE_ENDIAN=1 CANOPEN_BIG_ENDIAN= @@ -76,9 +81,6 @@ test=conftest rm -f $test $test.c -# Jaxe install is now disbaled by default -DISABLE_JAXE=1 - XENO_CONFIG=/usr/xenomai/bin/xeno-config ########################################################################### @@ -123,8 +125,9 @@ echo " --os=foo Use operative system 'foo' instead of trying to autodetect." echo " --prefix=foo Use prefix 'foo' instead of default ${SUB_PREFIX}." echo " --target=foo Use 'foo' as build target." - echo " Where 'foo' can be \"generic\" to have independant CAN and TIMERS driver" - echo " or" + echo " \"generic\" for have independant CAN and TIMERS driver" + echo " \"unix\" for unix-like systems" + echo " \"win32\" for win32 systems" echo " \"hcs12\" for HCS12 micro-controller" 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')" @@ -161,48 +164,6 @@ SUB_OPT_JAXE=jaxe fi fi -########################################################################### -# DEFAULT TARGET/DRIVERS GUESSING # -########################################################################### -# If target not specified, try to gess one -if [ "$SUB_TARGET" = "" ]; then - SUB_TARGET=generic -fi - -# If target generic, try to gess can -if [ "$SUB_TARGET" = "generic" -a "$SUB_CAN_DRIVER" = "" ]; then - if [ -e /usr/lib/libpcan.so ]; then - echo "Choosing installed Peak driver as CAN driver." - SUB_CAN_DRIVER=peak - else - echo "Choosing virtual CAN driver." - SUB_CAN_DRIVER=virtual - SUB_LED_ENABLE=YES - 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." - SUB_TIMERS_DRIVER=unix -fi - -if [ "$SUB_CAN_DRIVER" = "peak" ]; then - if [ ! -e /usr/lib/libpcan.so ]; then - echo "Peak driver hasn't been installed !" - exit -1 - fi -fi ########################################################################### # GUESS OS/ARCH # @@ -379,8 +340,74 @@ fi ########################################################################### +# DEFAULT TARGET/DRIVERS GUESSING # +########################################################################### +# If target not specified, try to gess one +if [ "$SUB_TARGET" = "" ]; then + if [ "$SUB_OS_NAME" = "CYGWIN" ]; then + echo "Choosing win32 target" + SUB_TARGET=win32 + else + echo "Choosing unix target" + SUB_TARGET=unix + fi +fi + +# Try to gess can +if [ "$SUB_CAN_DRIVER" = "" ]; then + if [ "$SUB_TARGET" = "unix" ]; then + if [ -e /usr/lib/libpcan.so ]; then + echo "Choosing installed Peak driver as CAN driver." + SUB_CAN_DRIVER=peak + else + echo "Choosing virtual CAN driver." + SUB_CAN_DRIVER=virtual + fi + fi + if [ "$SUB_TARGET" = "win32" ]; then + echo "CAN driver for windows --Not Implemented--" + fi +fi + +if [ "$SUB_TARGET" = "unix" -a "$SUB_LED_DRIVER" = "" ]; then + echo "Choosing stdout LED driver." + SUB_LED_DRIVER=stdout +fi + +if [ "$SUB_TARGET" = "unix" -a "$SUB_NVRAM_DRIVER" = "" ]; then + echo "Choosing binary file NVRAM driver. -- not implemented --" +# SUB_NVRAM_DRIVER=file +fi + +# If target is unix, default timers also +if [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "" ]; then + echo "Choosing unix timers driver." + SUB_TIMERS_DRIVER=unix +fi + +# Warn for unstalled peak driver if choosen +if [ "$SUB_CAN_DRIVER" = "peak" ]; then + if [ ! -e /usr/lib/libpcan.so ]; then + echo "Peak driver hasn't been installed !" + exit -1 + fi +fi + +########################################################################### # TARGET/DRIVER SPECIFIC CFLAGS and OPTIONS # ########################################################################### +if [ "$SUB_TARGET" = "generic" ]; then + if [ "$US_TO_TIMEVAL_FACTOR" = "" ]; then + US_TO_TIMEVAL_FACTOR=1 + fi + if [ "$TIMEVAL" = "" ]; then + TIMEVAL=UNS64 + fi + if [ "$TIMEVAL_MAX" = "" ]; then + TIMEVAL_MAX=0xffffffffffffffff + fi +fi + if [ "$SUB_TARGET" = "hcs12" ]; then # Only if we want to compile for a µC HCS12 # search for gcc hcs12 compiler m6811-elf-gcc or m68hc12-gcc ? @@ -399,8 +426,6 @@ SUB_PROG_CFLAGS=-m68hc12 fi fi - # hcs12 driver implement its own timers - SUB_TIMERS_ENABLE=YES fi if [ "$SUB_TARGET" = "ecos_lpc2138_sja1000" ]; then @@ -419,8 +444,6 @@ SUB_LSS_ENABLE=YES SUB_LED_ENABLE=YES SUB_NVRAM_ENABLE=YES - # ecos driver implement its own timers - SUB_TIMERS_ENABLE=NO fi @@ -430,6 +453,10 @@ SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lpcan fi +if [ "$SUB_CAN_DRIVER" = "none" ]; then + SUB_CAN_DRIVER= +fi + #### TIMERS_DRIVER #### if [ "$SUB_TIMERS_DRIVER" = "unix" ]; then @@ -442,6 +469,10 @@ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ `$XENO_CONFIG --xeno-cflags` fi +if [ "$SUB_TIMERS_DRIVER" = "none" ]; then + SUB_TIMERS_DRIVER= +fi + #### LED_DRIVER #### #enable led support if a led driver have been selected. if [ "$SUB_LED_DRIVER" != "" ]; then @@ -575,7 +606,10 @@ SDO_TIMEOUT_MS\ MAX_NB_TIMER\ CANOPEN_BIG_ENDIAN\ - CANOPEN_LITTLE_ENDIAN ; do + CANOPEN_LITTLE_ENDIAN\ + US_TO_TIMEVAL_FACTOR\ + TIMEVAL\ + TIMEVAL_MAX; do if [ "${!i}" = "" ]; then echo "// $i is not defined" >> include/config.h else @@ -605,51 +639,53 @@ ########################################################################### # CREATE MAKEFILES # ########################################################################### +# General Makefiles MAKEFILES=Makefile.in\ \ src/Makefile.in\ \ drivers/Makefile.in\ \ objdictgen/Makefile.in\ \ examples/Makefile.in +# Drivers dependent Makefiles +if [ "$SUB_TIMERS_DRIVER" != "" ]; then + MAKEFILES=$MAKEFILES\ +\ drivers/timers_$SUB_TIMERS_DRIVER/Makefile.in +fi + +if [ "$SUB_CAN_DRIVER" != "" ]; then + MAKEFILES=$MAKEFILES\ +\ 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 + +# Target dependent Makefiles +MAKEFILES=$MAKEFILES\ drivers/$SUB_TARGET/Makefile.in + +if [ "$SUB_TARGET" = "unix" ]; then + MAKEFILES=$MAKEFILES\ +\ examples/AppliMaster_Linux/Makefile.in\ +\ examples/AppliSlave_Linux/Makefile.in\ +\ examples/TestMasterSlave/Makefile.in +fi + if [ "$SUB_TARGET" = "hcs12" ]; then MAKEFILES=$MAKEFILES\ -\ drivers/hcs12/Makefile.in\ \ examples/AppliMaster_HCS12/Makefile.in\ \ examples/AppliSlave_HCS12/Makefile.in\ \ examples/gene_SYNC_HCS12/Makefile.in fi -if [ "$SUB_TIMERS_DRIVER" != "" ]; then - MAKEFILES=$MAKEFILES\ -\ drivers/timers_$SUB_TIMERS_DRIVER/Makefile.in -fi - -if [ "$SUB_CAN_DRIVER" != "" ]; then - MAKEFILES=$MAKEFILES\ -\ 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\ -\ examples/AppliMaster_Linux/Makefile.in\ -\ examples/AppliSlave_Linux/Makefile.in\ -\ examples/TestMasterSlave/Makefile.in -fi - if [ "$SUB_TARGET" = "ecos_lpc2138_sja1000" ]; then MAKEFILES=$MAKEFILES\ -\ drivers/ecos_lpc2138_sja1000/Makefile.in\ \ examples/ecos_lpc2138_sja1000/src/Makefile.in fi diff -r 6a5cdca4de01 -r a9543d2ccd56 drivers/generic/Makefile.in --- a/drivers/generic/Makefile.in Tue May 23 01:15:22 2006 +0200 +++ b/drivers/generic/Makefile.in Fri May 26 21:24:17 2006 +0200 @@ -36,7 +36,7 @@ LED_DRIVER = SUB_LED_DRIVER NVRAM_DRIVER = SUB_NVRAM_DRIVER -INCLUDES = -I../../include -I../../include/generic +INCLUDES = -I../../include -I../../include/$(SUB_TARGET) OBJS = @@ -74,23 +74,23 @@ #../$(CAN_DRIVER)/$(CAN_DRIVER).o: # $(MAKE) -C ../$(CAN_DRIVER) driver -libcanfestival_generic.a: $(OBJS) - @echo Building [libcanfestival_generic.a] +libcanfestival_$(TARGET).a: $(OBJS) + @echo Building [libcanfestival_$(TARGET).a] ar rc $@ $(OBJS) ranlib $@ -install: libcanfestival_generic.a +install: libcanfestival_$(TARGET).a mkdir -p $(PREFIX)/lib/ mkdir -p $(PREFIX)/include/canfestival - cp libcanfestival_generic.a $(PREFIX)/lib/ + cp libcanfestival_$(TARGET).a $(PREFIX)/lib/ cp $(SRC_HFILES) $(PREFIX)/include/canfestival uninstall: - rm -f $(PREFIX)/lib/libcanfestival_generic.a + rm -f $(PREFIX)/lib/libcanfestival_$(TARGET).a rm -f $(TARGET_HFILES) clean: - -\rm libcanfestival_generic.a + -\rm libcanfestival_$(TARGET).a mrproper: clean diff -r 6a5cdca4de01 -r a9543d2ccd56 drivers/unix/.cvsignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/drivers/unix/.cvsignore Fri May 26 21:24:17 2006 +0200 @@ -0,0 +1,2 @@ +Makefile +*.a diff -r 6a5cdca4de01 -r a9543d2ccd56 drivers/unix/Makefile.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/drivers/unix/Makefile.in Fri May 26 21:24:17 2006 +0200 @@ -0,0 +1,97 @@ +#! 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 +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/$(SUB_TARGET) + +OBJS = + +# add timers driver if any +ifneq ($(TIMERS_DRIVER),timers_) +OBJS += ../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o +endif + +# add can driver if any +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 + +all: driver + +driver: $(OBJS) + +#../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o: +# $(MAKE) -C ../$(TIMERS_DRIVER) driver + +#../$(CAN_DRIVER)/$(CAN_DRIVER).o: +# $(MAKE) -C ../$(CAN_DRIVER) driver + +libcanfestival_$(TARGET).a: $(OBJS) + @echo Building [libcanfestival_$(TARGET).a] + ar rc $@ $(OBJS) + ranlib $@ + +install: libcanfestival_$(TARGET).a + mkdir -p $(PREFIX)/lib/ + mkdir -p $(PREFIX)/include/canfestival + cp libcanfestival_$(TARGET).a $(PREFIX)/lib/ + cp $(SRC_HFILES) $(PREFIX)/include/canfestival + +uninstall: + rm -f $(PREFIX)/lib/libcanfestival_$(TARGET).a + rm -f $(TARGET_HFILES) + +clean: + -\rm libcanfestival_$(TARGET).a + +mrproper: clean + + diff -r 6a5cdca4de01 -r a9543d2ccd56 examples/Makefile.in --- a/examples/Makefile.in Tue May 23 01:15:22 2006 +0200 +++ b/examples/Makefile.in Fri May 26 21:24:17 2006 +0200 @@ -29,7 +29,7 @@ $(MAKE) -C AppliSlave_HCS12 $@ $(MAKE) -C gene_SYNC_HCS12 $@ endif -ifeq ($(TARGET),generic) +ifeq ($(TARGET),unix) $(MAKE) -C TestMasterSlave $@ endif @@ -39,7 +39,7 @@ $(MAKE) -C AppliSlave_HCS12 $@ $(MAKE) -C gene_SYNC_HCS12 $@ endif -ifeq ($(TARGET),generic) +ifeq ($(TARGET),unix) $(MAKE) -C TestMasterSlave $@ endif @@ -49,7 +49,7 @@ $(MAKE) -C AppliSlave_HCS12 $@ $(MAKE) -C gene_SYNC_HCS12 $@ endif -ifeq ($(TARGET),generic) +ifeq ($(TARGET),unix) $(MAKE) -C TestMasterSlave $@ endif diff -r 6a5cdca4de01 -r a9543d2ccd56 include/can_driver.h --- a/include/can_driver.h Tue May 23 01:15:22 2006 +0200 +++ b/include/can_driver.h Fri May 26 21:24:17 2006 +0200 @@ -23,8 +23,6 @@ #ifndef __can_driver_h__ #define __can_driver_h__ -#include "timerscfg.h" - struct struct_s_BOARD; typedef struct struct_s_BOARD s_BOARD; diff -r 6a5cdca4de01 -r a9543d2ccd56 include/generic/applicfg.h --- a/include/generic/applicfg.h Tue May 23 01:15:22 2006 +0200 +++ b/include/generic/applicfg.h Fri May 26 21:24:17 2006 +0200 @@ -26,9 +26,6 @@ #include #include -#include "cancfg.h" -#include "timerscfg.h" - // Define the architecture : little_endian or big_endian // ----------------------------------------------------- // Test : @@ -65,7 +62,7 @@ #define UNS40 #define UNS48 #define UNS56 -#define UNS64 +#define UNS64 unsigned long long // Reals #define REAL32 float @@ -96,3 +93,10 @@ #endif #endif + +#define CAN_HANDLE void* + +#define MS_TO_TIMEVAL(ms) ms*US_TO_TIMEVAL_FACTOR*1000 +#define US_TO_TIMEVAL(us) us*US_TO_TIMEVAL_FACTOR + +#define TASK_HANDLE pthread_t diff -r 6a5cdca4de01 -r a9543d2ccd56 include/unix/applicfg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/unix/applicfg.h Fri May 26 21:24:17 2006 +0200 @@ -0,0 +1,98 @@ +/* +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 __APPLICFG_LINUX__ +#define __APPLICFG_LINUX__ + +#include +#include + +#include "cancfg.h" +#include "timerscfg.h" + +// Define the architecture : little_endian or big_endian +// ----------------------------------------------------- +// Test : +// UNS32 v = 0x1234ABCD; +// char *data = &v; +// +// Result for a little_endian architecture : +// data[0] = 0xCD; +// data[1] = 0xAB; +// data[2] = 0x34; +// data[3] = 0x12; +// +// Result for a big_endian architecture : +// data[0] = 0x12; +// data[1] = 0x34; +// data[2] = 0xAB; +// data[3] = 0xCD; + +// Integers +#define INTEGER8 char +#define INTEGER16 short +#define INTEGER24 +#define INTEGER32 long +#define INTEGER40 +#define INTEGER48 +#define INTEGER56 +#define INTEGER64 + +// Unsigned integers +#define UNS8 unsigned char +#define UNS16 unsigned short +#define UNS32 unsigned long +#define UNS24 +#define UNS40 +#define UNS48 +#define UNS56 +#define UNS64 + +// Reals +#define REAL32 float +#define REAL64 double + +/// Definition of error and warning macros +// -------------------------------------- +#if defined DEBUG_ERR_CONSOLE_ON || defined DEBUG_WAR_CONSOLE_ON +#include +#endif + +/// Definition of MSG_ERR +// --------------------- +#ifdef DEBUG_ERR_CONSOLE_ON +# define MSG_ERR(num, str, val)/* \ + printf("%s,%d : 0X%x %s 0X%x \n",__FILE__, __LINE__,num, str, val);*/ +#else +# define MSG_ERR(num, str, val) +#endif + +/// Definition of MSG_WAR +// --------------------- +#ifdef DEBUG_WAR_CONSOLE_ON +# define MSG_WAR(num, str, val)/* \ + printf("%s,%d : 0X%x %s 0X%x \n",__FILE__, __LINE__,num, str, val);*/ +#else +# define MSG_WAR(num, str, val) +#endif + +#endif diff -r 6a5cdca4de01 -r a9543d2ccd56 src/Makefile.in --- a/src/Makefile.in Tue May 23 01:15:22 2006 +0200 +++ b/src/Makefile.in Fri May 26 21:24:17 2006 +0200 @@ -35,17 +35,11 @@ NVRAM_ENABLE = SUB_NVRAM_ENABLE CAN_DRIVER = SUB_CAN_DRIVER TIMERS_DRIVER = SUB_TIMERS_DRIVER -TIMERS_ENABLE = SUB_TIMERS_ENABLE INCLUDES = -I../include -I../include/$(TARGET) -I../include/$(CAN_DRIVER) -I../include/$(TIMERS_DRIVER) -I../drivers/$(TARGET) OBJS = $(TARGET)_objacces.o $(TARGET)_lifegrd.o $(TARGET)_sdo.o\ - $(TARGET)_pdo.o $(TARGET)_sync.o $(TARGET)_nmtSlave.o $(TARGET)_nmtMaster.o $(TARGET)_states.o - -# ecos driver shortcuts timer.c -ifeq ($(TIMERS_ENABLE),YES) -OBJS += $(TARGET)_timer.o -endif + $(TARGET)_pdo.o $(TARGET)_sync.o $(TARGET)_nmtSlave.o $(TARGET)_nmtMaster.o $(TARGET)_states.o $(TARGET)_timer.o # # # # Target specific paramters # # # # @@ -59,7 +53,7 @@ PROGDEFINES = -mnoshort -Wall -Wmissing-prototypes -fno-strict-aliasing endif -ifeq ($(TARGET),generic) +ifeq ($(TARGET),unix) OPT_CFLAGS = -O2 endif @@ -81,11 +75,6 @@ SRC_HFILES += ../include/nvram.h endif -ifeq ($(TIMERS_ENABLE),YES) -OBJS += $(TARGET)_timer.o -endif - - CFLAGS = SUB_OPT_CFLAGS all: canfestival