nico@215: nico@215: nico@215: CanFestival: include/data.h Source File nico@215: nico@215: nico@215: nico@215: nico@215:
nico@215:
nico@215:
nico@215:
nico@215: nico@215:

data.h

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

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