data.h

Go to the documentation of this file.
00001 /*
00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
00003 
00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
00005 
00006 See COPYING file for copyrights details.
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 
00024 #ifndef __data_h__
00025 #define __data_h__
00026 
00027 /* declaration of CO_Data type let us include all necessary headers
00028  struct struct_CO_Data can then be defined later
00029  */
00030 typedef struct struct_CO_Data CO_Data;
00031 
00032 #include "applicfg.h"
00033 #include "def.h"
00034 #include "can.h"
00035 #include "objdictdef.h"
00036 #include "objacces.h"
00037 #include "sdo.h"
00038 #include "pdo.h"
00039 #include "states.h"
00040 #include "lifegrd.h"
00041 #include "sync.h"
00042 #include "nmtMaster.h"
00043 
00044 /* This structurs contains all necessary information for a CanOpen node */
00045 struct struct_CO_Data {
00046         /* Object dictionary */
00047         UNS8 *bDeviceNodeId;
00048         const indextable *objdict;
00049         UNS8 *count_sync;
00050         quick_index *firstIndex;
00051         quick_index *lastIndex;
00052         UNS16 *ObjdictSize;
00053         const UNS8 *iam_a_slave;
00054         valueRangeTest_t valueRangeTest;
00055         
00056         /* SDO */
00057         s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS];
00058         /* s_sdo_parameter *sdo_parameters; */
00059 
00060         /* State machine */
00061         e_nodeState nodeState;
00062         s_state_communication CurrentCommunicationState;
00063         initialisation_t initialisation;
00064         preOperational_t preOperational;
00065         operational_t operational;
00066         stopped_t stopped;
00067 
00068         /* NMT-heartbeat */
00069         UNS8 *ConsumerHeartbeatCount;
00070         UNS32 *ConsumerHeartbeatEntries;
00071         TIMER_HANDLE *ConsumerHeartBeatTimers;
00072         UNS16 *ProducerHeartBeatTime;
00073         TIMER_HANDLE ProducerHeartBeatTimer;
00074         heartbeatError_t heartbeatError;
00075         e_nodeState NMTable[NMT_MAX_NODE_ID]; 
00076 
00077         /* SYNC */
00078         TIMER_HANDLE syncTimer;
00079         UNS32 *COB_ID_Sync;
00080         UNS32 *Sync_Cycle_Period;
00081         /*UNS32 *Sync_window_length;;*/
00082         post_sync_t post_sync;
00083         post_TPDO_t post_TPDO;
00084         
00085         /* PDO */
00086         s_process_var process_var;
00087         
00088         /* General */
00089         UNS8 toggle;
00090         CAN_HANDLE canHandle;   
00091         scanIndexOD_t scanIndexOD;
00092         storeODSubIndex_t storeODSubIndex; 
00093         
00094         /* DCF concise */
00095         UNS8* dcf_cursor;
00096         UNS32 dcf_count_targets;
00097         
00098 };
00099 
00100 #define NMTable_Initializer Unknown_state,
00101 
00102 #define s_transfer_Initializer {\
00103                 0,          /* nodeId */\
00104                 0,          /* wohami */\
00105                 SDO_RESET,  /* state */\
00106                 0,          /* toggle */\
00107                 0,          /* abortCode */\
00108                 0,          /* index */\
00109                 0,          /* subIndex */\
00110                 0,          /* count */\
00111                 0,          /* offset */\
00112                 {0},        /* data (static use, so that all the table is initialize at 0)*/\
00113                 0,          /* dataType */\
00114                 -1,         /* timer */\
00115                 NULL        /* Callback */\
00116           },
00117 
00118 /* A macro to initialize the data in client app.*/
00119 /* CO_Data structure */
00120 #define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\
00121         /* Object dictionary*/\
00122         & NODE_PREFIX ## _bDeviceNodeId,     /* bDeviceNodeId */\
00123         NODE_PREFIX ## _objdict,             /* objdict  */\
00124         NODE_PREFIX ## _count_sync,          /* count_sync */\
00125         & NODE_PREFIX ## _firstIndex,        /* firstIndex */\
00126         & NODE_PREFIX ## _lastIndex,         /* lastIndex */\
00127         & NODE_PREFIX ## _ObjdictSize,       /* ObjdictSize */\
00128         & NODE_PREFIX ## _iam_a_slave,       /* iam_a_slave */\
00129         NODE_PREFIX ## _valueRangeTest,      /* valueRangeTest */\
00130         \
00131         /* SDO, structure s_transfer */\
00132         {\
00133           REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\
00134         },\
00135         \
00136         /* State machine*/\
00137         Unknown_state,      /* nodeState */\
00138         /* structure s_state_communication */\
00139         {\
00140                 0,          /* csBoot_Up */\
00141                 0,          /* csSDO */\
00142                 0,          /* csEmergency */\
00143                 0,          /* csSYNC */\
00144                 0,          /* csHeartbeat */\
00145                 0           /* csPDO */\
00146         },\
00147         _initialisation,     /* initialisation */\
00148         _preOperational,     /* preOperational */\
00149         _operational,        /* operational */\
00150         _stopped,            /* stopped */\
00151         \
00152         /* NMT-heartbeat */\
00153         & NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
00154         NODE_PREFIX ## _obj1016,                   /* ConsumerHeartbeatEntries */\
00155         NODE_PREFIX ## _heartBeatTimers,           /* ConsumerHeartBeatTimers  */\
00156         & NODE_PREFIX ## _obj1017,                 /* ProducerHeartBeatTime */\
00157         TIMER_NONE,                                /* ProducerHeartBeatTimer */\
00158         _heartbeatError,           /* heartbeatError */\
00159         \
00160         {REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)},\
00161                                                    /* is  well initialized at "Unknown_state". Is it ok ? (FD)*/\
00162         \
00163         /* SYNC */\
00164         TIMER_NONE,                                /* syncTimer */\
00165         & NODE_PREFIX ## _obj1005,                 /* COB_ID_Sync */\
00166         & NODE_PREFIX ## _obj1006,                 /* Sync_Cycle_Period */\
00167         /*& NODE_PREFIX ## _obj1007, */            /* Sync_window_length */\
00168         _post_sync,                 /* post_sync */\
00169         _post_TPDO,                 /* post_TPDO */\
00170         \
00171         /* PDO, structure s_process_var */\
00172         {\
00173                 0,          /* count */\
00174                 {0}         /* data (static use, so that all the table is initialize at 0)*/\
00175         },\
00176         \
00177         /* General */\
00178         0,                                         /* toggle */\
00179         NULL,                   /* canSend */\
00180         NODE_PREFIX ## _scanIndexOD,                /* scanIndexOD */\
00181         _storeODSubIndex,                /* storeODSubIndex */\
00182         NULL,           /*dcf_cursor*/\
00183         1               /*dcf_count_targets*/\
00184 }
00185 
00186 #endif /* __data_h__ */
00187 
00188 

Generated on Fri Jun 8 08:51:39 2007 for CanFestival by  doxygen 1.5.1