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         s_PDO_status *PDO_status;
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         /* General */
00086         UNS8 toggle;
00087         CAN_HANDLE canHandle;   
00088         scanIndexOD_t scanIndexOD;
00089         storeODSubIndex_t storeODSubIndex; 
00090         
00091         /* DCF concise */
00092         UNS8* dcf_cursor;
00093         UNS32 dcf_count_targets;
00094         
00095 };
00096 
00097 #define NMTable_Initializer Unknown_state,
00098 
00099 #define s_transfer_Initializer {\
00100                 0,          /* nodeId */\
00101                 0,          /* wohami */\
00102                 SDO_RESET,  /* state */\
00103                 0,          /* toggle */\
00104                 0,          /* abortCode */\
00105                 0,          /* index */\
00106                 0,          /* subIndex */\
00107                 0,          /* count */\
00108                 0,          /* offset */\
00109                 {0},        /* data (static use, so that all the table is initialize at 0)*/\
00110                 0,          /* dataType */\
00111                 -1,         /* timer */\
00112                 NULL        /* Callback */\
00113           },
00114 
00115 /* A macro to initialize the data in client app.*/
00116 /* CO_Data structure */
00117 #define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\
00118         /* Object dictionary*/\
00119         & NODE_PREFIX ## _bDeviceNodeId,     /* bDeviceNodeId */\
00120         NODE_PREFIX ## _objdict,             /* objdict  */\
00121         NODE_PREFIX ## _PDO_status,          /* PDO_status */\
00122         & NODE_PREFIX ## _firstIndex,        /* firstIndex */\
00123         & NODE_PREFIX ## _lastIndex,         /* lastIndex */\
00124         & NODE_PREFIX ## _ObjdictSize,       /* ObjdictSize */\
00125         & NODE_PREFIX ## _iam_a_slave,       /* iam_a_slave */\
00126         NODE_PREFIX ## _valueRangeTest,      /* valueRangeTest */\
00127         \
00128         /* SDO, structure s_transfer */\
00129         {\
00130           REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\
00131         },\
00132         \
00133         /* State machine*/\
00134         Unknown_state,      /* nodeState */\
00135         /* structure s_state_communication */\
00136         {\
00137                 0,          /* csBoot_Up */\
00138                 0,          /* csSDO */\
00139                 0,          /* csEmergency */\
00140                 0,          /* csSYNC */\
00141                 0,          /* csHeartbeat */\
00142                 0           /* csPDO */\
00143         },\
00144         _initialisation,     /* initialisation */\
00145         _preOperational,     /* preOperational */\
00146         _operational,        /* operational */\
00147         _stopped,            /* stopped */\
00148         \
00149         /* NMT-heartbeat */\
00150         & NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
00151         NODE_PREFIX ## _obj1016,                   /* ConsumerHeartbeatEntries */\
00152         NODE_PREFIX ## _heartBeatTimers,           /* ConsumerHeartBeatTimers  */\
00153         & NODE_PREFIX ## _obj1017,                 /* ProducerHeartBeatTime */\
00154         TIMER_NONE,                                /* ProducerHeartBeatTimer */\
00155         _heartbeatError,           /* heartbeatError */\
00156         \
00157         {REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)},\
00158                                                    /* is  well initialized at "Unknown_state". Is it ok ? (FD)*/\
00159         \
00160         /* SYNC */\
00161         TIMER_NONE,                                /* syncTimer */\
00162         & NODE_PREFIX ## _obj1005,                 /* COB_ID_Sync */\
00163         & NODE_PREFIX ## _obj1006,                 /* Sync_Cycle_Period */\
00164         /*& NODE_PREFIX ## _obj1007, */            /* Sync_window_length */\
00165         _post_sync,                 /* post_sync */\
00166         _post_TPDO,                 /* post_TPDO */\
00167         \
00168         /* General */\
00169         0,                                         /* toggle */\
00170         NULL,                   /* canSend */\
00171         NODE_PREFIX ## _scanIndexOD,                /* scanIndexOD */\
00172         _storeODSubIndex,                /* storeODSubIndex */\
00173         NULL,           /*dcf_cursor*/\
00174         1               /*dcf_count_targets*/\
00175 }
00176 
00177 #endif /* __data_h__ */
00178 
00179 

Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  doxygen 1.5.1