# HG changeset patch # User etisserant # Date 1171386378 -3600 # Node ID 16c8ceea8f188a18b6128f26af36c17400dbe12d # Parent 0d84d95790d981298a04fed3f5248df3ad265b0c Removed all non-supported and uncontrolled source code. Please refer to CVS version "Before_..." to see old code. diff -r 0d84d95790d9 -r 16c8ceea8f18 configure --- a/configure Tue Feb 13 17:21:19 2007 +0100 +++ b/configure Tue Feb 13 18:06:18 2007 +0100 @@ -96,8 +96,6 @@ --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,8 +103,6 @@ echo "Debug messages enabled !!";; --debugPDO) DEBUG=PDO; echo "Debug messages (PDO) enabled !!";; - --enable-lss) SUB_LSS_ENABLE=YES; - echo "On user request: Will enable Auto Baudrate detect 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;; @@ -127,15 +123,11 @@ 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', 'lincan' or 'virtual')" echo " --timers=foo Use 'foo' as TIMERS driver (can be either 'unix' or 'xeno')" - 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 " --debug Enable debug messages." echo " --debugPDO Enable debug messages, using PDO." - echo " --enable-lss Enable Auto Baudrate detect Feature" echo echo "Stack compilation constants" echo " --MAX_CAN_BUS_ID [=1] Number of can bus to use" @@ -354,16 +346,6 @@ 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." @@ -415,25 +397,6 @@ fi fi -if [ "$SUB_TARGET" = "ecos_lpc2138_sja1000" ]; then - # search for gcc arm compiler arm-elf-gcc or arm-elf-gcc ? - if [ "$CC" = "" ]; then - which arm-elf-gcc >/dev/null 2>&1 - if (( $? )); then - echo "error : Could not find arm-elf-gcc" - else - CC=arm-elf-gcc - SUB_PROG_CFLAGS="-mcpu=arm7tdmi -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Os \ - -ffunction-sections -fdata-sections -fno-exceptions -finline-functions" - fi - fi - # ecos sja1000 driver implements calls needed by LSS. - SUB_LSS_ENABLE=YES - SUB_LED_ENABLE=YES - SUB_NVRAM_ENABLE=YES -fi - - #### CAN_DRIVER #### if [ "$SUB_CAN_DRIVER" = "peak" ]; then @@ -491,36 +454,6 @@ SUB_TIMERS_DRIVER= 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 # ########################################################################### @@ -691,38 +624,19 @@ \ 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\ -\ examples/AppliMaster_HCS12/Makefile.in\ -\ examples/AppliSlave_HCS12/Makefile.in\ \ examples/gene_SYNC_HCS12/Makefile.in fi -if [ "$SUB_TARGET" = "ecos_lpc2138_sja1000" ]; then - MAKEFILES=$MAKEFILES\ -\ examples/ecos_lpc2138_sja1000/src/Makefile.in -fi - for makefile_in in $MAKEFILES; do makefile=`echo $makefile_in | sed 's:.in$::'` echo "Creating $makefile" @@ -736,14 +650,9 @@ s:SUB_OPT_CFLAGS:${SUB_OPT_CFLAGS}: s:SUB_TARGET:${SUB_TARGET}: s:SUB_BINUTILS_PREFIX:${SUB_BINUTILS_PREFIX}: - s:SUB_LSS_ENABLE:${SUB_LSS_ENABLE}: - s:SUB_LED_ENABLE:${SUB_LED_ENABLE}: - s:SUB_NVRAM_ENABLE:${SUB_NVRAM_ENABLE}: 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 diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/Makefile.in --- a/drivers/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ b/drivers/Makefile.in Tue Feb 13 18:06:18 2007 +0100 @@ -24,19 +24,10 @@ TARGET = SUB_TARGET CAN_DRIVER = SUB_CAN_DRIVER TIMERS_DRIVER = SUB_TIMERS_DRIVER -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) $@ @@ -48,13 +39,6 @@ $(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) $@ @@ -66,13 +50,6 @@ $(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) $@ @@ -84,13 +61,6 @@ $(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) $@ @@ -102,13 +72,6 @@ $(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) $@ diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/can_socket/Makefile.in --- a/drivers/can_socket/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ b/drivers/can_socket/Makefile.in Tue Feb 13 18:06:18 2007 +0100 @@ -53,6 +53,6 @@ rm -f $(TARGET_HFILES) clean: - -\rm $(OBJS) + rm -f $(OBJS) mrproper: clean diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/can_virtual/Makefile.in --- a/drivers/can_virtual/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ b/drivers/can_virtual/Makefile.in Tue Feb 13 18:06:18 2007 +0100 @@ -58,6 +58,6 @@ rm -f $(TARGET_HFILES) clean: - rm $(OBJS) + rm -f $(OBJS) mrproper: clean diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/Makefile.in --- a/drivers/ecos_lpc2138_sja1000/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -#! gmake - -# -# Copyright (C) 2006 OREMEQ -# -# 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 = SUB_OPT_CFLAGS -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 -INCLUDES = -I../../include -I../../examples/ecos_lpc2138_sja1000/include - -ECOS_GLOBAL_CFLAGS=-mcpu=arm7tdmi -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Os -ffunction-sections -fdata-sections -fno-exceptions -finline-functions -ECOS_GLOBAL_LDFLAGS=-mcpu=arm7tdmi -Wl,--gc-sections -Wl,-static -nostdlib - -export CAN_CONTROLER_CLOCK_SPEED := 24.000 # Crystal frequency of the SJA1000 clock input. -export CAN_CONTROLER_PHASE_SHIFT_TOLERANCE := 3 #Synchronization Jump Width (SJW) (in SJA1000==> 0..3) - #To compensate for phase shifts between - #clock oscillators of different bus - # controllers, any bus controller must - #re-synchronize on any relevant signal - #edge of the current transmission. - - -OBJS = canOpenDriver.o lpc2138.o sja1000.o time_slicer.o -INCLUDE_H = applicfg.h baudrate_table.h canOpenDriver.h lpc2138.h lpc2138_defs.h \ -lpc2138_pinout.h sja1000.h time_slicer.h - -all: driver - -driver: build_baudrate $(OBJS) - -build_baudrate: - gcc -o build_baudrate build_baudrate.c - @echo "Generate The baudrate register structure in canControler.h regarding the" - @echo "SJA1000 clock speed defined in the Makefile, CAN_CONTROLER_CLOCK_SPEED" - ./build_baudrate $(CAN_CONTROLER_CLOCK_SPEED) $(CAN_CONTROLER_PHASE_SHIFT_TOLERANCE) - - -libcandriver.a: $(OBJS) - @echo " " - @echo "*********************************************" - @echo "**Building [libcandriver]" - @echo "*********************************************" - $(BINUTILS_PREFIX)ar rc $@ $(OBJS) - $(BINUTILS_PREFIX)ranlib $@ - -%o: %c - @echo " " - @echo "*********************************************" - @echo "**Compiling $< -> $@" - @echo "*********************************************" - $(CC) -g -c $(ECOS_GLOBAL_CFLAGS) $(INCLUDES) -I. -c -o $@ $< - -%o: %s - @echo " " - @echo "*********************************************" - @echo "**Compiling $< -> $@" - @echo "*********************************************" - $(CC) -c -x assembler-with-cpp $(ECOS_GLOBAL_CFLAGS) $(INCLUDES) -I. -o $@ $< - -install: - mkdir -p $(PREFIX)/lib - ln -s ../../../drivers/ecos_lpc2138_sja1000 $(PREFIX)/lib/driver - -uninstall: - rm -f ../../examples/ecos_lpc2138_sja1000/lib/driver - -clean: - rm -f $(OBJS) build_baudrate baudrate_table.h - -mrproper: clean - rm -f ../../lib/ecos_lpc2138_sja1000/libcandriver.a - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/ReadMe.txt --- a/drivers/ecos_lpc2138_sja1000/ReadMe.txt Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,247 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - ____ _ _ _ - / ___| / \ | \ | | ___ _ __ ___ _ __ -| | / _ \ | \| |/ _ \| '_ \ / _ \ '_ \ -| |___ / ___ \| |\ | (_) | |_) | __/ | | | - \____/_/ \_\_| \_|\___/| .__/ \___|_| |_| - |_| - ____ _ - / ___|__ _ _ __ __ _ __| | __ _ - | | / _` | '_ \ / _` |/ _` |/ _` | - | |__| (_| | | | | (_| | (_| | (_| | - \____\__,_|_| |_|\__,_|\__,_|\__,_| - - canfestival@canopencanada.ca -/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ - -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 -MARKETING 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 -*/ - - -CanFestival driver for the Philips ARM7 model LPC2138 , with a Philips -SJA1000 CAN controler, and running on the eCOS operating system. - -Driver Features: -Full CANfestival-3 support including: -DS-150/205: CAN Power Management Layer specification (sleep/wake-up) -DS-201: CAN low level layer -DS-301: CANopen Application layer and Communication Profile (basic CANopen specification) -DS-303-1: LED diagnostic usage (led.c) -DS-305: Layer Setting Service (lss.c) to set the baudrateand node ID in a PnP fashion. -NVRAM: Non Volatil Ram (nvram.c) Full support for internal Philips IAT programming FLASH mode - - -To use this driver, you need to proceed to do all these steps. -NB: We choose to leave this driver in .o object code to keep the capability -to make on-the-fly redefinition of some parameters for all examples. - -Step 1 ------------ -Have a developpement workstation. To build everything, we chose to use -an old AMD K6/2-300Mhz running with FreeBSD-5.2-RELEASE freely available -at http://www.freebsd.org/. -To install freebsd, download the two floppy images from -ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/5.2-RELEASE/floppies -and copy them to a simple floppy disk by typeing: - dd if=./image.dd of=/dev/fd0 - dd if=./image2.dd of=/dev/fd0 -and proceed to boot on them. -You can use Linux or Windows also or any other O/S where you can use GCC. - -on FreeBSD, you need to configure the serial port by editing the /etc/rc/serial -config file by adding this entry: - -lpc2000 () { - # Philips LPC2000 serial port configuration for 57600 bauds connection. - - ci=$1; shift - co=$1; shift - - for i in $* - do - # Lock clocal on, hupcl off. - # XON-XOFF printer - stty < /dev/ttyi${ci}${i} clocal -hupcl ixon -imaxbel -ixany -ixoff -crtscts 57600 - stty < /dev/ttyl${ci}${i} clocal hupcl - stty < /dev/cuai${co}${i} clocal -hupcl ixon -imaxbel -ixany -ixoff -crtscts 57600 - stty < /dev/cual${co}${i} clocal hupcl - done -} - -############### -lpc2000 d a 0 1 # to configure COM1 and COM2, mean, /dev/cuaa0 and /dev/cuaa1 -############### - -Step 2 ------------ -Find an upload tool to be able to flash the LPC2138. -We found the lpc2isp at the address: - - http://guest.engelschall.com/~martin/lpc21xx/isp/index.html - - You can use this upload script to call it with proper arguments. - -#!/bin/sh -lpc21isp -term -control build/terminal.hex /dev/cuaa1 57600 14746 - - -Step 3 ------------ -Proceed to build a GCC cross compiler to be able to produce ARM7TDMI compatible -binary. Go to the port directory of your FreeBSD - - cd /usr/ports/devel/arm-elf-binutils - gmake install - - cd /usr/ports/devel/arm-elf-gcc295 - gmake install - -And add the installation binary PATH to your environment variables. - - cd /etc - vi profile - - export PATH=$PATH:/usr/local/armelf/bin - - -Step 4 ------------ -Build an eCOS tree for the LPC2138. -Download eCOS from http://www.ecoscentric.com and proceed to compile -the configtool program. - - cd /usr/ports/devel/ecos-tools/ - gmake install - - untar our special package for eCOS named eCOS-OLIMEX-p2138.tgz in - the eCOS three on your files system. - -Start now your configtool for eCOS: - configtool - -Choose the right target -For our purpose, we choose to use an OLIMEX P2138 target board. -This target is not in the list, we created it from a derivative of -the OLIMEX P2106. We simply selected an other processor in the pulldown menu -of the configtool. The LPC2138. Adjust some memory capacity, and that's it. - -When all you need is properly selected in the configtool, you click on -Save_As and you suggest a name like My2138. -After, you click on Generate Build Tree. - cd My2138_build - gmake depend - gmake - gmake install - And now you have you own eCOS tree for your project in My2138_install - -Step 5 ------------ -Prepare the hardware board for this project. We chose to use an -http://www.olimex.com/ board, the P2138. -Any other LPC2138 evaluation could made the job. -On the P2138 board, we have a little area that we can use to solder -the SJA1000 controler. -See can_controler.gif to know how to solder all wires. - -Warning: If you want to use different GPIO (General Purpose Input Output) -pin to fit with your own project, -you can choose a different one, but you need -to be sure to properly define then in the lpc2138_pinout.h - -Step 6 ------------ -Put the CANfestival-3.tar.gz stuff in My2138_install/src/CANfestival-3 - cd My2138_install/src/CANfestival-3 - ./configure target=ecos-lpc2138-sja1000 - gmake - cd My2138_install/lib - ln -s My2138_install/src/CANfestival-3/src/libcanfestival.a - cd My2138_install/src - ln -s My2138_install/src/CANfestival-3/driver/ecos-lpc2138-sja1000 - -Step 7 ------------ -Now you are ready to build our demo. - cd My2138_install/src/CANfestival-3/examples/DS-406Master_ecos - gmake - - cd My2138_install/src/CANfestival-3/examples/TerminalSlave_ecos - gmake -Step 8 ------------ -To test, upload both .hex file to both targets with lpc21isp and -see the DS-406 absolut rotary encoder transmiting his absolute value to the -terminal. - - For more info about this project, see http://www.oremeq.qc.ca/ -Step 9 ------------ -For your own project, you can copy all the examples files in your own -directory and modify them. - -What is important to understand is: - -driver/ecos_lpc2138_sja1000: - - build_baudrate.c is a commande line tool to generate the proper - timing file for your sja1000 regarding your sja1000 clk. - see the Makefile for adjustment. - - canOpenDriver.c is the only link between the libcanfestival and - the hardware. - f_can_send - f_can_receive - interrupts - nvram_save/load - baudrate - - eCOS-OLIMEX-p2138.tgz eCOS package for the OLIMEX p2138 evaluation board - you have to untar that files in your eCOS three. - - sja1000.c containe only function for initialization or - configuration of the CAN controler. All this stuff is - _not_ use by the libcanfestival. You have to call them - from your main() to enable CAN with your needed configuration. - - hardware init - - lpc2138.c All the basic stuff to run the LPC2138 - iat_flash user programmable internal flash of the lpc2138 - - lpc2138_pinout.h Is your LPC2138 pinout definition. Modify this file - if you want to redefine your pinout affectation. - - time_slicer.c eCOS implementation of the CANfestival scheduler. - settimer - alarm - - applicfg.h is your configuration file for the libcanfestival - - lpc2138_pinout.h define all your GPIO to fit macros. - - -objdictedit: - Objdictedit will produce the dictionary. - Generate your dictionnary. (Or use an already made YourFile.od with - the tool: objdictgen.py - The job is to implement all functions define in the YourFIle.c in - your own project files. - -Enjoye!!!! - Canopen Canada core team - canfestival@canopencanada.ca diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/applicfg.h --- a/drivers/ecos_lpc2138_sja1000/applicfg.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -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_ECOS__ -#define __APPLICFG_ECOS__ - -#include -#include - -// 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 - -// Time unit : us -// Time resolution : 32bits -#define TIMEVAL unsigned int -#define TIMEVAL_MAX 0xffff -#define MS_TO_TIMEVAL(ms) ms*1000 -#define US_TO_TIMEVAL(us) us - -#define HANDLE int - -#if !defined(CAN_HANDLE) -#define CAN_HANDLE void* -#endif - -// 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 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/build_baudrate.c --- a/drivers/ecos_lpc2138_sja1000/build_baudrate.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -#include -#include - - -/* - CiA DS-301, p.20 -*/ -#define MAX_BIT_TIMING 9 -int table_bit_timing_settings[MAX_BIT_TIMING][3] = -{ - {1000, 8, 6}, /* baudrate, number of time quanta per bit, tsync+tseg1 */ - {800, 10, 8}, - {500, 16, 14}, - {250, 16, 14}, - {125, 16, 14}, - {100, 16, 14}, - { 50, 16, 14}, - { 25, 16, 14}, - { 10, 16, 14} -}; - - -void can_timing_registers(double f, int *v) -/* fill the vector v with the proper setting for TIMER 0 and TIMER 1 - regarding the clock and the baudrate */ -{ - int i; - - int BRP, TSEG1, TSEG2; - - double nominal, tq, tscl; - - double tclk = 1 / (f*1e6); /* sec */ - - for(i=0; i - -#include -#include - -#include -#include - -#include "applicfg.h" -#include -#include -#include -#include -#include -#include - -#include "lpc2138_pinout.h" -#include "lpc2138_defs.h" -#include "lpc2138.h" - -#include "sja1000.h" - -#include "time_slicer.h" - - -/* - SEND/RECEIVE -*/ -CAN_HANDLE canOpen(s_BOARD *board) -{ - return NULL; -} - -/***************************************************************************/ -int canClose(CAN_HANDLE fd0) -{ - return 0; -} - -UNS8 canReceive(CAN_HANDLE fd0, Message *m) -/* -Message *m : - typedef struct { - SHORT_CAN cob_id; // l'ID du mesg - UNS8 rtr; // remote transmission request. 0 if not rtr, - // 1 for a rtr message - UNS8 len; // message length (0 to 8) - UNS8 data[8]; // data - } Message; - -Fill the structure "Message" with data from the CAN receive buffer - -return : 0 -*/ -{ -/* - the sja1000 must be set to the PeliCAN mode -*/ - m->cob_id.w = sja1000_read(16) + (sja1000_read(17)<<8); // IO_PORTS_16(CAN0 + CANRCVID) >> 5 - - m->rtr = (sja1000_read(17) >> 4) & 0x01; // (IO_PORTS_8(CAN0 + CANRCVID + 1) >> 4) & 0x01; - - m->len = sja1000_read(18); - - m->data[0] = sja1000_read(19); - m->data[1] = sja1000_read(20); - m->data[2] = sja1000_read(21); - m->data[3] = sja1000_read(22); - m->data[4] = sja1000_read(23); - m->data[5] = sja1000_read(24); - m->data[6] = sja1000_read(25); - m->data[7] = sja1000_read(26); - - sja1000_write(CMR, 1<cob_id.w & 0xff); - sja1000_write(17, (m->cob_id.w >> 8) & 0xff); - sja1000_write(18, m->len); - - sja1000_write(19, m->data[0]); // tx data 1 - sja1000_write(20, m->data[1]); // tx data 2 - sja1000_write(21, m->data[2]); // tx data 3 - sja1000_write(22, m->data[3]); // tx data 4 - sja1000_write(23, m->data[4]); // tx data 5 - sja1000_write(24, m->data[5]); // tx data 6 - sja1000_write(25, m->data[6]); // tx data 7 - sja1000_write(26, m->data[7]); // tx data 8 - - sja1000_write(CMR,( (0< NVRAM_MAX_SIZE) - data_addr = NVRAM_BLOCK_SIZE; -} - -int _get_data_len(int type) -{ - int len = 0; /* number of bytes */ - switch(type) - { - case boolean: - len = 1; - break; - - case int8: - case uint8: - len = 1; - break; - case int16: - case uint16: - len = 2; - break; - case int24: - case uint24: - len = 3; - break; - case int32: - case uint32: - case real32: - len = 4; - break; - case int40: - case uint40: - len = 5; - break; - case int48: - case uint48: - len = 6; - break; - case int56: - case uint56: - len = 7; - break; - case int64: - case uint64: - case real64: - len = 8; - break; -#if 0 -/* TO DO */ - case visible_string: - case octet_string: - case unicode_string: - case time_of_day: - case time_difference: -#endif - } - - return len; -} - - -char nvram_write_data(int type, int access_attr, void *data) -/* return 0 if successfull */ -{ - int len = _get_data_len(type); - - if (data_len+len > NVRAM_BLOCK_SIZE) - { - iat_flash_write_page(data_addr); - data_len = 0; - data_addr += NVRAM_BLOCK_SIZE; - - /* wrap-around address pointer */ - if (data_addr > NVRAM_MAX_SIZE) - data_addr = NVRAM_BLOCK_SIZE; - - data_num_pages++; - } - - memcpy(((char *)data_page)+data_len, data, len); - - data_len += len; - - return 0; -} - - -char nvram_read_data(int type, int access_attr, void *data) -/* return 0 if successful */ -{ - int len = _get_data_len(type); - - if (data_len+len > NVRAM_BLOCK_SIZE) - { - data_addr += NVRAM_BLOCK_SIZE; - - /* wrap-around address pointer */ - if (data_addr > NVRAM_MAX_SIZE) - data_addr = NVRAM_BLOCK_SIZE; - - iat_flash_read_page(data_addr); - data_len = 0; - } - - memcpy(data, ((char *)data_page)+data_len, len); - - data_len += len; - - return 0; -} - -/* - NVRAM registers at block 0 - pos description - 0 version of the current dictionnary - 1 starting address for data block - 2 date of last writing - 3 address of the previous dictionnary - 4 size in pages of the current dict -*/ -void nvram_write_reg(UNS32 reg, UNS16 pos) -/* write reg at the position in the data block 0 */ -{ - regs_page[pos] = reg; -} - -UNS32 nvram_read_reg(UNS16 pos) -/* read reg at the position in the data block 0 */ -{ - return regs_page[pos]; -} - - -/* - LED -*/ - -void led_set_redgreen(UNS8 bits) -/* bits : each bit of this uns8 is assigned a led - 0=off, 1=on -*/ -{ - lpc2138_redgreenled_set(bits); -} - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/lpc2138.c --- a/drivers/ecos_lpc2138_sja1000/lpc2138.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,373 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: Christian Fortin (canfestival@canopencanada.ca) - -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 -*/ - -#include -#include - -#include "applicfg.h" -// #include "objdictdef.h" - -#include "lpc2138_pinout.h" -#include "lpc2138_defs.h" -#include "lpc2138.h" - -#define IAP_LOCATION 0x7ffffff1 - -// define a page of data of 256 bytes -// -short data_len; /* 0 to 256 bytes */ -unsigned int *data_page = NULL; -unsigned int data_addr; - -// local definitons -void ee_erase(unsigned int ,unsigned int[]); //function erases EEPROM -void ee_write_page(unsigned int); //function adds a record in EEPROM -void ee_read_page(unsigned int); //function reads the latest valid record in EEPROM - -typedef void (*IAP)(unsigned int [],unsigned int[]); -IAP iap_entry; - - -/***************************************************************************************/ - -void lpc2138_pinsel_set(int pin, LPC2138_PORT port, int size, int func) -{ - int i; - - for (i = 0; i < size; pin++, i++) - { - /* 2 bits par broche. */ - int shift = (pin - ((pin < 16) ? 0 : 16)) << 1; - - REG32_ADDR pinsel = (port == 1) ? - (REG32_ADDR) P1_PINSEL2_ADDR : ((pin < 16) ? - (REG32_ADDR) P0_PINSEL0_ADDR : (REG32_ADDR) P0_PINSEL1_ADDR); - - *pinsel = (*pinsel & ~(BITMASK_2 << shift)) | (func << shift); - } -} - -void lpc2138_pinsel_clear() -{ - P0_PINSEL0 = 0x00000000; - P0_PINSEL1 = 0x00000000; - P1_PINSEL2 = 0x00000000; -} - - -int lpc2138_printf(void) -{ - return lpc2138_fprintf(stdout); -} - - -int lpc2138_printf_pins(void) -{ - return lpc2138_fprintf_pins(stdout); -} - - -int lpc2138_fprintf(FILE *stream) -{ - return fprintf(stream, - "[p0=0x%08X,p0_iodir=0x%08X,p0_pinsel0=0x%08X,p0_pinsel1=0x%08X," \ - "p1=0x%08X,p1_iodir=0x%08X,p1_pinsel2=0x%08X]", - P0_IOPIN, P0_IODIR, P0_PINSEL0, P0_PINSEL1, - P1_IOPIN, P1_IODIR, P1_PINSEL2); -} - -int lpc2138_fprintf_pins(FILE *stream) -{ - return fprintf(stream, - "[cs_s1d13706=0x%X," \ - "cs_sja1000=0x%X," \ - "wait=0x%X," \ - "bhe=0x%X," \ - "interrupt_sja1000=0x%X," \ - "redgreenled=0x%X," \ - "ale=0x%X," \ - "rd=0x%X," \ - "wr=0x%X," \ - "data=0x%X," \ - "addresses=0x%X]", - lpc2138_cs_s1d13706_get(), - lpc2138_cs_sja1000_get(), - lpc2138_wait_get(), - lpc2138_bhe_get(), - lpc2138_redgreenled_get(), - lpc2138_interrupt_sja1000_get(), - lpc2138_ale_get(), - lpc2138_rd_get(), - lpc2138_wr_get(), - lpc2138_data_get(), - lpc2138_addresses_get()); -} - - -/* - SJA1000 interface -*/ - -unsigned char sja1000_read(unsigned char addr8) -{ - unsigned char data; - - lpc2138_data_set_mode(LPC2138_MODE_OUTPUT); - lpc2138_ale_set(1); - lpc2138_data_set(addr8); - - lpc2138_ale_set(0); - lpc2138_data_set_mode(LPC2138_MODE_INPUT); - - lpc2138_cs_sja1000_set(0); - lpc2138_rd_set(0); - data = lpc2138_data_get(); - data = lpc2138_data_get(); - - lpc2138_rd_set(1); - - lpc2138_cs_sja1000_set(1); - lpc2138_data_set_mode(LPC2138_MODE_OUTPUT); - - return data; -} - - -void sja1000_write(unsigned char addr8, unsigned char data) -{ - lpc2138_data_set_mode(LPC2138_MODE_OUTPUT); - - lpc2138_data_set(addr8); - - lpc2138_ale_set(1); - - lpc2138_ale_set(0); - lpc2138_cs_sja1000_set(0); - lpc2138_wr_set(0); - - lpc2138_data_set(data); - - lpc2138_wr_set(1); - lpc2138_cs_sja1000_set(1); - -} - -/* - FLASH interface -*/ - -/************************************************************************/ -/* */ -/* function: */ -/* void ee_erase(unsigned int command_ee,unsigned int result_ee[]) */ -/* */ -/* type: void */ -/* */ -/* parameters: */ -/* command_ee - Not used. */ -/* result_ee[0] - Returns a response to the last IAP command used. */ -/* 0 - EEPROM successfully erased. */ -/* For all other response values, see microcontroller */ -/* User Manual, IAP Commands and Status Codes Summary. */ -/* result_ee[1] - Not used. */ -/* */ -/* version: 1.1 (01/27/2006) */ -/* */ -/* constants defined in LPC2k_ee.h used in this function: */ -/* EE_SEC_L - microcontroller's Flash sector where EEPROM begins */ -/* EE_SEC_H - microcontroller's Flash sector where EEPROM ends */ -/* EE_CCLK - microcontroller's system clock (cclk) */ -/* */ -/* description: */ -/* This function erases LPC2000 on-chip Flash sectors selected to act */ -/* as an EEPROM. All Flash sectors between EE_SEC_L abd EE_SEC_H */ -/* (including these sectors) will be erased using the In Application */ -/* Programming (IAP) routines (see User Manual for more details). */ -/* Also, this function disables all interrupts while erasing the */ -/* EEPROM. If this is not needed, three lines of the ee_erase */ -/* subroutine can simply be commented-out without affecting the */ -/* routine performance at all. */ -/* */ -/* revision history: */ -/* - Rev. 1.1 adds interrupt disable feature. */ -/* */ -/************************************************************************/ -void iat_flash_erase(unsigned int command_ee,unsigned int result_ee[]) -{ - unsigned int command_iap[5]; - unsigned int result_iap[3]; - unsigned long int enabled_interrupts; - - enabled_interrupts = VICIntEnable; //disable all interrupts - VICIntEnClr = enabled_interrupts; - - command_iap[0]=50; // prepare sectors from EE_SEC_L to EE_SEC_H for erase - command_iap[1]=EE_SEC_L; - command_iap[2]=EE_SEC_H; - iap_entry=(IAP) IAP_LOCATION; - iap_entry(command_iap,result_iap); - - command_iap[0]=52; // erase sectors from EE_SEC_L to EE_SEC_H - command_iap[1]=EE_SEC_L; - command_iap[2]=EE_SEC_H; - command_iap[3]=EE_CCLK; - iap_entry=(IAP) IAP_LOCATION; - iap_entry(command_iap,result_iap); - - command_iap[0]=53; // blankcheck sectors from EE_SEC_L to EE_SEC_H - command_iap[1]=EE_SEC_L; - command_iap[2]=EE_SEC_H; - iap_entry=(IAP) IAP_LOCATION; - iap_entry(command_iap,result_iap); - - VICIntEnable = enabled_interrupts; //restore interrupt enable register - - result_ee[0]=result_iap[0]; - return; -} - -/************************************************************************/ -/* */ -/* function: */ -/* void ee_write(unsigned int command_ee,unsigned int result_ee[]) */ -/* */ -/* type: void */ -/* */ -/* parameters: */ -/* command_ee - An address of a content of ee_data type that has */ -/* to be programmed into EEPROM. */ -/* result_ee[0] - Returns a response to the last IAP command used. */ -/* 0 - data successfully programmed in EEPROM. */ -/* 501 - no space in EEPROM to program data. */ -/* For all other response values, see microcontroller */ -/* User Manual, IAP Commands and Status Codes Summary. */ -/* result_ee[1] - Not used. */ -/* */ -/* version: 1.1 (01/27/2006) */ -/* */ -/* constants defined in LPC2k_ee.h used in this function: */ -/* EE_BUFFER_SIZE - IAP buffer size; must be 256 or 512 */ -/* NO_SPACE_IN_EEPROM - EEPROM is full and no data can be programmed */ -/* EE_BUFFER_MASK - parameter used for interfacing with IAP */ -/* EE_REC_SIZE - ee_data structure size in bytes */ -/* EE_SEC_L - micro's Flash sector where EEPROM begins */ -/* EE_SEC_H - micro's Flash sector where EEPROM ends */ -/* EE_CCLK - micro's system clock (cclk) */ -/* */ -/* description: */ -/* This function writes a single structure of ee_data type into the */ -/* EEPROM using an In Application Programming (IAP) routines (see */ -/* User Manual for more details). command_ee contains an address of */ -/* this structure. EEPROM is scanned for the last (if any) record */ -/* identifier (EE_REC_ID), and a new record is added next to it. */ -/* Also, this function disables all interrupts while erasing the */ -/* EEPROM. If this is not needed, three lines of the ee_write */ -/* subroutine can simply be commented-out without affecting the */ -/* routine performance at all. */ -/* */ -/* revision history: */ -/* - Rev. 1.1 fixes a bug related to verifying a content written into */ -/* the EEPROM. 1.0 was reporting missmatch even when there were no */ -/* problems at all. */ -/* Rev. 1.1 adds interrupt disable feature. */ -/* */ -/************************************************************************/ - -void iat_flash_write_page(unsigned int addr) -{ - unsigned long int enabled_interrupts; - // unsigned char ee_buffer[16]; - unsigned int command_iap[5], result_iap[3]; - - enabled_interrupts = VICIntEnable; //disable all interrupts - VICIntEnClr = enabled_interrupts; - - iap_entry = (IAP) IAP_LOCATION; - - // prepare sectors from EE_SEC_L to EE_SEC_H for erase - command_iap[0] = 50; - command_iap[1] = EE_SEC_L; - command_iap[2] = EE_SEC_H; - iap_entry(command_iap, result_iap); - - // copy RAM to flash/eeprom - command_iap[0] = 51; - command_iap[1] = (unsigned int) (addr & EE_START_MASK); // 256 kb boundary - command_iap[2] = (unsigned int) (data_page); // should be on a word boundary - command_iap[3] = 256; - command_iap[4] = EE_CCLK; - iap_entry(command_iap, result_iap); - -#if 0 - // compare RAM and flash/eeprom - command_iap[0] = 56; - command_iap[1] = (unsigned int) data; - command_iap[2] = addr; - command_iap[3] = dlen; - iap_entry(command_iap, result_iap); -#endif - - VICIntEnable = enabled_interrupts; //restore interrupt enable register -} - - -/************************************************************************/ -/* */ -/* function: */ -/* void ee_read(unsigned int command_ee,unsigned int result_ee[]) */ -/* */ -/* type: void */ -/* */ -/* parameters: */ -/* command_ee - Not used. */ -/* result_ee[0] - Returns a response. */ -/* 0 - data successfully found in EEPROM. */ -/* 500 - no data/records available in EEPROM. */ -/* result_ee[1] - an address of the last record of ee_data type */ -/* in EEPROM. */ -/* */ -/* version: 1.1 (01/27/2006) */ -/* */ -/* constants defined in LPC2k_ee.h used in this function: */ -/* NO_RECORDS_AVAILABLE - EEPROM is empty/no records identifiable */ -/* with a record identifier (EE_REC_ID) found */ -/* EE_ADR_L - micro's Flash address from where EEPROM begins */ -/* EE_REC_SIZE - size (in bytes) of a ee_data structure */ -/* */ -/* description: */ -/* This function scans an EEPROM content looking for the last record */ -/* that can be identified with a record identifier (EE_REC_ID). When */ -/* such data is found, its address is passed as result_ee[1]. */ -/* */ -/* revision history: */ -/* - Rev. 1.0 had problems with accessing the last record in a fully */ -/* occupied EEPROM. Rev. 1.1 fixes this. */ -/* */ -/************************************************************************/ -void iat_flash_read_page(unsigned int addr) -{ - memcpy(data_page, (unsigned int *)addr, sizeof(unsigned int)*64); -} - - - - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/lpc2138.h --- a/drivers/ecos_lpc2138_sja1000/lpc2138.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: Christian Fortin (canfestival@canopencanada.ca) - -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 -*/ - - -#if !defined(_LPC2138_H_) -#define _LPC2138_H_ - - -/* block and maximum size of NVRRAM in bytes */ -#define NVRAM_BLOCK_SIZE 256 -#define NVRAM_MAX_SIZE 1024*512 - -extern short data_len; -extern short data_num_pages; -extern unsigned int *data_page; -extern unsigned int data_addr; - -extern unsigned int *regs_page; - -void lpc2138_pinsel_set(int pin, LPC2138_PORT port, int size, int func); -void lpc2138_pinsel_clear(void); - -int lpc2138_printf(void); -int lpc2138_printf_pins(void); - -int lpc2138_fprintf(FILE *stream); -int lpc2138_fprintf_pins(FILE *stream); - -unsigned char sja1000_read(unsigned char addr8); -void sja1000_write(unsigned char addr8, unsigned char data); - -void iat_flash_erase(unsigned int command_ee,unsigned int result_ee[]); -void iat_flash_write_page(unsigned int addr); -void iat_flash_read_page(unsigned int addr); - -void iat_flash_write_regs(void); -void iat_flash_read_regs(void); - -#endif - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/lpc2138_defs.h --- a/drivers/ecos_lpc2138_sja1000/lpc2138_defs.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,529 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: Christian Fortin (canfestival@canopencanada.ca) - -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 -*/ - -/** - * Définitions pour le LPC2138. - */ - -#if !defined(_LPC2138_DEF_H_) -#define _LPC2138_DEF_H_ - -#include - -// #include "types.h" - -#define BITMASK_0 0x00000000 -#define BITMASK_1 0x00000001 -#define BITMASK_2 0x00000003 -#define BITMASK_4 0x0000000F -#define BITMASK_8 0x000000FF -#define BITMASK_16 0x0000FFFF -#define BITMASK_32 0xFFFFFFFF - -typedef volatile unsigned char REG8; -typedef volatile unsigned char *REG8_ADDR; -typedef volatile unsigned short REG16; -typedef volatile unsigned short *REG16_ADDR; -typedef volatile unsigned int REG32; -typedef volatile unsigned int *REG32_ADDR; - - -#define SET_EQ_SET = -#define SET_EQ_CLR = - -#define P0_IOPIN_ADDR 0xE0028000 -#define P0_IOSET_ADDR 0xE0028004 -#define P0_IODIR_ADDR 0xE0028008 -#define P0_IOCLR_ADDR 0xE002800C -#define P0_PINSEL0_ADDR 0xE002C000 -#define P0_PINSEL1_ADDR 0xE002C004 - -#define P1_IOPIN_ADDR 0xE0028010 -#define P1_IOSET_ADDR 0xE0028014 -#define P1_IODIR_ADDR 0xE0028018 -#define P1_IOCLR_ADDR 0xE002801C -#define P1_PINSEL2_ADDR 0xE002C014 - -#define DACR_ADDR 0xE006C000 - -/* Vectored Interrupt Controller (VIC) */ -#define VICVectAddr_ADDR 0xFFFFF030 -#define VICVectAddr0_ADDR 0xFFFFF100 -#define VICVectCntl0_ADDR 0xFFFFF200 -#define VICIntEnable_ADDR 0xFFFFF010 - -/* External Interrupts */ -#define EXTINT_ADDR 0xE01FC140 -#define INTWAKE_ADDR 0xE01FC144 -#define EXTMODE_ADDR 0xE01FC148 -#define EXTPOLAR_ADDR 0xE01FC14C - -#ifdef TEST -#include "test_stubs.h" -#endif - -/* Vectored Interrupt Controller (VIC) */ -#define VICIRQStatus (*((REG32_ADDR) 0xFFFFF000)) -#define VICFIQStatus (*((REG32_ADDR) 0xFFFFF004)) -#define VICRawIntr (*((REG32_ADDR) 0xFFFFF008)) -#define VICIntSelect (*((REG32_ADDR) 0xFFFFF00C)) -#define VICIntEnable (*((REG32_ADDR) 0xFFFFF010)) -#define VICIntEnClr (*((REG32_ADDR) 0xFFFFF014)) -#define VICSoftInt (*((REG32_ADDR) 0xFFFFF018)) -#define VICSoftIntClr (*((REG32_ADDR) 0xFFFFF01C)) -#define VICProtection (*((REG32_ADDR) 0xFFFFF020)) -#define VICVectAddr (*((REG32_ADDR) 0xFFFFF030)) -#define VICDefVectAddr (*((REG32_ADDR) 0xFFFFF034)) -#define VICVectAddr0 (*((REG32_ADDR) 0xFFFFF100)) -#define VICVectAddr1 (*((REG32_ADDR) 0xFFFFF104)) -#define VICVectAddr2 (*((REG32_ADDR) 0xFFFFF108)) -#define VICVectAddr3 (*((REG32_ADDR) 0xFFFFF10C)) -#define VICVectAddr4 (*((REG32_ADDR) 0xFFFFF110)) -#define VICVectAddr5 (*((REG32_ADDR) 0xFFFFF114)) -#define VICVectAddr6 (*((REG32_ADDR) 0xFFFFF118)) -#define VICVectAddr7 (*((REG32_ADDR) 0xFFFFF11C)) -#define VICVectAddr8 (*((REG32_ADDR) 0xFFFFF120)) -#define VICVectAddr9 (*((REG32_ADDR) 0xFFFFF124)) -#define VICVectAddr10 (*((REG32_ADDR) 0xFFFFF128)) -#define VICVectAddr11 (*((REG32_ADDR) 0xFFFFF12C)) -#define VICVectAddr12 (*((REG32_ADDR) 0xFFFFF130)) -#define VICVectAddr13 (*((REG32_ADDR) 0xFFFFF134)) -#define VICVectAddr14 (*((REG32_ADDR) 0xFFFFF138)) -#define VICVectAddr15 (*((REG32_ADDR) 0xFFFFF13C)) -#define VICVectCntl0 (*((REG32_ADDR) 0xFFFFF200)) -#define VICVectCntl1 (*((REG32_ADDR) 0xFFFFF204)) -#define VICVectCntl2 (*((REG32_ADDR) 0xFFFFF208)) -#define VICVectCntl3 (*((REG32_ADDR) 0xFFFFF20C)) -#define VICVectCntl4 (*((REG32_ADDR) 0xFFFFF210)) -#define VICVectCntl5 (*((REG32_ADDR) 0xFFFFF214)) -#define VICVectCntl6 (*((REG32_ADDR) 0xFFFFF218)) -#define VICVectCntl7 (*((REG32_ADDR) 0xFFFFF21C)) -#define VICVectCntl8 (*((REG32_ADDR) 0xFFFFF220)) -#define VICVectCntl9 (*((REG32_ADDR) 0xFFFFF224)) -#define VICVectCntl10 (*((REG32_ADDR) 0xFFFFF228)) -#define VICVectCntl11 (*((REG32_ADDR) 0xFFFFF22C)) -#define VICVectCntl12 (*((REG32_ADDR) 0xFFFFF230)) -#define VICVectCntl13 (*((REG32_ADDR) 0xFFFFF234)) -#define VICVectCntl14 (*((REG32_ADDR) 0xFFFFF238)) -#define VICVectCntl15 (*((REG32_ADDR) 0xFFFFF23C)) - -#define P0_IOPIN (*((REG32_ADDR) P0_IOPIN_ADDR)) -#define P0_IOSET (*((REG32_ADDR) P0_IOSET_ADDR)) -#define P0_IODIR (*((REG32_ADDR) P0_IODIR_ADDR)) -#define P0_IOCLR (*((REG32_ADDR) P0_IOCLR_ADDR)) -#define P0_PINSEL0 (*((REG32_ADDR) P0_PINSEL0_ADDR)) -#define P0_PINSEL1 (*((REG32_ADDR) P0_PINSEL1_ADDR)) - -#define P1_IOPIN (*((REG32_ADDR) P1_IOPIN_ADDR)) -#define P1_IOSET (*((REG32_ADDR) P1_IOSET_ADDR)) -#define P1_IODIR (*((REG32_ADDR) P1_IODIR_ADDR)) -#define P1_IOCLR (*((REG32_ADDR) P1_IOCLR_ADDR)) -#define P1_PINSEL2 (*((REG32_ADDR) P1_PINSEL2_ADDR)) - -#define DACR (*((REG32_ADDR) DACR_ADDR)) - -/* External Interrupts */ -#define EXTINT (*((REG32_ADDR) EXTINT_ADDR)) -#define INTWAKE (*((REG32_ADDR) INTWAKE_ADDR)) -#define EXTMODE (*((REG32_ADDR) EXTMODE_ADDR)) -#define EXTPOLAR (*((REG32_ADDR) EXTPOLAR_ADDR)) - - -/* Timer 0 */ -#define T0IR (*((REG32_ADDR) 0xE0004000)) -#define T0TCR (*((REG32_ADDR) 0xE0004004)) -#define T0TC (*((REG32_ADDR) 0xE0004008)) -#define T0PR (*((REG32_ADDR) 0xE000400C)) -#define T0PC (*((REG32_ADDR) 0xE0004010)) -#define T0MCR (*((REG32_ADDR) 0xE0004014)) -#define T0MR0 (*((REG32_ADDR) 0xE0004018)) -#define T0MR1 (*((REG32_ADDR) 0xE000401C)) -#define T0MR2 (*((REG32_ADDR) 0xE0004020)) -#define T0MR3 (*((REG32_ADDR) 0xE0004024)) -#define T0CCR (*((REG32_ADDR) 0xE0004028)) -#define T0CR0 (*((REG32_ADDR) 0xE000402C)) -#define T0CR1 (*((REG32_ADDR) 0xE0004030)) -#define T0CR2 (*((REG32_ADDR) 0xE0004034)) -#define T0CR3 (*((REG32_ADDR) 0xE0004038)) -#define T0EMR (*((REG32_ADDR) 0xE000403C)) -#define T0CTCR (*((REG32_ADDR) 0xE0004070)) - -/* Timer 1 */ -#define T1IR (*((REG32_ADDR) 0xE0008000)) -#define T1TCR (*((REG32_ADDR) 0xE0008004)) -#define T1TC (*((REG32_ADDR) 0xE0008008)) -#define T1PR (*((REG32_ADDR) 0xE000800C)) -#define T1PC (*((REG32_ADDR) 0xE0008010)) -#define T1MCR (*((REG32_ADDR) 0xE0008014)) -#define T1MR0 (*((REG32_ADDR) 0xE0008018)) -#define T1MR1 (*((REG32_ADDR) 0xE000801C)) -#define T1MR2 (*((REG32_ADDR) 0xE0008020)) -#define T1MR3 (*((REG32_ADDR) 0xE0008024)) -#define T1CCR (*((REG32_ADDR) 0xE0008028)) -#define T1CR0 (*((REG32_ADDR) 0xE000802C)) -#define T1CR1 (*((REG32_ADDR) 0xE0008030)) -#define T1CR2 (*((REG32_ADDR) 0xE0008034)) -#define T1CR3 (*((REG32_ADDR) 0xE0008038)) -#define T1EMR (*((REG32_ADDR) 0xE000803C)) -#define T1CTCR (*((REG32_ADDR) 0xE0008070)) - -/* Real Time Clock */ -#define ILR (*((REG8_ADDR) 0xE0024000)) -#define CTC (*((REG16_ADDR) 0xE0024004)) -#define CCR (*((REG8_ADDR) 0xE0024008)) -#define CIIR (*((REG8_ADDR) 0xE002400C)) -#define AMR (*((REG8_ADDR) 0xE0024010)) -#define CTIME0 (*((REG32_ADDR) 0xE0024014)) -#define CTIME1 (*((REG32_ADDR) 0xE0024018)) -#define CTIME2 (*((REG32_ADDR) 0xE002401C)) -#define SEC (*((REG8_ADDR) 0xE0024020)) -#define MIN (*((REG8_ADDR) 0xE0024024)) -#define HOUR (*((REG8_ADDR) 0xE0024028)) -#define DOM (*((REG8_ADDR) 0xE002402C)) -#define DOW (*((REG8_ADDR) 0xE0024030)) -#define DOY (*((REG16_ADDR) 0xE0024034)) -#define MONTH (*((REG8_ADDR) 0xE0024038)) -#define YEAR (*((REG16_ADDR) 0xE002403C)) -#define ALSEC (*((REG8_ADDR) 0xE0024060)) -#define ALMIN (*((REG8_ADDR) 0xE0024064)) -#define ALHOUR (*((REG8_ADDR) 0xE0024068)) -#define ALDOM (*((REG8_ADDR) 0xE002406C)) -#define ALDOW (*((REG8_ADDR) 0xE0024070)) -#define ALDOY (*((REG16_ADDR) 0xE0024074)) -#define ALMON (*((REG8_ADDR) 0xE0024078)) -#define ALYEAR (*((REG16_ADDR) 0xE002407C)) -#define PREINT (*((REG16_ADDR) 0xE0024080)) -#define PREFRAC (*((REG16_ADDR) 0xE0024084)) - -/* SPI Registers */ -#define S0SPCR (*((REG32_ADDR) 0xE0020000)) -#define S0SPSR (*((REG32_ADDR) 0xE0020004)) -#define S0SPDR (*((REG32_ADDR) 0xE0020008)) -#define S0SPCCR (*((REG32_ADDR) 0xE002000C)) -#define S0SPINT (*((REG32_ADDR) 0xE002001C)) - -/* SSP Registers */ -#define SSPCR0 (*((REG32_ADDR) 0xE0068000)) -#define SSPCR1 (*((REG32_ADDR) 0xE0068004)) -#define SSPDR (*((REG32_ADDR) 0xE0068008)) -#define SSPSR (*((REG32_ADDR) 0xE006800C)) -#define SSPCPSR (*((REG32_ADDR) 0xE0068010)) -#define SSPIMSC (*((REG32_ADDR) 0xE0068014)) -#define SSPRIS (*((REG32_ADDR) 0xE0068018)) -#define SSPMIS (*((REG32_ADDR) 0xE006801C)) -#define SSPICR (*((REG32_ADDR) 0xE0068020)) - - -typedef enum { - LPC2138_MODE_INPUT = 0, - LPC2138_MODE_OUTPUT = 1 -} LPC2138_MODE; - -typedef enum { - P0 = 0, - P1 = 1 -} LPC2138_PORT; - -/* === Fonctions "#define" génériques ======================================= */ - -#define _cat(a, b) a##b -#define _CAT(a, b) _cat(a, b) - -#define _PIN(pin) LPC2138_##pin -#define _PORT(pin) LPC2138_##pin##_PORT -#define _SIZE(pin) LPC2138_##pin##_SIZE - -/* ((P[0|1]_IOPIN >> pin) & BITMASK_[0-32]) */ -#define lpc2138_get(pin) \ - ((_CAT(_PORT(pin), _IOPIN) >> _PIN(pin)) & _CAT(BITMASK_, _SIZE(pin))) - -#define lpc2138_set(pin, i) \ - { if (_SIZE(pin) == 1) { lpc2138_set_bit(pin, i); } \ - else { lpc2138_set_all(pin, i); } } - -#define lpc2138_set_bit(pin, i) \ - { if ((i) == 1) { _CAT(_PORT(pin), _IOSET) SET_EQ_SET (1 << _PIN(pin)); } \ - else { _CAT(_PORT(pin), _IOCLR) SET_EQ_CLR (1 << _PIN(pin)); } } - -#define lpc2138_set_all(pin, i) \ - (_CAT(_PORT(pin), _IOPIN) = \ - (_CAT(_PORT(pin), _IOPIN) & \ - ~(_CAT(BITMASK_, _SIZE(pin)) << _PIN(pin))) | ((i) << _PIN(pin))) - -/* Identique à lpc2138_set(p, f, nbits, i) sans effet secondaire (plus lent). */ -#define lpc2138_set_SAFE_(pin, i) \ - ((_SIZE(pin) == 1) && lpc2138_set_bit_SAFE_(pin, (i)) || \ - lpc2138_set_all(pin, (i))) - -/* Identique à lpc2138_set_bit(p, f, i) sans effet secondaire (plus lent). */ -#define lpc2138_set_bit_SAFE_(pin, i) \ - ((i == 1) && (_CAT(_PORT(pin), _IOSET) SET_EQ_SET (1 << _PIN(pin))) || \ - (_CAT(_PORT(pin), _IOCLR) SET_EQ_CLR (1 << _PIN(pin)))) - -#define lpc2138_set_mode(pin, mode) \ - (_CAT(_PORT(pin), _IODIR) = (mode == LPC2138_MODE_OUTPUT) ? \ - (_CAT(_PORT(pin), _IODIR)|(_CAT(BITMASK_, _SIZE(pin)) << _PIN(pin))) : \ - (_CAT(_PORT(pin), _IODIR) & ~(_CAT(BITMASK_, _SIZE(pin)) << _PIN(pin)))) - -#define lpc2138_set_pinsel(pin, func) \ - lpc2138_pinsel_set(_PIN(pin), _PORT(pin), _SIZE(pin), func) - -/* === Fonctions pinout "#define" par défaut ================================ */ - -#ifndef lpc2138_uart0_tx_set_pinsel -#define lpc2138_uart0_tx_set_pinsel(func) lpc2138_set_pinsel(uart0_tx, func) -#endif - -#ifndef lpc2138_uart0_rx_set_pinsel -#define lpc2138_uart0_rx_set_pinsel(func) lpc2138_set_pinsel(uart0_rx, func) -#endif - -#ifndef lpc2138_cs_s1d13706_get -#define lpc2138_cs_s1d13706_get() lpc2138_get (cs_s1d13706) -#endif - -#ifndef lpc2138_cs_s1d13706_set -#define lpc2138_cs_s1d13706_set(i) lpc2138_set (cs_s1d13706, i) -#endif - -#ifndef lpc2138_cs_s1d13706_set_mode -#define lpc2138_cs_s1d13706_set_mode(mode) lpc2138_set_mode (cs_s1d13706, mode) -#endif - -#ifndef lpc2138_cs_s1d13706_set_pinsel -#define lpc2138_cs_s1d13706_set_pinsel(func) lpc2138_set_pinsel(cs_s1d13706, func) -#endif - -#ifndef lpc2138_cs_sja1000_get -#define lpc2138_cs_sja1000_get() lpc2138_get (cs_sja1000) -#endif - -#ifndef lpc2138_cs_sja1000_set -#define lpc2138_cs_sja1000_set(i) lpc2138_set (cs_sja1000, i) -#endif - -#ifndef lpc2138_cs_sja1000_set_mode -#define lpc2138_cs_sja1000_set_mode(mode) lpc2138_set_mode (cs_sja1000, mode) -#endif - -#ifndef lpc2138_cs_sja1000_set_pinsel -#define lpc2138_cs_sja1000_set_pinsel(func) lpc2138_set_pinsel(cs_sja1000, func) -#endif - -#ifndef lpc2138_wait_get -#define lpc2138_wait_get() lpc2138_get (wait) -#endif - -#ifndef lpc2138_wait_set -#define lpc2138_wait_set(i) lpc2138_set (wait, i) -#endif - -#ifndef lpc2138_wait_set_mode -#define lpc2138_wait_set_mode(mode) lpc2138_set_mode (wait, mode) -#endif - -#ifndef lpc2138_wait_set_pinsel -#define lpc2138_wait_set_pinsel(func) lpc2138_set_pinsel(wait, func) -#endif - -#ifndef lpc2138_bhe_get -#define lpc2138_bhe_get() lpc2138_get (bhe) -#endif - -#ifndef lpc2138_bhe_set -#define lpc2138_bhe_set(i) lpc2138_set (bhe, i) -#endif - -#ifndef lpc2138_bhe_set_mode -#define lpc2138_bhe_set_mode(mode) lpc2138_set_mode (bhe, mode) -#endif - -#ifndef lpc2138_bhe_set_pinsel -#define lpc2138_bhe_set_pinsel(func) lpc2138_set_pinsel(bhe, func) -#endif - -#ifndef lpc2138_interrupt_sja1000_get -#define lpc2138_interrupt_sja1000_get() lpc2138_get (interrupt_sja1000) -#endif - -#ifndef lpc2138_interrupt_sja1000_set -#define lpc2138_interrupt_sja1000_set(i) lpc2138_set (interrupt_sja1000, i) -#endif - -#ifndef lpc2138_interrupt_sja1000_set_mode -#define lpc2138_interrupt_sja1000_set_mode(mode) lpc2138_set_mode (interrupt_sja1000, mode) -#endif - -#ifndef lpc2138_interrupt_sja1000_set_pinsel -#define lpc2138_interrupt_sja1000_set_pinsel(func) lpc2138_set_pinsel(interrupt_sja1000, func) -#endif - -#ifndef lpc2138_redgreenled_get -#define lpc2138_redgreenled_get() lpc2138_get (redgreenled) -#endif - -#ifndef lpc2138_redgreenled_set -#define lpc2138_redgreenled_set(i) lpc2138_set (redgreenled, i) -#endif - -#ifndef lpc2138_redgreenled_set_mode -#define lpc2138_redgreenled_set_mode(mode) lpc2138_set_mode (redgreenled, mode) -#endif - -#ifndef lpc2138_redgreenled_set_pinsel -#define lpc2138_redgreenled_set_pinsel(func) lpc2138_set_pinsel(redgreenled, func) -#endif - -#ifndef lpc2138_dac0_set -#define lpc2138_dac0_set() lpc2138_set (dac0, i) -#endif - -#ifndef lpc2138_dac0_set_value -#define lpc2138_dac0_set_value(i) DACR = ((1 << 16) | ((i & 0x3FF) << 6)) -#endif - -#ifndef lpc2138_dac0_set_pinsel -#define lpc2138_dac0_set_pinsel(func) lpc2138_set_pinsel(dac0, func) -#endif - -#ifndef lpc2138_spi0_set -#define lpc2138_spi0_set() lpc2138_set (spi0, i) -#endif - -#ifndef lpc2138_spi0_set_value -#define lpc2138_spi0_set_value(i) SSPDR = i -#endif - -#ifndef lpc2138_spi0_set_pinsel -#define lpc2138_spi0_set_pinsel(func) lpc2138_set_pinsel(spi0, func) -#endif - -#ifndef lpc2138_ale_get -#define lpc2138_ale_get() lpc2138_get (ale) -#endif - -#ifndef lpc2138_ale_set -#define lpc2138_ale_set(i) lpc2138_set (ale, i) -#endif - -#ifndef lpc2138_ale_set_mode -#define lpc2138_ale_set_mode(mode) lpc2138_set_mode (ale, mode) -#endif -#ifndef lpc2138_ale_set_pinsel -#define lpc2138_ale_set_pinsel(func) lpc2138_set_pinsel(ale, func) -#endif - -#ifndef lpc2138_rd_get -#define lpc2138_rd_get() lpc2138_get (rd) -#endif - -#ifndef lpc2138_rd_set -#define lpc2138_rd_set(i) lpc2138_set (rd, i) -#endif - -#ifndef lpc2138_rd_set_mode -#define lpc2138_rd_set_mode(mode) lpc2138_set_mode (rd, mode) -#endif - -#ifndef lpc2138_rd_set_pinsel -#define lpc2138_rd_set_pinsel(func) lpc2138_set_pinsel(rd, func) -#endif - -#ifndef lpc2138_wr_get -#define lpc2138_wr_get() lpc2138_get (wr) -#endif - -#ifndef lpc2138_wr_set -#define lpc2138_wr_set(i) lpc2138_set (wr, i) -#endif - -#ifndef lpc2138_wr_set_mode -#define lpc2138_wr_set_mode(mode) lpc2138_set_mode (wr, mode) -#endif - -#ifndef lpc2138_wr_set_pinsel -#define lpc2138_wr_set_pinsel(func) lpc2138_set_pinsel(wr, func) -#endif - -#ifndef lpc2138_data_get -#define lpc2138_data_get() lpc2138_get (data) -#endif - -#ifndef lpc2138_data_set -#define lpc2138_data_set(i) lpc2138_set (data, i) -#endif - -#ifndef lpc2138_data_set_mode -#define lpc2138_data_set_mode(mode) lpc2138_set_mode (data, mode) -#endif - -#ifndef lpc2138_data_set_pinsel -#define lpc2138_data_set_pinsel(func) lpc2138_set_pinsel(data, func) -#endif - -#ifndef lpc2138_addresses_get -#define lpc2138_addresses_get() ((lpc2138_get (a17_mr) << 17) | \ - (lpc2138_get (a16) << 16) | \ - (lpc2138_get (a0_a15))) -#endif - -#ifndef lpc2138_addresses_set -#define lpc2138_addresses_set(i) lpc2138_set (a17_mr, ((i >> 17) & BITMASK_1)); \ - lpc2138_set (a16, ((i >> 16) & BITMASK_1)); \ - lpc2138_set (a0_a15, ((i) & BITMASK_16)) -#endif - -#ifndef lpc2138_addresses_set_mode -#define lpc2138_addresses_set_mode(mode) (lpc2138_set_mode (a17_mr, mode), \ - lpc2138_set_mode (a16, mode), \ - lpc2138_set_mode (a0_a15, mode)) -#endif - -#ifndef lpc2138_addresses_set_pinsel -#define lpc2138_addresses_set_pinsel(func) (lpc2138_set_pinsel(a17_mr, func), \ - lpc2138_set_pinsel(a16, func), \ - lpc2138_set_pinsel(a0_a15, func)) -#endif - -#define CMR 1 -#define RRB 2 // 1=released message in fifo are released -#define AT 1 // 1= cancel next tranmission -#define SR 2 -#define TBS 2 // 1=released the cpu may write a message in the transmit buffer -#define SRR 4 // 1=present a message shall be transmit and receive sim -#define TR 0 // 1=present a message shall be transmit - - -/* - FLASH -*/ -#define EE_SEC_L 1 // Flash sector where EEPROM begins (see UM for details) -#define EE_SEC_H 3 // Flash sector where EEPROM ends (see UM for details) -#define EE_ADDR_L 0x00001000 // Must match the EE_SEC_L Flash sector start address -#define EE_ADDR_H 0x00003FFF // Must match the EE_SEC_H Flash sector end address -#define EE_CCLK 60000 // system clock cclk expressed in kHz (5*12 MHz) -#define EE_BUFFER_SIZE 256 -#define EE_START_MASK 0xFFFFFF00 -#define EE_BUFFER_MASK 0x000000F0 - - -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/lpc2138_pinout.h --- a/drivers/ecos_lpc2138_sja1000/lpc2138_pinout.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: Christian Fortin (canfestival@canopencanada.ca) - -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 -*/ - -/** - * Définitions du brochage LPC2138 par défaut. - */ -#if !defined(_LPC2138_PINOUT_H_) -#define _LPC2138_PINOUT_H_ - -#define LPC2138_uart0_tx 0 /* Pin 0 */ -#define LPC2138_uart0_tx_PORT P0 -#define LPC2138_uart0_tx_SIZE 1 - -#define LPC2138_uart0_rx 1 /* Pin 1 */ -#define LPC2138_uart0_rx_PORT P0 -#define LPC2138_uart0_rx_SIZE 1 - -#define LPC2138_cs_sja1000 4 /* Pin 4 */ -#define LPC2138_cs_sja1000_PORT P0 -#define LPC2138_cs_sja1000_SIZE 1 - -#define LPC2138_cs_s1d13706 5 /* Pin 5 */ -#define LPC2138_cs_s1d13706_PORT P0 -#define LPC2138_cs_s1d13706_SIZE 1 - -#define LPC2138_wait 7 /* Pin 7 */ -#define LPC2138_wait_PORT P0 -#define LPC2138_wait_SIZE 1 - -#define LPC2138_uart1_tx 8 /* Pin 8 */ -#define LPC2138_uart1_tx_PORT P0 -#define LPC2138_uart1_tx_SIZE 1 - -#define LPC2138_uart1_rx 9 /* Pin 9 */ -#define LPC2138_uart1_rx_PORT P0 -#define LPC2138_uart1_rx_SIZE 1 - -#define LPC2138_bhe 10 /* Pin 10 */ -#define LPC2138_bhe_PORT P0 -#define LPC2138_bhe_SIZE 1 - -#define LPC2138_a17_mr 12 /* Pin 12 */ -#define LPC2138_a17_mr_PORT P0 -#define LPC2138_a17_mr_SIZE 1 - -#define LPC2138_a16 13 /* Pin 13 */ -#define LPC2138_a16_PORT P0 -#define LPC2138_a16_SIZE 1 - -#define LPC2138_interrupt_sja1000 14 /* Pin 14 */ -#define LPC2138_interrupt_sja1000_PORT P0 -#define LPC2138_interrupt_sja1000_SIZE 1 - -#define LPC2138_data 16 /* Pins 16-23 */ -#define LPC2138_data_PORT P0 -#define LPC2138_data_SIZE 8 - -#define LPC2138_dac0 25 /* Pin 25 */ -#define LPC2138_dac0_PORT P0 -#define LPC2138_dac0_SIZE 1 - -#define LPC2138_ale 26 /* Pin 26 */ -#define LPC2138_ale_PORT P0 -#define LPC2138_ale_SIZE 1 - -#define LPC2138_redgreenled 27 /* Pin 27 */ -#define LPC2138_redgreenled_PORT P0 -#define LPC2138_redgreenled_SIZE 2 - -#define LPC2138_rd 29 /* Pin 29 */ -#define LPC2138_rd_PORT P0 -#define LPC2138_rd_SIZE 1 - -#define LPC2138_wr 30 /* Pin 30 */ -#define LPC2138_wr_PORT P0 -#define LPC2138_wr_SIZE 1 - -#define LPC2138_a0_a15 16 /* Pins 16-31 */ -#define LPC2138_a0_a15_PORT P1 -#define LPC2138_a0_a15_SIZE 16 - -#define LPC2138_addresses_SIZE 18 - -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/notes.txt --- a/drivers/ecos_lpc2138_sja1000/notes.txt Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -canOpenDriver.c - f_can_send - f_can_receive - interrupts - nvram_save/load - baudrate - -sja1000.c - hardware init - -lpc2138.c - iat_flash - -time_slicer.c - settimer - alarm - - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/nvram.h --- a/drivers/ecos_lpc2138_sja1000/nvram.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - ____ _ _ _ - / ___| / \ | \ | | ___ _ __ ___ _ __ -| | / _ \ | \| |/ _ \| '_ \ / _ \ '_ \ -| |___ / ___ \| |\ | (_) | |_) | __/ | | | - \____/_/ \_\_| \_|\___/| .__/ \___|_| |_| - |_| - ____ _ - / ___|__ _ _ __ __ _ __| | __ _ - | | / _` | '_ \ / _` |/ _` |/ _` | - | |__| (_| | | | | (_| | (_| | (_| | - \____\__,_|_| |_|\__,_|\__,_|\__,_| - - canfestival@canopencanada.ca -/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ - -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 -*/ - -#if !defined(_NVRAM_IO_H_) -#define _NVRAM_IO_H_ - - -int nvram_open(void); -void nvram_close(void); - -char nvram_write_data(int type, int access_attr, void *data); -char nvram_read_data(int type, int access_attr, void *data); - -void nvram_write_regs(void); -void nvram_read_regs(void); - -#endif - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/nvram_iap.c --- a/drivers/ecos_lpc2138_sja1000/nvram_iap.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,365 +0,0 @@ -/* - canfestival@canopencanada.ca - -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 - -flash.c - save to / retrieve from the non-volatile memory - to be tested - - can we write/read into an address without working with the whole page (256bytes) -*/ - - -#include -#include - -#include "applicfg.h" -#include "data.h" -#include "objdictdef.h" - -#include "lpc2138_defs.h" /* LPC21xx definitions */ - -#define IAP_LOCATION 0x7ffffff1 - - -// define a page of data of NVRAM_BLOCK_SIZE bytes -// -short data_len; /* 0 to NVRAM_BLOCK_SIZE bytes */ -short data_num_pages; -unsigned int *data_page = NULL; -unsigned int data_addr; - -unsigned int *regs_page = NULL; - -// local definitons -void ee_erase(unsigned int ,unsigned int[]); //function erases EEPROM -void ee_write_page(unsigned int); //function adds a record in EEPROM -void ee_read_page(unsigned int); //function reads the latest valid record in EEPROM - -typedef void (*IAP)(unsigned int [],unsigned int[]); -IAP iap_entry; - - -int iat_init() -{ - int n = NVRAM_BLOCK_SIZE / sizeof(unsigned int); - - /* some actions to initialise the flash */ - data_len = 0; - data_num_pages = 0; - - data_page = (unsigned int *)malloc(sizeof(unsigned int) * n); - memset(data_page, 0, sizeof(unsigned int)*n); - - if (data_page == NULL) - return -1; - - regs_page = (unsigned int *)malloc(sizeof(unsigned int) * n); - memset(regs_page, 0, sizeof(unsigned int)*n); - if (regs_page == NULL) - return -2; - - iat_flash_read_regs(); - - /* start the data at the location specified in the registers */ - if (0) /* for now it is 0, but put here a test to know whether - or not the NVRAM has been written before */ - data_addr = regs_page[1]; - else - data_addr = NVRAM_BLOCK_SIZE; /* let start at block 1 */ - - return 0; -} - - -void iat_end() -{ - /* write the last page before closing */ - iat_flash_write_page(data_addr); - - /* some actions to end accessing the flash */ - free(data_page); - - regs_page[4] = data_num_pages; - /* write the registers to the NVRAM before closing */ - iat_flash_write_regs(); - free(regs_page); -} - - - -/************************************************************************/ -/* */ -/* function: */ -/* void ee_erase(unsigned int command_ee,unsigned int result_ee[]) */ -/* */ -/* type: void */ -/* */ -/* parameters: */ -/* command_ee - Not used. */ -/* result_ee[0] - Returns a response to the last IAP command used. */ -/* 0 - EEPROM successfully erased. */ -/* For all other response values, see microcontroller */ -/* User Manual, IAP Commands and Status Codes Summary. */ -/* result_ee[1] - Not used. */ -/* */ -/* version: 1.1 (01/27/2006) */ -/* */ -/* constants defined in LPC2k_ee.h used in this function: */ -/* EE_SEC_L - microcontroller's Flash sector where EEPROM begins */ -/* EE_SEC_H - microcontroller's Flash sector where EEPROM ends */ -/* EE_CCLK - microcontroller's system clock (cclk) */ -/* */ -/* description: */ -/* This function erases LPC2000 on-chip Flash sectors selected to act */ -/* as an EEPROM. All Flash sectors between EE_SEC_L abd EE_SEC_H */ -/* (including these sectors) will be erased using the In Application */ -/* Programming (IAP) routines (see User Manual for more details). */ -/* Also, this function disables all interrupts while erasing the */ -/* EEPROM. If this is not needed, three lines of the ee_erase */ -/* subroutine can simply be commented-out without affecting the */ -/* routine performance at all. */ -/* */ -/* revision history: */ -/* - Rev. 1.1 adds interrupt disable feature. */ -/* */ -/************************************************************************/ -void ee_erase(unsigned int command_ee,unsigned int result_ee[]) -{ - unsigned int command_iap[5]; - unsigned int result_iap[3]; - unsigned long int enabled_interrupts; - - enabled_interrupts = VICIntEnable; //disable all interrupts - VICIntEnClr = enabled_interrupts; - - command_iap[0]=50; // prepare sectors from EE_SEC_L to EE_SEC_H for erase - command_iap[1]=EE_SEC_L; - command_iap[2]=EE_SEC_H; - iap_entry=(IAP) IAP_LOCATION; - iap_entry(command_iap,result_iap); - - command_iap[0]=52; // erase sectors from EE_SEC_L to EE_SEC_H - command_iap[1]=EE_SEC_L; - command_iap[2]=EE_SEC_H; - command_iap[3]=EE_CCLK; - iap_entry=(IAP) IAP_LOCATION; - iap_entry(command_iap,result_iap); - - command_iap[0]=53; // blankcheck sectors from EE_SEC_L to EE_SEC_H - command_iap[1]=EE_SEC_L; - command_iap[2]=EE_SEC_H; - iap_entry=(IAP) IAP_LOCATION; - iap_entry(command_iap,result_iap); - - VICIntEnable = enabled_interrupts; //restore interrupt enable register - - result_ee[0]=result_iap[0]; - return; -} - -/************************************************************************/ -/* */ -/* function: */ -/* void ee_write(unsigned int command_ee,unsigned int result_ee[]) */ -/* */ -/* type: void */ -/* */ -/* parameters: */ -/* command_ee - An address of a content of ee_data type that has */ -/* to be programmed into EEPROM. */ -/* result_ee[0] - Returns a response to the last IAP command used. */ -/* 0 - data successfully programmed in EEPROM. */ -/* 501 - no space in EEPROM to program data. */ -/* For all other response values, see microcontroller */ -/* User Manual, IAP Commands and Status Codes Summary. */ -/* result_ee[1] - Not used. */ -/* */ -/* version: 1.1 (01/27/2006) */ -/* */ -/* constants defined in LPC2k_ee.h used in this function: */ -/* EE_BUFFER_SIZE - IAP buffer size; must be 256 or 512 */ -/* NO_SPACE_IN_EEPROM - EEPROM is full and no data can be programmed */ -/* EE_BUFFER_MASK - parameter used for interfacing with IAP */ -/* EE_REC_SIZE - ee_data structure size in bytes */ -/* EE_SEC_L - micro's Flash sector where EEPROM begins */ -/* EE_SEC_H - micro's Flash sector where EEPROM ends */ -/* EE_CCLK - micro's system clock (cclk) */ -/* */ -/* description: */ -/* This function writes a single structure of ee_data type into the */ -/* EEPROM using an In Application Programming (IAP) routines (see */ -/* User Manual for more details). command_ee contains an address of */ -/* this structure. EEPROM is scanned for the last (if any) record */ -/* identifier (EE_REC_ID), and a new record is added next to it. */ -/* Also, this function disables all interrupts while erasing the */ -/* EEPROM. If this is not needed, three lines of the ee_write */ -/* subroutine can simply be commented-out without affecting the */ -/* routine performance at all. */ -/* */ -/* revision history: */ -/* - Rev. 1.1 fixes a bug related to verifying a content written into */ -/* the EEPROM. 1.0 was reporting missmatch even when there were no */ -/* problems at all. */ -/* Rev. 1.1 adds interrupt disable feature. */ -/* */ -/************************************************************************/ - -void ee_write_page(unsigned int addr) -{ - unsigned long int enabled_interrupts; - // unsigned char ee_buffer[16]; - unsigned int command_iap[5], result_iap[3]; - - enabled_interrupts = VICIntEnable; //disable all interrupts - VICIntEnClr = enabled_interrupts; - - iap_entry = (IAP) IAP_LOCATION; - - // prepare sectors from EE_SEC_L to EE_SEC_H for erase - command_iap[0] = 50; - command_iap[1] = EE_SEC_L; - command_iap[2] = EE_SEC_H; - iap_entry(command_iap, result_iap); - - // copy RAM to flash/eeprom - command_iap[0] = 51; - command_iap[1] = (unsigned int) (addr & EE_START_MASK); // 256 kb boundary - command_iap[2] = (unsigned int) (data_page); // should be on a word boundary - command_iap[3] = 256; - command_iap[4] = EE_CCLK; - iap_entry(command_iap, result_iap); - -#if 0 - // compare RAM and flash/eeprom - command_iap[0] = 56; - command_iap[1] = (unsigned int) data; - command_iap[2] = addr; - command_iap[3] = dlen; - iap_entry(command_iap, result_iap); -#endif - - VICIntEnable = enabled_interrupts; //restore interrupt enable register -} - - -/************************************************************************/ -/* */ -/* function: */ -/* void ee_read(unsigned int command_ee,unsigned int result_ee[]) */ -/* */ -/* type: void */ -/* */ -/* parameters: */ -/* command_ee - Not used. */ -/* result_ee[0] - Returns a response. */ -/* 0 - data successfully found in EEPROM. */ -/* 500 - no data/records available in EEPROM. */ -/* result_ee[1] - an address of the last record of ee_data type */ -/* in EEPROM. */ -/* */ -/* version: 1.1 (01/27/2006) */ -/* */ -/* constants defined in LPC2k_ee.h used in this function: */ -/* NO_RECORDS_AVAILABLE - EEPROM is empty/no records identifiable */ -/* with a record identifier (EE_REC_ID) found */ -/* EE_ADR_L - micro's Flash address from where EEPROM begins */ -/* EE_REC_SIZE - size (in bytes) of a ee_data structure */ -/* */ -/* description: */ -/* This function scans an EEPROM content looking for the last record */ -/* that can be identified with a record identifier (EE_REC_ID). When */ -/* such data is found, its address is passed as result_ee[1]. */ -/* */ -/* revision history: */ -/* - Rev. 1.0 had problems with accessing the last record in a fully */ -/* occupied EEPROM. Rev. 1.1 fixes this. */ -/* */ -/************************************************************************/ -void ee_read_page(unsigned int addr) -{ - memcpy(data_page, (unsigned int *)addr, sizeof(unsigned int)*64); -} - - -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// - - -/* - CAN FESTIVAL interface functions -*/ - - -int _get_data_len(int type) -{ - int len = 0; /* number of bytes */ - switch(type) - { - case boolean: - len = 1; - break; - - case int8: - case uint8: - len = 1; - break; - case int16: - case uint16: - len = 2; - break; - case int24: - case uint24: - len = 3; - break; - case int32: - case uint32: - case real32: - len = 4; - break; - case int40: - case uint40: - len = 5; - break; - case int48: - case uint48: - len = 6; - break; - case int56: - case uint56: - len = 7; - break; - case int64: - case uint64: - case real64: - len = 8; - break; -#if 0 -/* TO DO */ - case visible_string: - case octet_string: - case unicode_string: - case time_of_day: - case time_difference: -#endif - } - - return len; -} - - - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/nvram_iap.h --- a/drivers/ecos_lpc2138_sja1000/nvram_iap.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - canfestival@canopencanada.ca - -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 -*/ - -/************************************************************************/ -/* */ -/* LPC2k_ee.H: Header file enabling EEPROM support */ -/* for Philips LPC2000 microcontroller's on-chip Flash memory */ -/* (revision 1.0, May 13th, 2005.) */ -/* */ -/* This file is to be used with LPC2k_ee.c file */ -/* */ -/* IMPORTANT: on-chip Flash memory sector(s) intended to be used as */ -/* an EEPROM will be unavailable for regular code storage! The smallest */ -/* amount of Flash memory that can be used as an EEPROM is a single */ -/* Flash sector (regardless of the Flash sector actual size). */ -/* */ -/* If size of desired EEPROM requires several Flash sectors, these */ -/* sectors must be a consecutive ones. */ -/* */ -/************************************************************************/ - -#define EE_SEC_L 1 //Flash sector where EEPROM begins (see UM for details) -#define EE_SEC_H 3 //Flash sector where EEPROM ends (see UM for details) -#define EE_ADDR_L 0x00001000 //Must match the EE_SEC_L Flash sector start address -#define EE_ADDR_H 0x00003FFF //Must match the EE_SEC_H Flash sector end address -#define EE_CCLK 60000 //system clock cclk expressed in kHz (5*12 MHz) - -/************************************************************************/ -/* */ -/* ee_data structure can be defined differently from this example. */ -/* The only requirement is to have _id field as it is defined here */ -/* since EE_REC_ID character is used to identify a record's presence */ -/* in the EEPROM memory. */ -/* */ -/* ==================================================================== */ -/* */ -/* IMPORTANT ARM memory access considerations: */ -/* */ -/* char : byte alligned. Can be accessed at any location in memory. */ -/* */ -/* short int: occupies 2 consecutive bytes. It can be read/write */ -/* accessed only when half-word alligned. Therefore, it is */ -/* located at addresses ending with 0x0, 0x2, 0x4, 0x6, 0x8, */ -/* 0xA, 0xC or 0xE. */ -/* */ -/* int : occupies 4 consecutive bytes. It can be read/write */ -/* accessed only when half-word alligned. Therefore, it is */ -/* located at addresses ending with 0x0, 0x4, 0x8 or 0xC. */ -/* */ -/* ==================================================================== */ -/* */ -/* Due to the LPC2000 Flash memory characteristics, an ee_data */ -/* structure size (EE_REC_SIZE) is limited to the following set: */ -/* */ -/* LPC2101/2/3, LPC2131/2/4/6/8, LPC2141/2/4/6/8: 0x10, 0x20, 0x40, */ -/* 0x80 or 0x100 */ -/* */ -/* LPC2104/5/6, LPC2112/4/9, LPC2124/9, LPC2192/4: 0x10, 0x20, 0x40, */ -/* 0x80, 0x100 or 0x200 */ -/* */ -/* ==================================================================== */ -/* */ -/* example1: */ -/* */ -/* struct ee_data{ //structure starts as word alligned */ -/* unsigned char _id; //1 byte - no allignement restr. */ -/* // 3 BYTE GAP!!!! */ -/* unsigned int _rec_count; //4 bytes - must be word alligned! */ -/* unsigned char _cs; //1 byte - no allignement restr. */ -/*}; // next structure will start as */ -/* // word alligned... */ -/* Structure in example 1 occupies 12 bytes of memory */ -/* */ -/* -------------------------------------------------------------------- */ -/* */ -/* example2: */ -/* */ -/* struct ee_data{ //structure starts as word alligned */ -/* unsigned char _id; //1 byte - no allignement restr. */ -/* unsigned char _cs; //1 byte - no allignement restr. */ -/* // 2 BYTE GAP!!!! */ -/* unsigned int _rec_count; //4 bytes - must be word alligned! */ -/*}; // next structure will start as */ -/* // word alligned... */ -/* Structure in example 2 occupies 8 bytes of memory */ -/* */ -/************************************************************************/ - -struct ee_data{ - unsigned char _id; // 4 bytes: 1 byte (char) + 3 byte GAP! - unsigned int _rec_count; // 4 bytes (int) - unsigned int _counter; // 4 bytes (int) - unsigned char _cs; // 4 bytes: 1 byte (char) + 3 byte GAP! -}; // 16 bytes total - -/************************************************************************/ -/* */ -/* Disclaimer: all observations presented in example1, example 2 and */ -/* ee_data structure defined here are based on Keil's ARM compiler. */ -/* If another compiler is used, memory usage would have to be */ -/* re-examined and verified. */ -/* */ -/************************************************************************/ - - -#define EE_REC_SIZE 0x10 //see restrictions from above - -/********************************************************************/ -/* */ -/* Valid combinations for */ -/* EE_REC_SIZE, EE_BUFFER_SIZE, EE_BUFFER_MASK and EE_START_MASK */ -/* */ -/* EE_BUFFER_SIZE ! EE_START_MASK ! EE_REC_SIZE ! EE_BUFFER_MASK */ -/* ---------------------------------------------------------------- */ -/* 256 0xFFFFFF00 0x010 0xF0 */ -/* 256 0xFFFFFF00 0x020 0xE0 */ -/* 256 0xFFFFFF00 0x040 0xC0 */ -/* 256 0xFFFFFF00 0x080 0x80 */ -/* 256 0xFFFFFF00 0x100 0x00 */ -/* ---------------------------------------------------------------- */ -/* 512 0xFFFFFE00 0x010 0x1F0 */ -/* 512 0xFFFFFE00 0x020 0x1E0 */ -/* 512 0xFFFFFE00 0x040 0x1C0 */ -/* 512 0xFFFFFE00 0x080 0x180 */ -/* 512 0xFFFFFE00 0x100 0x100 */ -/* 512 0xFFFFFE00 0x200 0x000 */ -/********************************************************************/ -/* For LPC2101/2/3, LPC213x and LPC214x EE_BUFFER_SIZE is 256. */ -/* For all other LPC2000 devices EE_BUFFER_SIZE is always 512. */ -/********************************************************************/ -#define EE_BUFFER_SIZE 256 -#define EE_START_MASK 0xFFFFFF00 -#define EE_BUFFER_MASK 0x000000F0 - -/********************************************************************/ -/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ -/*!! !!*/ -/*!! !!*/ -/*!! DO NOT MODIFY THE FOLLOWING CODE!!! !!*/ -/*!! =================================== !!*/ -/*!! !!*/ -/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ -/********************************************************************/ - -#define EE_REC_ID 0xAA -#define EE_SIZE (EE_ADDR_H+1-EE_ADDR_L) -#define NO_RECORDS_AVAILABLE 500 -#define NO_SPACE_IN_EEPROM 501 -#define INDEX_OUT_OF_RANGE 502 - -#ifndef _EEPROM_ - extern const unsigned char eeprom[]; - extern void ee_erase(unsigned int , unsigned int []); //function erases EEPROM - extern void ee_write(unsigned int , unsigned int []); //function adds a record in EEPROM - extern void ee_read (unsigned int , unsigned int []); //function reads the latest valid record in EEPROM - extern void ee_readn(unsigned int , unsigned int []); //function reads n-th record in EEPROM - extern void ee_count(unsigned int , unsigned int []); //function counts records in EEPROM -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/nvram_readme --- a/drivers/ecos_lpc2138_sja1000/nvram_readme Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -procedure for NVRAM -=================== - -data block 0 ------------- -This data block is located at the beginning of the NVRAM and contains -a series of registers. -eg. 1. the version number of the current dictionnary (32 bits) - 2. pointer to the current dictionnary (32 bits) - 3. date of last dictionnary dump (32 bits) - 4. pointer to the last dict (32 bits) - 5. size in page of the current dict - -a minimum number of registers should always be in this block (including a number of 'for future use' 32 bits registers). the remaining space will be left to the developper - -a 256kb data block could handled 64 registers - -data block 1 to N ------------------ -The place where to put the content of the dictionnary - - -procedure to write in the NVRAM -------------------------------- -for each sub-index -add a flag indicating the state - = 0 : normal - = -1 : this is a old sub-index, no longer used - = +1 : this is a new sub-index - -the sub-indexed flaged to -1 could be remove when doing a new release of dictionnary -eg. from BIOS V0 to V1, flag the old sub-index to -1. but when going to V2, those must be remove from the dictionnary - -this flag is important when reloading the old NVRAM content. Since the writing and reading are done sequentially, the dictionnary and the NVRAM must be synchronised. - - -ON BOOT -------- -1. read the block data 0 and check the NVRAM version number against the current dictionnary -if the dict version = NVRAM version, then read the NVRAM using the normal procedure (state=0 and state=+1) -if the dict version is newer then the NVRAM, read the NVRAM using the state=0 and state=-1 . this will ensure a synchone reading of the data - -2. if this is a new NVRAM, write the whole dictionnary to a NEW position in the NVRAM. - write all sub-indexes with state=0 and =+1, do not write does with state=-1 - write the new version number in the registery and the date - - -ON WRITE --------- -write the content of the whole dict (only those sub-indexes that must be saved) to the NVRAM -write the version number -write the date - - -NEW VERSION OF BIOS -------------------- -When a new version of BIOS is downloaded into the device, special procedure must be taken (cf. ON BOOT and ON WRITE). But to avoid problem during the update (i.e. lost of NVRAM data or worst NVRAM corruption) fewer NVRAM manipulation should be performed. Therefore, when writing the new dictionary to NVRAM, it should be put AFTER the previous one. This will provide a way to go back and fetch the previous dictionnary saved values if needed. - -Obviously, the NVRAM has a limited capacity and it is possible that the new BIOS will overshoot the upper limit of memory. In that case, the algorithm should do a loop-around the addressed. Meaning, if the last block of data is reached, go back to data block 1 (data block 0 = registers). If the NVRAM is large enough, it should not cause problem (i.e. overwritting the beginning of the actual dict). - -Data Block 0 has the offset in memory to access the current dict. It also containt the pointer to the last version of the dict. Since the algo writing to the NVRAM does not compact memory, the size of the dict is not necessarily the size of the NVRAM memory it occupies. diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/sja1000.c --- a/drivers/ecos_lpc2138_sja1000/sja1000.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: Christian Fortin (canfestival@canopencanada.ca) - -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 -*/ - -#include -#include - -#include "lpc2138_pinout.h" -#include "lpc2138_defs.h" -#include "lpc2138.h" - -#include "sja1000.h" - - -#define CYGNUM_HAL_INTERRUPT_1 CYGNUM_HAL_INTERRUPT_EINT1 -#define CYGNUM_HAL_PRI_HIGH 0 - - -cyg_uint32 interrupt_1_isr(cyg_vector_t vector, cyg_addrword_t data); -void interrupt_1_dsr(cyg_vector_t vector, - cyg_ucount32 count, - cyg_addrword_t data); - - -/* Interrupt for CAN device. */ -static cyg_interrupt interrupt_1; -static cyg_handle_t interrupt_1_handle; - - -void init_sja1000(void) -{ - do - { - sja1000_write(MOD, 1< - -#include -#include - -#include -#include - -#include "applicfg.h" - -#include - - -#define max(a,b) a>b?a:b -#define min(a,b) astate & TIMER_ARMED) // if row is active - { - if (row->val <= real_total_sleep_time) // to be trigged - { - if (!row->interval) // if simply outdated - { - row->state = TIMER_TRIG; // ask for trig - } - else // or period have expired - { - // set val as interval, with overrun correction - row->val = row->interval - (overrun % row->interval); - row->state = TIMER_TRIG_PERIOD; // ask for trig, periodic - // Check if this new timer value is the soonest - next_wakeup = min(row->val,next_wakeup); - } - } - else - { - // Each armed timer value in decremented. - row->val -= real_total_sleep_time; - - // Check if this new timer value is the soonest - next_wakeup = min(row->val,next_wakeup); - } - } - } - - // Remember how much time we should sleep. - total_sleep_time = next_wakeup; - - // Set timer to soonest occurence - setTimer(next_wakeup); - - // Then trig them or not. - for(i=0; i<=last_timer_raw; i++) - { - s_timer_entry *row = (timers+i); - - if (row->state & TIMER_TRIG) - { - row->state &= ~TIMER_TRIG; // reset trig state (will be free if not periodic) - (*row->callback)(row->d, row->id); // trig ! - } - } -} - - - - -TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period) -{ - int i; - TIMER_HANDLE row_number = TIMER_NONE; - - if (callback == NULL) // nothing to store - return TIMER_NONE; - - // in order to decide new timer setting we have to run over all timer rows - - for(i=0; i <= last_timer_raw + 1 && i < MAX_NB_TIMER; i++) - { - s_timer_entry *row = (timers+i); - - if (row->state == TIMER_FREE) // an empty row - { // just store - row->callback = callback; - row->d = d; - row->id = id; - row->val = value; - row->interval = period; - row->state = TIMER_ARMED; - - row_number = i; - break; - } - } - - if (row_number != TIMER_NONE) // if successfull - { - if (row_number == last_timer_raw + 1) last_timer_raw++; - - // set next wakeup alarm if new entry is sooner than others, or if it is alone - unsigned int real_timer_value = min(value, TIMEVAL_MAX); - unsigned int elapsed_time = getElapsedTime(); - - if (total_sleep_time > elapsed_time && total_sleep_time - elapsed_time > real_timer_value) - { - total_sleep_time = elapsed_time + real_timer_value; - setTimer(real_timer_value); - } - - return row_number; - } - - return TIMER_NONE; -} - -// --------- Use this to remove an alarm --------- -TIMER_HANDLE DelAlarm(TIMER_HANDLE handle) -{ - if (handle != TIMER_NONE) - { - if (handle == last_timer_raw) - last_timer_raw--; - timers[handle].state = TIMER_FREE; - } - else - { - } - - return TIMER_NONE; -} diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/time_slicer.h --- a/drivers/ecos_lpc2138_sja1000/time_slicer.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: Christian Fortin (canfestival@canopencanada.ca) - -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 -*/ - - -#if !defined(_TIME_SLICER_H_) -#define _TIME_SLICER_H_ - - -extern cyg_handle_t alarm_handle_timer; - -void chrono_timer(cyg_handle_t alarmH, cyg_addrword_t data); -void init_timer(void); - - -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/ecos_lpc2138_sja1000/timerscfg.h --- a/drivers/ecos_lpc2138_sja1000/timerscfg.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* -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 __TIMERSCFG_H__ -#define __TIMERSCFG_H__ - -#include - -// Time unit : us -// Time resolution : 64bit (~584942 years) -// #define TIMEVAL unsigned long long -// #define TIMEVAL_MAX 0xffffffffffffffff -// #define MS_TO_TIMEVAL(ms) ms*1000 -// #define US_TO_TIMEVAL(us) us - -#define TASK_HANDLE pthread_t - -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/led_stdout/.cvsignore --- a/drivers/led_stdout/.cvsignore Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Makefile diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/led_stdout/Makefile.in --- a/drivers/led_stdout/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -#! 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 -f $(OBJS) - -mrproper: clean - - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/led_stdout/led_stdout.c --- a/drivers/led_stdout/led_stdout.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -/***************************************************************************/ -#include -#include - -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"); -} - - diff -r 0d84d95790d9 -r 16c8ceea8f18 drivers/nvram_file/nvram_file.c --- a/drivers/nvram_file/nvram_file.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -#include - - -/* size of NVRAM in bytes */ -#define NVRAM_MAX_SIZE 262144 - -/* size of block in byte */ -#define NVRAM_BLOCK_SIZE 256 - -#define NVRAM_FILE_NAME "__nvram__" - -FILE *nvram_file = NULL; - - -void iat_flash_read_regs(); -void iat_flash_write_regs(); -void iat_flash_write_page(unsigned int); -void iat_flash_read_page(unsigned int); - - -short data_len; /* 0 to NVRAM_BLOCK_SIZE bytes */ -short data_num_pages; -unsigned int *data_page = NULL; -unsigned int data_addr; - -unsigned int *regs_page = NULL; - -int iat_init() -{ - int i; - - nvram_file = fopen(NVRAM_FILE_NAME, "wr"); - if (nvram_file == NULL) - return -1; - - int n = NVRAM_BLOCK_SIZE / sizeof(unsigned int); - - /* some actions to initialise the flash */ - data_len = 0; - data_num_pages = 0; - - data_page = (unsigned int *)malloc(sizeof(unsigned int) * n); - memset(data_page, 0, sizeof(unsigned int)*n); - - if (data_page == NULL) - return -1; - - regs_page = (unsigned int *)malloc(sizeof(unsigned int) * n); - memset(regs_page, 0, sizeof(unsigned int)*n); - if (regs_page == NULL) - return -2; - - iat_flash_read_regs(); - - /* start the data at the location specified in the registers */ - if (0) /* for now it is 0, but put here a test to know whether - or not the NVRAM has been written before */ - data_addr = regs_page[1]; - else - data_addr = NVRAM_BLOCK_SIZE; /* let start at block 1 */ - - /* create a file the size of the simulated NVRAM */ - for(i=0; i $(PGR).s - -MSG: - $(BINUTILS_PREFIX)readelf -S $(PGR).elf - @echo - $(BINUTILS_PREFIX)size $(PGR).elf - -clean: - rm -f $(MASTER_OBJS) - -mrproper: clean - rm -f $(PGR).elf $(PGR).s19 $(PGR).b $(PGR).s - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/appli.c --- a/examples/AppliMaster_HCS12/appli.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1143 +0,0 @@ -/* -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 -*/ - -#include /* for NULL */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "def.h" -#include "can.h" -#include "objdictdef.h" -#include "objacces.h" -#include "canOpenDriver.h" -#include "sdo.h" -#include "pdo.h" -#include "init.h" -#include "timer.h" -#include "lifegrd.h" -#include "sync.h" - -#include "nmtMaster.h" - -// For prototype of exit(); -#define exit _exit - - - - -// HCS12 configuration -// ----------------------------------------------------- - -enum E_CanBaudrate -{ - CAN_BAUDRATE_250K, - CAN_BAUDRATE_500K, - CAN_BAUDRATE_1M, - CAN_BAUDRATE_OLD_VALUE -}; - -const canBusTime CAN_Baudrates[] = -{ - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 3, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 13 tq for the TIME 1 segment (tseg1 = 12) - - 2 tq for the TIME 2 segment (tseg2 = 1) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 4 MHZ (brp = 3+1), and there are 16 tq in the bit time, - so the freq of the bit time is 250 kHz. - */ - }, - - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 13 tq for the TIME 1 segment (tseg1 = 12) - - 2 tq for the TIME 2 segment (tseg2 = 1) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 8 MHZ (brp = 1+1), and there are 16 tq in the bit time, - so the freq of the bit time is 500 kHz. - */ - }, - - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 4, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 5 tq for the TIME 1 segment (tseg1 = 4) - - 2 tq for the TIME 2 segment (tseg2 = 1) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 8 MHZ (brp = 1+1), and there are 8 tq in the bit time, - so the freq of the bit time is 1 MHz. - */ - }, - - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 0, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 1, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 1, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 4, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 9, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 10 tq for the TIME 1 segment (tseg1 = 9) - - 5 tq for the TIME 2 segment (tseg2 = 4) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 16 MHZ (brp = 0), and there are 16 tq in the bit time, - so the freq of the bit time is 1 MHz. - */ - } -}; - - - -// Required definition variables -// ----------------------------- -// The variables that you should define for debugging. -// They are used by the macro MSG_ERR and MSG_WAR in applicfg.h -// if the node is a slave, they can be mapped in the object dictionnary. - -UNS8 printMsgErrToConsole = 1; -UNS8 printMsgWarToConsole = 1; - -// The variables mapped in the object dictionnary -// ---------------------------------------------- -extern UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x0 -extern UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x0 -extern UNS8 second; // Mapped at index 0x6002, subindex 0x1 -extern UNS8 minutes; // Mapped at index 0x6002, subindex 0x2 -extern UNS8 hour; // Mapped at index 0x6002, subindex 0x3 -extern UNS8 day; // Mapped at index 0x6002, subindex 0x4 -extern UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x1 -extern UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x2 - -/*************************User's variables declaration**************************/ -UNS8 connectedNode[128]; -volatile UNS8 sec = 0; // To count the time every second -UNS8 softCount = 0; - -/* The variable to map in a PDO is defined at index and subIndex. Its length is size bytes */ -typedef struct mappedVar -{ - UNS32 index; - UNS8 subIndex; - UNS8 size; // in byte -} s_mappedVar; - -typedef struct heartbeatConsumer -{ - UNS8 nodeProducer; - UNS16 time_ms; -} s_heartbeatConsumer; - -/**************************prototypes*****************************************/ -/* You *must* have these 2 functions in your code*/ -void heartbeatError(UNS8 heartbeatID ); -void SD0timeoutError(UNS8 bus_id, UNS8 line); - -void waitMessage (void ); -void heartBeat (void ); -void transmitSync (void); -e_nodeState stateNode (UNS8 node); -void configure_master_SDO (UNS32 index, UNS8 serverNode); -UNS8 waitingWriteToSlaveDict ( UNS8 slaveNode, UNS8 error); -UNS8 waitingReadToSlaveDict (UNS8 slaveNode, void * data, UNS8 * size, UNS8 error); -UNS8 configure_client_SDO (UNS8 slaveNode, UNS8 clientNode); -void masterMappingPDO (UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar); -void slaveMappingPDO (UNS8 slaveNode, UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar); -void masterHeartbeatConsumer (s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats); -void masterHeartbeatProducer (UNS16 time); -void slaveHeartbeatConsumer (UNS8 slaveNode, s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats); -void slaveHeartbeatProducer (UNS8 slaveNode, UNS16 time); -void masterPDOTransmissionMode (UNS32 indexPDO, UNS8 transType); -void slavePDOTransmissionMode (UNS8 slaveNode, UNS32 indexPDO, UNS8 transType); -void masterSYNCPeriod (UNS32 SYNCPeriod); -int main (void); - -// Interruption timer 3. (The timer 4 is used by CanOpen) -void __attribute__((interrupt)) timer3Hdl (void); -void incDate (void); -void initLeds (void); -void initCanHCS12 (void); -void initTimerClk (void); - - -/*****************************************************************************/ -void heartbeatError(UNS8 heartbeatID) -{ - // MSG_ERR should send the values canopenErrNB and canopenErrVAL on event in a PDO, - // But we do not have mapped the variables in a PDO, so it sends nothing. - // See the note at the end of END CONFIGURING THE NETWORK. - MSG_WAR(0x2F00, "HeartBeat, no response from node : ", heartbeatID); -} - -/*****************************************************************************/ -void SD0timeoutError (UNS8 bus_id, UNS8 line) -{ - // Informations on what occurs are in transfers[bus_id][line].... - // See scanSDOtimeout() in sdo.c -} - -//------------------------------------------------------------------------------ -/************************** FUNCTIONS TO CONFIGURE THE NETWORK******************/ - -//------------------------------------------------------------------------------ -/* Node mode result after NodeGuard query */ -e_nodeState stateNode(UNS8 node) -{ - e_nodeState state = getNodeState(0, node); - switch (state) { - case Unknown_state: - MSG_WAR(0x3F05, "Not connected (Does not have sent its status) node :", node); - break; - case Operational: - MSG_WAR(0x3F06, "Ok, in operational mode, node : ", node); - break; - case Pre_operational: - MSG_WAR(0x3F07, "OK in pre-operational mode, node : ", node); - break; - default: - MSG_WAR(0x3F08, "OK connected but in curious mode, node : ", node); - } - return state; -} - -//------------------------------------------------------------------------------ -/* The master is writing in its dictionnary to configure the SDO parameters -to communicate with server_node -*/ -void configure_master_SDO(UNS32 index, UNS8 serverNode) -{ - UNS32 data32; - UNS8 data8; - UNS8 sizeData = 4 ; // in bytes - - /* At subindex 1, the cobId of the Can message from the client. - It is always defined inside the server dictionnary as 0x600 + server_node. - So, we have no choice here ! */ - data32 = 0x600 + serverNode; - setODentry(index, 1, &data32, sizeData, 0); - - { - // Test - UNS32 *pbData; - UNS8 length; - UNS32 returnValue; - UNS8 dataType; - // Relecture - MSG_WAR(0x1000, "Reading index : ", index); - MSG_WAR(0x1000, " subindex : ", 1); - returnValue = getODentry(index, 1, (void * *)&pbData, (UNS8 *)&length, &dataType, 0); - MSG_WAR(0x1000, " val : ", *pbData); - } - - - /* At subindex 2, the cobId of the Can message from the server to the client. - It is always defined inside the server dictionnary as 0x580 + client_node. - So, we have no choice here ! */ - data32 = 0x580 + serverNode; - setODentry(index, 2, &data32, sizeData, 0); - - /* At subindex 3, the node of the server */ - data8 = serverNode; - sizeData = 1; - setODentry(index, 3, &data8, sizeData, 0); - - { - UNS8 *pbData; - UNS8 length; - UNS32 returnValue; - UNS8 dataType; - // Relecture - MSG_WAR(0x1000, "Reading index : ", index); - MSG_WAR(0x1000, " subindex : ", 3); - returnValue = getODentry(index, 1, (void * *)&pbData, (UNS8 *)&length, &dataType, 0); - MSG_WAR(0x1000, " val : ", *pbData); - } -} - -//------------------------------------------------------------------------------ -/* - */ -UNS8 waitingWriteToSlaveDict(UNS8 slaveNode, UNS8 error) -{ - UNS8 err; - UNS32 abortCode; - MSG_WAR(0x3F21, "Sending SDO to write in dictionnary of node : ", slaveNode); - if (error) { - MSG_ERR(0x1F22, "Unable to send the SDO to node ", slaveNode); - return -1; - } - /* Waiting until the slave has responded */ - while (getWriteResultNetworkDict (0, slaveNode, &abortCode) == SDO_DOWNLOAD_IN_PROGRESS) { - // Check if some SDO response are missing - scanSDOtimeout(); - } - - err = getWriteResultNetworkDict (0, slaveNode, &abortCode); - if (err == SDO_FINISHED) { - MSG_WAR(0x3F22, "SDO download finished to Node : ", slaveNode); - // Release the line. Don't forget !!! - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - return 0; - } - - if (err == SDO_ABORTED_RCV) { - MSG_WAR(0x2F20, "Received SDO abort from node : ", slaveNode); - } - - if (err == SDO_ABORTED_INTERNAL) { - MSG_WAR(0x2F20, "Internal SDO abort for node : ", slaveNode); - } - // Looking for the line transfert number to read the index, subindex and releasing the line. - { - UNS8 line; - err = getSDOlineOnUse(0, slaveNode, SDO_CLIENT, &line); - if (err) { - MSG_WAR(0x2F21, "No line found for node : ", slaveNode); - exit(-1); - } - MSG_WAR (0x2F22, "while writing at his index : ", transfers[0][line].index); - MSG_WAR (0x2F23, " subIndex : ", transfers[0][line].subIndex); - //Releasing the line. - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - exit(-1); - } - return 0; -} - -//------------------------------------------------------------------------------ -/* - */ -UNS8 waitingReadToSlaveDict(UNS8 slaveNode, void * data, UNS8 * size, UNS8 error) -{ - UNS8 err; - UNS32 abortCode; - MSG_WAR(0x3F2A, "Sending SDO to read in dictionnary of node : ", slaveNode); - if (error) { - MSG_ERR(0x1F2B, "Unable to send the SDO to node ", slaveNode); - return -1; - } - /* Waiting until the slave has responded */ - while (getReadResultNetworkDict (0, slaveNode, data, size, &abortCode) == SDO_UPLOAD_IN_PROGRESS) { - // Check if some SDO response are missing - scanSDOtimeout(); - } - err = getReadResultNetworkDict (0, slaveNode, data, size, &abortCode); - if (err == SDO_FINISHED) { - MSG_WAR(0x3F2C, "SDO upload finished to Node : ", slaveNode); - // Release the line. Don't forget !!! - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - return 0; - } - if (err == SDO_ABORTED_RCV) { - MSG_WAR(0x2F2D, "Received SDO abort from node : ", slaveNode); - } - - if (err == SDO_ABORTED_INTERNAL) { - MSG_WAR(0x2F2E, "Internal SDO abort for node : ", slaveNode); - } - // Looking for the line transfert number to read the index, subindex and releasing the line. - { - UNS8 line; - err = getSDOlineOnUse(0, slaveNode, SDO_CLIENT, &line); - if (err) { - MSG_WAR(0x2F2F, "No line found for node : ", slaveNode); - exit(-1); - } - MSG_WAR (0x2F30, "while writing at his index : ", transfers[0][line].index); - MSG_WAR (0x2F31, " subIndex : ", transfers[0][line].subIndex); - //Releasing the line. - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - exit(-1); - } - - return 0; -} - -//------------------------------------------------------------------------------ -/* The master is writing in the slave dictionnary to configure the SDO parameters -Remember that the slave is the server, and the master is the client. - */ -UNS8 configure_client_SDO(UNS8 slaveNode, UNS8 clientNode) -{ - UNS8 data; - UNS8 NbDataToWrite = 1 ; // in bytes - UNS8 err = 0; - MSG_WAR(0x3F20, "Configuring SDO by writing in dictionnary Node ", slaveNode); - /* It is only to put at subindex 3 the serverNode. It is optionnal. - In the slave dictionary, only one SDO server is defined, at index - 0x1200 */ - data = clientNode; - err = writeNetworkDict(0, slaveNode, 0x1200, 3, NbDataToWrite, 0, &data); - waitingWriteToSlaveDict(slaveNode, err); - - return 0; -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterMappingPDO(UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar) -{ - UNS32 *pbData; - UNS32 data32; - UNS8 i; - UNS8 size = 0; - UNS8 dataType; - - if ((indexPDO >= 0x1400) && (indexPDO <= 0x15FF)) - MSG_WAR(0x3F30, "Configuring MASTER for PDO receive, COBID : ", cobId); - - if ((indexPDO >= 0x1800) && (indexPDO <= 0x19FF)) - MSG_WAR(0x3F31, "Configuring MASTER for PDO transmit, COBID : ", cobId); - - /* At indexPDO, subindex 1, defining the cobId of the PDO */ - setODentry(indexPDO, 1, &cobId, 4, 0); - /* The mapping ... */ - /* ----------------*/ - /* At subindex 0, the number of variables in the PDO */ - setODentry(indexPDO + 0x200, 0, &nbVar, 1, 0); - getODentry(indexPDO + 0x200, 0, (void * *)&pbData, &size, &dataType, 0); - /* At each subindex 1 .. nbVar, The index,subindex and size of the variable to map in - the PDO. The first variable after the COBID is defined at subindex 1, ... - The data to write is the concatenation on 32 bits of (msb ... lsb) : - index(16b),subIndex(8b),sizeVariable(8b) -*/ - for (i = 0 ; i < nbVar ; i++) { - data32 = ((tabMappedVar + i)->index << 16) | - (((tabMappedVar + i)->subIndex & 0xFF) << 8) | - ((tabMappedVar + i)->size & 0xFF); - // Write dictionary - setODentry(indexPDO + 0x200, i + 1, &data32, 4, 0); - -# ifdef MORE_COMMENTS - printf("Mapped variable defined at index 0x%X, subIndex 0x%X, %d bits\n", - (tabMappedVar + i)->index, (tabMappedVar + i)->subIndex, 8 * (tabMappedVar + i)->size); - // Only to verify. - // Read dictionnary - getODentry(indexPDO + 0x200, i + 1, (void * *)&pbData, &size, &dataType, 0); - printf("Writen à index 0x%X, subIndex 0x%X, %d bits : 0x%08X\n", - indexPDO + 0x200, i + 1, 8 * size, *pbData); -# endif - - } -} - -//------------------------------------------------------------------------------ -/* - */ - -void slaveMappingPDO(UNS8 slaveNode, UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar) -{ - UNS32 data32; - UNS8 i; - UNS8 err; - UNS8 nbBytes = 1; - if ((indexPDO >= 0x1400) && (indexPDO <= 0x15FF)) - MSG_WAR(0x3F32, "Configuring slave for PDO receive, COBID : ", cobId); - - if ((indexPDO >= 0x1800) && (indexPDO <= 0x19FF)) - MSG_WAR(0x3F33, "Configuring slave for PDO transmit, COBID : ", cobId); - - /* At indexPDO, subindex 1, defining the cobId of the PDO */ - err = writeNetworkDict(0, slaveNode, indexPDO, 1, 4, 0, &cobId); - waitingWriteToSlaveDict(slaveNode, err); - - /* The mapping ... */ - /* ----------------*/ - /* At subindex 0, the number of variables in the PDO */ - err = writeNetworkDict(0, slaveNode, indexPDO + 0x200, 0, nbBytes, 0, &nbVar); - waitingWriteToSlaveDict(slaveNode, err); - - /* At each subindex 1 .. nbVar, The index,subindex and size of the variable to map in - the PDO. The first variable after the COBID is defined at subindex 1, ... - The data to write is the concatenation on 32 bits of (msb ... lsb) : - index(16b),subIndex(8b),sizeVariable(8b) -*/ - for (i = 0 ; i < nbVar ; i++) { - data32 = ((tabMappedVar + i)->index << 16) | - (((tabMappedVar + i)->subIndex & 0xFF) << 8) | - ((tabMappedVar + i)->size & 0xFF); - - // Write dictionary - err = writeNetworkDict(0, slaveNode, indexPDO + 0x200, i + 1, 4, 0, &data32); - waitingWriteToSlaveDict(slaveNode, err); - -# ifdef MORE_COMMENTS - printf("Mapped variable defined at index 0x%X, subIndex 0x%X, %d bits\n", - (tabMappedVar + i)->index, (tabMappedVar + i)->subIndex, 8 * (tabMappedVar + i)->size); - - printf("At node 0x%X Writen at index 0x%X, subIndex 0x%X, %d bits : 0x%08X\n", - slaveNode, indexPDO + 0x200, i + 1, 32, data32); -# endif - - } -} - -//------------------------------------------------------------------------------ -/* - */ -void masterHeartbeatConsumer(s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats) -{ - UNS32 data; - UNS8 i; - UNS8 nbHB = nbHeartbeats; - - MSG_WAR(0x3F40, "Configuring heartbeats consumers for master", 0); - /* At index 1016, subindex 0 : the nb of consumers (ie nb of nodes of which are expecting heartbeats) */ - setODentry(0x1016, 0, & nbHB, 1, 0); - - /* At Index 1016, subindex 1, ... : 32 bit values : msb ... lsb : - 00 - node_consumer (8b) - time_ms (16b) - Put 0 to ignore the entry. - */ - for (i = 0 ; i < nbHeartbeats ; i++) { - data = (((tabHeartbeatConsumer + i)->nodeProducer & 0xFF)<< 16) | ((tabHeartbeatConsumer + i)->time_ms & 0xFFFF); - setODentry(0x1016, i + 1, & data, 4, 0); - } -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterHeartbeatProducer(UNS16 time) -{ - UNS16 hbTime = time; - MSG_WAR(0x3F45, "Configuring heartbeat producer for master", 0); - /* At index 1017, subindex 0, defining the time to send the heartbeat. Put 0 to never send heartbeat */ - setODentry(0x1017, 0, &hbTime, 2, 0); -} - -//------------------------------------------------------------------------------ -/* - */ -void slaveHeartbeatConsumer(UNS8 slaveNode, s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats) -{ - UNS32 data; - UNS8 err; - UNS8 i; - - MSG_WAR(0x3F46, "Configuring heartbeats consumers for node : ", slaveNode); - - /* At Index 1016, subindex 1, ... : 32 bit values : msb ... lsb : - 00 - node_consumer (8b) - time_ms (16b) - Put 0 to ignore the entry. - */ - for (i = 0 ; i < nbHeartbeats ; i++) { - data = (((tabHeartbeatConsumer + i)->nodeProducer & 0xFF)<< 16) | - ((tabHeartbeatConsumer + i)->time_ms & 0xFFFF); - err = writeNetworkDict(0, slaveNode, 0x1016, i + 1, 4, 0, &data); - waitingWriteToSlaveDict(slaveNode, err); - } -} - -//------------------------------------------------------------------------------ -/* - */ - -void slaveHeartbeatProducer(UNS8 slaveNode, UNS16 time) -{ - UNS8 err; - MSG_WAR(0x3F47, "Configuring heartbeat producer for node : ", slaveNode); - /* At index 1017, subindex 0, defining the time to send the heartbeat. Put 0 to never send heartbeat */ - - err = writeNetworkDict(0, slaveNode, 0x1017, 0, 2, 0, &time); - waitingWriteToSlaveDict(slaveNode, err); -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterPDOTransmissionMode(UNS32 indexPDO, UNS8 transType) -{ - MSG_WAR(0x3F48, "Configuring transmission from master, indexPDO : ", indexPDO); - - /* At subindex 2, the transmission type */ - setODentry(indexPDO, 2, &transType, 1, 0); -} - - -//------------------------------------------------------------------------------ -/* - */ - -void slavePDOTransmissionMode(UNS8 slaveNode, UNS32 indexPDO, UNS8 transType) -{ - UNS8 err; - MSG_WAR(0x3F41, "Configuring transmission mode for node : ", slaveNode); - MSG_WAR(0x3F42, " indexPDO : ", indexPDO); - - err = writeNetworkDict(0, slaveNode, indexPDO, 2, 1, 0, &transType); - waitingWriteToSlaveDict(slaveNode, err); -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterSYNCPeriod(UNS32 SYNCPeriod) -{ - UNS32 cobId = 0x40000080; - MSG_WAR(0x3F49, "Configuring master to send SYNC every ... micro-seconds :", SYNCPeriod); - /* At index 0x1006, subindex 0 : the period in ms */ - setODentry(0x1006, 0, &SYNCPeriod , 4, 0); - /* At index 0x1005, subindex 0 : Device generate SYNC signal with CobId 0x80 */ - setODentry(0x1005, 0, &cobId, 4, 0); -} - -//------------------------------------------------------------------------------ - - -//Initialisation of the port B for the leds. -void initLeds(void) -{ - // Port B is output - IO_PORTS_8(DDRB)= 0XFF; - // RAZ - IO_PORTS_8(PORTB) = 0xFF; -} - -//------------------------------------------------------------------------------ - - - -void initCanHCS12 (void) -{ - //Init the HCS12 microcontroler for CanOpen - initHCS12(); - // Init the HCS12 CAN driver - const canBusInit bi0 = { - 0, /* no low power */ - 0, /* no time stamp */ - 1, /* enable MSCAN */ - 0, /* clock source : oscillator (In fact, it is not used) */ - 0, /* no loop back */ - 0, /* no listen only */ - 0, /* no low pass filter for wk up */ - CAN_Baudrates[CAN_BAUDRATE_250K], - { - 0x00, /* Filter on 16 bits. See Motorola Block Guide V02.14 fig 4-3 */ - 0x00, 0xFF, /* filter 0 hight accept all msg */ - 0x00, 0xFF, /* filter 0 low accept all msg */ - 0x00, 0xFF, /* filter 1 hight filter all of msg */ - 0x00, 0xFF, /* filter 1 low filter all of msg */ - 0x00, 0xFF, /* filter 2 hight filter most of msg */ - 0x00, 0xFF, /* filter 2 low filter most of msg */ - 0x00, 0xFF, /* filter 3 hight filter most of msg */ - 0x00, 0xFF, /* filter 3 low filter most of msg */ - } - }; - - canInit(CANOPEN_LINE_NUMBER_USED, bi0); //initialize filters... - unlock(); // Allow interruptions -} - -/*********************************************************************/ -// For Second timer -void incDate(void) -{ - if (sec == 59) - sec = 0; - else - sec++; - - // Toggle the led 4 every seconds - IO_PORTS_8(PORTB) ^= 0x10; - -} - -// Init the time for the second counter -void initTimerClk(void) -{ - - lock(); // Inhibe les interruptions - - // Configuration du Channel 3 - IO_PORTS_8(TIOS) |= 0x08; // Canal 3 en sortie - IO_PORTS_8(TCTL2) &= ~(0xC0); // Canal 3 déconnecté du pin de sortie - IO_PORTS_8(TIE) |= 0x08; // Autorise interruption Canal 3 - IO_PORTS_8(TSCR1) |= 0x80; // Mise en route du timer - unlock(); // Autorise les interruptions -} - - -/*********************************************************************/ -void __attribute__((interrupt)) timer3Hdl(void) -{ - //IO_PORTS_8(PORTB) ^= 0x10; - //IO_PORTS_8(PORTB) &= ~0x20; - IO_PORTS_8(TFLG1) = 0x08; // RAZ du flag interruption timer 3 - // Calcul evt suivant. Clock 8 MHz -> 8000 evt de 1 ms!! Doit tenir sur 16 bits - // Attention, ça change si on utilise la pll - // Lorsque le timer atteindra la valeur de TC3 (16 bits), l'interruption timer3Hdl sera déclenchée - // Si on utilise la PLL à 24 MHZ, alors la vitesse du bus est multipliée par 3. - -/* Assume that our board uses a 16 MHz quartz */ -/* Without pre-division, 8000 counts takes 1 ms. */ -/* We are using a pre-divisor of 32. (register TSCR2) See in CanOpenDriverHC12/timerhw.c */ -/* So 1000 counts takes 4 ms. */ -/* We must have a soft counter of 250 to count a second. */ - -/* - We check in an interrupt handler if a message is arrived. -*/ - receiveMsgHandler(0); - - IO_PORTS_16(TC3H) += (1000); // IT every 4000 count. - softCount++; - if (softCount == 250) { - softCount = 0; - incDate(); - } -} - - - - -/*****************************************************************************/ - - - -/********************************* MAIN ***************************************/ - - -int main() -{ - - UNS8 second_last; - UNS8 minutes_last; - UNS8 sendingResetError = 0; - UNS8 ok, i; - - /* initialisation du bus Can */ - initCanHCS12(); - - /* arrays initialisation, etc */ - initCANopenMain(); - - /* arrays initialisation, etc */ - initCANopenMaster(); - -/* Defining the node Id */ - setNodeId(0x01); - MSG_WAR(0x3F50, "My node ID is : ", getNodeId()); - - /* Put the master in operational mode */ - setState(Operational); - - /* Init the table of connected nodes */ - for (i = 0 ; i < 128 ; i++) - connectedNode[i] = 0; - - /* Initialisation */ - initLeds(); - initTimer( ); - initTimerClk(); - - - - /******************** CONFIGURING THE NETWORK **************************/ - - /* Which nodes are connected ? */ - /* Sending a request Node guard to node 5 and 6 */ - MSG_WAR(0x3F04, "Sending a node guard to node : ", 5); - masterReadNodeState(0, 0x05); - - /* Sending a message to the node 6, only as example */ - MSG_WAR(0x3F04, "Sending a node guard to node : ", 6); - masterReadNodeState(0, 0x06); - /* Waiting for a second the response */ - sec = 0; - while (sec < 2) {}; - - /* Whose node have answered ? */ - connectedNode[5] = stateNode(5); - if (connectedNode[5] != Unknown_state) { - MSG_WAR(0x3F06, "Node 5 connected. Its state is : ", connectedNode[5]); - } - else { - MSG_WAR(0x3F07, "Node 5 NOT connected ", connectedNode[5]); - } - - connectedNode[6] = stateNode(6); - if (connectedNode[6] != Unknown_state) { - MSG_WAR(0x3F08, "Node 6 connected. Its state is : ", connectedNode[6]); - } - else { - MSG_WAR(0x3F09, "Node 6 NOT connected ", connectedNode[6]); - } - - /* Configure the SDO master to communicate with node 5 and node 6 */ - configure_master_SDO(0x1280, 0x05); - /* Configure the SDO of node 5 */ - /* getNodeId() returns my node Id */ - configure_client_SDO(0x05, getNodeId()); - - /* Mapping of the PDO - Chose some COBID in (hexa) 181-1FF, 201-27F, 281-2FF, 301-37F, - 381-3FF, 401-47F, 481-4FF, 501-57F, - without other restriction. - (Of course, you must not define 2 PDO transmit with the same cobId !!) - */ - - /* - *** PDO node 1 <-- node 5 *** - *** cobId 0x181 ************* - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - day [0x6002 - 0x04 - 8] - hour [0x6002 - 0x03 - 8] - second [0x6002 - 0x01 - 8] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bits]: - day [0x2000 - 0x04 - 8] - hour [0x2000 - 0x03 - 8] - second [0x2000 - 0x01 - 8] -*/ - - /* Configuring the first PDO receive, defined at index 0x1400 and 0x1600 */ - { - s_mappedVar tabMappedVar[8] = { {0x6002,4,8}, {0x6002,3,8}, {0x6002,1,8}, }; - masterMappingPDO(0x1400, 0x181, tabMappedVar, 3); - } - - /* Configuring the first PDO transmit, defined at index 0x1800 and 0x1A00 */ - { - s_mappedVar tabMappedVar[8] = { {0x2000,4,8}, {0x2000,3,8}, {0x2000,1,8}, }; - slaveMappingPDO(0x05, 0x1800, 0x181, tabMappedVar, 3); - } - /* - *** PDO node 1 <-- node 5 *** - *** cobId 0x182 ************* - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - minute [0x6002 - 0x02 - 8] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bits]: - minute [0x2000 - 0x02 - 8] - */ - - /* Configuring PDO receive, defined at index 0x1400 and 0x1600 */ - { - s_mappedVar tabMappedVar[8] = { {0x6002,2,8} }; - masterMappingPDO(0x1401, 0x182, tabMappedVar, 1); - } - - /* Configuring PDO transmit, defined at index 0x1800 and 0x1A00 */ - { - s_mappedVar tabMappedVar[8] = { {0x2000,2,8} }; - slaveMappingPDO(0x05, 0x1801, 0x182, tabMappedVar, 1); - } - - - /* - *** PDO node 1 <-- node 5 *** - *** cobId 0x183 ************* - Error management : By this way, The node can send by PDO an error - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - canopenErrNb_node5 [0x6000 - 0x00 - 32] - canopenErrVal_node5 [0x6001 - 0x00 - 32] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bytes]: - canopenErrNb [0x6000 - 0x00 - 32] - canopenErrVal [0x6001 - 0x00 - 32] - */ - - /* Configuring PDO receive, defined at index 0x1402 and 0x1602 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - masterMappingPDO(0x1402, 0x183, tabMappedVar, 2); - } - - /* Configuring PDO transmit, defined at index 0x1802 and 0x1A02 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - slaveMappingPDO(0x05, 0x1802, 0x183, tabMappedVar, 2); - } - - /* - *** PDO node 1 --> node 5 *** - *** cobId 0x184 ************* - Error management : To reset the error - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - canopenErrNb_node5 [0x6000 - 0x00 - 32] - canopenErrVal_node5 [0x6001 - 0x00 - 32] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bytes]: - canopenErrNb [0x6000 - 0x00 - 32] - canopenErrVal [0x6001 - 0x00 - 32] - */ - - /* Configuring PDO transmit, defined at index 0x1803 and 0x1103 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - masterMappingPDO(0x1801, 0x184, tabMappedVar, 2); - } - - /* Configuring PDO transmit, defined at index 0x1403 and 0x1603 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - slaveMappingPDO(0x05, 0x1400, 0x184, tabMappedVar, 2); - } - - /* Configuring the node 5 heartbeat */ - /* Check every 3000 ms if it have received a heartbeat from node 1 */ - { - UNS8 nbHeartbeatsToReceive = 1; - s_heartbeatConsumer tabHeartbeatConsumer[10] = {{1, 0xBB8}}; - slaveHeartbeatConsumer(0x05, tabHeartbeatConsumer, nbHeartbeatsToReceive); - } - /* Sending every 1000 ms an heartbeat */ - slaveHeartbeatProducer(0x05, 0x3E8); - - /* Configuring the master heartbeat */ - /* Check every 3000 ms if it have received a heartbeat from node 5 */ - { - UNS8 nbHeartbeatsToReceive = 1; - s_heartbeatConsumer tabHeartbeatConsumer[10] = {{5, 0xBB8}}; - masterHeartbeatConsumer(tabHeartbeatConsumer, nbHeartbeatsToReceive); - } - - /* Sending every 1000 ms an heartbeat */ - masterHeartbeatProducer(0x3E8); - - - - /* Configuring the transmission mode of the PDO */ - slavePDOTransmissionMode(0x05, 0x1800, TRANS_EVERY_N_SYNC (1)); - slavePDOTransmissionMode(0x05, 0x1801, TRANS_EVENT); - slavePDOTransmissionMode(0x05, 0x1802, TRANS_EVENT); - masterPDOTransmissionMode(0x1801, TRANS_EVENT); - - - /* Configuring the master to send a SYNC message every 1 s */ - /* Note than any other node can send the SYNC instead of the master */ - masterSYNCPeriod(1000000); - - { - // Reading the period of heartbeat which has been written in node 5 dictionary - UNS8 node = 5; - UNS16 index = 0x1017; - UNS8 subindex = 0; - //UNS8 notused = 0; - UNS16 hb = 0; - UNS8 size_data = 0; - UNS8 error; - MSG_WAR(0x3F50, "Reading dictionary noeud 5, 1017/0", 0); - error = readNetworkDict(0, node, index, subindex, 0); - //error = readNetworkDict(0, node, index, subindex, ¬used); - if (error) { - MSG_ERR(0x1F50, "!!! ERROR reading dictionary noeud 5, 1017/0", 0); - exit (-1); - } - /* Waiting until the server has responded */ - error = waitingReadToSlaveDict(node, (UNS16 *)&hb, &size_data, error); - MSG_WAR(0x1F51, "Read dictionary of node 5, index/subindex 1017/0 value = ", hb); - MSG_WAR(0x1F51, " size of data (bytes) = ", size_data); - } - - /* Put the node 5 in operational mode - The mode is changed according to the slave state machine mode : - initialisation ---> pre-operational (Automatic transition) - pre-operational <--> operational - pre-operational <--> stopped - pre-operational, operational, stopped -> initialisation - NMT_Start_Node // Put the node in operational mode - NMT_Stop_Node // Put the node in stopped mode - NMT_Enter_PreOperational // Put the node in pre_operational mode - NMT_Reset_Node // Put the node in initialization mode - NMT_Reset_Comunication // Put the node in initialization mode - */ - masterSendNMTstateChange(0, 0x05, NMT_Start_Node); - - // Note - //----- - // We do not have mapped the variable canopenErrNB and canopenErrVAL. - // We should have done that ! - // the macro MSG_ERR try to send the PDO(s) which contains these two variables. - // While the PDO will not be found, if you are printing the warnings in file pdo.c, - // it will print "0X393B Unable to send variable on event : not mapped in a PDO to send on event" for - // example when you enter the function heartbeatError. - - /******************** END CONFIGURING THE NETWORK **********************/ - - - - /* Init the errors values that may send the node 5 */ - canopenErrNB_node5 = 0; - canopenErrVAL_node5 = 0; - - /***********/ - /* Running */ - /***********/ - - /* SDO test with node 5 */ - /* This code may takes too much room in memory if you are also debugging the file sdo.c */ - { - // Reading string - UNS8 dataW[20]; - UNS8 dataR[20]; - UNS8 size; - UNS8 err; - MSG_WAR(0x3F05, "Test SDO", 0); - - MSG_WAR(0x3F10, "Writing to node 5 at 0x6002-0 ...", 0); - strcpy(dataW, "Au Revoir"); - MSG_WAR(0x3F10, dataW, 0); - size = 20; - err = writeNetworkDict(0, 5, 0x6002, 0, 10, visible_string, dataW); - err = waitingWriteToSlaveDict(5, err); - - err = readNetworkDict(0, 5, 0x6002, 0, visible_string); - err = waitingReadToSlaveDict(5, dataR, &size, err); - MSG_WAR(0x3F08, "Read from node 5 at 0x6002-0" , 0); - MSG_WAR(0x3F08, dataR, 0); - - MSG_WAR(0x3F08, "node 5. Hardware version. (default = compil. date) ...", 0); - err = readNetworkDict(0, 5, 0x1009, 0, visible_string); - - err = waitingReadToSlaveDict(5, dataR, &size, err); - MSG_WAR(0x3F08, dataR, 0); - - MSG_WAR(0x3F08, "node 5. Software version. (default = compil. time) ...", 0); - err = readNetworkDict(0, 5, 0x100A, 0, visible_string); - err = waitingReadToSlaveDict(5, dataR, &size, err); - MSG_WAR(0x3F08, dataR, 0); - } - - // Node identity ? - { - UNS8 *data; - UNS8 size; - UNS8 dataType; - // Manufacturer Device name (default = empty string) - getODentry(0x1008, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Hardware version. (default = compilation. date) - getODentry(0x1009, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Software version. (default = compilation. time) - getODentry(0x100A, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - } - - while(1) { - // To transmit the SYNC if it is time to do. - computeSYNC(); - - // Testing if heartsbeat have been received, and send a heartbeat if it is time. - heartbeatMGR(); - - // Messages received ? - // The function is called in void __attribute__((interrupt)) timer3Hdl (void) - //receiveMsgHandler(0); - - if (minutes != minutes_last) { - MSG_WAR(0x3F80, "Minutes changed :", minutes); - minutes_last = minutes; - } - - if (second != second_last) { - MSG_WAR(0x3F81, "Seconds : ", second); - second_last = second; - - if (canopenErrNB_node5) { - MSG_WAR(0x3F82, "Received an error from node 5, NB : ", canopenErrNB_node5); - MSG_WAR(0x3F83, " VALUE : ", canopenErrVAL_node5); - // Reseting the error - canopenErrNB_node5 = 0; - canopenErrVAL_node5 = 0; - sendingResetError = 1; - } - - if ((second == 00) && sendingResetError) { - MSG_WAR(0x3F84, - "Sending to node 5 a PDO envent to reset the error NB and VAL : ",0); - sendPDOevent(0, &canopenErrNB_node5); - sendingResetError = 0; - } - - - } // end if (second != second_last) - - - } // end while - - - return (0); -} - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/objdict.c --- a/examples/AppliMaster_HCS12/objdict.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,642 +0,0 @@ -/* -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 -*/ - -#include - -#include -#include "def.h" -#include "can.h" -#include "objdictdef.h" -#include "pdo.h" -#include "sdo.h" -#include "sync.h" -#include "lifegrd.h" -#include "nmtSlave.h" - -/**************************************************************************/ -/* Declaration of the mapped variables */ -/**************************************************************************/ - - - -/*// Copy and uncomment this code to your main file -extern UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x00 -extern UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x00 -extern UNS8 second; // Mapped at index 0x6002, subindex 0x01 -extern UNS8 minutes; // Mapped at index 0x6002, subindex 0x02 -extern UNS8 hour; // Mapped at index 0x6002, subindex 0x03 -extern UNS8 day; // Mapped at index 0x6002, subindex 0x04 -extern UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x01 -extern UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x02 - -// END copy to main file -*/ - -UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x00 -UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x00 -UNS8 second; // Mapped at index 0x6002, subindex 0x01 -UNS8 minutes; // Mapped at index 0x6002, subindex 0x02 -UNS8 hour; // Mapped at index 0x6002, subindex 0x03 -UNS8 day; // Mapped at index 0x6002, subindex 0x04 -UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x01 -UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x02 - -/**************************************************************************/ -/* Declaration of the value range types */ -/**************************************************************************/ - - - -UNS32 valueRangeTest (UNS8 typeValue, UNS32 unsValue, REAL32 realValue) -{ - return 0; -} - - -/**************************************************************************/ -/* The node id */ -/**************************************************************************/ -/* Computed by strNode */ -/* node_id default value. - This default value is deprecated. - You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code. -*/ -#define NODE_ID 0x01 -UNS8 bDeviceNodeId = NODE_ID; - - -//*****************************************************************************/ -/* Computed by strStartDico */ - -/* Array of message processing information */ -/* Should not be modified */ -volatile const proceed_info proceed_infos[] = { - {NMT, "NMT", NULL}, - {SYNC, "SYNC", proceedSYNC}, - {TIME_STAMP, "TStmp", NULL}, - {PDO1tx, "PDO1t", proceedPDO}, - {PDO1rx, "PDO1r", proceedPDO}, - {PDO2tx, "PDO2t", proceedPDO}, - {PDO2rx, "PDO2r", proceedPDO}, - {PDO3tx, "PDO3t", proceedPDO}, - {PDO3rx, "PDO3r", proceedPDO}, - {PDO4tx, "PDO4t", proceedPDO}, - {PDO4rx, "PDO4r", proceedPDO}, - {SDOtx, "SDOt", proceedSDO}, - {SDOrx, "SDOr", proceedSDO}, - {0xD, "Unkw", NULL}, - {NODE_GUARD, "NGrd", proceedNMTerror}, - {0xF, "Unkw", NULL} -}; - - // Macros definition - -/* Beware : -index *must* be writen 4 numbers in hexa -sub_index *must* be writen 2 numbers in hexa -size_variable_in_UNS8 *must* be writen 2 numbers in hexa -*/ -#define PDO_MAP(index, sub_index, size_variable_in_bits)\ -0x ## index ## sub_index ## size_variable_in_bits - -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// -// OBJECT DICTIONARY -// -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// Make your change, depending of your application - - -/* index 0x1000 : Device type. - You have to change the value below, so - it fits your canopen-slave-module */ - - /* Not used, so, should not be modified */ - - UNS32 obj1000 = 0; - subindex Index1000[] = - { - { RO, uint32, sizeof(UNS32), (void*)&obj1000 } - }; - -/* index 0x1001 : Error register. - Change the entries to fit your application - Not used, so, should not be modified */ - /*const*/ UNS8 obj1001 = 0x0; - /*const*/ subindex Index1001[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1001 } - }; - -/* index 0x1005 : COB_ID SYNC */ - /* Should not be modified */ - UNS32 obj1005 = 0x00000080; // bit 30 = 1 : device can generate a SYNC message - // Beware, it is over written when the node - // enters in reset mode - // See initResetMode() in init.c - /*const*/ subindex Index1005[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1005 } - }; - -/* index 0x1006 : SYNC period */ - // For producing the SYNC signal every n micro-seconds. - // Put O to not producing SYNC - /*const*/ UNS32 obj1006 = 0x0; - // Default 0 to not produce SYNC // - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - /*const*/ subindex Index1006[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1006 } - }; - -/* index 0x1007 : Synchronous Window Length - Seems to be needed by DS401 to generate the SYNC signal ! */ - /*const*/ UNS32 obj1007 = 0x0; /* Default 0 */ - /*const*/ subindex Index1007[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1007 } - }; - -/* index 0x1008 : Manufacturer device name */ - UNS8 obj1008[] = "Appli_Master_HC12"; /* Default 0 */ - subindex Index1008[] = - { - { RO, uint32, sizeof(obj1008), (void*)&obj1008 } - }; - -/* index 0x1009 : Manufacturer hardware version */ - UNS8 obj1009[] = __DATE__; /* Default 0 */ - subindex Index1009[] = - { - { RO, uint32, sizeof(obj1009), (void*)&obj1009 } - }; - -/* index 0x100A : Manufacturer software version */ - UNS8 obj100A[] = __TIME__; /* Default 0 */ - subindex Index100A[] = - { - { RO, uint32, sizeof(obj100A), (void*)&obj100A} - }; - -/* index 0x1016 : HeartBeat consumers - The nodes which can send a heartbeat */ - static UNS32 obj1016[] = {// Consumer time for each node - 0x00000000}; // Format 0x00NNTTTT (N=Node T=time in ms) - - static UNS8 obj1016_cnt = 1; // 1 nodes could send me - // their heartbeat. - subindex Index1016[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1016_cnt }, - { RW, uint32, sizeof(UNS32), (void*)&obj1016[0] } - }; - -/* index 0x1017 : Heartbeat producer - Every HBProducerTime, the node sends its heartbeat */ - static UNS16 obj1017 = 0; //HBProducerTime in ms. If 0 : not activated - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - subindex Index1017[] = - { - { RW, uint16, sizeof(UNS16), &obj1017 } - }; - -/* index 0x1018 : Identity object */ - /** index 1018: identify object. Adjust the entries for your node/company - */ - /* Values can be modified */ - - s_identity obj1018 = - { - 4, // number of supported entries - 0, // Vendor-ID (given by the can-cia) - 0, // Product Code - 0, // Revision number - 0 // serial number - }; - - subindex Index1018[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1018.count }, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.vendor_id}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.product_code}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.revision_number}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.serial_number} - }; - -/* index 0x1200 : The SDO Server parameters */ - /* BEWARE You cannot define more than one SDO server */ - /* The values should not be modified here, - but can be changed at runtime */ - // Beware that the default values that you could put here - // will be over written at the initialisation of the node. - // See setNodeId() in init.c - static s_sdo_parameter obj1200 = - { 3, // Number of entries. Always 3 for the SDO - 0x600 + NODE_ID, // The cob_id transmited in CAN msg to the server - 0x580 + NODE_ID, // The cob_id received in CAN msg from the server - NODE_ID // The node id of the client. Should not be modified - }; - static subindex Index1200[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1200.count }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_client }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_server }, - { RW, uint8, sizeof( UNS8), (void*)&obj1200.node_id } - }; - -/* index 0x1280 : SDO client parameter */ - static s_sdo_parameter obj1280 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1280[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1280.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1280.node_id } - }; - -/* index 0x1281 : SDO client parameter */ - static s_sdo_parameter obj1281 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1281[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1281.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1281.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1281.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1281.node_id } - }; - -/* index 0x1400 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1400 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1400[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1400.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1400.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1400.type }, - }; - -/* index 0x1401 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1401 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1401[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1401.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1401.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1401.type }, - }; - -/* index 0x1402 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1402 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1402[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1402.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1402.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1402.type }, - }; - -/* index 0x1600 : PDO receive mapping parameter of PDO communication index 0x1400 */ - static UNS8 obj1600_cnt = 0; // Number of mapped variables - static UNS32 obj1600_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1600[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1600_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[7]} - }; - -/* index 0x1601 : PDO receive mapping parameter of PDO communication index 0x1401 */ - static UNS8 obj1601_cnt = 0; // Number of mapped variables - static UNS32 obj1601_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1601[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1601_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[7]} - }; - -/* index 0x1602 : PDO receive mapping parameter of PDO communication index 0x1402 */ - static UNS8 obj1602_cnt = 0; // Number of mapped variables - static UNS32 obj1602_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1602[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1602_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[7]} - }; - -/* index 0x1800 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1800 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1800[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1800.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1800.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1800.type }, - }; - -/* index 0x1801 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1801 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1801[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1801.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1801.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1801.type }, - }; - -/* index 0x1802 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1802 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1802[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1802.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1802.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1802.type }, - }; - -/* index 0x1A00 : PDO transmit mapping parameter of PDO communication index 0x1800 */ - static UNS8 obj1A00_cnt = 0; // Number of mapped variables - static UNS32 obj1A00_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A00[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A00_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[7]} - }; - -/* index 0x1A01 : PDO transmit mapping parameter of PDO communication index 0x1801 */ - static UNS8 obj1A01_cnt = 0; // Number of mapped variables - static UNS32 obj1A01_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A01[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A01_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[7]} - }; - -/* index 0x1A02 : PDO transmit mapping parameter of PDO communication index 0x1802 */ - static UNS8 obj1A02_cnt = 0; // Number of mapped variables - static UNS32 obj1A02_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A02[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A02_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[7]} - }; - - -/* index 0x6000 : Mapped variable */ - subindex Index6000[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB_node5 } - }; - -/* index 0x6001 : Mapped variable */ - subindex Index6001[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL_node5 } - }; - -/* index 0x6002 : Mapped variable */ - static UNS8 highestSubIndex_6002 = 4; // number of subindex - 1 - subindex Index6002[] = - { - { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_6002 }, - { RW, uint8, sizeof (UNS8), (void*)&second }, - { RW, uint8, sizeof (UNS8), (void*)&minutes }, - { RW, uint8, sizeof (UNS8), (void*)&hour }, - { RW, uint8, sizeof (UNS8), (void*)&day } - }; - -/* index 0x6003 : Mapped variable */ - static UNS8 highestSubIndex_6003 = 2; // number of subindex - 1 - subindex Index6003[] = - { - { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_6003 }, - { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB }, - { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL } - }; - -const indextable objdict[] = -{ - DeclareIndexTableEntry(Index1000, 0x1000), - DeclareIndexTableEntry(Index1001, 0x1001), - DeclareIndexTableEntry(Index1005, 0x1005), - DeclareIndexTableEntry(Index1006, 0x1006), - DeclareIndexTableEntry(Index1007, 0x1007), - DeclareIndexTableEntry(Index1008, 0x1008), - DeclareIndexTableEntry(Index1009, 0x1009), - DeclareIndexTableEntry(Index100A, 0x100A), - DeclareIndexTableEntry(Index1016, 0x1016), - DeclareIndexTableEntry(Index1017, 0x1017), - DeclareIndexTableEntry(Index1018, 0x1018), - DeclareIndexTableEntry(Index1200, 0x1200), - DeclareIndexTableEntry(Index1280, 0x1280), - DeclareIndexTableEntry(Index1281, 0x1281), - DeclareIndexTableEntry(Index1400, 0x1400), - DeclareIndexTableEntry(Index1401, 0x1401), - DeclareIndexTableEntry(Index1402, 0x1402), - DeclareIndexTableEntry(Index1600, 0x1600), - DeclareIndexTableEntry(Index1601, 0x1601), - DeclareIndexTableEntry(Index1602, 0x1602), - DeclareIndexTableEntry(Index1800, 0x1800), - DeclareIndexTableEntry(Index1801, 0x1801), - DeclareIndexTableEntry(Index1802, 0x1802), - DeclareIndexTableEntry(Index1A00, 0x1A00), - DeclareIndexTableEntry(Index1A01, 0x1A01), - DeclareIndexTableEntry(Index1A02, 0x1A02), - DeclareIndexTableEntry(Index6000, 0x6000), - DeclareIndexTableEntry(Index6001, 0x6001), - DeclareIndexTableEntry(Index6002, 0x6002), - DeclareIndexTableEntry(Index6003, 0x6003), -}; - -// To count at which received SYNC a PDO must be sent. -// Even if no pdoTransmit are defined, at least one entry is computed -// for compilations issues. -UNS8 count_sync[1] = {0, }; - -UNS16 firstIndex (enum e_first_object object, UNS16 *lastIndex) -{ - switch (object) { - case FIRST_SDO_SERVER : - *lastIndex = 11; - return 11; - case FIRST_SDO_CLIENT : - *lastIndex = 13; - return 12; - case FIRST_PDO_RCV : - *lastIndex = 16; - return 14; - case FIRST_PDO_RCV_MAP : - *lastIndex = 19; - return 17; - case FIRST_PDO_TRS : - *lastIndex = 22; - return 20; - case FIRST_PDO_TRS_MAP : - *lastIndex = 25; - return 23; - } - *lastIndex = 0; - return 0; -} - -UNS16 getObjdictSize (void) -{ - return sizeof(objdict)/sizeof(objdict[0]); -} diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/objdict.html --- a/examples/AppliMaster_HCS12/objdict.html Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ - - - - -CANOpen object dictionary Configuration - - - -

Object dictionary for Node :

-

-Mastermaster -

-

Overview

-

- How to make the object dictionary of the node ? - First, use Jaxe (command run_objdict) to edit an xml description file -of the dictionary : objdict.xml. -Then, run the php program : makeobjetdict.php. You can launch php through a web browser -if you have installed a server, or, on Linux, you can launch php in command line : -php-cgi makeobjetdict.php. It compute the file objdict.c. Link it to - your project. -
Note : To define the node id, use in your code the function setNodeId(UNS8 nodeId) -

-

- Then the node can be connected to the network. The master must configure it - by sending SDO. It will write values in its index, subindex. What to configure ? -

    -
  • Receiving heartbeats from which nodes ? Waiting time ?
  • -
  • Emitting heartbeats or not ? time btw 2 heartbeats ?
  • -
  • Defining a cobId for each PDO receive and transmit
  • -
  • How to transmit a PDO ? on synchro ? request ? event ?
  • -
  • What variables to put in each PDO receive and transmit ?
  • -
  • ...
  • -
-

- To avoid configuring the node at the connection, you can put the values directly -in the dictionary objdict.c. But it is boring and unsafe because it is too easy to make -a mistake ! - - -

Number of heartbeat consumers : - 1 -

-

This means that the node can expect heartbeats sent by 1 nodes.

-

Number of SDO clients : - 10 -

-

Usualy, a slave node does not have the use of SDO clients, but - today, for the library, you must define one. The Master, which can - send SDO to "n" slaves nodes, must define here "n" SDO - clients. Remember that in most cases, the SDO protocol is used by - the master to configure a slave dictionary or read a value. In - this use, the master is the client, and the slave is the server.

-

Maximum objects in a PDO (receive or transmit) : - 8 -

-

This is defining how many variables can be transmited in a - PDO. (maximum is 8).

-

For each variable, a table is created, so if you have less room - in memory, put a value under 8.

-

Number of PDO receive : - 3 -

-

The node can receive 3 PDO.

-

The communication parameters are defined at index 0x1400 to 0x1400 + 2

-

The mapping parameters are defined at index 0x1600 to 0x1600 + 2

-

Number of PDO transmit : - 3 -

-

The node can transmit 3 PDO.

-

The communication parameters are defined at index 0x1800 to 0x1800 + 2

-

The mapping parameters are defined at index 0x1A00 to 0x1A00 + 2

-

Mapped variables and tables

-

3 tables are defined for the mapping, starting at index 0x2000, 0x6000 and 0x6200. - You must start the mapping at the beginning of one of a table, without holes in index -or subindex. For example, variables in 0x2000 and 0x2001 is ok, but variables in 0x2000 and 0x2002 is not allowed, because you are loosing room in memory. It is the same for the subindex. -

-

Here are some others rules for the mapping :

-
    -
  • At an Index, you can map a variable at subindex 0x0 or 0x1, as you like.
  • -
  • To map several variables at the same Index, you must start at subindex 0x1, - because in this case, the subindex 0x0 contains the number of subindex.
  • -
  • You cannot map variables and tables at the same index.
  • -
  • The mapping of a table is always starting at subindex 0x1.
  • -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameBitsIndexSub-index
canopenErrNB_node5320x60000x0
canopenErrVAL_node5320x60010x0
second80x60020x1
minutes80x60020x02
hour80x60020x3
day80x60020x4
canopenErrNB320x60030x01
canopenErrVAL320x60030x02
- - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/objdict.xml --- a/examples/AppliMaster_HCS12/objdict.xml Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/trace32_flash_debug.cmm --- a/examples/AppliMaster_HCS12/trace32_flash_debug.cmm Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -; Réinitialisation -SYS.d - -; Effacer l'écran -WinCLEAR - -;Raffraichissement de trace32 toutes les 1 secondes -setup.urate 1 - -; Choix du microcontrôleur cible -SYStem.CPU MCS12DP256 - -; Vitesse de commuication debugger / carte HCS12 - SYStem.BdmClock 8.0MHZ - -; initialiser le uc en mode debug -SYStem.UP - -; Reset des registres -r.reset - -; Charger le programme -DATA.LOAD.ELF appliMaster.elf /gnu /nocode /GHILLS - -; Positionner le compteur de programme -r.set PC _start - -; Positionner le pointeur de pile -r.set SP _stack - -; Afficher le code source -data.list - -; Afficher les registres -r - -; Afficher le contenu de la mémoire -DATA.dump 140 - - -; Fin du programme de script -ENDDO - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/trace32_flash_debug_sans_init.cmm --- a/examples/AppliMaster_HCS12/trace32_flash_debug_sans_init.cmm Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -; Réinitialisation -SYS.d - -; Effacer l'écran -;WinCLEAR - -;Raffraichissement de trace32 toutes les 1 secondes -setup.urate 1 - -; Choix du microcontrôleur cible -SYStem.CPU MCS12DP256 - -; Vitesse de commuication debugger / carte HCS12 - SYStem.BdmClock 8.0MHZ - -; initialiser le uc en mode debug -SYStem.UP - -; Reset des registres -r.reset - -; Charger le programme -DATA.LOAD.ELF appliMaster.elf /gnu /nocode /GHILLS - -; Positionner le compteur de programme -r.set PC _start - -; Positionner le pointeur de pile -r.set SP _stack - - - - -; Fin du programme de script -ENDDO - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/trace32_flash_programmer.cmm --- a/examples/AppliMaster_HCS12/trace32_flash_programmer.cmm Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -; Programmation de la mémoire flash - - -; Réinitialisation -SYS.d - -; Effacer l'écran -WinCLEAR - -; Vitesse de transmission : -SYStem.BdmClock 8.0MHZ - -; Choix du microcontrôleur cible -SYStem.CPU MCS12DP256 - -; Flash page 0X3E accessible entre 0X4000 et 0X7FFF -; cf Motorola, registre MISC - -system.option ROMHM ON - - -; Enlever tous les points d'arrêt -b.res - -; Utiliser les points d'arrêts onchip -map.bonchip - -; Connexion à la carte CS12 -system.up - -flash.reset - - -; Effacement de la flash -PRINT "Effacement de la flash" -FLASH.Erase all - -; Passage en mode programmation de la flash -print "Programmation de la flash non paginée (48KO) 1 " -FLASH.Program 0x4000--0x7FFF - -;print "Chargement du programme en flash 1" -DATA.LOAD.ELF appliMaster.elf 0x4000--0x7FFF - - -FLASH.Program off -print "Flash programmée 1" - - -; Passage en mode programmation de la flash -print "Programmation de la flash non paginée (48KO) 2" -FLASH.Program 0x308000--0x30BFFF - -;print "Chargement du programme en flash 2" -DATA.LOAD.ELF appliMaster.elf 0x8000--0xBFFF - - -FLASH.Program off -print "Flash programmée 2" - -; Passage en mode programmation de la flash -print "Programmation de la flash non paginée (48KO) 3" -FLASH.Program 0xC000--0xFFFF - -;print "Chargement du programme en flash 3" -DATA.LOAD.ELF appliMaster.elf 0xC000--0xFFFF - - -FLASH.Program off -print "Flash programmée 3" - - -;Reset du HCS12 -system.up - -;Reset de trace32 -SYS.d - - -ENDDO - - - - - - - - - - - - - - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_HCS12/vectors.s --- a/examples/AppliMaster_HCS12/vectors.s Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -;;/* M68HC11 Interrupt vectors table -;; Copyright (C) 1999 Free Software Foundation, Inc. -;; Written by Stephane Carrez (stcarrez@worldnet.fr) -;; -;;This file 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. -;; -;;In addition to the permissions in the GNU General Public License, the -;;Free Software Foundation gives you unlimited permission to link the -;;compiled version of this file with other programs, and to distribute -;;those programs without any restriction coming from the use of this -;;file. (The General Public License restrictions do apply in other -;;respects; for example, they cover modification of the file, and -;;distribution when not linked into another program.) -;; -;;This file 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; see the file COPYING. If not, write to -;;the Free Software Foundation, 59 Temple Place - Suite 330, -;;Boston, MA 02111-1307, USA. -;; ---------------------------------------------- -;; Modified by Francis Dupin for MC9S12DP256. April 2003 -;; francis.dupin@inrets.fr -;;*/ - - .sect .text - .globl _start - .globl can4HdlTra - .globl can4HdlRcv - .globl can4HdlErr - .globl can4HdlWup - .globl can3HdlTra - .globl can3HdlRcv - .globl can3HdlErr - .globl can3HdlWup - .globl can2HdlTra - .globl can2HdlRcv - .globl can2HdlErr - .globl can2HdlWup - .globl can1HdlTra - .globl can1HdlRcv - .globl can1HdlErr - .globl can1HdlWup - .globl can0HdlTra - .globl can0HdlRcv - .globl can0HdlErr - .globl can0HdlWup - .globl timerOvflHdl - .globl timer3IC - .globl timer2IC - .globl timer1IC - .globl timer0IC - -;; Default interrupt handler. - .sect .text -def: - rti - -;; -;; Interrupt vectors are in a specific section that is -;; mapped at 0xff00. For the example program, the reset handler -;; points to the generic crt0 entry point. -;; - .sect .vectors - .globl vectors -vectors: - - .word def ; ff00 - .word def ; ff02 - .word def ; ff04 - .word def ; ff06 - .word def ; ff08 - .word def ; ff0a - .word def ; ff0c - .word def ; ff0e - .word def ; ff10 - .word def ; ff12 - .word def ; ff14 - .word def ; ff16 - .word def ; ff18 - .word def ; ff1a - .word def ; ff1c - .word def ; ff1e - .word def ; ff20 - .word def ; ff22 - .word def ; ff24 - .word def ; ff26 - .word def ; ff28 - .word def ; ff2a - .word def ; ff2c - .word def ; ff2e - .word def ; ff30 - .word def ; ff32 - .word def ; ff34 - .word def ; ff36 - .word def ; ff38 - .word def ; ff3a - .word def ; ff3c - .word def ; ff3e - .word def ; ff40 - .word def ; ff42 - .word def ; ff44 - .word def ; ff46 - .word def ; ff48 - .word def ; ff4a - .word def ; ff4c - .word def ; ff4e - .word def ; ff50 - .word def ; ff52 - .word def ; ff54 - .word def ; ff56 - .word def ; ff58 - .word def ; ff5a - .word def ; ff5c - .word def ; ff5e - .word def ; ff60 - .word def ; ff62 - .word def ; ff64 - .word def ; ff66 - .word def ; ff68 - .word def ; ff6a - .word def ; ff6c - .word def ; ff6e - .word def ; ff70 - .word def ; ff72 - .word def ; ff74 - .word def ; ff76 - .word def ; ff78 - .word def ; ff7a - .word def ; ff7c - .word def ; ff7e - .word def ; ff80 - .word def ; ff82 - .word def ; ff84 - .word def ; ff86 - .word def ; ff88 - .word def ; ff8a - .word def ; ff8c - .word def ; ff8e - - ;; MSCAN - .word can4HdlTra ; ff90 (MSCAN4 Transmit) - .word can4HdlRcv ; ff92 (MSCAN4 Receive) - .word can4HdlErr ; ff94 (MSCAN4 Errors) - .word can4HdlWup ; ff96 (MSCAN4 Wake up) - .word can3HdlTra ; ff98 (MSCAN3 Transmit) - .word can3HdlRcv ; ff9a (MSCAN3 Receive) - .word can3HdlErr ; ff9c (MSCAN3 Errors) - .word can3HdlWup ; ff9e (MSCAN3 Wake up) - .word can2HdlTra ; ffa0 (MSCAN2 Transmit) - .word can2HdlRcv ; ffa2 (MSCAN2 Receive) - .word can2HdlErr ; ffa4 (MSCAN2 Errors) - .word can2HdlWup ; ffa6 (MSCAN2 Wake up) - .word can1HdlTra ; ffa8 (MSCAN1 Transmit) - .word can1HdlRcv ; ffaa (MSCAN1 Receive) - .word can1HdlErr ; ffac (MSCAN1 Errors) - .word can1HdlWup ; ffae (MSCAN1 Wake up) - .word can0HdlTra ; ffb0 (MSCAN0 Transmit) - .word can0HdlRcv ; ffb2 (MSCAN0 Receive) - .word can0HdlErr ; ffb4 (MSCAN0 Errors) - .word can0HdlWup ; ffb6 (MSCAN0 Wake up) - - .word def ; ffb8 - .word def ; ffba - .word def ; ffbc - .word def ; ffbe - - .word def ; ffc0 - .word def ; ffc2 - .word def ; ffc4 - .word def ; ffc6 - .word def ; ffc8 - .word def ; ffca (Modulus Down Counter underflow) - .word def ; ffcc - .word def ; ffce - .word def ; ffd0 - .word def ; ffd2 - .word def ; ffd4 - - ;; SCI - .word def ; ffd6 - - ;; SPI - .word def ; ffd8 - .word def ; ffda (PAII) - .word def ; ffdc (PAOVI) - .word def ;ffde (TOI) - - ;; Timer Output Compare - .word def ; ffe0 Timer Chanel 7 - .word def ; ffe2 Timer Chanel 6 - .word def ; ffe4 Timer Chanel 5 - .word timer4Hdl ; ffe6 Timer Chanel 4 used by Canopen - .word timer3Hdl ; ffe8 Timer Chanel 3 For the date - .word def ; ffea Timer Chanel 2 - .word def ; ffec Timer Chanel 1 - .word def ; ffee Timer Chanel 0 - - ;; Misc - .word def ; fff0 (RTII) - .word def ; fff2 (IRQ) - .word def ; fff4 (XIRQ) - .word def ; fff6 (SWI) - .word def ; fff8 (ILL) - .word def ; fffa (COP Failure) - .word def ; fffc (COP Clock monitor) - .word _start ; fffe (reset) - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_Linux/.cvsignore --- a/examples/AppliMaster_Linux/.cvsignore Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Makefile diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_Linux/Makefile.in --- a/examples/AppliMaster_Linux/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -#! 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 -OS_NAME = SUB_OS_NAME -ARCH_NAME = SUB_ARCH_NAME -PREFIX = SUB_PREFIX -TARGET = SUB_TARGET - -LIBPATH = /usr/lib -LIBINC = /usr/include -LIB = -L$(LIBPATH) -lpcan - -INCLUDES = -I../../include -I../../include/peak - -MASTER_OBJS = objdict.o appli.o - -OBJS = $(MASTER_OBJS) ../../src/peak_pdo.o ../../src/peak_sdo.o ../../src/peak_init.o ../../src/peak_sync.o\ - ../../src/peak_objacces.o ../../src/peak_lifegrd.o ../../src/peak_timer.o ../../src/peak_nmtMaster.o\ - ../../drivers/peak/canOpenDriver.o ../../drivers/peak/timerhw.o - - -all: AppliMaster - -AppliMaster: $(OBJS) - $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -lpthread -lstdc++ $(OBJS) $(LIB) - -%o: %c - $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -D_REENTRANT -c $< - -clean: - -rm $(MASTER_OBJS) - -mrproper: clean - -rm AppliMaster - - - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_Linux/appli.c --- a/examples/AppliMaster_Linux/appli.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1005 +0,0 @@ -/* -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 -*/ - -#include -#include -#include -#include -#include -#include - - -#include -#include -#include - -#include "def.h" -#include "can.h" -#include "objdictdef.h" -#include "objacces.h" -#include "canOpenDriver.h" -#include "sdo.h" -#include "pdo.h" -#include "init.h" -#include "timer.h" -#include "lifegrd.h" -#include "sync.h" - -#include "nmtMaster.h" - - - -// For prototype of exit(); -#define exit _exit - - -// Adlink 7841 or Peak PCI/CAN board -// --------------------------------- - -// Baudrate values for Peak board : -// CAN_BAUD_1M CAN_BAUD_500K CAN_BAUD_250K CAN_BAUD_125K CAN_BAUD_100K CAN_BAUD_50K -// CAN_BAUD_20K CAN_BAUD_10K CAN_BAUD_5K - -#ifdef CAN_BAUD_250K -# define BAUDRATE CAN_BAUD_250K -#else -// Appli have been compiled for Adlink-arbraca. Baudrate not used -# define BAUDRATE 0 -#endif - -s_BOARD board = {"0", BAUDRATE}; - - -// Required definition variables -// ----------------------------- -// The variables that you should define for debugging. -// They are used by the macro MSG_ERR and MSG_WAR in applicfg.h -// if the node is a slave, they can be mapped in the object dictionnary. - -UNS8 printMsgErrToConsole = 1; -UNS8 printMsgWarToConsole = 1; - -// The variables mapped in the object dictionnary -// ---------------------------------------------- -extern UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x0 -extern UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x0 -extern UNS8 second; // Mapped at index 0x6002, subindex 0x1 -extern UNS8 minutes; // Mapped at index 0x6002, subindex 0x2 -extern UNS8 hour; // Mapped at index 0x6002, subindex 0x3 -extern UNS8 day; // Mapped at index 0x6002, subindex 0x4 -extern UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x1 -extern UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x2 - - -/*************************User's variables declaration**************************/ -pthread_t threadM; -pthread_t threadH; -pthread_t threadS; -UNS8 connectedNode[128]; - -/* The variable to map in a PDO is defined at index and subIndex. Its length is size bytes */ -typedef struct mappedVar -{ - UNS32 index; - UNS8 subIndex; - UNS8 size; // in byte -} s_mappedVar; - -typedef struct heartbeatConsumer -{ - UNS8 nodeProducer; - UNS16 time_ms; -} s_heartbeatConsumer; - -/**************************prototypes*****************************************/ -/* You *must* have these 2 functions in your code*/ -void heartbeatError (UNS8 heartbeatID ); -void SD0timeoutError(UNS8 bus_id, UNS8 line); - -void waitMessage (void ); -void heartBeat (void ); -void transmitSync (void); -e_nodeState stateNode (UNS8 node); -void configure_master_SDO (UNS32 index, UNS8 serverNode); -UNS8 waitingWriteToSlaveDict (UNS8 slaveNode, UNS8 error); -UNS8 waitingReadToSlaveDict (UNS8 slaveNode, void * data, UNS8 * size, UNS8 error); -UNS8 configure_client_SDO (UNS8 slaveNode, UNS8 clientNode); -void masterMappingPDO (UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar); -void slaveMappingPDO (UNS8 slaveNode, UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar); -void masterHeartbeatConsumer (s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats); -void masterHeartbeatProducer (UNS16 time); -void slaveHeartbeatConsumer (UNS8 slaveNode, s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats); -void slaveHeartbeatProducer (UNS8 slaveNode, UNS16 time); -void masterPDOTransmissionMode (UNS32 indexPDO, UNS8 transType); -void slavePDOTransmissionMode (UNS8 slaveNode, UNS32 indexPDO, UNS8 transType); -void masterSYNCPeriod (UNS32 SYNCPeriod); -int main (int argc,char **argv); - -/*****************************************************************************/ -void heartbeatError(UNS8 heartbeatID) -{ - // MSG_ERR should send the values canopenErrNB and canopenErrVAL on event in a PDO, - // But we do not have mapped the variables in a PDO, so it sends nothing. - // See the note at the end of END CONFIGURING THE NETWORK. - MSG_WAR(0x2F00, "HeartBeat, no response from node : ", heartbeatID); -} - -/*****************************************************************************/ -void SD0timeoutError (UNS8 bus_id, UNS8 line) -{ - // Informations on what occurs are in transfers[bus_id][line].... - // See scanSDOtimeout() in sdo.c -} - -/*********************************** THREADS **********************************/ -//------------------------------------------------------------------------------ -// Wait for a received message -void waitMessage(void) -{ - while (1) { - receiveMsgHandler(0); // blocked until new message - } -} - -//------------------------------------------------------------------------------ -/* Sending SYNC */ -void transmitSync(void) -{ - while (1) { - computeSYNC(); // Use the value in the dictionnary - usleep(1000); // Sleep 1 ms - - } -} - -/************************** FUNCTIONS TO CONFIGURE THE NETWORK******************/ - - - -//------------------------------------------------------------------------------ -/* Node mode result after NodeGuard query */ -e_nodeState stateNode(UNS8 node) -{ - e_nodeState state = getNodeState(0, node); - switch (state) { - case Unknown_state: - MSG_WAR(0x3F05, "Not connected (Does not have sent its status) node :", node); - break; - case Operational: - MSG_WAR(0x3F06, "Ok, in operational mode, node : ", node); - break; - case Pre_operational: - MSG_WAR(0x3F07, "OK in pre-operational mode, node : ", node); - break; - default: - MSG_WAR(0x3F08, "OK connected but in curious mode, node : ", node); - } - return state; -} - -//------------------------------------------------------------------------------ -/* The master is writing in its dictionnary to configure the SDO parameters -to communicate with server_node -*/ -void configure_master_SDO(UNS32 index, UNS8 serverNode) -{ - UNS32 data32; - UNS8 data8; - UNS8 sizeData = 4 ; // in bytes - - /* At subindex 1, the cobId of the Can message from the client. - It is always defined inside the server dictionnary as 0x600 + server_node. - So, we have no choice here ! */ - data32 = 0x600 + serverNode; - setODentry(index, 1, &data32, sizeData, 0); - - { - // Test - UNS32 *pbData; - UNS8 length; - UNS32 returnValue; - UNS8 dataType; - // Relecture - MSG_WAR(0x1000, "Reading index : ", index); - MSG_WAR(0x1000, " subindex : ", 1); - returnValue = getODentry(index, 1, (void * *)&pbData, (UNS8 *)&length, &dataType, 0); - MSG_WAR(0x1000, " val : ", *pbData); - } - - - /* At subindex 2, the cobId of the Can message from the server to the client. - It is always defined inside the server dictionnary as 0x580 + client_node. - So, we have no choice here ! */ - data32 = 0x580 + serverNode; - setODentry(index, 2, &data32, sizeData, 0); - - /* At subindex 3, the node of the server */ - data8 = serverNode; - sizeData = 1; - setODentry(index, 3, &data8, sizeData, 0); - - { - UNS8 *pbData; - UNS8 length; - UNS32 returnValue; - UNS8 dataType; - // Relecture - MSG_WAR(0x1000, "Reading index : ", index); - MSG_WAR(0x1000, " subindex : ", 3); - returnValue = getODentry(index, 1, (void * *)&pbData, (UNS8 *)&length, &dataType, 0); - MSG_WAR(0x1000, " val : ", *pbData); - } -} - -//------------------------------------------------------------------------------ -/* - */ -UNS8 waitingWriteToSlaveDict(UNS8 slaveNode, UNS8 error) -{ - UNS8 err; - UNS32 abortCode; - MSG_WAR(0x3F21, "Sending SDO to write in dictionnary of node : ", slaveNode); - if (error) { - MSG_ERR(0x1F22, "Unable to send the SDO to node ", slaveNode); - return -1; - } - /* Waiting until the slave has responded */ - while (getWriteResultNetworkDict (0, slaveNode, &abortCode) == SDO_DOWNLOAD_IN_PROGRESS) { - // Check if some SDO response are missing - scanSDOtimeout(); - } - - err = getWriteResultNetworkDict (0, slaveNode, &abortCode); - if (err == SDO_FINISHED) { - MSG_WAR(0x3F22, "SDO download finished to Node : ", slaveNode); - // Release the line. Don't forget !!! - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - return 0; - } - - if (err == SDO_ABORTED_RCV) { - MSG_WAR(0x2F20, "Received SDO abort from node : ", slaveNode); - } - - if (err == SDO_ABORTED_INTERNAL) { - MSG_WAR(0x2F20, "Internal SDO abort for node : ", slaveNode); - } - // Looking for the line transfert number to read the index, subindex and releasing the line. - { - UNS8 line; - err = getSDOlineOnUse(0, slaveNode, SDO_CLIENT, &line); - if (err) { - MSG_WAR(0x2F21, "No line found for node : ", slaveNode); - exit(-1); - } - MSG_WAR (0x2F22, "while writing at his index : ", transfers[0][line].index); - MSG_WAR (0x2F23, " subIndex : ", transfers[0][line].subIndex); - //Releasing the line. - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - exit(-1); - } - return 0; -} - -//------------------------------------------------------------------------------ -/* - */ -UNS8 waitingReadToSlaveDict(UNS8 slaveNode, void * data, UNS8 * size, UNS8 error) -{ - UNS8 err; - UNS32 abortCode; - MSG_WAR(0x3F2A, "Sending SDO to read in dictionnary of node : ", slaveNode); - if (error) { - MSG_ERR(0x1F2B, "Unable to send the SDO to node ", slaveNode); - return -1; - } - /* Waiting until the slave has responded */ - while (getReadResultNetworkDict (0, slaveNode, data, size, &abortCode) == SDO_UPLOAD_IN_PROGRESS) { - // Check if some SDO response are missing - scanSDOtimeout(); - } - err = getReadResultNetworkDict (0, slaveNode, data, size, &abortCode); - if (err == SDO_FINISHED) { - MSG_WAR(0x3F2C, "SDO upload finished to Node : ", slaveNode); - // Release the line. Don't forget !!! - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - return 0; - } - if (err == SDO_ABORTED_RCV) { - MSG_WAR(0x2F2D, "Received SDO abort from node : ", slaveNode); - } - - if (err == SDO_ABORTED_INTERNAL) { - MSG_WAR(0x2F2E, "Internal SDO abort for node : ", slaveNode); - } - // Looking for the line transfert number to read the index, subindex and releasing the line. - { - UNS8 line; - err = getSDOlineOnUse(0, slaveNode, SDO_CLIENT, &line); - if (err) { - MSG_WAR(0x2F2F, "No line found for node : ", slaveNode); - exit(-1); - } - MSG_WAR (0x2F30, "while writing at his index : ", transfers[0][line].index); - MSG_WAR (0x2F31, " subIndex : ", transfers[0][line].subIndex); - //Releasing the line. - closeSDOtransfer(0, slaveNode, SDO_CLIENT); - exit(-1); - } - - return 0; -} - - -//------------------------------------------------------------------------------ -/* The master is writing in the slave dictionnary to configure the SDO parameters -Remember that the slave is the server, and the master is the client. - */ -UNS8 configure_client_SDO(UNS8 slaveNode, UNS8 clientNode) -{ - UNS8 data; - UNS8 NbDataToWrite = 1 ; // in bytes - UNS8 err = 0; - MSG_WAR(0x3F20, "Configuring SDO by writing in dictionnary Node", slaveNode); - /* It is only to put at subindex 3 the serverNode. It is optionnal. - In the slave dictionary, only one SDO server is defined, at index - 0x1200 */ - data = clientNode; - err = writeNetworkDict(0, slaveNode, 0x1200, 3, NbDataToWrite, 0, &data); - waitingWriteToSlaveDict(slaveNode, err); - - return 0; -} - -//------------------------------------------------------------------------------ - -void masterMappingPDO(UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar) -{ - UNS32 *pbData; - UNS32 data32; - UNS8 i; - UNS8 size = 0; - UNS8 dataType; - - if ((indexPDO >= 0x1400) && (indexPDO <= 0x15FF)) - MSG_WAR(0x3F30, "Configuring MASTER for PDO receive, COBID : ", cobId); - - if ((indexPDO >= 0x1800) && (indexPDO <= 0x19FF)) - MSG_WAR(0x3F31, "Configuring MASTER for PDO transmit, COBID : ", cobId); - - /* At indexPDO, subindex 1, defining the cobId of the PDO */ - setODentry(indexPDO, 1, &cobId, 4, 0); - /* The mapping ... */ - /* ----------------*/ - /* At subindex 0, the number of variables in the PDO */ - setODentry(indexPDO + 0x200, 0, &nbVar, 1, 0); - getODentry(indexPDO + 0x200, 0, (void * *)&pbData, &size, &dataType, 0); - /* At each subindex 1 .. nbVar, The index,subindex and size of the variable to map in - the PDO. The first variable after the COBID is defined at subindex 1, ... - The data to write is the concatenation on 32 bits of (msb ... lsb) : - index(16b),subIndex(8b),sizeVariable(8b) -*/ - for (i = 0 ; i < nbVar ; i++) { - data32 = ((tabMappedVar + i)->index << 16) | - (((tabMappedVar + i)->subIndex & 0xFF) << 8) | - ((tabMappedVar + i)->size & 0xFF); - // Write dictionary - setODentry(indexPDO + 0x200, i + 1, &data32, 4, 0); - -# ifdef MORE_COMMENTS - printf("Mapped variable defined at index 0x%X, subIndex 0x%X, %d bits\n", - (tabMappedVar + i)->index, (tabMappedVar + i)->subIndex, 8 * (tabMappedVar + i)->size); - // Only to verify. - // Read dictionnary - getODentry(indexPDO + 0x200, i + 1, (void * *)&pbData, &size, &dataType, 0); - printf("Writen à index 0x%X, subIndex 0x%X, %d bits : 0x%08X\n", - indexPDO + 0x200, i + 1, 8 * size, *pbData); -# endif - - } -} - -//------------------------------------------------------------------------------ -/* - */ - -void slaveMappingPDO(UNS8 slaveNode, UNS32 indexPDO, UNS32 cobId, - s_mappedVar *tabMappedVar, UNS8 nbVar) -{ - UNS32 data32; - UNS8 i; - UNS8 err; - UNS8 nbBytes = 1; - if ((indexPDO >= 0x1400) && (indexPDO <= 0x15FF)) - MSG_WAR(0x3F32, "Configuring slave for PDO receive, COBID : ", cobId); - - if ((indexPDO >= 0x1800) && (indexPDO <= 0x19FF)) - MSG_WAR(0x3F33, "Configuring slave for PDO transmit, COBID : ", cobId); - - /* At indexPDO, subindex 1, defining the cobId of the PDO */ - err = writeNetworkDict(0, slaveNode, indexPDO, 1, 4, 0, &cobId); - waitingWriteToSlaveDict(slaveNode, err); - - /* The mapping ... */ - /* ----------------*/ - /* At subindex 0, the number of variables in the PDO */ - err = writeNetworkDict(0, slaveNode, indexPDO + 0x200, 0, nbBytes, 0, &nbVar); - waitingWriteToSlaveDict(slaveNode, err); - - /* At each subindex 1 .. nbVar, The index,subindex and size of the variable to map in - the PDO. The first variable after the COBID is defined at subindex 1, ... - The data to write is the concatenation on 32 bits of (msb ... lsb) : - index(16b),subIndex(8b),sizeVariable(8b) -*/ - for (i = 0 ; i < nbVar ; i++) { - data32 = ((tabMappedVar + i)->index << 16) | - (((tabMappedVar + i)->subIndex & 0xFF) << 8) | - ((tabMappedVar + i)->size & 0xFF); - - // Write dictionary - err = writeNetworkDict(0, slaveNode, indexPDO + 0x200, i + 1, 4, 0, &data32); - waitingWriteToSlaveDict(slaveNode, err); - -# ifdef MORE_COMMENTS - printf("Mapped variable defined at index 0x%X, subIndex 0x%X, %d bits\n", - (tabMappedVar + i)->index, (tabMappedVar + i)->subIndex, 8 * (tabMappedVar + i)->size); - - printf("At node 0x%X Writen at index 0x%X, subIndex 0x%X, %d bits : 0x%08X\n", - slaveNode, indexPDO + 0x200, i + 1, 32, data32); -# endif - - } -} - -//------------------------------------------------------------------------------ -/* - */ -void masterHeartbeatConsumer(s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats) -{ - UNS32 data; - UNS8 i; - UNS8 nbHB = nbHeartbeats; - - MSG_WAR(0x3F40, "Configuring heartbeats consumers for master", 0); - /* At index 1016, subindex 0 : the nb of consumers (ie nb of nodes of which are expecting heartbeats) */ - setODentry(0x1016, 0, & nbHB, 1, 0); - - /* At Index 1016, subindex 1, ... : 32 bit values : msb ... lsb : - 00 - node_consumer (8b) - time_ms (16b) - Put 0 to ignore the entry. - */ - for (i = 0 ; i < nbHeartbeats ; i++) { - data = (((tabHeartbeatConsumer + i)->nodeProducer & 0xFF)<< 16) | ((tabHeartbeatConsumer + i)->time_ms & 0xFFFF); - setODentry(0x1016, i + 1, & data, 4, 0); - } -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterHeartbeatProducer(UNS16 time) -{ - UNS16 hbTime = time; - MSG_WAR(0x3F45, "Configuring heartbeat producer for master", 0); - /* At index 1017, subindex 0, defining the time to send the heartbeat. Put 0 to never send heartbeat */ - setODentry(0x1017, 0, &hbTime, 2, 0); -} - -//------------------------------------------------------------------------------ -/* - */ -void slaveHeartbeatConsumer(UNS8 slaveNode, s_heartbeatConsumer - *tabHeartbeatConsumer, UNS8 nbHeartbeats) -{ - UNS32 data; - UNS8 err; - UNS8 i; - - MSG_WAR(0x3F46, "Configuring heartbeats consumers for node : ", slaveNode); - - /* At Index 1016, subindex 1, ... : 32 bit values : msb ... lsb : - 00 - node_consumer (8b) - time_ms (16b) - Put 0 to ignore the entry. - */ - for (i = 0 ; i < nbHeartbeats ; i++) { - data = (((tabHeartbeatConsumer + i)->nodeProducer & 0xFF)<< 16) | - ((tabHeartbeatConsumer + i)->time_ms & 0xFFFF); - err = writeNetworkDict(0, slaveNode, 0x1016, i + 1, 4, 0, &data); - waitingWriteToSlaveDict(slaveNode, err); - } -} - -//------------------------------------------------------------------------------ -/* - */ - -void slaveHeartbeatProducer(UNS8 slaveNode, UNS16 time) -{ - UNS8 err; - MSG_WAR(0x3F47, "Configuring heartbeat producer for node : ", slaveNode); - /* At index 1017, subindex 0, defining the time to send the heartbeat. Put 0 to never send heartbeat */ - - err = writeNetworkDict(0, slaveNode, 0x1017, 0, 2, 0, &time); - waitingWriteToSlaveDict(slaveNode, err); -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterPDOTransmissionMode(UNS32 indexPDO, UNS8 transType) -{ - MSG_WAR(0x3F48, "Configuring transmission from master, indexPDO : ", indexPDO); - - /* At subindex 2, the transmission type */ - setODentry(indexPDO, 2, &transType, 1, 0); -} - - -//------------------------------------------------------------------------------ -/* - */ - -void slavePDOTransmissionMode(UNS8 slaveNode, UNS32 indexPDO, UNS8 transType) -{ - UNS8 err; - MSG_WAR(0x3F41, "Configuring transmission mode for node : ", slaveNode); - MSG_WAR(0x3F42, " indexPDO : ", indexPDO); - - err = writeNetworkDict(0, slaveNode, indexPDO, 2, 1, 0, &transType); - waitingWriteToSlaveDict(slaveNode, err); - -} - -//------------------------------------------------------------------------------ -/* - */ - -void masterSYNCPeriod(UNS32 SYNCPeriod) -{ - UNS32 cobId = 0x40000080; - MSG_WAR(0x3F49, "Configuring master to send SYNC every ... micro-seconds :", SYNCPeriod); - /* At index 0x1006, subindex 0 : the period in ms */ - setODentry(0x1006, 0, &SYNCPeriod , 4, 0); - /* At index 0x1005, subindex 0 : Device generate SYNC signal with CobId 0x80 */ - setODentry(0x1005, 0, &cobId, 4, 0); -} - -void help() -{ - printf("**************************************************************\n"); - printf("* AppliMaster *\n"); - printf("* [-b b] *\n"); - printf("* *\n"); - printf("* b : bus [default 0] *\n"); - printf("* *\n"); - printf("* This exemple run AppliMaster on bus 0 *\n"); - printf("* AppliMaster -b 0 *\n"); - printf("* *\n"); - printf("**************************************************************\n"); -} - -/****************************************************************************/ -/*************************** MAIN *****************************************/ -/****************************************************************************/ -int main(int argc,char **argv) -{ - UNS8 second_last; - UNS8 minutes_last; - UNS8 sendingResetError = 0; - int i; - HANDLE ok; - char c; - extern char *optarg; - - while ((c = getopt(argc, argv, "-b:")) != EOF) - { - switch(c) - { - case 'b' : - if (optarg[0] == 0) - { - help(); - exit(1); - } - board.busname = optarg; - break; - default: - help(); - exit(1); - } - } - - /****************************** INITIALISATION *******************************/ - - /* Launch the timer*/ - initTimer( ); - - /* arrays initialisation, etc */ - initCANopenMain(); - - /* arrays initialisation, etc */ - initCANopenMaster(); - - /* Defining the node Id */ - setNodeId(0x01); - MSG_WAR(0x3F50, "My node ID is : ", getNodeId()); - - /* Put the master in operational mode */ - setState(Operational); - - - /* Init the table of connected nodes */ - for (i = 0 ; i < 128 ; i++) - connectedNode[i] = 0; - - - ok = f_can_open(& board); - if (ok == NULL) { - MSG_ERR(0x1F02,"Unable to open the board", 0); - MSG_ERR(0x1F03,"Edit includeMakefileLinux to verify that the application is configured for the good board", 0); - exit (-1); - } - else { - MSG_WAR(0x3F03, "Board 0 opened ", 0); - } - - - /* Launch the thread to receive the messages */ - pthread_create( &threadM, NULL, (void *)&waitMessage, NULL); - - - - - - - - - - - - - - - - /******************** CONFIGURING THE NETWORK **************************/ - - /* Which nodes are connected ? */ - /* Sending a request Node guard to node 5 and 6 */ - MSG_WAR(0x3F04, "Sending a node guard to node : ", 5); - masterReadNodeState(0, 0x05); - /* Sending a message to the node 6, only as example */ - MSG_WAR(0x3F04, "Sending a node guard to node : ", 6); - masterReadNodeState(0, 0x06); - /* Waiting for a second the response */ - sleep(1); - - /* Whose node have answered ? */ - connectedNode[5] = stateNode(5); - connectedNode[6] = stateNode(6); - - /* Configure the SDO master to communicate with node 5 and node 6 */ - configure_master_SDO(0x1280, 0x05); - - - /* Configure the SDO of node 5 */ - /* getNodeId() returns my node Id */ - configure_client_SDO(0x05, getNodeId()); - /* Mapping of the PDO - Chose some COBID in (hexa) 181-1FF, 201-27F, 281-2FF, 301-37F, - 381-3FF, 401-47F, 481-4FF, 501-57F, - without other restriction. - (Of course, you must not define 2 PDO transmit with the same cobId !!) - */ - - /* - *** PDO node 1 <-- node 5 *** - *** cobId 0x181 ************* - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - day [0x6002 - 0x04 - 8] - hour [0x6002 - 0x03 - 8] - second [0x6002 - 0x01 - 8] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bits]: - day [0x2000 - 0x04 - 8] - hour [0x2000 - 0x03 - 8] - second [0x2000 - 0x01 - 8] -*/ - - /* Configuring the first PDO receive, defined at index 0x1400 and 0x1600 */ - { - s_mappedVar tabMappedVar[8] = { {0x6002,4,8}, {0x6002,3,8}, {0x6002,1,8}, }; - masterMappingPDO(0x1400, 0x181, tabMappedVar, 3); - } - - /* Configuring the first PDO transmit, defined at index 0x1800 and 0x1A00 */ - { - s_mappedVar tabMappedVar[8] = { {0x2000,4,8}, {0x2000,3,8}, {0x2000,1,8}, }; - slaveMappingPDO(0x05, 0x1800, 0x181, tabMappedVar, 3); - } - /* - *** PDO node 1 <-- node 5 *** - *** cobId 0x182 ************* - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - minute [0x6002 - 0x02 - 8] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bits]: - minute [0x2000 - 0x02 - 8] - */ - - /* Configuring PDO receive, defined at index 0x1400 and 0x1600 */ - { - s_mappedVar tabMappedVar[8] = { {0x6002,2,8} }; - masterMappingPDO(0x1401, 0x182, tabMappedVar, 1); - } - - /* Configuring PDO transmit, defined at index 0x1800 and 0x1A00 */ - { - s_mappedVar tabMappedVar[8] = { {0x2000,2,8} }; - slaveMappingPDO(0x05, 0x1801, 0x182, tabMappedVar, 1); - } - - - /* - *** PDO node 1 <-- node 5 *** - *** cobId 0x183 ************* - Error management : By this way, The node can send by PDO an error - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - canopenErrNb_node5 [0x6000 - 0x00 - 32] - canopenErrVal_node5 [0x6001 - 0x00 - 32] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bytes]: - canopenErrNb [0x6000 - 0x00 - 32] - canopenErrVal [0x6001 - 0x00 - 32] - */ - - /* Configuring PDO receive, defined at index 0x1402 and 0x1602 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - masterMappingPDO(0x1402, 0x183, tabMappedVar, 2); - } - - /* Configuring PDO transmit, defined at index 0x1802 and 0x1A02 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - slaveMappingPDO(0x05, 0x1802, 0x183, tabMappedVar, 2); - } - - /* - *** PDO node 1 --> node 5 *** - *** cobId 0x184 ************* - Error management : To reset the error - MASTER (node 1) - Mapped to variables (node1) [index-subindex-size_bits]: - canopenErrNb_node5 [0x6000 - 0x00 - 32] - canopenErrVal_node5 [0x6001 - 0x00 - 32] - - SLAVE (node 5) - Mapped to variables (node5) [index-subindex-size_bytes]: - canopenErrNb [0x6000 - 0x00 - 32] - canopenErrVal [0x6001 - 0x00 - 32] - */ - - /* Configuring PDO transmit, defined at index 0x1803 and 0x1103 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - masterMappingPDO(0x1801, 0x184, tabMappedVar, 2); - } - - /* Configuring PDO transmit, defined at index 0x1403 and 0x1603 */ - { - s_mappedVar tabMappedVar[8] = { {0x6000,0,32}, {0x6001, 0, 32}}; - slaveMappingPDO(0x05, 0x1400, 0x184, tabMappedVar, 2); - } - - /* Configuring the node 5 heartbeat */ - /* Check every 3000 ms if it have received a heartbeat from node 1 */ - { - UNS8 nbHeartbeatsToReceive = 1; - s_heartbeatConsumer tabHeartbeatConsumer[10] = {{1, 0xBB8}}; - slaveHeartbeatConsumer(0x05, tabHeartbeatConsumer, nbHeartbeatsToReceive); - } - /* Sending every 1000 ms an heartbeat */ - slaveHeartbeatProducer(0x05, 0x3E8); - - /* Configuring the master heartbeat */ - /* Check every 3000 ms if it have received a heartbeat from node 5 */ - { - UNS8 nbHeartbeatsToReceive = 1; - s_heartbeatConsumer tabHeartbeatConsumer[10] = {{5, 0xBB8}}; - masterHeartbeatConsumer(tabHeartbeatConsumer, nbHeartbeatsToReceive); - } - - /* Sending every 1000 ms an heartbeat */ - masterHeartbeatProducer(0x3E8); - - - - /* Configuring the transmission mode of the PDO */ - slavePDOTransmissionMode(0x05, 0x1800, TRANS_EVERY_N_SYNC (1)); - slavePDOTransmissionMode(0x05, 0x1801, TRANS_EVENT); - slavePDOTransmissionMode(0x05, 0x1802, TRANS_EVENT); - masterPDOTransmissionMode(0x1801, TRANS_EVENT); - - /* Configuring the master to send a SYNC message every 1 s */ - /* Note than any other node can send the SYNC instead of the master */ - masterSYNCPeriod(1000000); - - { - // Reading the period of heartbeat which has been written in node 5 dictionary - UNS8 node = 5; - UNS16 index = 0x1017; - UNS8 subindex = 0; - //UNS8 notused = 0; - UNS16 hb = 0; - UNS8 size_data = 0; - UNS8 error; - MSG_WAR(0x3F50, "Reading dictionary noeud 5, 1017/0", 0); - error = readNetworkDict(0, node, index, subindex, 0); - //error = readNetworkDict(0, node, index, subindex, ¬used); - if (error) { - MSG_ERR(0x1F50, "!!! ERROR reading dictionary noeud 5, 1017/0", 0); - exit (-1); - } - /* Waiting until the server has responded */ - error = waitingReadToSlaveDict(node, (UNS16 *)&hb, &size_data, error); - MSG_WAR(0x1F51, "Read dictionary of node 5, index/subindex 1017/0 value = ", hb); - MSG_WAR(0x1F51, " size of data (bytes) = ", size_data); - } - - - - /* Put the node 5 in operational mode - The mode is changed according to the slave state machine mode : - initialisation ---> pre-operational (Automatic transition) - pre-operational <--> operational - pre-operational <--> stopped - pre-operational, operational, stopped -> initialisation - NMT_Start_Node // Put the node in operational mode - NMT_Stop_Node // Put the node in stopped mode - NMT_Enter_PreOperational // Put the node in pre_operational mode - NMT_Reset_Node // Put the node in initialization mode - NMT_Reset_Comunication // Put the node in initialization mode - */ - masterSendNMTstateChange(0, 0x05, NMT_Start_Node); - - - // Note - //----- - // We do not have mapped the variable canopenErrNB and canopenErrVAL. - // We should have done that ! - // the macro MSG_ERR try to send the PDO(s) which contains these two variables. - // While the PDO will not be found, if you are printing the warnings in file pdo.c, - // it will print "0X393B Unable to send variable on event : not mapped in a PDO to send on event" for - // example when you enter the function heartbeatError. - - /******************** END CONFIGURING THE NETWORK **********************/ - - /* Launch the thread to send the SYNC message */ - pthread_create( &threadS, NULL, (void *)&transmitSync , NULL); - /* Init the errors values that may send the node 5 */ - canopenErrNB_node5 = 0; - canopenErrVAL_node5 = 0; - - /****************************** RUNNING *******************************/ - - /* SDO test with node 5 */ - { - // Reading string - UNS8 dataW[20]; - UNS8 dataR[20]; - UNS8 size; - UNS8 err; - MSG_WAR(0x3F05, "Test SDO", 0); - - MSG_WAR(0x3F10, "Writing string to node 5 index 0x6002, subindex 0 ...", 0); - strcpy(dataW, "Au Revoir"); - MSG_WAR(0x3F10, dataW, 0); - size = 20; - err = writeNetworkDict(0, 5, 0x6002, 0, 10, visible_string, dataW); - err = waitingWriteToSlaveDict(5, err); - - err = readNetworkDict(0, 5, 0x6002, 0, visible_string); - err = waitingReadToSlaveDict(5, dataR, &size, err); - MSG_WAR(0x3F08, "Data read from node 5 index 0x6002, subindex 0 ..." , 0); - MSG_WAR(0x3F08, dataR, 0); - - MSG_WAR(0x3F08, "node 5. Hardware version. (default = compil. date) ...", 0); - err = readNetworkDict(0, 5, 0x1009, 0, visible_string); - err = waitingReadToSlaveDict(5, dataR, &size, err); - MSG_WAR(0x3F08, dataR, 0); - - MSG_WAR(0x3F08, "node 5. Software version. (default = compil. time) ...", 0); - err = readNetworkDict(0, 5, 0x100A, 0, visible_string); - err = waitingReadToSlaveDict(5, dataR, &size, err); - MSG_WAR(0x3F08, dataR, 0); - } - - // Node identity ? - { - UNS8 *data; - UNS8 size; - UNS8 dataType; - // Manufacturer Device name (default = empty string) - getODentry(0x1008, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Hardware version. (default = compilation. date) - getODentry(0x1009, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Software version. (default = compilation. time) - getODentry(0x100A, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - } - - while (1) { - if (minutes != minutes_last) { - printf("Minutes changed\n"); - minutes_last = minutes; - } - - if (second != second_last) { - printf("Date : %d, %02dH%02d-%02d\n", day, hour, minutes, second); - second_last = second; - - if (canopenErrNB_node5) { - printf("Received an error from node 5, NB : 0x%X, value : 0x%X\n", - canopenErrNB_node5 , canopenErrVAL_node5); - // Resetting the error - canopenErrNB_node5 = 0; - canopenErrVAL_node5 = 0; - sendingResetError = 1; - } - - if ((second < 5) && sendingResetError) { - printf("Sending to node 5 a PDO event to reset the error NB: 0x%X and VAL: 0x%X\n", - canopenErrNB_node5, canopenErrVAL_node5); - - sendPDOevent(0, &canopenErrNB_node5); - sendingResetError = 0; - } - - - } // end if (second != second_last) - - // Testing if heartsbeat have been received, and send a heartbeat if it is time. - // I have put that in a thread, but I don't know why, on HB not received, - // it doesn't returns from heartbeatError() to the thread. - heartbeatMGR(); - - usleep(10000); - - } - return 0; -} diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_Linux/objdict.c --- a/examples/AppliMaster_Linux/objdict.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,770 +0,0 @@ -/* -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 -*/ - -#include - -#include -#include "def.h" -#include "can.h" -#include "objdictdef.h" -#include "pdo.h" -#include "sdo.h" -#include "sync.h" -#include "lifegrd.h" -#include "nmtSlave.h" - -/**************************************************************************/ -/* Declaration of the mapped variables */ -/**************************************************************************/ - - - -/*// Copy and uncomment this code to your main file -extern UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x00 -extern UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x00 -extern UNS8 second; // Mapped at index 0x6002, subindex 0x01 -extern UNS8 minutes; // Mapped at index 0x6002, subindex 0x02 -extern UNS8 hour; // Mapped at index 0x6002, subindex 0x03 -extern UNS8 day; // Mapped at index 0x6002, subindex 0x04 -extern UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x01 -extern UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x02 - -// END copy to main file -*/ - -UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x00 -UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x00 -UNS8 second; // Mapped at index 0x6002, subindex 0x01 -UNS8 minutes; // Mapped at index 0x6002, subindex 0x02 -UNS8 hour; // Mapped at index 0x6002, subindex 0x03 -UNS8 day; // Mapped at index 0x6002, subindex 0x04 -UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x01 -UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x02 - -/**************************************************************************/ -/* Declaration of the value range types */ -/**************************************************************************/ - - - -UNS32 valueRangeTest (UNS8 typeValue, UNS32 unsValue, REAL32 realValue) -{ - return 0; -} - - -/**************************************************************************/ -/* The node id */ -/**************************************************************************/ -/* Computed by strNode */ -/* node_id default value. - This default value is deprecated. - You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code. -*/ -#define NODE_ID 0x01 -UNS8 bDeviceNodeId = NODE_ID; - - -//*****************************************************************************/ -/* Computed by strStartDico */ - -/* Array of message processing information */ -/* Should not be modified */ -volatile const proceed_info proceed_infos[] = { - {NMT, "NMT", NULL}, - {SYNC, "SYNC", proceedSYNC}, - {TIME_STAMP, "TStmp", NULL}, - {PDO1tx, "PDO1t", proceedPDO}, - {PDO1rx, "PDO1r", proceedPDO}, - {PDO2tx, "PDO2t", proceedPDO}, - {PDO2rx, "PDO2r", proceedPDO}, - {PDO3tx, "PDO3t", proceedPDO}, - {PDO3rx, "PDO3r", proceedPDO}, - {PDO4tx, "PDO4t", proceedPDO}, - {PDO4rx, "PDO4r", proceedPDO}, - {SDOtx, "SDOt", proceedSDO}, - {SDOrx, "SDOr", proceedSDO}, - {0xD, "Unkw", NULL}, - {NODE_GUARD, "NGrd", proceedNMTerror}, - {0xF, "Unkw", NULL} -}; - - // Macros definition - -/* Beware : -index *must* be writen 4 numbers in hexa -sub_index *must* be writen 2 numbers in hexa -size_variable_in_UNS8 *must* be writen 2 numbers in hexa -*/ -#define PDO_MAP(index, sub_index, size_variable_in_bits)\ -0x ## index ## sub_index ## size_variable_in_bits - -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// -// OBJECT DICTIONARY -// -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// Make your change, depending of your application - - -/* index 0x1000 : Device type. - You have to change the value below, so - it fits your canopen-slave-module */ - - /* Not used, so, should not be modified */ - - UNS32 obj1000 = 0; - subindex Index1000[] = - { - { RO, uint32, sizeof(UNS32), (void*)&obj1000 } - }; - -/* index 0x1001 : Error register. - Change the entries to fit your application - Not used, so, should not be modified */ - /*const*/ UNS8 obj1001 = 0x0; - /*const*/ subindex Index1001[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1001 } - }; - -/* index 0x1005 : COB_ID SYNC */ - /* Should not be modified */ - UNS32 obj1005 = 0x00000080; // bit 30 = 1 : device can generate a SYNC message - // Beware, it is over written when the node - // enters in reset mode - // See initResetMode() in init.c - /*const*/ subindex Index1005[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1005 } - }; - -/* index 0x1006 : SYNC period */ - // For producing the SYNC signal every n micro-seconds. - // Put O to not producing SYNC - /*const*/ UNS32 obj1006 = 0x0; - // Default 0 to not produce SYNC // - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - /*const*/ subindex Index1006[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1006 } - }; - -/* index 0x1007 : Synchronous Window Length - Seems to be needed by DS401 to generate the SYNC signal ! */ - /*const*/ UNS32 obj1007 = 0x0; /* Default 0 */ - /*const*/ subindex Index1007[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1007 } - }; - -/* index 0x1008 : Manufacturer device name */ - UNS8 obj1008[] = "Appli_Master_Linux"; /* Default 0 */ - subindex Index1008[] = - { - { RO, uint32, sizeof(obj1008), (void*)&obj1008 } - }; - -/* index 0x1009 : Manufacturer hardware version */ - UNS8 obj1009[] = __DATE__; /* Default 0 */ - subindex Index1009[] = - { - { RO, uint32, sizeof(obj1009), (void*)&obj1009 } - }; - -/* index 0x100A : Manufacturer software version */ - UNS8 obj100A[] = __TIME__; /* Default 0 */ - subindex Index100A[] = - { - { RO, uint32, sizeof(obj100A), (void*)&obj100A} - }; - -/* index 0x1016 : HeartBeat consumers - The nodes which can send a heartbeat */ - static UNS32 obj1016[] = {// Consumer time for each node - 0x00000000}; // Format 0x00NNTTTT (N=Node T=time in ms) - - static UNS8 obj1016_cnt = 1; // 1 nodes could send me - // their heartbeat. - subindex Index1016[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1016_cnt }, - { RW, uint32, sizeof(UNS32), (void*)&obj1016[0] } - }; - -/* index 0x1017 : Heartbeat producer - Every HBProducerTime, the node sends its heartbeat */ - static UNS16 obj1017 = 0; //HBProducerTime in ms. If 0 : not activated - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - subindex Index1017[] = - { - { RW, uint16, sizeof(UNS16), &obj1017 } - }; - -/* index 0x1018 : Identity object */ - /** index 1018: identify object. Adjust the entries for your node/company - */ - /* Values can be modified */ - - s_identity obj1018 = - { - 4, // number of supported entries - 0, // Vendor-ID (given by the can-cia) - 0, // Product Code - 0, // Revision number - 0 // serial number - }; - - subindex Index1018[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1018.count }, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.vendor_id}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.product_code}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.revision_number}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.serial_number} - }; - -/* index 0x1200 : The SDO Server parameters */ - /* BEWARE You cannot define more than one SDO server */ - /* The values should not be modified here, - but can be changed at runtime */ - // Beware that the default values that you could put here - // will be over written at the initialisation of the node. - // See setNodeId() in init.c - static s_sdo_parameter obj1200 = - { 3, // Number of entries. Always 3 for the SDO - 0x600 + NODE_ID, // The cob_id transmited in CAN msg to the server - 0x580 + NODE_ID, // The cob_id received in CAN msg from the server - NODE_ID // The node id of the client. Should not be modified - }; - static subindex Index1200[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1200.count }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_client }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_server }, - { RW, uint8, sizeof( UNS8), (void*)&obj1200.node_id } - }; - -/* index 0x1280 : SDO client parameter */ - static s_sdo_parameter obj1280 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1280[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1280.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1280.node_id } - }; - -/* index 0x1281 : SDO client parameter */ - static s_sdo_parameter obj1281 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1281[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1281.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1281.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1281.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1281.node_id } - }; - -/* index 0x1282 : SDO client parameter */ - static s_sdo_parameter obj1282 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1282[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1282.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1282.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1282.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1282.node_id } - }; - -/* index 0x1283 : SDO client parameter */ - static s_sdo_parameter obj1283 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1283[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1283.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1283.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1283.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1283.node_id } - }; - -/* index 0x1284 : SDO client parameter */ - static s_sdo_parameter obj1284 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1284[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1284.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1284.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1284.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1284.node_id } - }; - -/* index 0x1285 : SDO client parameter */ - static s_sdo_parameter obj1285 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1285[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1285.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1285.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1285.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1285.node_id } - }; - -/* index 0x1286 : SDO client parameter */ - static s_sdo_parameter obj1286 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1286[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1286.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1286.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1286.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1286.node_id } - }; - -/* index 0x1287 : SDO client parameter */ - static s_sdo_parameter obj1287 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1287[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1287.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1287.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1287.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1287.node_id } - }; - -/* index 0x1288 : SDO client parameter */ - static s_sdo_parameter obj1288 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1288[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1288.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1288.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1288.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1288.node_id } - }; - -/* index 0x1289 : SDO client parameter */ - static s_sdo_parameter obj1289 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1289[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1289.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1289.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1289.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1289.node_id } - }; - -/* index 0x1400 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1400 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1400[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1400.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1400.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1400.type }, - }; - -/* index 0x1401 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1401 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1401[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1401.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1401.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1401.type }, - }; - -/* index 0x1402 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1402 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1402[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1402.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1402.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1402.type }, - }; - -/* index 0x1600 : PDO receive mapping parameter of PDO communication index 0x1400 */ - static UNS8 obj1600_cnt = 0; // Number of mapped variables - static UNS32 obj1600_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1600[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1600_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[7]} - }; - -/* index 0x1601 : PDO receive mapping parameter of PDO communication index 0x1401 */ - static UNS8 obj1601_cnt = 0; // Number of mapped variables - static UNS32 obj1601_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1601[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1601_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[7]} - }; - -/* index 0x1602 : PDO receive mapping parameter of PDO communication index 0x1402 */ - static UNS8 obj1602_cnt = 0; // Number of mapped variables - static UNS32 obj1602_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1602[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1602_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[7]} - }; - -/* index 0x1800 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1800 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1800[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1800.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1800.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1800.type }, - }; - -/* index 0x1801 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1801 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1801[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1801.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1801.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1801.type }, - }; - -/* index 0x1802 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1802 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1802[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1802.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1802.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1802.type }, - }; - -/* index 0x1A00 : PDO transmit mapping parameter of PDO communication index 0x1800 */ - static UNS8 obj1A00_cnt = 0; // Number of mapped variables - static UNS32 obj1A00_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A00[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A00_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[7]} - }; - -/* index 0x1A01 : PDO transmit mapping parameter of PDO communication index 0x1801 */ - static UNS8 obj1A01_cnt = 0; // Number of mapped variables - static UNS32 obj1A01_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A01[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A01_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[7]} - }; - -/* index 0x1A02 : PDO transmit mapping parameter of PDO communication index 0x1802 */ - static UNS8 obj1A02_cnt = 0; // Number of mapped variables - static UNS32 obj1A02_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A02[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A02_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[7]} - }; - - -/* index 0x6000 : Mapped variable */ - subindex Index6000[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB_node5 } - }; - -/* index 0x6001 : Mapped variable */ - subindex Index6001[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL_node5 } - }; - -/* index 0x6002 : Mapped variable */ - static UNS8 highestSubIndex_6002 = 4; // number of subindex - 1 - subindex Index6002[] = - { - { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_6002 }, - { RW, uint8, sizeof (UNS8), (void*)&second }, - { RW, uint8, sizeof (UNS8), (void*)&minutes }, - { RW, uint8, sizeof (UNS8), (void*)&hour }, - { RW, uint8, sizeof (UNS8), (void*)&day } - }; - -/* index 0x6003 : Mapped variable */ - static UNS8 highestSubIndex_6003 = 2; // number of subindex - 1 - subindex Index6003[] = - { - { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_6003 }, - { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB }, - { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL } - }; - -const indextable objdict[] = -{ - DeclareIndexTableEntry(Index1000, 0x1000), - DeclareIndexTableEntry(Index1001, 0x1001), - DeclareIndexTableEntry(Index1005, 0x1005), - DeclareIndexTableEntry(Index1006, 0x1006), - DeclareIndexTableEntry(Index1007, 0x1007), - DeclareIndexTableEntry(Index1008, 0x1008), - DeclareIndexTableEntry(Index1009, 0x1009), - DeclareIndexTableEntry(Index100A, 0x100A), - DeclareIndexTableEntry(Index1016, 0x1016), - DeclareIndexTableEntry(Index1017, 0x1017), - DeclareIndexTableEntry(Index1018, 0x1018), - DeclareIndexTableEntry(Index1200, 0x1200), - DeclareIndexTableEntry(Index1280, 0x1280), - DeclareIndexTableEntry(Index1281, 0x1281), - DeclareIndexTableEntry(Index1282, 0x1282), - DeclareIndexTableEntry(Index1283, 0x1283), - DeclareIndexTableEntry(Index1284, 0x1284), - DeclareIndexTableEntry(Index1285, 0x1285), - DeclareIndexTableEntry(Index1286, 0x1286), - DeclareIndexTableEntry(Index1287, 0x1287), - DeclareIndexTableEntry(Index1288, 0x1288), - DeclareIndexTableEntry(Index1289, 0x1289), - DeclareIndexTableEntry(Index1400, 0x1400), - DeclareIndexTableEntry(Index1401, 0x1401), - DeclareIndexTableEntry(Index1402, 0x1402), - DeclareIndexTableEntry(Index1600, 0x1600), - DeclareIndexTableEntry(Index1601, 0x1601), - DeclareIndexTableEntry(Index1602, 0x1602), - DeclareIndexTableEntry(Index1800, 0x1800), - DeclareIndexTableEntry(Index1801, 0x1801), - DeclareIndexTableEntry(Index1802, 0x1802), - DeclareIndexTableEntry(Index1A00, 0x1A00), - DeclareIndexTableEntry(Index1A01, 0x1A01), - DeclareIndexTableEntry(Index1A02, 0x1A02), - DeclareIndexTableEntry(Index6000, 0x6000), - DeclareIndexTableEntry(Index6001, 0x6001), - DeclareIndexTableEntry(Index6002, 0x6002), - DeclareIndexTableEntry(Index6003, 0x6003), -}; - -// To count at which received SYNC a PDO must be sent. -// Even if no pdoTransmit are defined, at least one entry is computed -// for compilations issues. -UNS8 count_sync[1] = {0, }; - -UNS16 firstIndex (enum e_first_object object, UNS16 *lastIndex) -{ - switch (object) { - case FIRST_SDO_SERVER : - *lastIndex = 11; - return 11; - case FIRST_SDO_CLIENT : - *lastIndex = 21; - return 12; - case FIRST_PDO_RCV : - *lastIndex = 24; - return 22; - case FIRST_PDO_RCV_MAP : - *lastIndex = 27; - return 25; - case FIRST_PDO_TRS : - *lastIndex = 30; - return 28; - case FIRST_PDO_TRS_MAP : - *lastIndex = 33; - return 31; - } - *lastIndex = 0; - return 0; -} - -UNS16 getObjdictSize (void) -{ - return sizeof(objdict)/sizeof(objdict[0]); -} diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_Linux/objdict.html --- a/examples/AppliMaster_Linux/objdict.html Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ - - - - -CANOpen object dictionary Configuration - - - -

Object dictionary for Node :

-

-Mastermaster -

-

Overview

-

- How to make the object dictionary of the node ? - First, use Jaxe (command run_objdict) to edit an xml description file -of the dictionary : objdict.xml. -Then, run the php program : makeobjetdict.php. You can launch php through a web browser -if you have installed a server, or, on Linux, you can launch php in command line : -php-cgi makeobjetdict.php. It compute the file objdict.c. Link it to - your project. -
Note : To define the node id, use in your code the function setNodeId(UNS8 nodeId) -

-

- Then the node can be connected to the network. The master must configure it - by sending SDO. It will write values in its index, subindex. What to configure ? -

    -
  • Receiving heartbeats from which nodes ? Waiting time ?
  • -
  • Emitting heartbeats or not ? time btw 2 heartbeats ?
  • -
  • Defining a cobId for each PDO receive and transmit
  • -
  • How to transmit a PDO ? on synchro ? request ? event ?
  • -
  • What variables to put in each PDO receive and transmit ?
  • -
  • ...
  • -
-

- To avoid configuring the node at the connection, you can put the values directly -in the dictionary objdict.c. But it is boring and unsafe because it is too easy to make -a mistake ! - - -

Number of heartbeat consumers : - 1 -

-

This means that the node can expect heartbeats sent by 1 nodes.

-

Number of SDO clients : - 10 -

-

Usualy, a slave node does not have the use of SDO clients, but - today, for the library, you must define one. The Master, which can - send SDO to "n" slaves nodes, must define here "n" SDO - clients. Remember that in most cases, the SDO protocol is used by - the master to configure a slave dictionary or read a value. In - this use, the master is the client, and the slave is the server.

-

Maximum objects in a PDO (receive or transmit) : - 8 -

-

This is defining how many variables can be transmited in a - PDO. (maximum is 8).

-

For each variable, a table is created, so if you have less room - in memory, put a value under 8.

-

Number of PDO receive : - 3 -

-

The node can receive 3 PDO.

-

The communication parameters are defined at index 0x1400 to 0x1400 + 2

-

The mapping parameters are defined at index 0x1600 to 0x1600 + 2

-

Number of PDO transmit : - 3 -

-

The node can transmit 3 PDO.

-

The communication parameters are defined at index 0x1800 to 0x1800 + 2

-

The mapping parameters are defined at index 0x1A00 to 0x1A00 + 2

-

Mapped variables and tables

-

3 tables are defined for the mapping, starting at index 0x2000, 0x6000 and 0x6200. - You must start the mapping at the beginning of one of a table, without holes in index -or subindex. For example, variables in 0x2000 and 0x2001 is ok, but variables in 0x2000 and 0x2002 is not allowed, because you are loosing room in memory. It is the same for the subindex. -

-

Here are some others rules for the mapping :

-
    -
  • At an Index, you can map a variable at subindex 0x0 or 0x1, as you like.
  • -
  • To map several variables at the same Index, you must start at subindex 0x1, - because in this case, the subindex 0x0 contains the number of subindex.
  • -
  • You cannot map variables and tables at the same index.
  • -
  • The mapping of a table is always starting at subindex 0x1.
  • -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameBitsIndexSub-index
canopenErrNB_node5320x60000x0
canopenErrVAL_node5320x60010x0
second80x60020x1
minutes80x60020x02
hour80x60020x3
day80x60020x4
canopenErrNB320x60030x01
canopenErrVAL320x60030x02
- - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliMaster_Linux/objdict.xml --- a/examples/AppliMaster_Linux/objdict.xml Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/Makefile.in --- a/examples/AppliSlave_HCS12/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -#! 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 = -Os -CFLAGS = SUB_OPT_CFLAGS -PROG_CFLAGS = SUB_PROG_CFLAGS -OS_NAME = SUB_OS_NAME -ARCH_NAME = SUB_ARCH_NAME -PREFIX = SUB_PREFIX -BINUTILS_PREFIX = SUB_BINUTILS_PREFIX -TARGET = SUB_TARGET - -INCLUDES = -I../../include -I../../include/hcs12 -MEMORY_X = ../../include/hcs12/board/arch - -OBJCOPY = $(BINUTILS_PREFIX)objcopy -OBJCOPY_FLAGS = --only-section=.text --only-section=.rodata --only-section=.vectors --only-section=.data - -PROGDEFINES = -mnoshort -Wall -Wmissing-prototypes -fno-strict-aliasing -g - -PGR=AppliSlave - -SLAVE_OBJS = objdict.o appli.o vectors.o - -OBJS = ../../src/hc12_pdo.o ../../src/hc12_sdo.o ../../src/hc12_init.o ../../src/hc12_sync.o\ - ../../src/hc12_objacces.o ../../src/hc12_lifegrd.o ../../src/hc12_timer.o ../../src/hc12_nmtSlave.o\ - ../../drivers/hc12/canOpenDriver.o ../../drivers/hc12/ports.o ../../drivers/hc12/interrupt.o\ - ../../drivers/hc12/timerhw.o ../../drivers/hc12/variahw.o $(SLAVE_OBJS) - -LDFLAGS= -Wl,-m,m68hc12elfb -L$(MEMORY_X) - -all: $(PGR).elf $(PGR).s19 $(PGR).b $(PGR).s MSG - -%o: %c - $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -c -o $@ $< - -%o: %s - $(CC) -c -x assembler-with-cpp $(PROG_CFLAGS) -o $@ $< - -$(PGR).elf: $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) - -$(PGR).s19: $(PGR).elf - $(OBJCOPY) --output-target=srec $(OBJCOPY_FLAGS) $< $@ - -$(PGR).b: $(PGR).elf - $(OBJCOPY) --output-target=binary --gap-fill=255 --only-section=.data $(OBJCOPY_FLAGS) $< $@ - -$(PGR).s: $(PGR).elf - @echo "Desassemble" - $(BINUTILS_PREFIX)objdump -D $(PGR).elf > $(PGR).s - -MSG: - $(BINUTILS_PREFIX)readelf -S $(PGR).elf - @echo - $(BINUTILS_PREFIX)size $(PGR).elf - -clean: - rm -f $(SLAVE_OBJS) - -mrproper: clean - rm -f $(PGR).elf $(PGR).s19 $(PGR).b $(PGR).s - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/appli.c --- a/examples/AppliSlave_HCS12/appli.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,514 +0,0 @@ -/* -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 -*/ - -#include /* for NULL */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "../include/def.h" -#include "../include/can.h" -#include "../include/objdictdef.h" -#include "../include/objacces.h" -#include "../include/canOpenDriver.h" -#include "../include/sdo.h" -#include "../include/pdo.h" -#include "../include/init.h" -#include "../include/timer.h" -#include "../include/lifegrd.h" -#include "../include/sync.h" - -#include "../include/nmtSlave.h" - - - -// HCS12 configuration -// ----------------------------------------------------- - -enum E_CanBaudrate -{ - CAN_BAUDRATE_250K, - CAN_BAUDRATE_500K, - CAN_BAUDRATE_1M, - CAN_BAUDRATE_OLD_VALUE -}; - -const canBusTime CAN_Baudrates[] = -{ - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 3, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 13 tq for the TIME 1 segment (tseg1 = 12) - - 2 tq for the TIME 2 segment (tseg2 = 1) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 4 MHZ (brp = 3+1), and there are 16 tq in the bit time, - so the freq of the bit time is 250 kHz. - */ - }, - - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 13 tq for the TIME 1 segment (tseg1 = 12) - - 2 tq for the TIME 2 segment (tseg2 = 1) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 8 MHZ (brp = 1+1), and there are 16 tq in the bit time, - so the freq of the bit time is 500 kHz. - */ - }, - - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 4, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 5 tq for the TIME 1 segment (tseg1 = 4) - - 2 tq for the TIME 2 segment (tseg2 = 1) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 8 MHZ (brp = 1+1), and there are 8 tq in the bit time, - so the freq of the bit time is 1 MHz. - */ - }, - - { - 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ - 0, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ - 1, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ - 1, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ - 4, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ - 9, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ - - /* - With these values, - - The width of the bit time is 16 time quantum : - - 1 tq for the SYNC segment (could not be modified) - - 10 tq for the TIME 1 segment (tseg1 = 9) - - 5 tq for the TIME 2 segment (tseg2 = 4) - - Because the bus clock of the MSCAN is 16 MHZ, and the - freq of the time quantum is 16 MHZ (brp = 0), and there are 16 tq in the bit time, - so the freq of the bit time is 1 MHz. - */ - } -}; - - -// The variables sent or updated by PDO -// ----------------------------------------------------- -extern UNS8 seconds; // Mapped at index 0x2000, subindex 0x1 -extern UNS8 minutes; // Mapped at index 0x2000, subindex 0x2 -extern UNS8 hours; // Mapped at index 0x2000, subindex 0x3 -extern UNS8 day; // Mapped at index 0x2000, subindex 0x4 -extern UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x0 -extern UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x0 - -// Required definition variables -// ----------------------------- -// The variables that you should define for debugging. -// They are used by the macro MSG_ERR and MSG_WAR in applicfg.h -// if the node is a slave, they can be mapped in the object dictionnary. -// if not null, allow the printing of message to the console -// Could be managed by PDO -UNS8 printMsgErrToConsole = 1; -UNS8 printMsgWarToConsole = 1; - - - -/*************************User's variables declaration**************************/ -UNS8 softCount = 0; -UNS8 lastMinute = 0; -UNS8 lastSecond = 0; -UNS8 sendingError = 0; -//--------------------------------FONCTIONS------------------------------------- -/* You *must* have these 2 functions in your code*/ -void heartbeatError(UNS8 heartbeatID); -void SD0timeoutError(UNS8 bus_id, UNS8 line); - -// Interruption timer 3. (The timer 4 is used by CanOpen) -void __attribute__((interrupt)) timer3Hdl (void); - -void incDate(void); -void initLeds(void); -void initTimerClk(void); -void initCanHCS12 (void); -void initialisation(void); -void preOperational(void); -void operational(void); -void stopped(void); -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Interruption timer 3 -void __attribute__((interrupt)) timer3Hdl (void) -{ - //IO_PORTS_8(PORTB) ^= 0x10; - //IO_PORTS_8(PORTB) &= ~0x20; - IO_PORTS_8(TFLG1) = 0x08; // RAZ du flag interruption timer 3 - // Calcul evt suivant. Clock 8 MHz -> 8000 evt de 1 ms!! Doit tenir sur 16 bits - // Attention, ça change si on utilise la pll - // Lorsque le timer atteindra la valeur de TC3 (16 bits), l'interruption timer3Hdl sera déclenchée - // Si on utilise la PLL à 24 MHZ, alors la vitesse du bus est multipliée par 3. - -/* Assume that our board uses a 16 MHz quartz */ -/* Without pre-division, 8000 counts takes 1 ms. */ -/* We are using a pre-divisor of 32. (register TSCR2) See in CanOpenDriverHC12/timerhw.c */ -/* So 10000 counts takes 40 ms. */ -/* We must have a soft counter of 25 to count a second. */ - - IO_PORTS_16(TC3H) += (10000); // IT every 40000 count. - softCount++; - if (softCount == 25) { - softCount = 0; - incDate(); - } -} - -//------------------------------------------------------------------------------ -void heartbeatError(UNS8 heartbeatID) -{ - MSG_ERR(0x1F00, "!!! No heart beat received from node : ", heartbeatID); -} - -//------------------------------------------------------------------------------ -void SD0timeoutError (UNS8 bus_id, UNS8 line) -{ - // Informations on what occurs are in transfers[bus_id][line].... - // See scanSDOtimeout() in sdo.c -} - -//------------------------------------------------------------------------------ -// Incrementation of the date, every second -void incDate(void) -{ - if (seconds == 59) { - seconds = 0; - if (minutes == 59) { - minutes = 0; - if (hours == 23) { - hours = 0; - day++; - } - else - hours++; - } - else - minutes++; - } - else - seconds++; - - // Toggle the led 4 every seconds - IO_PORTS_8(PORTB) ^= 0x10; - -} - -//Initialisation of the port B for the leds. -void initLeds(void) -{ - // Port B is output - IO_PORTS_8(DDRB)= 0XFF; - // RAZ - IO_PORTS_8(PORTB) = 0xFF; -} - - - -//------------------------------------------------------------------------------ -// Init the timer for the clock demo -void initTimerClk(void) -{ - - lock(); // Inhibe les interruptions - - // Configuration du Channel 3 - IO_PORTS_8(TIOS) |= 0x08; // Canal 3 en sortie - IO_PORTS_8(TCTL2) &= ~(0xC0); // Canal 3 déconnecté du pin de sortie - IO_PORTS_8(TIE) |= 0x08; // Autorise interruption Canal 3 - IO_PORTS_8(TSCR1) |= 0x80; // Mise en route du timer - unlock(); // Autorise les interruptions -} - - -//------------------------------------------------------------------------------ - -// A placer avant initTimer de la bibliothèque CanOpen -/* void initTimerbis(void) */ -/* { */ - -/* lock(); // Inhibe les interruptions */ -/* // Configuration des IT Channels (0..3) */ -/* IO_PORTS_8(TIOS) &= 0xF0; // Canals 0->3 en entrées. */ -/* IO_PORTS_8(TCTL4) &= 0XFD; // Canal 0 détection sur front montant. */ -/* IO_PORTS_8(TCTL4) |= 0X01; */ -/* IO_PORTS_8(TCTL4) &= 0XF7; // Canal 1 détection sur front montant. */ -/* IO_PORTS_8(TCTL4) |= 0X04; */ -/* IO_PORTS_8(TCTL4) &= 0XDF; // Canal 2 détection sur front montant. */ -/* IO_PORTS_8(TCTL4) |= 0X10; */ -/* IO_PORTS_8(TCTL4) &= 0X7F; // Canal 3 détection sur front montant. */ -/* IO_PORTS_8(TCTL4) |= 0X40; */ -/* IO_PORTS_8(TSCR2) |= 0X05; // Pre-scaler = 32. */ - -/* IO_PORTS_8(ICOVW) |= 0x0F; // La sauvgrade des valeures de TC0 et TC0H */ -/* // correspondant aux canals (0..3) jusqu'a la */ -/* // prochaine lecture dans ces registres. */ -/* MASK = IO_PORTS_8(ICSYS); */ -/* MASK &= 0xFE; // Canals (0..3) en IC QUEUE MODE. */ -/* MASK |= 0x08; // Canals (0..3) : génére une interruption aprés */ -/* // la capture de deux valeures du timer sur detection */ -/* // d'un front montant à l'entrée des canals (0..3). */ -/* MASK |= 0x02; */ -/* IO_PORTS_8(ICSYS) = MASK; */ -/* IO_PORTS_16(TC0HH); // Vider le registre holding correspondant au canal0. */ -/* IO_PORTS_8(TSCR1) |= 0x10; // RAZ automatique des flags d'interruption aprés lecture */ -/* // dans les registres correspondant. */ - -/* IO_PORTS_8(TIE) |= 0x0F; // Autorise interruption Canals (0..3). */ -/* IO_PORTS_8(TSCR2) |= 0X80; // Autorise interruption sur l'Overflow. */ -/* unlock(); // Autorise les interruptions */ - -/* } */ - -//------------------------------------------------------------------------------ - - - -void initCanHCS12 (void) -{ - //Init the HCS12 microcontroler for CanOpen - initHCS12(); - // Init the HCS12 CAN driver - const canBusInit bi0 = { - 0, /* no low power */ - 0, /* no time stamp */ - 1, /* enable MSCAN */ - 0, /* clock source : oscillator (In fact, it is not used) */ - 0, /* no loop back */ - 0, /* no listen only */ - 0, /* no low pass filter for wk up */ - CAN_Baudrates[CAN_BAUDRATE_250K], - { - 0x00, /* Filter on 16 bits. See Motorola Block Guide V02.14 fig 4-3 */ - 0x00, 0xFF, /* filter 0 hight accept all msg */ - 0x00, 0xFF, /* filter 0 low accept all msg */ - 0x00, 0xFF, /* filter 1 hight filter all of msg */ - 0x00, 0xFF, /* filter 1 low filter all of msg */ - 0x00, 0xFF, /* filter 2 hight filter most of msg */ - 0x00, 0xFF, /* filter 2 low filter most of msg */ - 0x00, 0xFF, /* filter 3 hight filter most of msg */ - 0x00, 0xFF, /* filter 3 low filter most of msg */ - } - }; - - canInit(CANOPEN_LINE_NUMBER_USED, bi0); //initialize filters... - unlock(); // Allow interruptions -} - - -/*********************************************************************/ -void initialisation( void ) -{ - //initcapteur(); //initialisation du capteur, timer, compteurs logiciels - initCanHCS12(); //initialisation du bus Can - MSG_WAR(0X3F05, "I am in INITIALISATION mode ", 0); - /* Defining the node Id */ - setNodeId(0x05); - MSG_WAR(0x3F06, "My node ID is : ", getNodeId()); - { - UNS8 *data; - UNS8 size; - UNS8 dataType; - // Manufacturer Device name (default = empty string) - getODentry(0x1008, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Hardware version. (default = compilation. date) - getODentry(0x1009, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Software version. (default = compilation. time) - getODentry(0x100A, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - } - initCANopenMain(); //initialisation du canopen - heartbeatInit(); //initialisation du lifeguarding - initResetMode(); - initTimer(); //initialisation of the timer used by Canopen - initTimerClk(); -} - - -/*********************************************************************/ -void preOperational(void) -{ - // Test if the heartBeat have been received. Send headbeat - heartbeatMGR(); - // Read message - receiveMsgHandler(0); -} - - -/********************************************************************/ -void operational( void ) -{ - - // Init the errors - canopenErrNB = 0; - canopenErrVAL = 0; - - // Test if the heartBeat have been received. Send headbeat - heartbeatMGR(); - // Read message - receiveMsgHandler(0); - - if (lastMinute != minutes) { - MSG_WAR(0x3F00, "event : minutes change -> node decides to send it. Value : ", minutes); - sendPDOevent( 0, &minutes ); - lastMinute = minutes; - } - - if (canopenErrNB == 0) - sendingError = 0; - - - if (lastSecond != seconds) { - MSG_WAR (0x3F50, "Seconds = ", seconds); - if ((seconds == 50) && (sendingError == 0)) - { - MSG_ERR(0x1F55, "DEMO of ERROR. Sent by PDO. Value : ", 0xABCD); - sendingError = 1; - } - - if (canopenErrNB) { - MSG_WAR(0x3F56, "ERROR nb : ", canopenErrNB); - } - lastSecond = seconds; - - } - -} - - -/*****************************************************************************/ -void stopped( void ) -{ - heartbeatMGR(); - // Read message - receiveMsgHandler(0); -} - - -/*****************************************************************************/ - - - -/********************************* MAIN ***************************************/ - - -int main () -{ - e_nodeState lastState = Unknown_state; - - /* CanOpen slave state machine */ - /* ------------------------------------*/ - - while(1) { /* slave's state machine */ - - switch( getState() ) { - case Initialisation: - if (lastState != getState()) { - initLeds(); - IO_PORTS_8(PORTB) &= ~ 0x01; // led 0 : ON - IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3 : OFF - MSG_WAR(0X3F10, "Entering in INITIALISATION mode ", 0); - } - initialisation(); - /* change automatically into pre_operational state */ - lastState = Initialisation; - setState(Pre_operational); - break; - - case Pre_operational: - if (lastState != getState()) { - IO_PORTS_8(PORTB) &= ~ 0x03; // leds 0, 1 : ON - IO_PORTS_8(PORTB) |= 0x0C; // leds 2, 3 : OFF - MSG_WAR(0X3F11, "Entering in PRE_OPERATIONAL mode ", 0); - initPreOperationalMode(); - } - preOperational(); - if (lastState == Initialisation) - slaveSendBootUp(0); - lastState = Pre_operational; - break; - - case Operational: - if (lastState != getState()) { - IO_PORTS_8(PORTB) &= ~ 0x07; // leds 0, 1, 2 : ON - IO_PORTS_8(PORTB) |= 0x08; // leds 3 : OFF - MSG_WAR(0X3F12, "Entering in OPERATIONAL mode ", 0); - } - operational(); - lastState = Operational; - break; - - case Stopped: - if (lastState != getState()) { - IO_PORTS_8(PORTB) |= 0x0F; // leds 0, 1, 2, 3 : OFF - MSG_WAR(0X3F13, "Entering in STOPPED mode", 0); - } - stopped(); - lastState = Stopped; - break; - }//end switch case - - } - return (0); -} - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/objdict.c --- a/examples/AppliSlave_HCS12/objdict.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,621 +0,0 @@ -/* -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 -*/ - -#include - -#include -#include "def.h" -#include "can.h" -#include "objdictdef.h" -#include "pdo.h" -#include "sdo.h" -#include "sync.h" -#include "lifegrd.h" -#include "nmtSlave.h" - -/**************************************************************************/ -/* Declaration of the mapped variables */ -/**************************************************************************/ - - - -/*// Copy and uncomment this code to your main file -extern UNS8 seconds; // Mapped at index 0x2000, subindex 0x01 -extern UNS8 minutes; // Mapped at index 0x2000, subindex 0x02 -extern UNS8 hours; // Mapped at index 0x2000, subindex 0x03 -extern UNS8 day; // Mapped at index 0x2000, subindex 0x04 -extern UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x00 -extern UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x00 -extern UNS8 strTest[10]; // Mapped at index 0x6002, subindex 0x00 - -// END copy to main file -*/ - -UNS8 seconds; // Mapped at index 0x2000, subindex 0x01 -UNS8 minutes; // Mapped at index 0x2000, subindex 0x02 -UNS8 hours; // Mapped at index 0x2000, subindex 0x03 -UNS8 day; // Mapped at index 0x2000, subindex 0x04 -UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x00 -UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x00 -UNS8 strTest[10]; // Mapped at index 0x6002, subindex 0x00 - -/**************************************************************************/ -/* Declaration of the value range types */ -/**************************************************************************/ - - - -UNS32 valueRangeTest (UNS8 typeValue, UNS32 unsValue, REAL32 realValue) -{ - return 0; -} - - -/**************************************************************************/ -/* The node id */ -/**************************************************************************/ -/* Computed by strNode */ -/* node_id default value. - This default value is deprecated. - You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code. -*/ -#define NODE_ID 0x01 -UNS8 bDeviceNodeId = NODE_ID; - - -//*****************************************************************************/ -/* Computed by strStartDico */ - -/* Array of message processing information */ -/* Should not be modified */ -volatile const proceed_info proceed_infos[] = { - {NMT, "NMT", proceedNMTstateChange}, - {SYNC, "SYNC", proceedSYNC}, - {TIME_STAMP, "TStmp", NULL}, - {PDO1tx, "PDO1t", proceedPDO}, - {PDO1rx, "PDO1r", proceedPDO}, - {PDO2tx, "PDO2t", proceedPDO}, - {PDO2rx, "PDO2r", proceedPDO}, - {PDO3tx, "PDO3t", proceedPDO}, - {PDO3rx, "PDO3r", proceedPDO}, - {PDO4tx, "PDO4t", proceedPDO}, - {PDO4rx, "PDO4r", proceedPDO}, - {SDOtx, "SDOt", proceedSDO}, - {SDOrx, "SDOr", proceedSDO}, - {0xD, "Unkw", NULL}, - {NODE_GUARD, "NGrd", proceedNMTerror}, - {0xF, "Unkw", NULL} -}; - - // Macros definition - -/* Beware : -index *must* be writen 4 numbers in hexa -sub_index *must* be writen 2 numbers in hexa -size_variable_in_UNS8 *must* be writen 2 numbers in hexa -*/ -#define PDO_MAP(index, sub_index, size_variable_in_bits)\ -0x ## index ## sub_index ## size_variable_in_bits - -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// -// OBJECT DICTIONARY -// -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// Make your change, depending of your application - - -/* index 0x1000 : Device type. - You have to change the value below, so - it fits your canopen-slave-module */ - - /* Not used, so, should not be modified */ - - UNS32 obj1000 = 0; - subindex Index1000[] = - { - { RO, uint32, sizeof(UNS32), (void*)&obj1000 } - }; - -/* index 0x1001 : Error register. - Change the entries to fit your application - Not used, so, should not be modified */ - /*const*/ UNS8 obj1001 = 0x0; - /*const*/ subindex Index1001[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1001 } - }; - -/* index 0x1005 : COB_ID SYNC */ - /* Should not be modified */ - UNS32 obj1005 = 0x00000080; // bit 30 = 1 : device can generate a SYNC message - // Beware, it is over written when the node - // enters in reset mode - // See initResetMode() in init.c - /*const*/ subindex Index1005[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1005 } - }; - -/* index 0x1006 : SYNC period */ - // For producing the SYNC signal every n micro-seconds. - // Put O to not producing SYNC - /*const*/ UNS32 obj1006 = 0x0; - // Default 0 to not produce SYNC // - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - /*const*/ subindex Index1006[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1006 } - }; - -/* index 0x1007 : Synchronous Window Length - Seems to be needed by DS401 to generate the SYNC signal ! */ - /*const*/ UNS32 obj1007 = 0x0; /* Default 0 */ - /*const*/ subindex Index1007[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1007 } - }; - -/* index 0x1008 : Manufacturer device name */ - UNS8 obj1008[] = "Appli_Slave_HC12"; /* Default 0 */ - subindex Index1008[] = - { - { RO, uint32, sizeof(obj1008), (void*)&obj1008 } - }; - -/* index 0x1009 : Manufacturer hardware version */ - UNS8 obj1009[] = __DATE__; /* Default 0 */ - subindex Index1009[] = - { - { RO, uint32, sizeof(obj1009), (void*)&obj1009 } - }; - -/* index 0x100A : Manufacturer software version */ - UNS8 obj100A[] = __TIME__; /* Default 0 */ - subindex Index100A[] = - { - { RO, uint32, sizeof(obj100A), (void*)&obj100A} - }; - -/* index 0x1016 : HeartBeat consumers - The nodes which can send a heartbeat */ - static UNS32 obj1016[] = {// Consumer time for each node - 0x00000000}; // Format 0x00NNTTTT (N=Node T=time in ms) - - static UNS8 obj1016_cnt = 1; // 1 nodes could send me - // their heartbeat. - subindex Index1016[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1016_cnt }, - { RW, uint32, sizeof(UNS32), (void*)&obj1016[0] } - }; - -/* index 0x1017 : Heartbeat producer - Every HBProducerTime, the node sends its heartbeat */ - static UNS16 obj1017 = 0; //HBProducerTime in ms. If 0 : not activated - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - subindex Index1017[] = - { - { RW, uint16, sizeof(UNS16), &obj1017 } - }; - -/* index 0x1018 : Identity object */ - /** index 1018: identify object. Adjust the entries for your node/company - */ - /* Values can be modified */ - - s_identity obj1018 = - { - 4, // number of supported entries - 0, // Vendor-ID (given by the can-cia) - 0, // Product Code - 0, // Revision number - 0 // serial number - }; - - subindex Index1018[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1018.count }, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.vendor_id}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.product_code}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.revision_number}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.serial_number} - }; - -/* index 0x1200 : The SDO Server parameters */ - /* BEWARE You cannot define more than one SDO server */ - /* The values should not be modified here, - but can be changed at runtime */ - // Beware that the default values that you could put here - // will be over written at the initialisation of the node. - // See setNodeId() in init.c - static s_sdo_parameter obj1200 = - { 3, // Number of entries. Always 3 for the SDO - 0x600 + NODE_ID, // The cob_id transmited in CAN msg to the server - 0x580 + NODE_ID, // The cob_id received in CAN msg from the server - NODE_ID // The node id of the client. Should not be modified - }; - static subindex Index1200[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1200.count }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_client }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_server }, - { RW, uint8, sizeof( UNS8), (void*)&obj1200.node_id } - }; - -/* index 0x1280 : SDO client parameter */ - static s_sdo_parameter obj1280 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1280[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1280.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1280.node_id } - }; - -/* index 0x1400 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1400 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1400[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1400.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1400.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1400.type }, - }; - -/* index 0x1401 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1401 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1401[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1401.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1401.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1401.type }, - }; - -/* index 0x1402 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1402 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1402[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1402.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1402.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1402.type }, - }; - -/* index 0x1600 : PDO receive mapping parameter of PDO communication index 0x1400 */ - static UNS8 obj1600_cnt = 0; // Number of mapped variables - static UNS32 obj1600_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1600[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1600_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[7]} - }; - -/* index 0x1601 : PDO receive mapping parameter of PDO communication index 0x1401 */ - static UNS8 obj1601_cnt = 0; // Number of mapped variables - static UNS32 obj1601_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1601[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1601_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[7]} - }; - -/* index 0x1602 : PDO receive mapping parameter of PDO communication index 0x1402 */ - static UNS8 obj1602_cnt = 0; // Number of mapped variables - static UNS32 obj1602_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1602[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1602_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[7]} - }; - -/* index 0x1800 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1800 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1800[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1800.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1800.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1800.type }, - }; - -/* index 0x1801 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1801 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1801[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1801.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1801.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1801.type }, - }; - -/* index 0x1802 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1802 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1802[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1802.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1802.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1802.type }, - }; - -/* index 0x1A00 : PDO transmit mapping parameter of PDO communication index 0x1800 */ - static UNS8 obj1A00_cnt = 0; // Number of mapped variables - static UNS32 obj1A00_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A00[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A00_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[7]} - }; - -/* index 0x1A01 : PDO transmit mapping parameter of PDO communication index 0x1801 */ - static UNS8 obj1A01_cnt = 0; // Number of mapped variables - static UNS32 obj1A01_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A01[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A01_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[7]} - }; - -/* index 0x1A02 : PDO transmit mapping parameter of PDO communication index 0x1802 */ - static UNS8 obj1A02_cnt = 0; // Number of mapped variables - static UNS32 obj1A02_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A02[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A02_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[7]} - }; - - -/* index 0x2000 : Mapped variable */ - static UNS8 highestSubIndex_2000 = 4; // number of subindex - 1 - subindex Index2000[] = - { - { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_2000 }, - { RW, uint8, sizeof (UNS8), (void*)&seconds }, - { RW, uint8, sizeof (UNS8), (void*)&minutes }, - { RW, uint8, sizeof (UNS8), (void*)&hours }, - { RW, uint8, sizeof (UNS8), (void*)&day } - }; - -/* index 0x6000 : Mapped variable */ - subindex Index6000[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB } - }; - -/* index 0x6001 : Mapped variable */ - subindex Index6001[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL } - }; - -/* index 0x6002 : Mapped variable */ - subindex Index6002[] = - { - { RW, visible_string, sizeof (strTest), (void*)&strTest } - }; - -const indextable objdict[] = -{ - DeclareIndexTableEntry(Index1000, 0x1000), - DeclareIndexTableEntry(Index1001, 0x1001), - DeclareIndexTableEntry(Index1005, 0x1005), - DeclareIndexTableEntry(Index1006, 0x1006), - DeclareIndexTableEntry(Index1007, 0x1007), - DeclareIndexTableEntry(Index1008, 0x1008), - DeclareIndexTableEntry(Index1009, 0x1009), - DeclareIndexTableEntry(Index100A, 0x100A), - DeclareIndexTableEntry(Index1016, 0x1016), - DeclareIndexTableEntry(Index1017, 0x1017), - DeclareIndexTableEntry(Index1018, 0x1018), - DeclareIndexTableEntry(Index1200, 0x1200), - DeclareIndexTableEntry(Index1280, 0x1280), - DeclareIndexTableEntry(Index1400, 0x1400), - DeclareIndexTableEntry(Index1401, 0x1401), - DeclareIndexTableEntry(Index1402, 0x1402), - DeclareIndexTableEntry(Index1600, 0x1600), - DeclareIndexTableEntry(Index1601, 0x1601), - DeclareIndexTableEntry(Index1602, 0x1602), - DeclareIndexTableEntry(Index1800, 0x1800), - DeclareIndexTableEntry(Index1801, 0x1801), - DeclareIndexTableEntry(Index1802, 0x1802), - DeclareIndexTableEntry(Index1A00, 0x1A00), - DeclareIndexTableEntry(Index1A01, 0x1A01), - DeclareIndexTableEntry(Index1A02, 0x1A02), - DeclareIndexTableEntry(Index2000, 0x2000), - DeclareIndexTableEntry(Index6000, 0x6000), - DeclareIndexTableEntry(Index6001, 0x6001), - DeclareIndexTableEntry(Index6002, 0x6002), -}; - -// To count at which received SYNC a PDO must be sent. -// Even if no pdoTransmit are defined, at least one entry is computed -// for compilations issues. -UNS8 count_sync[1] = {0, }; - -UNS16 firstIndex (enum e_first_object object, UNS16 *lastIndex) -{ - switch (object) { - case FIRST_SDO_SERVER : - *lastIndex = 11; - return 11; - case FIRST_SDO_CLIENT : - *lastIndex = 12; - return 12; - case FIRST_PDO_RCV : - *lastIndex = 15; - return 13; - case FIRST_PDO_RCV_MAP : - *lastIndex = 18; - return 16; - case FIRST_PDO_TRS : - *lastIndex = 21; - return 19; - case FIRST_PDO_TRS_MAP : - *lastIndex = 24; - return 22; - } - *lastIndex = 0; - return 0; -} - -UNS16 getObjdictSize (void) -{ - return sizeof(objdict)/sizeof(objdict[0]); -} diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/objdict.html --- a/examples/AppliSlave_HCS12/objdict.html Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ - - - - -CANOpen object dictionary Configuration - - - -

Object dictionary for Node :

-

-Linux_slaveslave -

-

Overview

-

- How to make the object dictionary of the node ? - First, use Jaxe (command run_objdict) to edit an xml description file -of the dictionary : objdict.xml. -Then, run the php program : makeobjetdict.php. You can launch php through a web browser -if you have installed a server, or, on Linux, you can launch php in command line : -php-cgi makeobjetdict.php. It compute the file objdict.c. Link it to - your project. -
Note : To define the node id, use in your code the function setNodeId(UNS8 nodeId) -

-

- Then the node can be connected to the network. The master must configure it - by sending SDO. It will write values in its index, subindex. What to configure ? -

    -
  • Receiving heartbeats from which nodes ? Waiting time ?
  • -
  • Emitting heartbeats or not ? time btw 2 heartbeats ?
  • -
  • Defining a cobId for each PDO receive and transmit
  • -
  • How to transmit a PDO ? on synchro ? request ? event ?
  • -
  • What variables to put in each PDO receive and transmit ?
  • -
  • ...
  • -
-

- To avoid configuring the node at the connection, you can put the values directly -in the dictionary objdict.c. But it is boring and unsafe because it is too easy to make -a mistake ! - - -

Number of heartbeat consumers : - 1 -

-

This means that the node can expect heartbeats sent by 1 nodes.

-

Number of SDO clients : - 1 -

-

Usualy, a slave node does not have the use of SDO clients, but - today, for the library, you must define one. The Master, which can - send SDO to "n" slaves nodes, must define here "n" SDO - clients. Remember that in most cases, the SDO protocol is used by - the master to configure a slave dictionary or read a value. In - this use, the master is the client, and the slave is the server.

-

Maximum objects in a PDO (receive or transmit) : - 8 -

-

This is defining how many variables can be transmited in a - PDO. (maximum is 8).

-

For each variable, a table is created, so if you have less room - in memory, put a value under 8.

-

Number of PDO receive : - 3 -

-

The node can receive 3 PDO.

-

The communication parameters are defined at index 0x1400 to 0x1400 + 2

-

The mapping parameters are defined at index 0x1600 to 0x1600 + 2

-

Number of PDO transmit : - 3 -

-

The node can transmit 3 PDO.

-

The communication parameters are defined at index 0x1800 to 0x1800 + 2

-

The mapping parameters are defined at index 0x1A00 to 0x1A00 + 2

-

Mapped variables and tables

-

3 tables are defined for the mapping, starting at index 0x2000, 0x6000 and 0x6200. - You must start the mapping at the beginning of one of a table, without holes in index -or subindex. For example, variables in 0x2000 and 0x2001 is ok, but variables in 0x2000 and 0x2002 is not allowed, because you are loosing room in memory. It is the same for the subindex. -

-

- The access of the variable is by default "rw" (read-write) or "ro" (read-only). A read-only variable cannot be mapped in a PDO receive. -

-

Here are some others rules for the mapping :

-
    -
  • At an Index, you can map a variable at subindex 0x0 or 0x1, as you like.
  • -
  • To map several variables at the same Index, you must start at subindex 0x1, - because in this case, the subindex 0x0 contains the number of subindex.
  • -
  • You cannot map variables and tables at the same index.
  • -
  • The mapping of a table is always starting at subindex 0x1.
  • -
- - - - - - - - - - - - - - - - - - - - - - - -
Var NameBitsIndexSub-indexaccess
seconds80x20000x1rw
minutes80x20000x02rw
hours80x20000x3rw
day80x20000x4rw
canopenErrNB320x60000x0rw
canopenErrVAL320x60010x0rw
Table NameBitsIndexSub-indexaccess
- - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/objdict.xml --- a/examples/AppliSlave_HCS12/objdict.xml Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/trace32_flash_debug.cmm --- a/examples/AppliSlave_HCS12/trace32_flash_debug.cmm Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -; Réinitialisation -SYS.d - -; Effacer l'écran -WinCLEAR - -;Raffraichissement de trace32 toutes les 1 secondes -setup.urate 1 - -; Choix du microcontrôleur cible -SYStem.CPU MCS12DP256 - -; Vitesse de commuication debugger / carte HCS12 - SYStem.BdmClock 8.0MHZ - -; initialiser le uc en mode debug -SYStem.UP - -; Reset des registres -r.reset - -; Charger le programme -DATA.LOAD.ELF appliSlave.elf /gnu /nocode /GHILLS - -; Positionner le compteur de programme -r.set PC _start - -; Positionner le pointeur de pile -r.set SP _stack - -; Afficher le code source -data.list - -; Afficher les registres -;r - -; Afficher le contenu de la mémoire -;DATA.dump 140 - - -; Fin du programme de script -ENDDO - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/trace32_flash_debug_sans_init.cmm --- a/examples/AppliSlave_HCS12/trace32_flash_debug_sans_init.cmm Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -; Réinitialisation -SYS.d - -; Effacer l'écran -;WinCLEAR - -;Raffraichissement de trace32 toutes les 1 secondes -setup.urate 1 - -; Choix du microcontrôleur cible -SYStem.CPU MCS12DP256 - -; Vitesse de commuication debugger / carte HCS12 - SYStem.BdmClock 8.0MHZ - -; initialiser le uc en mode debug -SYStem.UP - -; Reset des registres -r.reset - -; Charger le programme -DATA.LOAD.ELF appliSlave.elf /gnu /nocode /GHILLS - -; Positionner le compteur de programme -r.set PC _start - -; Positionner le pointeur de pile -r.set SP _stack - - - - -; Fin du programme de script -ENDDO - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/trace32_flash_programmer.cmm --- a/examples/AppliSlave_HCS12/trace32_flash_programmer.cmm Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -; Programmation de la mémoire flash - - -; Réinitialisation -SYS.d - -; Effacer l'écran -WinCLEAR - -; Vitesse de transmission : -SYStem.BdmClock 8.0MHZ - -; Choix du microcontrôleur cible -SYStem.CPU MCS12DP256 - -; Flash page 0X3E accessible entre 0X4000 et 0X7FFF -; cf Motorola, registre MISC - -system.option ROMHM ON - - -; Enlever tous les points d'arrêt -b.res - -; Utiliser les points d'arrêts onchip -map.bonchip - -; Connexion à la carte CS12 -system.up - -flash.reset - - -; Effacement de la flash -PRINT "Effacement de la flash" -FLASH.Erase all - -; Passage en mode programmation de la flash -print "Programmation de la flash non paginée (48KO) 1 " -FLASH.Program 0x4000--0x7FFF - -;print "Chargement du programme en flash 1" -DATA.LOAD.ELF appliSlave.elf 0x4000--0x7FFF - - -FLASH.Program off -print "Flash programmée 1" - - -; Passage en mode programmation de la flash -print "Programmation de la flash non paginée (48KO) 2" -FLASH.Program 0x308000--0x30BFFF - -;print "Chargement du programme en flash 2" -DATA.LOAD.ELF appliSlave.elf 0x8000--0xBFFF - - -FLASH.Program off -print "Flash programmée 2" - -; Passage en mode programmation de la flash -print "Programmation de la flash non paginée (48KO) 3" -FLASH.Program 0xC000--0xFFFF - -;print "Chargement du programme en flash 3" -DATA.LOAD.ELF appliSlave.elf 0xC000--0xFFFF - - -FLASH.Program off -print "Flash programmée 3" - - -;Reset du HCS12 -system.up - -;Reset de trace32 -SYS.d - - -ENDDO - - - - - - - - - - - - - - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_HCS12/vectors.s --- a/examples/AppliSlave_HCS12/vectors.s Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -;;/* M68HC11 Interrupt vectors table -;; Copyright (C) 1999 Free Software Foundation, Inc. -;; Written by Stephane Carrez (stcarrez@worldnet.fr) -;; -;;This file 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. -;; -;;In addition to the permissions in the GNU General Public License, the -;;Free Software Foundation gives you unlimited permission to link the -;;compiled version of this file with other programs, and to distribute -;;those programs without any restriction coming from the use of this -;;file. (The General Public License restrictions do apply in other -;;respects; for example, they cover modification of the file, and -;;distribution when not linked into another program.) -;; -;;This file 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; see the file COPYING. If not, write to -;;the Free Software Foundation, 59 Temple Place - Suite 330, -;;Boston, MA 02111-1307, USA. -;; ---------------------------------------------- -;; Modified by Francis Dupin for MC9S12DP256. April 2003 -;; francis.dupin@inrets.fr -;;*/ - - .sect .text - .globl _start - .globl can4HdlTra - .globl can4HdlRcv - .globl can4HdlErr - .globl can4HdlWup - .globl can3HdlTra - .globl can3HdlRcv - .globl can3HdlErr - .globl can3HdlWup - .globl can2HdlTra - .globl can2HdlRcv - .globl can2HdlErr - .globl can2HdlWup - .globl can1HdlTra - .globl can1HdlRcv - .globl can1HdlErr - .globl can1HdlWup - .globl can0HdlTra - .globl can0HdlRcv - .globl can0HdlErr - .globl can0HdlWup - .globl timerOvflHdl - .globl timer3IC - .globl timer2IC - .globl timer1IC - .globl timer0IC - -;; Default interrupt handler. - .sect .text -def: - rti - -;; -;; Interrupt vectors are in a specific section that is -;; mapped at 0xff00. For the example program, the reset handler -;; points to the generic crt0 entry point. -;; - .sect .vectors - .globl vectors -vectors: - - .word def ; ff00 - .word def ; ff02 - .word def ; ff04 - .word def ; ff06 - .word def ; ff08 - .word def ; ff0a - .word def ; ff0c - .word def ; ff0e - .word def ; ff10 - .word def ; ff12 - .word def ; ff14 - .word def ; ff16 - .word def ; ff18 - .word def ; ff1a - .word def ; ff1c - .word def ; ff1e - .word def ; ff20 - .word def ; ff22 - .word def ; ff24 - .word def ; ff26 - .word def ; ff28 - .word def ; ff2a - .word def ; ff2c - .word def ; ff2e - .word def ; ff30 - .word def ; ff32 - .word def ; ff34 - .word def ; ff36 - .word def ; ff38 - .word def ; ff3a - .word def ; ff3c - .word def ; ff3e - .word def ; ff40 - .word def ; ff42 - .word def ; ff44 - .word def ; ff46 - .word def ; ff48 - .word def ; ff4a - .word def ; ff4c - .word def ; ff4e - .word def ; ff50 - .word def ; ff52 - .word def ; ff54 - .word def ; ff56 - .word def ; ff58 - .word def ; ff5a - .word def ; ff5c - .word def ; ff5e - .word def ; ff60 - .word def ; ff62 - .word def ; ff64 - .word def ; ff66 - .word def ; ff68 - .word def ; ff6a - .word def ; ff6c - .word def ; ff6e - .word def ; ff70 - .word def ; ff72 - .word def ; ff74 - .word def ; ff76 - .word def ; ff78 - .word def ; ff7a - .word def ; ff7c - .word def ; ff7e - .word def ; ff80 - .word def ; ff82 - .word def ; ff84 - .word def ; ff86 - .word def ; ff88 - .word def ; ff8a - .word def ; ff8c - .word def ; ff8e - - ;; MSCAN - .word can4HdlTra ; ff90 (MSCAN4 Transmit) - .word can4HdlRcv ; ff92 (MSCAN4 Receive) - .word can4HdlErr ; ff94 (MSCAN4 Errors) - .word can4HdlWup ; ff96 (MSCAN4 Wake up) - .word can3HdlTra ; ff98 (MSCAN3 Transmit) - .word can3HdlRcv ; ff9a (MSCAN3 Receive) - .word can3HdlErr ; ff9c (MSCAN3 Errors) - .word can3HdlWup ; ff9e (MSCAN3 Wake up) - .word can2HdlTra ; ffa0 (MSCAN2 Transmit) - .word can2HdlRcv ; ffa2 (MSCAN2 Receive) - .word can2HdlErr ; ffa4 (MSCAN2 Errors) - .word can2HdlWup ; ffa6 (MSCAN2 Wake up) - .word can1HdlTra ; ffa8 (MSCAN1 Transmit) - .word can1HdlRcv ; ffaa (MSCAN1 Receive) - .word can1HdlErr ; ffac (MSCAN1 Errors) - .word can1HdlWup ; ffae (MSCAN1 Wake up) - .word can0HdlTra ; ffb0 (MSCAN0 Transmit) - .word can0HdlRcv ; ffb2 (MSCAN0 Receive) - .word can0HdlErr ; ffb4 (MSCAN0 Errors) - .word can0HdlWup ; ffb6 (MSCAN0 Wake up) - - .word def ; ffb8 - .word def ; ffba - .word def ; ffbc - .word def ; ffbe - - .word def ; ffc0 - .word def ; ffc2 - .word def ; ffc4 - .word def ; ffc6 - .word def ; ffc8 - .word def ; ffca (Modulus Down Counter underflow) - .word def ; ffcc - .word def ; ffce - .word def ; ffd0 - .word def ; ffd2 - .word def ; ffd4 - - ;; SCI - .word def ; ffd6 - - ;; SPI - .word def ; ffd8 - .word def ; ffda (PAII) - .word def ; ffdc (PAOVI) - .word def ;ffde (TOI) - - ;; Timer Output Compare - .word def ; ffe0 Timer Chanel 7 - .word def ; ffe2 Timer Chanel 6 - .word def ; ffe4 Timer Chanel 5 - .word timer4Hdl ; ffe6 Timer Chanel 4 used by Canopen - .word timer3Hdl ; ffe8 Timer Chanel 3 For the date - .word def ; ffea Timer Chanel 2 - .word def ; ffec Timer Chanel 1 - .word def ; ffee Timer Chanel 0 - - ;; Misc - .word def ; fff0 (RTII) - .word def ; fff2 (IRQ) - .word def ; fff4 (XIRQ) - .word def ; fff6 (SWI) - .word def ; fff8 (ILL) - .word def ; fffa (COP Failure) - .word def ; fffc (COP Clock monitor) - .word _start ; fffe (reset) - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_Linux/.cvsignore --- a/examples/AppliSlave_Linux/.cvsignore Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Makefile diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_Linux/Makefile.in --- a/examples/AppliSlave_Linux/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#! 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 -OS_NAME = SUB_OS_NAME -ARCH_NAME = SUB_ARCH_NAME -PREFIX = SUB_PREFIX -TARGET = SUB_TARGET - -LIBPATH = /usr/lib -LIBINC = /usr/include -LIB = -L$(LIBPATH) -lpcan - -INCLUDES = -I../../include -I../../include/peak - -SLAVE_OBJS = objdict.o appli.o - -OBJS = $(SLAVE_OBJS) ../../src/peak_pdo.o ../../src/peak_sdo.o ../../src/peak_init.o ../../src/peak_sync.o\ - ../../src/peak_objacces.o ../../src/peak_lifegrd.o ../../src/peak_timer.o ../../src/peak_nmtSlave.o\ - ../../drivers/peak/canOpenDriver.o ../../drivers/peak/timerhw.o - - -all: AppliSlave - -AppliSlave: $(OBJS) - $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -lpthread -lstdc++ $(OBJS) $(LIB) - -%o: %c - $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -D_REENTRANT -c $< - -clean: - -rm $(SLAVE_OBJS) - -mrproper: clean - -rm AppliSlave - - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_Linux/appli.c --- a/examples/AppliSlave_Linux/appli.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,344 +0,0 @@ -/* -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 -*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "def.h" -#include "can.h" -#include "canOpenDriver.h" -#include "sdo.h" -#include "pdo.h" -#include "init.h" -#include "timer.h" -#include "lifegrd.h" - -#include "nmtSlave.h" - -// Adlink 7841 or Peak PCI/CAN board -// --------------------------------- - -// Baudrate values for Peak board : -// CAN_BAUD_1M CAN_BAUD_500K CAN_BAUD_250K CAN_BAUD_125K CAN_BAUD_100K CAN_BAUD_50K -// CAN_BAUD_20K CAN_BAUD_10K CAN_BAUD_5K - -#ifdef CAN_BAUD_250K -# define BAUDRATE CAN_BAUD_250K -#else -// Appli have been compiled for Adlink-arbraca. Baudrate not used -# define BAUDRATE 0 -#endif - -s_BOARD board = {"1", BAUDRATE}; - - -// The variables sent or updated by PDO -// ----------------------------------------------------- -extern UNS8 seconds; // Mapped at index 0x2000, subindex 0x1 -extern UNS8 minutes; // Mapped at index 0x2000, subindex 0x2 -extern UNS8 hours; // Mapped at index 0x2000, subindex 0x3 -extern UNS8 day; // Mapped at index 0x2000, subindex 0x4 -extern UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x0 -extern UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x0 - -// Required definition variables -// ----------------------------- -// The variables that you should define for debugging. -// They are used by the macro MSG_ERR and MSG_WAR in applicfg.h -// if the node is a slave, they can be mapped in the object dictionnary. -// if not null, allow the printing of message to the console -// Could be managed by PDO -UNS8 printMsgErrToConsole = 1; -UNS8 printMsgWarToConsole = 1; - - - -/*************************User's variables declaration**************************/ -struct tm date; -struct tm *ptrdate; -struct tm date_prec; -time_t tme; -UNS8 lastSecond; -e_nodeState lastState; -pthread_t threadRcvMsg; -pthread_t threadHeartbeatAndSDO; -UNS8 sendingError = 0; - - -/******************************prototypes*****************************/ -/* You *must* have these 2 functions in your code*/ -void heartbeatError(UNS8 heartbeatID); -void SD0timeoutError(UNS8 bus_id, UNS8 line); - -UNS8 scanSDOtimeout(void); -void preOperational(void); -void operational(void); -void stopped(void); -void waitMessage(void); -void waitMessage_heartbeat(void); - -/*********************************************************************/ -void heartbeatError(UNS8 heartbeatID) -{ - MSG_ERR(0x1F00, "!!! No heart beat received from node : ", heartbeatID); -} - -/*****************************************************************************/ -void SD0timeoutError (UNS8 bus_id, UNS8 line) -{ - // Informations on what occurs are in transfers[bus_id][line].... - // See scanSDOtimeout() in sdo.c -} - -/*********************************** THREADS **********************************/ -//------------------------------------------------------------------------------ -// Wait for a received message -void waitMessage( void ) -{ - while (1) { - receiveMsgHandler(0); // blocked until new message - } -} - -//------------------------------------------------------------------------------ -// Heartbeat Manager (sending and receiving) and test SDO timeout -void heartbeatAndSDO(void) -{ - while (1) { - heartbeatMGR(); - // Check if some SDO response are missing - scanSDOtimeout(); - // Sleep 10 ms - usleep(10000); - } -} - -/*********************************************************************/ -void preOperational( void ) -{ - /* Init some variables */ - canopenErrNB = 0; - canopenErrVAL = 0; -} - - -/********************************************************************/ -void operational( void ) -{ - /* read systeme date */ - tme = time (&tme); - ptrdate = gmtime(&tme); - date = *ptrdate; - - /* Update the dictionary */ - day = date.tm_mday; - hours = date.tm_hour; - minutes = date.tm_min; - seconds = date.tm_sec; - - - if ( date_prec.tm_min != date.tm_min ) { - MSG_WAR(0x3F00, "event : minutes change -> node decides to send it. Value : ", date.tm_min); - sendPDOevent( 0, &minutes ); - date_prec = date; - } - if (canopenErrNB == 0) - sendingError = 0; - - if (lastSecond != seconds) { - MSG_WAR (0x3F50, "Seconds = ", seconds); - if ((seconds == 50) && (sendingError == 0)) - { - MSG_ERR(0x1F55, "DEMO of ERROR. Sent by PDO. Value : ", 0xABCD); - sendingError = 1; - } - - if (canopenErrNB) { - MSG_WAR(0x3F56, "ERROR nb : ", canopenErrNB); - } - lastSecond = seconds; - - } -} - - -/*****************************************************************************/ -void stopped( void ) -{ -} - -void help() -{ - printf("**************************************************************\n"); - printf("* AppliSlave *\n"); - printf("* [-b b] *\n"); - printf("* *\n"); - printf("* b : bus [default 1] *\n"); - printf("* *\n"); - printf("* This exemple run AppliSlave on bus 0 *\n"); - printf("* AppliSlave -b 0 *\n"); - printf("* *\n"); - printf("**************************************************************\n"); -} - -/****************************************************************************/ -/*************************** MAIN *****************************************/ -/****************************************************************************/ -int main(int argc,char **argv) -{ - - HANDLE ok; - UNS32 * pSize; - UNS32 size; - pSize = &size; - char c; - extern char *optarg; - - while ((c = getopt(argc, argv, "-b:")) != EOF) - { - switch(c) - { - case 'b' : - if (optarg[0] == 0) - { - help(); - exit(1); - } - board.busname = optarg; - break; - default: - help(); - exit(1); - } - } - - // Global initialization before launching the threads. (also done in init mode. - /* Defining the node Id */ - setNodeId(0x05); - MSG_WAR(0x3F06, "My node ID is : ", getNodeId()); - initCANopenMain(); - initTimer( ); - heartbeatInit(); - initResetMode(); - - /* Launch the thread to receive the messages */ - pthread_create( &threadRcvMsg, NULL, (void *)&waitMessage, NULL); - /* Launch the thread to manage the heartbeat */ - pthread_create( &threadHeartbeatAndSDO, NULL, (void *)&heartbeatAndSDO, NULL); - - /* open the communication with the board */ - ok = f_can_open(& board); - if (ok == NULL) { - MSG_ERR(0x1F02,"Unable to open the board", 0); - MSG_ERR(0x1F03,"Edit includeMakefileLinux to verify that the application is configured for the good board", 0); - exit (-1); - } - else { - MSG_WAR(0x3F03, "Board 1 opened ", 0); - /* slave's state initialization */ - setState(Initialisation); - lastState = Unknown_state; - - - while(1) { /* slave's state machine */ - switch( getState() ) { - case Initialisation: - if (lastState != getState()) - MSG_WAR(0X3F05, "I am in INITIALISATION mode ", 0); - /* Defining the node Id */ - setNodeId(0x05); - MSG_WAR(0x3F06, "My node ID is : ", getNodeId()); - // Node identity ? - { - UNS8 *data; - UNS8 size; - UNS8 dataType; - // Manufacturer Device name (default = empty string) - getODentry(0x1008, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Hardware version. (default = compilation. date) - getODentry(0x1009, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - // Manufacturer Software version. (default = compilation. time) - getODentry(0x100A, 0x0, (void **)&data, &size, &dataType, 0); - MSG_WAR(0x3F09, data, 0); - } - - initCANopenMain(); - initTimer( ); - heartbeatInit(); - initResetMode(); - /* the slave send an NMT trame to say to the master - that it is going to enter into operational state - In fact, you must send the boot-up when you are in - operational mode ! - */ - - /* change automatically into pre_operational state */ - lastState = getState(); - setState(Pre_operational); - break; - - case Pre_operational: - if (lastState != getState()) - { - MSG_WAR(0X3F11, "I am in PRE_OPERATIONAL mode ", 0); - // Some stuff to do when the node enter in pre-operational mode - initPreOperationalMode(); - } - if (lastState == Initialisation) - slaveSendBootUp(0); - lastState = getState(); - preOperational( ); - break; - - case Operational: - if (lastState != getState()) - MSG_WAR(0X3F12, "I am in OPERATIONAL mode ", 0); - lastState = getState(); - operational( ); - break; - - case Stopped: - if (lastState != getState()) - MSG_WAR(0X3F13, "I am in STOPPED mode", 0); - lastState = getState(); - stopped( ); - break; - }//end switch case - // Sleep 10 ms - usleep(10000); - }//end while - }//end else - - - return 0; -} - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_Linux/objdict.c --- a/examples/AppliSlave_Linux/objdict.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,621 +0,0 @@ -/* -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 -*/ - -#include - -#include -#include "def.h" -#include "can.h" -#include "objdictdef.h" -#include "pdo.h" -#include "sdo.h" -#include "sync.h" -#include "lifegrd.h" -#include "nmtSlave.h" - -/**************************************************************************/ -/* Declaration of the mapped variables */ -/**************************************************************************/ - - - -/*// Copy and uncomment this code to your main file -extern UNS8 seconds; // Mapped at index 0x2000, subindex 0x01 -extern UNS32 minutes; // Mapped at index 0x2000, subindex 0x02 -extern UNS8 hours; // Mapped at index 0x2000, subindex 0x03 -extern UNS8 day; // Mapped at index 0x2000, subindex 0x04 -extern UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x00 -extern UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x00 -extern UNS8 strTest[10]; // Mapped at index 0x6002, subindex 0x00 - -// END copy to main file -*/ - -UNS8 seconds; // Mapped at index 0x2000, subindex 0x01 -UNS32 minutes; // Mapped at index 0x2000, subindex 0x02 -UNS8 hours; // Mapped at index 0x2000, subindex 0x03 -UNS8 day; // Mapped at index 0x2000, subindex 0x04 -UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x00 -UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x00 -UNS8 strTest[10]; // Mapped at index 0x6002, subindex 0x00 - -/**************************************************************************/ -/* Declaration of the value range types */ -/**************************************************************************/ - - - -UNS32 valueRangeTest (UNS8 typeValue, UNS32 unsValue, REAL32 realValue) -{ - return 0; -} - - -/**************************************************************************/ -/* The node id */ -/**************************************************************************/ -/* Computed by strNode */ -/* node_id default value. - This default value is deprecated. - You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code. -*/ -#define NODE_ID 0x01 -UNS8 bDeviceNodeId = NODE_ID; - - -//*****************************************************************************/ -/* Computed by strStartDico */ - -/* Array of message processing information */ -/* Should not be modified */ -volatile const proceed_info proceed_infos[] = { - {NMT, "NMT", proceedNMTstateChange}, - {SYNC, "SYNC", proceedSYNC}, - {TIME_STAMP, "TStmp", NULL}, - {PDO1tx, "PDO1t", proceedPDO}, - {PDO1rx, "PDO1r", proceedPDO}, - {PDO2tx, "PDO2t", proceedPDO}, - {PDO2rx, "PDO2r", proceedPDO}, - {PDO3tx, "PDO3t", proceedPDO}, - {PDO3rx, "PDO3r", proceedPDO}, - {PDO4tx, "PDO4t", proceedPDO}, - {PDO4rx, "PDO4r", proceedPDO}, - {SDOtx, "SDOt", proceedSDO}, - {SDOrx, "SDOr", proceedSDO}, - {0xD, "Unkw", NULL}, - {NODE_GUARD, "NGrd", proceedNMTerror}, - {0xF, "Unkw", NULL} -}; - - // Macros definition - -/* Beware : -index *must* be writen 4 numbers in hexa -sub_index *must* be writen 2 numbers in hexa -size_variable_in_UNS8 *must* be writen 2 numbers in hexa -*/ -#define PDO_MAP(index, sub_index, size_variable_in_bits)\ -0x ## index ## sub_index ## size_variable_in_bits - -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// -// OBJECT DICTIONARY -// -//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -// Make your change, depending of your application - - -/* index 0x1000 : Device type. - You have to change the value below, so - it fits your canopen-slave-module */ - - /* Not used, so, should not be modified */ - - UNS32 obj1000 = 0; - subindex Index1000[] = - { - { RO, uint32, sizeof(UNS32), (void*)&obj1000 } - }; - -/* index 0x1001 : Error register. - Change the entries to fit your application - Not used, so, should not be modified */ - /*const*/ UNS8 obj1001 = 0x0; - /*const*/ subindex Index1001[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1001 } - }; - -/* index 0x1005 : COB_ID SYNC */ - /* Should not be modified */ - UNS32 obj1005 = 0x00000080; // bit 30 = 1 : device can generate a SYNC message - // Beware, it is over written when the node - // enters in reset mode - // See initResetMode() in init.c - /*const*/ subindex Index1005[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1005 } - }; - -/* index 0x1006 : SYNC period */ - // For producing the SYNC signal every n micro-seconds. - // Put O to not producing SYNC - /*const*/ UNS32 obj1006 = 0x0; - // Default 0 to not produce SYNC // - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - /*const*/ subindex Index1006[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1006 } - }; - -/* index 0x1007 : Synchronous Window Length - Seems to be needed by DS401 to generate the SYNC signal ! */ - /*const*/ UNS32 obj1007 = 0x0; /* Default 0 */ - /*const*/ subindex Index1007[] = - { - { RW, uint32, sizeof(UNS32), (void*)&obj1007 } - }; - -/* index 0x1008 : Manufacturer device name */ - UNS8 obj1008[] = "Appli_Slave_Linux"; /* Default 0 */ - subindex Index1008[] = - { - { RO, uint32, sizeof(obj1008), (void*)&obj1008 } - }; - -/* index 0x1009 : Manufacturer hardware version */ - UNS8 obj1009[] = __DATE__; /* Default 0 */ - subindex Index1009[] = - { - { RO, uint32, sizeof(obj1009), (void*)&obj1009 } - }; - -/* index 0x100A : Manufacturer software version */ - UNS8 obj100A[] = __TIME__; /* Default 0 */ - subindex Index100A[] = - { - { RO, uint32, sizeof(obj100A), (void*)&obj100A} - }; - -/* index 0x1016 : HeartBeat consumers - The nodes which can send a heartbeat */ - static UNS32 obj1016[] = {// Consumer time for each node - 0x00000000}; // Format 0x00NNTTTT (N=Node T=time in ms) - - static UNS8 obj1016_cnt = 1; // 1 nodes could send me - // their heartbeat. - subindex Index1016[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1016_cnt }, - { RW, uint32, sizeof(UNS32), (void*)&obj1016[0] } - }; - -/* index 0x1017 : Heartbeat producer - Every HBProducerTime, the node sends its heartbeat */ - static UNS16 obj1017 = 0; //HBProducerTime in ms. If 0 : not activated - // Beware, it is over written when the - // node enters in reset mode. - // See initResetMode() in init.c - subindex Index1017[] = - { - { RW, uint16, sizeof(UNS16), &obj1017 } - }; - -/* index 0x1018 : Identity object */ - /** index 1018: identify object. Adjust the entries for your node/company - */ - /* Values can be modified */ - - s_identity obj1018 = - { - 4, // number of supported entries - 0, // Vendor-ID (given by the can-cia) - 0, // Product Code - 0, // Revision number - 0 // serial number - }; - - subindex Index1018[] = - { - { RO, uint8, sizeof(UNS8), (void*)&obj1018.count }, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.vendor_id}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.product_code}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.revision_number}, - { RO, uint32, sizeof(UNS32), (void*)&obj1018.serial_number} - }; - -/* index 0x1200 : The SDO Server parameters */ - /* BEWARE You cannot define more than one SDO server */ - /* The values should not be modified here, - but can be changed at runtime */ - // Beware that the default values that you could put here - // will be over written at the initialisation of the node. - // See setNodeId() in init.c - static s_sdo_parameter obj1200 = - { 3, // Number of entries. Always 3 for the SDO - 0x600 + NODE_ID, // The cob_id transmited in CAN msg to the server - 0x580 + NODE_ID, // The cob_id received in CAN msg from the server - NODE_ID // The node id of the client. Should not be modified - }; - static subindex Index1200[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1200.count }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_client }, - { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_server }, - { RW, uint8, sizeof( UNS8), (void*)&obj1200.node_id } - }; - -/* index 0x1280 : SDO client parameter */ - static s_sdo_parameter obj1280 = - { 3, // Nb of entries - 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId - 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId - 0x0 // server NodeId - }; - static subindex Index1280[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1280.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_client }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_server }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1280.node_id } - }; - -/* index 0x1400 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1400 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1400[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1400.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1400.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1400.type }, - }; - -/* index 0x1401 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1401 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1401[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1401.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1401.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1401.type }, - }; - -/* index 0x1402 : PDO receive communication parameter */ - static s_pdo_communication_parameter obj1402 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1402[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1402.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1402.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1402.type }, - }; - -/* index 0x1600 : PDO receive mapping parameter of PDO communication index 0x1400 */ - static UNS8 obj1600_cnt = 0; // Number of mapped variables - static UNS32 obj1600_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1600[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1600_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[7]} - }; - -/* index 0x1601 : PDO receive mapping parameter of PDO communication index 0x1401 */ - static UNS8 obj1601_cnt = 0; // Number of mapped variables - static UNS32 obj1601_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1601[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1601_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[7]} - }; - -/* index 0x1602 : PDO receive mapping parameter of PDO communication index 0x1402 */ - static UNS8 obj1602_cnt = 0; // Number of mapped variables - static UNS32 obj1602_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1602[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1602_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[7]} - }; - -/* index 0x1800 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1800 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1800[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1800.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1800.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1800.type }, - }; - -/* index 0x1801 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1801 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1801[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1801.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1801.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1801.type }, - }; - -/* index 0x1802 : PDO transmit communication parameter */ - static s_pdo_communication_parameter obj1802 = - { 2, // Largest subindex supported - 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) - 253 // Transmission type. See objdictdef.h - }; - static subindex Index1802[] = - { - { RO, uint8, sizeof( UNS8 ), (void*)&obj1802.count }, - { RW, uint8, sizeof( UNS32 ), (void*)&obj1802.cob_id }, - { RW, uint8, sizeof( UNS8 ), (void*)&obj1802.type }, - }; - -/* index 0x1A00 : PDO transmit mapping parameter of PDO communication index 0x1800 */ - static UNS8 obj1A00_cnt = 0; // Number of mapped variables - static UNS32 obj1A00_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A00[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A00_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[7]} - }; - -/* index 0x1A01 : PDO transmit mapping parameter of PDO communication index 0x1801 */ - static UNS8 obj1A01_cnt = 0; // Number of mapped variables - static UNS32 obj1A01_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A01[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A01_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[7]} - }; - -/* index 0x1A02 : PDO transmit mapping parameter of PDO communication index 0x1802 */ - static UNS8 obj1A02_cnt = 0; // Number of mapped variables - static UNS32 obj1A02_mappedVar[] = { - // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : - // PDO_MAP(6035,12,16) - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00), - PDO_MAP(0000, 00, 00) - }; - subindex Index1A02[] = - { - { RW, uint8, sizeof( UNS8 ), (void*)&obj1A02_cnt }, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[0]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[1]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[2]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[3]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[4]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[5]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[6]}, - { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[7]} - }; - - -/* index 0x2000 : Mapped variable */ - static UNS8 highestSubIndex_2000 = 4; // number of subindex - 1 - subindex Index2000[] = - { - { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_2000 }, - { RW, uint8, sizeof (UNS8), (void*)&seconds }, - { RW, uint32, sizeof (UNS32), (void*)&minutes }, - { RW, uint8, sizeof (UNS8), (void*)&hours }, - { RW, uint8, sizeof (UNS8), (void*)&day } - }; - -/* index 0x6000 : Mapped variable */ - subindex Index6000[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB } - }; - -/* index 0x6001 : Mapped variable */ - subindex Index6001[] = - { - { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL } - }; - -/* index 0x6002 : Mapped variable */ - subindex Index6002[] = - { - { RW, visible_string, sizeof (strTest), (void*)&strTest } - }; - -const indextable objdict[] = -{ - DeclareIndexTableEntry(Index1000, 0x1000), - DeclareIndexTableEntry(Index1001, 0x1001), - DeclareIndexTableEntry(Index1005, 0x1005), - DeclareIndexTableEntry(Index1006, 0x1006), - DeclareIndexTableEntry(Index1007, 0x1007), - DeclareIndexTableEntry(Index1008, 0x1008), - DeclareIndexTableEntry(Index1009, 0x1009), - DeclareIndexTableEntry(Index100A, 0x100A), - DeclareIndexTableEntry(Index1016, 0x1016), - DeclareIndexTableEntry(Index1017, 0x1017), - DeclareIndexTableEntry(Index1018, 0x1018), - DeclareIndexTableEntry(Index1200, 0x1200), - DeclareIndexTableEntry(Index1280, 0x1280), - DeclareIndexTableEntry(Index1400, 0x1400), - DeclareIndexTableEntry(Index1401, 0x1401), - DeclareIndexTableEntry(Index1402, 0x1402), - DeclareIndexTableEntry(Index1600, 0x1600), - DeclareIndexTableEntry(Index1601, 0x1601), - DeclareIndexTableEntry(Index1602, 0x1602), - DeclareIndexTableEntry(Index1800, 0x1800), - DeclareIndexTableEntry(Index1801, 0x1801), - DeclareIndexTableEntry(Index1802, 0x1802), - DeclareIndexTableEntry(Index1A00, 0x1A00), - DeclareIndexTableEntry(Index1A01, 0x1A01), - DeclareIndexTableEntry(Index1A02, 0x1A02), - DeclareIndexTableEntry(Index2000, 0x2000), - DeclareIndexTableEntry(Index6000, 0x6000), - DeclareIndexTableEntry(Index6001, 0x6001), - DeclareIndexTableEntry(Index6002, 0x6002), -}; - -// To count at which received SYNC a PDO must be sent. -// Even if no pdoTransmit are defined, at least one entry is computed -// for compilations issues. -UNS8 count_sync[1] = {0, }; - -UNS16 firstIndex (enum e_first_object object, UNS16 *lastIndex) -{ - switch (object) { - case FIRST_SDO_SERVER : - *lastIndex = 11; - return 11; - case FIRST_SDO_CLIENT : - *lastIndex = 12; - return 12; - case FIRST_PDO_RCV : - *lastIndex = 15; - return 13; - case FIRST_PDO_RCV_MAP : - *lastIndex = 18; - return 16; - case FIRST_PDO_TRS : - *lastIndex = 21; - return 19; - case FIRST_PDO_TRS_MAP : - *lastIndex = 24; - return 22; - } - *lastIndex = 0; - return 0; -} - -UNS16 getObjdictSize (void) -{ - return sizeof(objdict)/sizeof(objdict[0]); -} diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_Linux/objdict.html --- a/examples/AppliSlave_Linux/objdict.html Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ - - - - -CANOpen object dictionary Configuration - - - -

Object dictionary for Node :

-

-Linux_slaveslave -

-

Overview

-

- How to make the object dictionary of the node ? - First, use Jaxe (command run_objdict) to edit an xml description file -of the dictionary : objdict.xml. -Then, run the php program : makeobjetdict.php. You can launch php through a web browser -if you have installed a server, or, on Linux, you can launch php in command line : -php-cgi makeobjetdict.php. It compute the file objdict.c. Link it to - your project. -
Note : To define the node id, use in your code the function setNodeId(UNS8 nodeId) -

-

- Then the node can be connected to the network. The master must configure it - by sending SDO. It will write values in its index, subindex. What to configure ? -

    -
  • Receiving heartbeats from which nodes ? Waiting time ?
  • -
  • Emitting heartbeats or not ? time btw 2 heartbeats ?
  • -
  • Defining a cobId for each PDO receive and transmit
  • -
  • How to transmit a PDO ? on synchro ? request ? event ?
  • -
  • What variables to put in each PDO receive and transmit ?
  • -
  • ...
  • -
-

- To avoid configuring the node at the connection, you can put the values directly -in the dictionary objdict.c. But it is boring and unsafe because it is too easy to make -a mistake ! - - -

Number of heartbeat consumers : - 1 -

-

This means that the node can expect heartbeats sent by 1 nodes.

-

Number of SDO clients : - 1 -

-

Usualy, a slave node does not have the use of SDO clients, but - today, for the library, you must define one. The Master, which can - send SDO to "n" slaves nodes, must define here "n" SDO - clients. Remember that in most cases, the SDO protocol is used by - the master to configure a slave dictionary or read a value. In - this use, the master is the client, and the slave is the server.

-

Maximum objects in a PDO (receive or transmit) : - 8 -

-

This is defining how many variables can be transmited in a - PDO. (maximum is 8).

-

For each variable, a table is created, so if you have less room - in memory, put a value under 8.

-

Mapped variables and tables

-

3 tables are defined for the mapping, starting at index 0x2000, 0x6000 and 0x6200. - You must start the mapping at the beginning of one of a table, without holes in index -or subindex. For example, variables in 0x2000 and 0x2001 is ok, but variables in 0x2000 and 0x2002 is not allowed, because you are loosing room in memory. It is the same for the subindex. -

-

- The access of the variable is by default "rw" (read-write) or "ro" (read-only). A read-only variable cannot be mapped in a PDO receive. -

-

Here are some others rules for the mapping :

-
    -
  • At an Index, you can map a variable at subindex 0x0 or 0x1, as you like.
  • -
  • To map several variables at the same Index, you must start at subindex 0x1, - because in this case, the subindex 0x0 contains the number of subindex.
  • -
  • You cannot map variables and tables at the same index.
  • -
  • The mapping of a table is always starting at subindex 0x1.
  • -
- - - - - - - - - - - - - - - - - - - - - - - -
Var NameBitsIndexSub-indexaccess
seconds80x20000x1rw
minutes80x20000x02rw
hours80x20000x3rw
day80x20000x4rw
canopenErrNB320x60000x0rw
canopenErrVAL320x60010x0rw
Table NameBitsIndexSub-indexaccess
- - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/AppliSlave_Linux/objdict.xml --- a/examples/AppliSlave_Linux/objdict.xml Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/TestMasterSlave/TestMaster.c --- a/examples/TestMasterSlave/TestMaster.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,339 +0,0 @@ - -/* File generated by gen_cfile.py. Should not be modified. */ - -#include "TestMaster.h" - -/**************************************************************************/ -/* Declaration of the mapped variables */ -/**************************************************************************/ -UNS8 MasterMap1 = 0x0; /* Mapped at index 0x2000, subindex 0x00 */ -UNS8 MasterMap2 = 0x0; /* Mapped at index 0x2001, subindex 0x00 */ -UNS8 MasterMap3 = 0x0; /* Mapped at index 0x2002, subindex 0x00 */ -UNS8 MasterMap4 = 0x0; /* Mapped at index 0x2003, subindex 0x00 */ - -/**************************************************************************/ -/* Declaration of the value range types */ -/**************************************************************************/ - -UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value) -{ - switch (typeValue) { - } - return 0; -} - -/**************************************************************************/ -/* The node id */ -/**************************************************************************/ -/* node_id default value.*/ -UNS8 TestMaster_bDeviceNodeId = 0x00; - -/**************************************************************************/ -/* Array of message processing information */ - -const UNS8 TestMaster_iam_a_slave = 0; - -TIMER_HANDLE TestMaster_heartBeatTimers[1] = {TIMER_NONE,}; - -/* -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - OBJECT DICTIONARY - -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -*/ - -/* index 0x1000 : Device Type. */ - UNS32 TestMaster_obj1000 = 0x12D; /* 301 */ - subindex TestMaster_Index1000[] = - { - { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1000 } - }; - -/* index 0x1001 : Error Register. */ - UNS8 TestMaster_obj1001 = 0x0; /* 0 */ - subindex TestMaster_Index1001[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_obj1001 } - }; - -/* index 0x1005 : SYNC COB ID. */ - UNS32 TestMaster_obj1005 = 0x40000080; /* 1073741952 */ - ODCallback_t TestMaster_Index1005_callbacks[] = - { - NULL, - }; - subindex TestMaster_Index1005[] = - { - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1005 } - }; - -/* index 0x1006 : Communication / Cycle Period. */ - UNS32 TestMaster_obj1006 = 0xC350; /* 50000 */ - ODCallback_t TestMaster_Index1006_callbacks[] = - { - NULL, - }; - subindex TestMaster_Index1006[] = - { - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1006 } - }; - -/* index 0x1010 : Store parameters. */ - UNS8 TestMaster_highestSubIndex_obj1010 = 4; /* number of subindex - 1*/ - UNS32 TestMaster_obj1010_Save_All_Parameters = 0x0; /* 0 */ - UNS32 TestMaster_obj1010_Save_Communication_Parameters = 0x0; /* 0 */ - UNS32 TestMaster_obj1010_Save_Application_Parameters = 0x0; /* 0 */ - UNS32 TestMaster_obj1010_Save_Manufacturer_Parameters = 0x0; /* 0 */ - ODCallback_t TestMaster_Index1010_callbacks[] = - { - NULL, - NULL, - NULL, - NULL, - NULL, - }; - subindex TestMaster_Index1010[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1010 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_All_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Communication_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Application_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Manufacturer_Parameters } - }; - -/* index 0x1011 : Restore Default Parameters. */ - UNS8 TestMaster_highestSubIndex_obj1011 = 4; /* number of subindex - 1*/ - UNS32 TestMaster_obj1011_Restore_All_Default_Parameters = 0x0; /* 0 */ - UNS32 TestMaster_obj1011_Restore_Communication_Default_Parameters = 0x0; /* 0 */ - UNS32 TestMaster_obj1011_Restore_Application_Default_Parameters = 0x0; /* 0 */ - UNS32 TestMaster_obj1011_Restore_Manufacturer_Default_Parameters = 0x0; /* 0 */ - ODCallback_t TestMaster_Index1011_callbacks[] = - { - NULL, - NULL, - NULL, - NULL, - NULL, - }; - subindex TestMaster_Index1011[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1011 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_All_Default_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Communication_Default_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Application_Default_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Manufacturer_Default_Parameters } - }; - -/* index 0x1016 : Consumer Heartbeat Time. */ - UNS8 TestMaster_highestSubIndex_obj1016 = 1; /* number of subindex - 1*/ - UNS32 TestMaster_obj1016[] = - { - 0x20802 /* 133122 */ - }; - subindex TestMaster_Index1016[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1016 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1016[0] } - }; - -/* index 0x1017 : Producer Heartbeat Time */ - UNS16 TestMaster_obj1017 = 0x0; /* 0 */ - -/* index 0x1018 : Identity. */ - UNS8 TestMaster_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/ - UNS32 TestMaster_obj1018_Vendor_ID = 0x0; /* 0 */ - UNS32 TestMaster_obj1018_Product_Code = 0x0; /* 0 */ - UNS32 TestMaster_obj1018_Revision_Number = 0x0; /* 0 */ - UNS32 TestMaster_obj1018_Serial_Number = 0x0; /* 0 */ - subindex TestMaster_Index1018[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1018 }, - { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Vendor_ID }, - { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Product_Code }, - { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Revision_Number }, - { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Serial_Number } - }; - -/* index 0x1280 : Client SDO 1 Parameter. */ - UNS8 TestMaster_highestSubIndex_obj1280 = 3; /* number of subindex - 1*/ - UNS32 TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x602; /* 1538 */ - UNS32 TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x582; /* 1410 */ - UNS32 TestMaster_obj1280_Node_ID_of_the_SDO_Server = 0x2; /* 2 */ - subindex TestMaster_Index1280[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1280 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_Node_ID_of_the_SDO_Server } - }; - -/* index 0x1400 : Receive PDO 1 Parameter. */ - UNS8 TestMaster_highestSubIndex_obj1400 = 5; /* number of subindex - 1*/ - UNS32 TestMaster_obj1400_COB_ID_used_by_PDO = 0x182; /* 386 */ - UNS8 TestMaster_obj1400_Transmission_Type = 0x1; /* 1 */ - UNS16 TestMaster_obj1400_Inhibit_Time = 0x0; /* 0 */ - UNS16 TestMaster_obj1400_Compatibility_Entry = 0x0; /* 0 */ - UNS16 TestMaster_obj1400_Event_Timer = 0x0; /* 0 */ - subindex TestMaster_Index1400[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1400 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1400_COB_ID_used_by_PDO }, - { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Transmission_Type }, - { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Inhibit_Time }, - { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Compatibility_Entry }, - { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Event_Timer } - }; - -/* index 0x1401 : Receive PDO 2 Parameter. */ - UNS8 TestMaster_highestSubIndex_obj1401 = 5; /* number of subindex - 1*/ - UNS32 TestMaster_obj1401_COB_ID_used_by_PDO = 0x282; /* 642 */ - UNS8 TestMaster_obj1401_Transmission_Type = 0x1; /* 1 */ - UNS16 TestMaster_obj1401_Inhibit_Time = 0x0; /* 0 */ - UNS16 TestMaster_obj1401_Compatibility_Entry = 0x0; /* 0 */ - UNS16 TestMaster_obj1401_Event_Timer = 0x0; /* 0 */ - subindex TestMaster_Index1401[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1401 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1401_COB_ID_used_by_PDO }, - { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1401_Transmission_Type }, - { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Inhibit_Time }, - { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Compatibility_Entry }, - { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Event_Timer } - }; - -/* index 0x1600 : Receive PDO 1 Mapping. */ - UNS8 TestMaster_highestSubIndex_obj1600 = 2; /* number of subindex - 1*/ - UNS32 TestMaster_obj1600[] = - { - 0x20000008, /* 536870920 */ - 0x20010008 /* 536936456 */ - }; - subindex TestMaster_Index1600[] = - { - { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1600 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[0] }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[1] } - }; - -/* index 0x1601 : Receive PDO 2 Mapping. */ - UNS8 TestMaster_highestSubIndex_obj1601 = 2; /* number of subindex - 1*/ - UNS32 TestMaster_obj1601[] = - { - 0x20020008, /* 537001992 */ - 0x20030008 /* 537067528 */ - }; - subindex TestMaster_Index1601[] = - { - { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1601 }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1601[0] }, - { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1601[1] } - }; - -/* index 0x2000 : Mapped variable MasterMap1 */ - ODCallback_t MasterMap1_callbacks[] = - { - NULL, - }; - subindex TestMaster_Index2000[] = - { - { RW, uint8, sizeof (UNS8), (void*)&MasterMap1 } - }; - -/* index 0x2001 : Mapped variable MasterMap2 */ - subindex TestMaster_Index2001[] = - { - { RW, uint8, sizeof (UNS8), (void*)&MasterMap2 } - }; - -/* index 0x2002 : Mapped variable MasterMap3 */ - subindex TestMaster_Index2002[] = - { - { RW, uint8, sizeof (UNS8), (void*)&MasterMap3 } - }; - -/* index 0x2003 : Mapped variable MasterMap4 */ - subindex TestMaster_Index2003[] = - { - { RW, uint8, sizeof (UNS8), (void*)&MasterMap4 } - }; - -const indextable TestMaster_objdict[] = -{ - { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000}, - { (subindex*)TestMaster_Index1001,sizeof(TestMaster_Index1001)/sizeof(TestMaster_Index1001[0]), 0x1001}, - { (subindex*)TestMaster_Index1005,sizeof(TestMaster_Index1005)/sizeof(TestMaster_Index1005[0]), 0x1005}, - { (subindex*)TestMaster_Index1006,sizeof(TestMaster_Index1006)/sizeof(TestMaster_Index1006[0]), 0x1006}, - { (subindex*)TestMaster_Index1010,sizeof(TestMaster_Index1010)/sizeof(TestMaster_Index1010[0]), 0x1010}, - { (subindex*)TestMaster_Index1011,sizeof(TestMaster_Index1011)/sizeof(TestMaster_Index1011[0]), 0x1011}, - { (subindex*)TestMaster_Index1016,sizeof(TestMaster_Index1016)/sizeof(TestMaster_Index1016[0]), 0x1016}, - { (subindex*)TestMaster_Index1018,sizeof(TestMaster_Index1018)/sizeof(TestMaster_Index1018[0]), 0x1018}, - { (subindex*)TestMaster_Index1280,sizeof(TestMaster_Index1280)/sizeof(TestMaster_Index1280[0]), 0x1280}, - { (subindex*)TestMaster_Index1400,sizeof(TestMaster_Index1400)/sizeof(TestMaster_Index1400[0]), 0x1400}, - { (subindex*)TestMaster_Index1401,sizeof(TestMaster_Index1401)/sizeof(TestMaster_Index1401[0]), 0x1401}, - { (subindex*)TestMaster_Index1600,sizeof(TestMaster_Index1600)/sizeof(TestMaster_Index1600[0]), 0x1600}, - { (subindex*)TestMaster_Index1601,sizeof(TestMaster_Index1601)/sizeof(TestMaster_Index1601[0]), 0x1601}, - { (subindex*)TestMaster_Index2000,sizeof(TestMaster_Index2000)/sizeof(TestMaster_Index2000[0]), 0x2000}, - { (subindex*)TestMaster_Index2001,sizeof(TestMaster_Index2001)/sizeof(TestMaster_Index2001[0]), 0x2001}, - { (subindex*)TestMaster_Index2002,sizeof(TestMaster_Index2002)/sizeof(TestMaster_Index2002[0]), 0x2002}, - { (subindex*)TestMaster_Index2003,sizeof(TestMaster_Index2003)/sizeof(TestMaster_Index2003[0]), 0x2003}, -}; - -const indextable * TestMaster_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks) -{ - int i; - *callbacks = NULL; - switch(wIndex){ - case 0x1000: i = 0;break; - case 0x1001: i = 1;break; - case 0x1005: i = 2;*callbacks = TestMaster_Index1005_callbacks; break; - case 0x1006: i = 3;*callbacks = TestMaster_Index1006_callbacks; break; - case 0x1010: i = 4;*callbacks = TestMaster_Index1010_callbacks; break; - case 0x1011: i = 5;*callbacks = TestMaster_Index1011_callbacks; break; - case 0x1016: i = 6;break; - case 0x1018: i = 7;break; - case 0x1280: i = 8;break; - case 0x1400: i = 9;break; - case 0x1401: i = 10;break; - case 0x1600: i = 11;break; - case 0x1601: i = 12;break; - case 0x2000: i = 13;*callbacks = MasterMap1_callbacks; break; - case 0x2001: i = 14;break; - case 0x2002: i = 15;break; - case 0x2003: i = 16;break; - default: - *errorCode = OD_NO_SUCH_OBJECT; - return NULL; - } - *errorCode = OD_SUCCESSFUL; - return &TestMaster_objdict[i]; -} - -/* To count at which received SYNC a PDO must be sent. - * Even if no pdoTransmit are defined, at least one entry is computed - * for compilations issues. - */ -UNS8 TestMaster_count_sync[1] = {0,}; - -quick_index TestMaster_firstIndex = { - 0, /* SDO_SVR */ - 8, /* SDO_CLT */ - 9, /* PDO_RCV */ - 11, /* PDO_RCV_MAP */ - 0, /* PDO_TRS */ - 0 /* PDO_TRS_MAP */ -}; - -quick_index TestMaster_lastIndex = { - 0, /* SDO_SVR */ - 8, /* SDO_CLT */ - 10, /* PDO_RCV */ - 12, /* PDO_RCV_MAP */ - 0, /* PDO_TRS */ - 0 /* PDO_TRS_MAP */ -}; - -UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]); - -CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster); - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/TestMasterSlave/TestSlave.c --- a/examples/TestMasterSlave/TestSlave.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,329 +0,0 @@ - -/* File generated by gen_cfile.py. Should not be modified. */ - -#include "TestSlave.h" - -/**************************************************************************/ -/* Declaration of the mapped variables */ -/**************************************************************************/ -UNS8 SlaveMap1 = 0x0; /* Mapped at index 0x2000, subindex 0x00 */ -UNS8 SlaveMap2 = 0x0; /* Mapped at index 0x2001, subindex 0x00 */ -UNS8 SlaveMap3 = 0x0; /* Mapped at index 0x2002, subindex 0x00 */ -UNS8 SlaveMap4 = 0x0; /* Mapped at index 0x2003, subindex 0x00 */ - -/**************************************************************************/ -/* Declaration of the value range types */ -/**************************************************************************/ - -UNS32 TestSlave_valueRangeTest (UNS8 typeValue, void * value) -{ - switch (typeValue) { - } - return 0; -} - -/**************************************************************************/ -/* The node id */ -/**************************************************************************/ -/* node_id default value.*/ -UNS8 TestSlave_bDeviceNodeId = 0x00; - -/**************************************************************************/ -/* Array of message processing information */ - -const UNS8 TestSlave_iam_a_slave = 1; - -TIMER_HANDLE TestSlave_heartBeatTimers[1]; - -/* -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - OBJECT DICTIONARY - -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -*/ - -/* index 0x1000 : Device Type. */ - UNS32 TestSlave_obj1000 = 0x12D; /* 301 */ - subindex TestSlave_Index1000[] = - { - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1000 } - }; - -/* index 0x1001 : Error Register. */ - UNS8 TestSlave_obj1001 = 0x0; /* 0 */ - subindex TestSlave_Index1001[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_obj1001 } - }; - -/* index 0x1005 : SYNC COB ID. */ - UNS32 TestSlave_obj1005 = 0x80; /* 128 */ - ODCallback_t TestSlave_Index1005_callbacks[] = - { - NULL, - }; - subindex TestSlave_Index1005[] = - { - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1005 } - }; - -/* index 0x1006 : Communication / Cycle Period. */ - UNS32 TestSlave_obj1006 = 0x0; /* 0 */ - ODCallback_t TestSlave_Index1006_callbacks[] = - { - NULL, - }; - subindex TestSlave_Index1006[] = - { - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1006 } - }; - -/* index 0x1010 : Store parameters. */ - UNS8 TestSlave_highestSubIndex_obj1010 = 4; /* number of subindex - 1*/ - UNS32 TestSlave_obj1010_Save_All_Parameters = 0x0; /* 0 */ - UNS32 TestSlave_obj1010_Save_Communication_Parameters = 0x0; /* 0 */ - UNS32 TestSlave_obj1010_Save_Application_Parameters = 0x0; /* 0 */ - UNS32 TestSlave_obj1010_Save_Manufacturer_Parameters = 0x0; /* 0 */ - ODCallback_t TestSlave_Index1010_callbacks[] = - { - NULL, - NULL, - NULL, - NULL, - NULL, - }; - subindex TestSlave_Index1010[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1010 }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_All_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Communication_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Application_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Manufacturer_Parameters } - }; - -/* index 0x1011 : Restore Default Parameters. */ - UNS8 TestSlave_highestSubIndex_obj1011 = 4; /* number of subindex - 1*/ - UNS32 TestSlave_obj1011_Restore_All_Default_Parameters = 0x0; /* 0 */ - UNS32 TestSlave_obj1011_Restore_Communication_Default_Parameters = 0x0; /* 0 */ - UNS32 TestSlave_obj1011_Restore_Application_Default_Parameters = 0x0; /* 0 */ - UNS32 TestSlave_obj1011_Restore_Manufacturer_Default_Parameters = 0x0; /* 0 */ - ODCallback_t TestSlave_Index1011_callbacks[] = - { - NULL, - NULL, - NULL, - NULL, - NULL, - }; - subindex TestSlave_Index1011[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1011 }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_All_Default_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Communication_Default_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Application_Default_Parameters }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Manufacturer_Default_Parameters } - }; - -/* index 0x1016 : Consumer Heartbeat Time */ - UNS8 TestSlave_highestSubIndex_obj1016 = 0; - UNS32 TestSlave_obj1016[]={0}; - -/* index 0x1017 : Producer Heartbeat Time. */ - UNS16 TestSlave_obj1017 = 0x3E8; /* 1000 */ - subindex TestSlave_Index1017[] = - { - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1017 } - }; - -/* index 0x1018 : Identity. */ - UNS8 TestSlave_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/ - UNS32 TestSlave_obj1018_Vendor_ID = 0x0; /* 0 */ - UNS32 TestSlave_obj1018_Product_Code = 0x0; /* 0 */ - UNS32 TestSlave_obj1018_Revision_Number = 0x0; /* 0 */ - UNS32 TestSlave_obj1018_Serial_Number = 0x0; /* 0 */ - subindex TestSlave_Index1018[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1018 }, - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Vendor_ID }, - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Product_Code }, - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Revision_Number }, - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Serial_Number } - }; - -/* index 0x1200 : Server SDO Parameter. */ - UNS8 TestSlave_highestSubIndex_obj1200 = 2; /* number of subindex - 1*/ - UNS32 TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO = 0x601; /* 1537 */ - UNS32 TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO = 0x581; /* 1409 */ - subindex TestSlave_Index1200[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1200 }, - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO }, - { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO } - }; - -/* index 0x1800 : Transmit PDO 1 Parameter. */ - UNS8 TestSlave_highestSubIndex_obj1800 = 5; /* number of subindex - 1*/ - UNS32 TestSlave_obj1800_COB_ID_used_by_PDO = 0x182; /* 386 */ - UNS8 TestSlave_obj1800_Transmission_Type = 0x1; /* 1 */ - UNS16 TestSlave_obj1800_Inhibit_Time = 0x0; /* 0 */ - UNS16 TestSlave_obj1800_Compatibility_Entry = 0x0; /* 0 */ - UNS16 TestSlave_obj1800_Event_Timer = 0x0; /* 0 */ - subindex TestSlave_Index1800[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1800 }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1800_COB_ID_used_by_PDO }, - { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1800_Transmission_Type }, - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Inhibit_Time }, - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Compatibility_Entry }, - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Event_Timer } - }; - -/* index 0x1801 : Transmit PDO 2 Parameter. */ - UNS8 TestSlave_highestSubIndex_obj1801 = 5; /* number of subindex - 1*/ - UNS32 TestSlave_obj1801_COB_ID_used_by_PDO = 0x282; /* 642 */ - UNS8 TestSlave_obj1801_Transmission_Type = 0x1; /* 1 */ - UNS16 TestSlave_obj1801_Inhibit_Time = 0x0; /* 0 */ - UNS16 TestSlave_obj1801_Compatibility_Entry = 0x0; /* 0 */ - UNS16 TestSlave_obj1801_Event_Timer = 0x0; /* 0 */ - subindex TestSlave_Index1801[] = - { - { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1801 }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1801_COB_ID_used_by_PDO }, - { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1801_Transmission_Type }, - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Inhibit_Time }, - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Compatibility_Entry }, - { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Event_Timer } - }; - -/* index 0x1A00 : Transmit PDO 1 Mapping. */ - UNS8 TestSlave_highestSubIndex_obj1A00 = 2; /* number of subindex - 1*/ - UNS32 TestSlave_obj1A00[] = - { - 0x20000008, /* 536870920 */ - 0x20010008 /* 536936456 */ - }; - subindex TestSlave_Index1A00[] = - { - { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A00 }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[0] }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[1] } - }; - -/* index 0x1A01 : Transmit PDO 2 Mapping. */ - UNS8 TestSlave_highestSubIndex_obj1A01 = 2; /* number of subindex - 1*/ - UNS32 TestSlave_obj1A01[] = - { - 0x20020008, /* 537001992 */ - 0x20030008 /* 537067528 */ - }; - subindex TestSlave_Index1A01[] = - { - { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A01 }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A01[0] }, - { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A01[1] } - }; - -/* index 0x2000 : Mapped variable SlaveMap1 */ - subindex TestSlave_Index2000[] = - { - { RW, uint8, sizeof (UNS8), (void*)&SlaveMap1 } - }; - -/* index 0x2001 : Mapped variable SlaveMap2 */ - subindex TestSlave_Index2001[] = - { - { RW, uint8, sizeof (UNS8), (void*)&SlaveMap2 } - }; - -/* index 0x2002 : Mapped variable SlaveMap3 */ - subindex TestSlave_Index2002[] = - { - { RW, uint8, sizeof (UNS8), (void*)&SlaveMap3 } - }; - -/* index 0x2003 : Mapped variable SlaveMap4 */ - subindex TestSlave_Index2003[] = - { - { RW, uint8, sizeof (UNS8), (void*)&SlaveMap4 } - }; - -const indextable TestSlave_objdict[] = -{ - { (subindex*)TestSlave_Index1000,sizeof(TestSlave_Index1000)/sizeof(TestSlave_Index1000[0]), 0x1000}, - { (subindex*)TestSlave_Index1001,sizeof(TestSlave_Index1001)/sizeof(TestSlave_Index1001[0]), 0x1001}, - { (subindex*)TestSlave_Index1005,sizeof(TestSlave_Index1005)/sizeof(TestSlave_Index1005[0]), 0x1005}, - { (subindex*)TestSlave_Index1006,sizeof(TestSlave_Index1006)/sizeof(TestSlave_Index1006[0]), 0x1006}, - { (subindex*)TestSlave_Index1010,sizeof(TestSlave_Index1010)/sizeof(TestSlave_Index1010[0]), 0x1010}, - { (subindex*)TestSlave_Index1011,sizeof(TestSlave_Index1011)/sizeof(TestSlave_Index1011[0]), 0x1011}, - { (subindex*)TestSlave_Index1017,sizeof(TestSlave_Index1017)/sizeof(TestSlave_Index1017[0]), 0x1017}, - { (subindex*)TestSlave_Index1018,sizeof(TestSlave_Index1018)/sizeof(TestSlave_Index1018[0]), 0x1018}, - { (subindex*)TestSlave_Index1200,sizeof(TestSlave_Index1200)/sizeof(TestSlave_Index1200[0]), 0x1200}, - { (subindex*)TestSlave_Index1800,sizeof(TestSlave_Index1800)/sizeof(TestSlave_Index1800[0]), 0x1800}, - { (subindex*)TestSlave_Index1801,sizeof(TestSlave_Index1801)/sizeof(TestSlave_Index1801[0]), 0x1801}, - { (subindex*)TestSlave_Index1A00,sizeof(TestSlave_Index1A00)/sizeof(TestSlave_Index1A00[0]), 0x1A00}, - { (subindex*)TestSlave_Index1A01,sizeof(TestSlave_Index1A01)/sizeof(TestSlave_Index1A01[0]), 0x1A01}, - { (subindex*)TestSlave_Index2000,sizeof(TestSlave_Index2000)/sizeof(TestSlave_Index2000[0]), 0x2000}, - { (subindex*)TestSlave_Index2001,sizeof(TestSlave_Index2001)/sizeof(TestSlave_Index2001[0]), 0x2001}, - { (subindex*)TestSlave_Index2002,sizeof(TestSlave_Index2002)/sizeof(TestSlave_Index2002[0]), 0x2002}, - { (subindex*)TestSlave_Index2003,sizeof(TestSlave_Index2003)/sizeof(TestSlave_Index2003[0]), 0x2003}, -}; - -const indextable * TestSlave_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks) -{ - int i; - *callbacks = NULL; - switch(wIndex){ - case 0x1000: i = 0;break; - case 0x1001: i = 1;break; - case 0x1005: i = 2;*callbacks = TestSlave_Index1005_callbacks; break; - case 0x1006: i = 3;*callbacks = TestSlave_Index1006_callbacks; break; - case 0x1010: i = 4;*callbacks = TestSlave_Index1010_callbacks; break; - case 0x1011: i = 5;*callbacks = TestSlave_Index1011_callbacks; break; - case 0x1017: i = 6;break; - case 0x1018: i = 7;break; - case 0x1200: i = 8;break; - case 0x1800: i = 9;break; - case 0x1801: i = 10;break; - case 0x1A00: i = 11;break; - case 0x1A01: i = 12;break; - case 0x2000: i = 13;break; - case 0x2001: i = 14;break; - case 0x2002: i = 15;break; - case 0x2003: i = 16;break; - default: - *errorCode = OD_NO_SUCH_OBJECT; - return NULL; - } - *errorCode = OD_SUCCESSFUL; - return &TestSlave_objdict[i]; -} - -/* To count at which received SYNC a PDO must be sent. - * Even if no pdoTransmit are defined, at least one entry is computed - * for compilations issues. - */ -UNS8 TestSlave_count_sync[2] = {0,}; - -quick_index TestSlave_firstIndex = { - 8, /* SDO_SVR */ - 0, /* SDO_CLT */ - 0, /* PDO_RCV */ - 0, /* PDO_RCV_MAP */ - 9, /* PDO_TRS */ - 11 /* PDO_TRS_MAP */ -}; - -quick_index TestSlave_lastIndex = { - 8, /* SDO_SVR */ - 0, /* SDO_CLT */ - 0, /* PDO_RCV */ - 0, /* PDO_RCV_MAP */ - 10, /* PDO_TRS */ - 12 /* PDO_TRS_MAP */ -}; - -UNS16 TestSlave_ObjdictSize = sizeof(TestSlave_objdict)/sizeof(TestSlave_objdict[0]); - -CO_Data TestSlave_Data = CANOPEN_NODE_DATA_INITIALIZER(TestSlave); - diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/ecos_lpc2138_sja1000/README --- a/examples/ecos_lpc2138_sja1000/README Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ - ____ ____ ______ __ ___ ______ ____ - / __ \ / __ \ / ____/ / |/ / / ____/ / __ \ - / / / / / /_/ / / __/ / /|_/ / / __/ / / / / - / /_/ / / _, _/ / /___ / / / / / /___ / /_/ / - \____/ /_/ |_| /_____/ /_/ /_/ /_____/ \___\_\ - -Observatoire de Recherche Environnementale sur l'ElectroMagnetisme du Quebec - -Video Register Address: 0x00000..0x1FFFF -Video Memory Address: 0x20000..0x3FFFF diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/ecos_lpc2138_sja1000/src/Makefile.in --- a/examples/ecos_lpc2138_sja1000/src/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -export PREFIX := /usr/local/ecos/2138_install -export COMMAND_PREFIX := arm-elf- -export CC := $(COMMAND_PREFIX)gcc -export OBJCOPY := $(COMMAND_PREFIX)objcopy - -ECOS_GLOBAL_CFLAGS=-mcpu=arm7tdmi -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Os -ffunction-sections -fdata-sections -fno-exceptions -finline-functions -ECOS_GLOBAL_LDFLAGS=-mcpu=arm7tdmi -Wl,--gc-sections -Wl,-static -nostdlib - -all: - -lpc2138.o : lpc2138.c lpc2138.h types.h -s1d13706.o : s1d13706.c lpc2138.h types.h -sja1000.o : sja1000.c lpc2138.h types.h - -.c.o: - $(CC) -g -c $(ECOS_GLOBAL_CFLAGS) -I$(PREFIX)/include -I$(PREFIX)/lib/driver $*.c - -clean: - rm -f *.hex *.elf *.o *~ diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/ecos_lpc2138_sja1000/src/elevation/encoder/6FX2001-5SS12.jpg Binary file examples/ecos_lpc2138_sja1000/src/elevation/encoder/6FX2001-5SS12.jpg has changed diff -r 0d84d95790d9 -r 16c8ceea8f18 examples/ecos_lpc2138_sja1000/src/elevation/encoder/ReadMe.txt --- a/examples/ecos_lpc2138_sja1000/src/elevation/encoder/ReadMe.txt Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ - ____ ____ ______ __ ___ ______ ____ - / __ \ / __ \ / ____/ / |/ / / ____/ / __ \ - / / / / / /_/ / / __/ / /|_/ / / __/ / / / / - / /_/ / / _, _/ / /___ / / / / / /___ / /_/ / - \____/ /_/ |_| /_____/ /_/ /_/ /_____/ \___\_\ - - http://www.oremeq.qc.ca/ - -This is an absolute rotary encoder gateway to CANopen. -We used for this demo an absolute rotary encoder from Siemens Automation -model: 6FX2001-5SS12 , see the 6FX2001-5SS12.jpg for an idea of the look. - -This Encoder work with the SSI31 protocol. The 31 mean 31 bits. And SSI -is a special version of the SPI protocol. - -The pinout for this encoder is: - 1=Clock - - 2=Clock + - 3=Data + - 4=Data - - 5=n.c. - 6=n.c. - 7=n.c. - 8= ???? - 9=n.c. - 10=n.c. - 11=+10 to 30 VDC @ 250mA - 12=GND - -Our LPC2138 implement the SSI31 protocol to pool the encoder -and fill the DS-406 specification for CANopen. - -You can find this specification at: http://www.can-cia.org/ -Ask for the document: CiA DS 406 V3.1: CANopen device profile for encoder - -To build this project, see $CANFESTIVAL_HOME/drivers/ecos_lpc2138_sja1000/ReadMe.txt -to prepare your environment. - -See the schematic.jpg in this directory. - - Enjoye! diff -r 0d84d95790d9 -r 16c8ceea8f18 include/led.h --- a/include/led.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - -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 -*/ - - -#if !defined(_LED_INDICATORS_H_) -#define _LED_INDICATORS_H_ - - -enum -{ - LED_NO_ERROR = 6, /* reference to States values */ - LED_AUTOBITRATE, - LED_INVALID_CONFIG, - LED_WARNING_LIMIT_REACH, - LED_ERROR_CTRL_EVENT, - LED_SYNC_ERROR, - LED_EVENT_TIMER_ERROR, - LED_BUS_OFF, - LED_PRG_DOWNLOAD -}; - - -void led_set_state(CO_Data *d, int state); - -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 include/led_driver.h --- a/include/led_driver.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* -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 diff -r 0d84d95790d9 -r 16c8ceea8f18 include/lss.h --- a/include/lss.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -#if !defined(_LSS_H_) -#define _LSS_H_ - - -void lss_SwitchModeGlobal(CO_Data *d, UNS32 mode); -void lss_SwitchModeSelective(CO_Data *d, UNS32 *LSSaddr); -void lss_ConfigureNode_ID(CO_Data *d, UNS32 node_id); - -void lss_ConfigureBitTimingParameters(CO_Data *d, - UNS32 table_selector, - UNS32 table_index); - -void lss_ActivateBitTimingParameters_master(CO_Data *d, UNS16 switch_delay); -void lss_ActivateBitTimingParameters_slave(UNS8 data1, UNS8 data2); - -void lss_StoreConfiguredParameters(CO_Data *d); -UNS32 lss_InquireLSSAddress(CO_Data *d, UNS32 *LSSaddr); - -void lss_IdentifyRemoteSlaves(CO_Data *d, - UNS32 vendor_id, - UNS32 product_code, - UNS32 rev_low, - UNS32 rev_high, - UNS32 serial_low, - UNS32 serial_high); - -UNS32 lss_validate_address(CO_Data *d); - -void lss_IdentifySlave(CO_Data *d); - - -#endif - diff -r 0d84d95790d9 -r 16c8ceea8f18 include/nvram.h --- a/include/nvram.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#if !defined(_NVRAM_H_) -#define _NVRAM_H_ - -int canSaveData(indextable *dict, int max_index); -int canReadData(indextable *dict, int max_index); - -#endif diff -r 0d84d95790d9 -r 16c8ceea8f18 include/nvram_driver.h --- a/include/nvram_driver.h Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -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 diff -r 0d84d95790d9 -r 16c8ceea8f18 objdictgen/objdictgen.py --- a/objdictgen/objdictgen.py Tue Feb 13 17:21:19 2007 +0100 +++ b/objdictgen/objdictgen.py Tue Feb 13 18:06:18 2007 +0100 @@ -56,7 +56,7 @@ manager = NodeManager() if os.path.isfile(fileIn): print "Parsing input file" - result = manager.ImportCurrentFromFile(fileIn) + result = manager.OpenFileInCurrent(fileIn) if type(result) != UnicodeType: Node = result else: diff -r 0d84d95790d9 -r 16c8ceea8f18 src/Makefile.in --- a/src/Makefile.in Tue Feb 13 17:21:19 2007 +0100 +++ b/src/Makefile.in Tue Feb 13 18:06:18 2007 +0100 @@ -30,9 +30,6 @@ PREFIX = SUB_PREFIX BINUTILS_PREFIX = SUB_BINUTILS_PREFIX TARGET = SUB_TARGET -LSS_ENABLE = SUB_LSS_ENABLE -LED_ENABLE = SUB_LED_ENABLE -NVRAM_ENABLE = SUB_NVRAM_ENABLE CAN_DRIVER = SUB_CAN_DRIVER TIMERS_DRIVER = SUB_TIMERS_DRIVER @@ -59,22 +56,6 @@ # # # # Options # # # # -ifeq ($(LSS_ENABLE),YES) -OBJS += $(TARGET)_lss.o -SRC_HFILES += ../include/lss.h -endif - -ifeq ($(LED_ENABLE),YES) -OBJS += $(TARGET)_led.o -SRC_HFILES += ../include/led.h -PROG_CFLAGS += -DLED_ENABLE -endif - -ifeq ($(NVRAM_ENABLE),YES) -OBJS += $(TARGET)_nvram.o -SRC_HFILES += ../include/nvram.h -endif - CFLAGS = SUB_OPT_CFLAGS all: canfestival diff -r 0d84d95790d9 -r 16c8ceea8f18 src/led.c --- a/src/led.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,321 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: CANopen Canada (canfestival@canopencanada.ca) - -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 - - DS-303-3 - LED implementation -*/ - -#include -#include - -#include -#include - -#include - -#include -#include - -#include "led.h" - - -void led_start_timer(CO_Data *, UNS32 t0); -void led_stop_timer(void); -void led_set_green(UNS8 on); -void led_set_red(UNS8 on); -void led_callback(CO_Data* d, UNS32 id); -void led_set_redgreen(CO_Data *d, unsigned char state); - - -/* 0 = always off, 1 = always on, 2 = flashing */ -static UNS8 led_state_red, led_state_green; - -static UNS16 led_sequence_red, led_seq_index_red; -static UNS16 led_sequence_green, led_seq_index_green; - -static UNS8 led_error_code = LED_NO_ERROR; - -const char *led_sequence_table[6] = /* up and downs of the sequence */ -{ - "01", /* flickering */ - "01", /* blinking */ - "100000", /* single flash */ - "10100000", /* double flash */ - "1010100000", /* triple flash */ - "101010100000" /* quadruple flash */ -}; - - -void led_set_state(CO_Data *d, int state) -{ -/*printf("led_set_state(%x)\n", state); */ - - switch(state) - { - case Initialisation: -/* - must create a timer for the leds with the scheduler -*/ - break; - case LED_AUTOBITRATE: - led_state_green = 2; - led_sequence_green = 0; - break; - case Pre_operational: - led_state_green = 2; - led_sequence_green = 1; - break; - case Stopped: - led_state_green = 2; - led_sequence_green = 2; - break; - case LED_PRG_DOWNLOAD: - led_state_green = 2; - led_sequence_green = 4; - break; - case Operational: - led_state_green = 1; - break; - } - - if (state == LED_AUTOBITRATE) - led_start_timer(d, 50); - - else if (led_state_green < 2 && led_state_red < 2) - { - led_stop_timer(); - - /*led_set_green(led_state_green); */ - /*led_set_red(led_state_red); */ - } - - else - led_start_timer(d, 200); -} - - -void led_set_error(CO_Data *d, UNS8 error) -{ - if (error == LED_NO_ERROR) - { - led_error_code = error; - - led_state_green = 0; - } - - else if (error == LED_AUTOBITRATE) - { - led_error_code = error; - - led_state_red = 2; - led_sequence_red = 0; - - led_start_timer(d, 50); - } - - else if (error > led_error_code) - { - led_error_code = error; - - if (error & LED_INVALID_CONFIG) - { - led_state_red = 2; - led_sequence_red = 1; - } - - else if (error & LED_WARNING_LIMIT_REACH) - { - led_state_red = 2; - led_sequence_red = 2; - } - - else if (error & LED_ERROR_CTRL_EVENT) - { - led_state_red = 2; - led_sequence_red = 3; - } - - else if (error & LED_SYNC_ERROR) - { - led_state_red = 2; - led_sequence_red = 4; - } - - else if (error & LED_EVENT_TIMER_ERROR) - { - led_state_red = 2; - led_sequence_green = 5; - } - - else if (error & LED_BUS_OFF) - { - led_state_green = 1; - } - - led_start_timer(d, 200); - /*led_set_red(led_state_red); */ - } - - if (led_state_green < 2 && led_state_red < 2) - { - led_stop_timer(); - - /*led_set_green(led_state_green); */ - /*led_set_red(led_state_red); */ - } -} - - -void led_start_timer(CO_Data* d, UNS32 tm) -{ - SetAlarm(d, 0, &led_callback, MS_TO_TIMEVAL(tm), MS_TO_TIMEVAL(tm)); - - led_seq_index_red = 0; - led_seq_index_green = 0; -} - - -void led_stop_timer(void) -{ -} - - -void led_callback(CO_Data *d, UNS32 id) -{ - UNS8 bits = 0; - - /* RED LED */ - if (led_sequence_table[led_sequence_red][led_seq_index_red] == '1') - { - if (led_state_red > 0) - bits = 1; - /* led_set_red(1); */ - } - else - { - /*if (led_state_red != 1) - led_set_red(0);*/ - } - - led_seq_index_red++; - if (led_seq_index_red > strlen(led_sequence_table[led_sequence_red])) - led_seq_index_red = 0; - - /* GREEN LED */ - if (led_sequence_table[led_sequence_green][led_seq_index_green] == '1') - { - if (led_state_green > 0) - bits = bits | 2; - /* led_set_green(1); */ - } - else - { - /* if (led_state_green != 1) - led_set_green(0); */ - } - - led_seq_index_green++; - if (led_seq_index_green > strlen(led_sequence_table[led_sequence_green])) - led_seq_index_green = 0; - - /*led_set_redgreen(d, bits); */ -} - - - - - -/* -char state(state); - - -Input function to set all the bihaviour indicator -typical state are: - NoError - RedLED=off - AutoBitRate_LSS - RedLED=flickering - GreenLED=flickering - InvalidConfiguration - RedLED=blinking - WarningLimitReached - RedLED=singleflash - ErrorControlEvent - RedLED=doubleflash - SyncError - RedLED=tripleflash - EventTimerError - RedLED=quadrupleflash - BusOFF - RedLED=on - PRE_OPERATIONAL - GreenLED=blinking - STOPPED - GreenLED=singleflash - Programm_Firmware_download - GreenLED=tripleflash - OPERATIONNAL - GreenLED=on -*/ - -/* -case LEDbihaviour: - on - - flickeringerror - RedLED(on) - RedLED(off) - flickeringerror - GreenLED(off) - GreenLED(on) - blinking - - singleflash - - doubleflash - - tripleflash - - quadrupleflash - - off -*/ - -/* -char LED(bitLEDs); -*/ - -/* -Output function to call the driver. - if bit=0, then turn LED Off - if bit=1, then turn LED On - -bit# color name -0 red error/status -1 green run/status -2 -3 -4 -5 -6 -7 -*/ - diff -r 0d84d95790d9 -r 16c8ceea8f18 src/lss.c --- a/src/lss.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,740 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: CANopen Canada (canfestival@canopencanada.ca) - -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 -*/ - -#include -#include - -#include -#include -#include -#include -#include "can_driver.h" - -#ifdef LED_ENABLE -#include "led.h" -#else -#define led_set_state(a,b) -#endif - -#include "lss.h" - - - -/* - NOTES - - 1. since in the LSS protocol all LSS Slave use the same COB, only 1 Slave - must be allowed to communicate with the Master - - 2. the Master always take the iniative. the Slave is only allowed to transmit - within a confirmed service - - 3. requesting message (from the Master) using COB-ID 2021 and response messages - (from the Slave) using COB-ID 2020 -*/ - -/* - 0 = this slave is not talking to the master - 1 = this slave is talking to the master (this slave has been selected via ) -*/ -int slave_selector; - -int current_mode; - -int lss_table_selector, lss_table_index; - - -/* slave storing the information sent by the master */ -UNS32 lss_buffer[10]; -/* - how this buffer is used - - for a SLAVE - [0..3] used to store the LSS Address - [4..9] use by LSS Identify Remort Slave - - for the MASTER - [0..3] hold the answer from the slave regarding its ID -*/ - - -void lss_copy(UNS8 *data, UNS32 value) -/* transfert 32 bits value into uns8 data vector */ -{ - data[0] = value & 0xff; - data[1] = (value>>8) & 0xff; - data[2] = (value>>16) & 0xff; - data[3] = (value>>24) & 0xff; -} - - -UNS32 lss_get_value(UNS8 *data) -/* build a 'UNS32' value from a 'unsigned char' vector */ -{ - return data[0] + (data[1]<<8) + (data[2]<<16) + (data[3]<<24); -} - - -void lss_init_msg(Message *msg) -{ - msg->cob_id.w = 0; - msg->rtr = 0; - msg->len = 0; - msg->data[0] = 0; - msg->data[1] = 0; - msg->data[2] = 0; - msg->data[3] = 0; - msg->data[4] = 0; - msg->data[5] = 0; - msg->data[6] = 0; - msg->data[7] = 0; -} - - -void lss_SwitchModeGlobal(CO_Data *d, UNS32 mode) -/* - this service is used to switch all LSS slaves in the network between operation - mode and configuration mode. -*/ -{ - Message msg; - lss_init_msg(&msg); - - /* - sending a COB-ID 2021 - [0] = 4 (for switch mode global) - [1] = 0 for operation mode, = 1 for configuration mode - [2..7] = 0 reserved - */ - - if (! *(d->iam_a_slave)) - { - msg.cob_id.w = 0x07E5 /* 2021 */; - - msg.len = 2; - msg.data[0] = 4; - msg.data[1] = (UNS8)mode; - - /* transmit */ - (*d->canSend)(&msg); - } - else - { - /* set mode global */ - current_mode = mode; - } -} - - -void lss_SwitchModeSelective_master(CO_Data *d, UNS32 *LSSaddr) -/* - LSS address : - vendor-id : provided by CiA - identical to the CANopen identity object - - select the slave corresponding to this ADDRESS -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (*(d->iam_a_slave)) /* not the master */ - return; - - msg.cob_id.w = 0x07E5 /* 2021 */; - msg.len=5; - - msg.data[0] = 64; - lss_copy(msg.data+1, LSSaddr[0]); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 65; - lss_copy(msg.data+1, LSSaddr[1]); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 66; - lss_copy(msg.data+1, LSSaddr[2]); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 67; - lss_copy(msg.data+1, LSSaddr[3]); - /* transmit */ - (*d->canSend)(&msg); -} - - -UNS32 lss_validate_address(CO_Data* d) -{ -#if 0 - extern s_identity obj1018; - - /* maybe we should go throught getODentry but those - data are 1) RO and 2) the proper ID of this device */ -#else - UNS32 r, vendor_id, product_code, revision_number, serial_number; - UNS8 sz = sizeof(UNS32), dt = int32; - - r = getODentry(d, 0x1018, 1, (void *)&vendor_id, &sz, &dt, 0); - r = getODentry(d, 0x1018, 2, (void *)&product_code, &sz, &dt, 0); - r = getODentry(d, 0x1018, 3, (void *)&revision_number, &sz, &dt, 0); - r = getODentry(d, 0x1018, 4, (void *)&serial_number, &sz, &dt, 0); - -#endif - /* - if - lss_buffer[0] == vendor-id - lss_buffer[1] == product code - lss_buffer[2] == revision - lss_buffer[3] == serial - - then return 1 - else return 0; - */ - - if (lss_buffer[0] == vendor_id && - lss_buffer[1] == product_code && - lss_buffer[2] == revision_number && - lss_buffer[3] == serial_number) - { - return 1; - } - - return 0; -} - - -void lss_SwitchModeSelective_slave(CO_Data *d) -/* - SwitchModeSelective for the SLAVE - received the frames from the master and start building - the lss address -*/ -{ - Message msg; - lss_init_msg(&msg); - - /* - the master broadcast the address of a particular slave - for 64,65 and 66 store the partial address - when 67 arrive process the call and asknowledge if necessary - */ - - if (lss_validate_address(d)) - { - /* slave should transmit cob_id 2020 */ - msg.cob_id.w = 0x07E4 /* 2020 */; - - msg.len = 2; - msg.data[0] = 68; - msg.data[1] = (UNS8)current_mode; - - /* transmit */ - (*d->canSend)(&msg); - } - - /* reset the address */ - lss_buffer[0] = 0; - lss_buffer[1] = 0; - lss_buffer[2] = 0; - lss_buffer[3] = 0; -} - - -void lss_ConfigureNode_ID(CO_Data *d, UNS32 node_id) -/* - through this service the LSS Master configures the NMT-address - parameter of a LSS slave. -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (!*(d->iam_a_slave)) - { - msg.cob_id.w = 0x07E5 /* 2021 */; - - msg.len = 2; - msg.data[0] = 17; - msg.data[1] = (UNS8)node_id; - - /* transmit */ - (*d->canSend)(&msg); - } - else - { - /* - receiving NODE ID from the master - */ - - /* - error code - 0 = success - 1 = node id out of range - 2..254 = reserved - 255 = implementation specific error occured - spec error = mode detailed error - */ - msg.cob_id.w = 0x07E4 /* 2020 */; - - msg.len = 3; - msg.data[0] = 17; - /* msg.data[1] = error code */ - /* msg.data[2] = spec error */ - - /* transmit */ - (*d->canSend)(&msg); - } -} - - -void lss_ConfigureBitTimingParameters(CO_Data *d, - UNS32 table_selector, - UNS32 table_index) -/* - this service allows all LSS slaves in configuration mode. - must be followed by an Activate Bit Timing Parameters -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (!*(d->iam_a_slave)) - { - msg.cob_id.w = 0x07E5 /* 2021 */; - - msg.len = 3; - msg.data[0] = 19; - msg.data[1] = (UNS8)table_selector; - msg.data[2] = (UNS8)table_index; - - /* transmit */ - (*d->canSend)(&msg); - } - else - { - UNS8 error_code; - - /* validate if this baudrate is possible */ - if (table_selector == 0 && baudrate_valid(table_index) == 1) - { - lss_table_selector = table_selector; - lss_table_index = table_index; - } - else - error_code = 1; /* bit timing not supported */ - - msg.cob_id.w = 0x07E4 /* 2020 */; - - msg.len = 3; - msg.data[0] = 19; - msg.data[1] = error_code; - msg.data[2] = 0; - - /* transmit */ - (*d->canSend)(&msg); - } - - led_set_state(d, LED_AUTOBITRATE); -} - - -void lss_ActivateBitTimingParameters_master(CO_Data *d, unsigned short switch_delay) -/* - switch_delay in ms - - switch_delay has to be longer than the longest timeof any node - in the network to avoid that a node already switches while another - stills transmist the old bit timing parameters -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (*(d->iam_a_slave)) - return; - - msg.cob_id.w = 0x07E5 /* 2021 */; - - msg.len = 3; - msg.data[0] = 21; - msg.data[1] = (UNS8)(switch_delay & 0xff); - msg.data[2] = (UNS8)((switch_delay >> 8) & 0xff); - -#ifdef LED_ENABLE - led_set_state(LED_AUTOBITRATE); -#endif - /* transmit */ - (*d->canSend)(&msg); -} - - -void lss_ActivateBitTimingParameters_slave(UNS8 byte_low, UNS8 byte_high) -{ - /* rebuild the delay value (short) from the 2 (UNS8) data */ - unsigned short switch_delay = byte_low + (((UNS16)byte_high)<<8); - - /* set the baudrate to the value proposed by the master */ - if (lss_table_selector == 0) - baudrate_set(lss_table_index); - - /* wait for switch_delay ms before continuing */ -} - - -void lss_StoreConfiguredParameters(CO_Data *d) -/* - store configured parameters into non-volatile storage -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (!*(d->iam_a_slave)) - { - msg.cob_id.w = 0x07E5 /* 2021 */; - - msg.len = 1; - msg.data[0] = 23; - - /* transmit */ - (*d->canSend)(&msg); - } - else - { - msg.cob_id.w = 0x07E4 /* 2020 */; - - msg.data[0] = 23; - /* msg.data[1] = error code; */ - /* msg.data[2] = spec err */ - - /* transmit */ - (*d->canSend)(&msg); - } -} - - -void lss_InquireLSSAddress_master(CO_Data *d, int flag) -/* - this service allows to determine the LSS-address parameters of a LSS-slave in - configuration mode - - request 1 single item of the LSS address - 0 = request vendor-id - 1 = request product-id - 2 = request revision - 3 = request serial -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (!*(d->iam_a_slave)) - { - msg.cob_id.w = 0x07E5 /* 2021 */; - - msg.len = 1; - msg.data[0] = 90 + flag; - - /* transmit */ - (*d->canSend)(&msg); - } -} - - -int lss_InquireLSSAddress_slave(CO_Data *d, int cs) -{ - Message msg; - lss_init_msg(&msg); - - if (!*(d->iam_a_slave)) /* not a slave */ - return -1; - - UNS32 value = 0; - - switch(cs) - { - case 90: - value = 0; /* = vendor id */ - break; - case 91: - value = 0; /* = product code */ - break; - case 92: - value = 0; /* = revision */ - break; - case 93: - value = 0; /* = serial */ - break; - } - - if (value > 0) - { - msg.cob_id.w = 0x07E4 /* 2020 */; - - msg.len=5; - msg.data[0] = cs; - lss_copy(msg.data+1, value); - - /* transmit */ - (*d->canSend)(&msg); - - return 0; - } - - return -1; -} - - -void lss_IdentifyRemoteSlaves(CO_Data *d, - UNS32 vendor_id, - UNS32 product_code, - UNS32 rev_low, - UNS32 rev_high, - UNS32 serial_low, - UNS32 serial_high) -/* - throught this service, the LSS Master requests all LSS slave whose LSS address - meets the LSSaddr_sel to idenfity themselves through LSS Identify Slave -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (!*(d->iam_a_slave)) - { - /* - request answers from all slaves corresponding - to the revision and serial range of values - */ - - msg.cob_id.w = 0x07E5 /* 2021 */; - msg.len=5; - - msg.data[0] = 70; - lss_copy(msg.data+1, vendor_id); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 71; - lss_copy(msg.data+1, product_code); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 72; /* revision number low */ - lss_copy(msg.data+1, rev_low); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 73; /* revision number high */ - lss_copy(msg.data+1, rev_high); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 74; /* serial number low */ - lss_copy(msg.data+1, serial_low); - /* transmit */ - (*d->canSend)(&msg); - - msg.data[0] = 75; /* serial number high */ - lss_copy(msg.data+1, serial_high); - /* transmit */ - (*d->canSend)(&msg); - } -} - - -int lss_validate_range_addr(CO_Data *d) -{ - /* - if - - lss_buffer[4] == vendor_id - lss_buffer[5] == product code - lss_buffer[6] <= revision <= lss_buffer[7] - lss_buffer[8] <= serial <= lss_buffer[9] - - then return 1 - else return 0 - */ - - UNS32 r, vendor_id, product_code, revision_number, serial_number; - UNS8 sz = sizeof(UNS32), dt = int32; - - r = getODentry(d, 0x1018, 1, (void *)&vendor_id, &sz, &dt, 0); - r = getODentry(d, 0x1018, 2, (void *)&product_code, &sz, &dt, 0); - r = getODentry(d, 0x1018, 3, (void *)&revision_number, &sz, &dt, 0); - r = getODentry(d, 0x1018, 4, (void *)&serial_number, &sz, &dt, 0); - - if (lss_buffer[4] == vendor_id && - lss_buffer[5] == product_code && - lss_buffer[6] <= revision_number && - revision_number <= lss_buffer[7] && - lss_buffer[8] <= serial_number && - serial_number <= lss_buffer[9]) - { - return 1; - } - - return 0; -} - - -void lss_IdentifySlave(CO_Data *d) -/* - through this service, an LSS slave indicates that it is a slave - with LSS address within the LSSaddr_sel -*/ -{ - Message msg; - lss_init_msg(&msg); - - if (lss_validate_range_addr(d)) - { - msg.cob_id.w = 0x07E4 /* 2020 */; - - msg.len = 1; - msg.data[0] = 79; - - /* transmit */ - (*d->canSend)(&msg); - } - - /* reset */ - lss_buffer[4] = 0; - lss_buffer[5] = 0; - lss_buffer[6] = 0; - lss_buffer[7] = 0; - lss_buffer[8] = 0; - lss_buffer[9] = 0; -} - - -int lss_process_msg(CO_Data *d, Message *msg) -{ - /* process the incoming message */ - if (msg->cob_id.w == 0x07E4 /* 2020 */) - { - // should be the master - // a slave just answered - switch(msg->data[0]) - { - /* slave acknowledging the SwitchModeSelective call */ - case 68: - /* msg->data[1] contains the 'mode global' value from the slave*/ - break; - - /* a slave had acknowledged the call from LSS Identify Remote Slave */ - case 79: - break; - - /* the slave acknowledged and sent the requested data */ - case 90: - lss_buffer[0] = lss_get_value(msg->data+1); - /* action ? */ - break; - case 91: - lss_buffer[1] = lss_get_value(msg->data+1); - /* action ? */ - break; - case 92: - lss_buffer[2] = lss_get_value(msg->data+1); - /* action ? */ - break; - case 93: - lss_buffer[3] = lss_get_value(msg->data+1); - /* action ? */ - break; - } - } - - else if (msg->cob_id.w == 0x07E5 /* 2021 */) - { - // should be a slave - // the master sent a request - switch(msg->data[0]) - { - case 4: - lss_SwitchModeGlobal(d, msg->data[1]); - break; - - case 17: - lss_ConfigureNode_ID(d, msg->data[1]); - break; - - case 19: - lss_ConfigureBitTimingParameters(d, msg->data[1], msg->data[2]); - break; - case 21: - lss_ActivateBitTimingParameters_slave(msg->data[1], msg->data[2]); - break; - - /* Switch Mode Selective */ - case 64: - lss_buffer[0] = lss_get_value(msg->data+1); - break; - case 65: - lss_buffer[1] = lss_get_value(msg->data+1); - break; - case 66: - lss_buffer[2] = lss_get_value(msg->data+1); - break; - case 67: - lss_buffer[3] = lss_get_value(msg->data+1); - lss_SwitchModeSelective_slave(d); - break; - - /* Identify Remote Slave */ - case 70: - lss_buffer[4] = lss_get_value(msg->data+1); - break; - case 71: - lss_buffer[5] = lss_get_value(msg->data+1); - break; - case 72: - lss_buffer[6] = lss_get_value(msg->data+1); - break; - case 73: - lss_buffer[7] = lss_get_value(msg->data+1); - break; - case 74: - lss_buffer[8] = lss_get_value(msg->data+1); - break; - case 75: - lss_buffer[9] = lss_get_value(msg->data+1); - lss_IdentifySlave(d); - break; - - /* Inquire Identify of Slave */ - case 90: - case 91: - case 92: - case 93: - lss_InquireLSSAddress_slave(d, msg->data[0]); - break; - } - } - - return 0; -} diff -r 0d84d95790d9 -r 16c8ceea8f18 src/nvram.c --- a/src/nvram.c Tue Feb 13 17:21:19 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - - Author: CANopen Canada (canfestival@canopencanada.ca) - -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 -*/ -/* - nvram.c - - save the content of the dictionnary into non-volatile memory - the order of storage must be the same as the order of retrieving - - note (1) - may need to store/retrieve specific data from non-volatile - in that case, we need to address where it is stored - without storing the address in a vector - - solution 1 : walk throught the list without action until the - sought object is found. - -*/ - -#include -#include -#include -#include -#include "can_driver.h" - - -int canSaveData(indextable *dict, int max_index) -{ - int i, j; - - if (nvram_open() < 0) - return -1; - - subindex *pSubindex; - - for(i=0; i