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  */
etisserant@240: 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 */
etisserant@240: 00047         UNS8 *bDeviceNodeId;
etisserant@240: 00048         const indextable *objdict;
etisserant@240: 00049         s_PDO_status *PDO_status;
etisserant@240: 00050         quick_index *firstIndex;
etisserant@240: 00051         quick_index *lastIndex;
etisserant@240: 00052         UNS16 *ObjdictSize;
etisserant@240: 00053         const UNS8 *iam_a_slave;
etisserant@240: 00054         valueRangeTest_t valueRangeTest;
nico@215: 00055         
nico@215: 00056         /* SDO */
etisserant@240: 00057         s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS];
nico@215: 00058         /* s_sdo_parameter *sdo_parameters; */
nico@215: 00059 
nico@215: 00060         /* State machine */
etisserant@240: 00061         e_nodeState nodeState;
etisserant@240: 00062         s_state_communication CurrentCommunicationState;
etisserant@240: 00063         initialisation_t initialisation;
etisserant@240: 00064         preOperational_t preOperational;
etisserant@240: 00065         operational_t operational;
etisserant@240: 00066         stopped_t stopped;
nico@215: 00067 
nico@215: 00068         /* NMT-heartbeat */
etisserant@240: 00069         UNS8 *ConsumerHeartbeatCount;
etisserant@240: 00070         UNS32 *ConsumerHeartbeatEntries;
etisserant@240: 00071         TIMER_HANDLE *ConsumerHeartBeatTimers;
etisserant@240: 00072         UNS16 *ProducerHeartBeatTime;
etisserant@240: 00073         TIMER_HANDLE ProducerHeartBeatTimer;
etisserant@240: 00074         heartbeatError_t heartbeatError;
etisserant@240: 00075         e_nodeState NMTable[NMT_MAX_NODE_ID]; 
nico@215: 00076 
nico@215: 00077         /* SYNC */
etisserant@240: 00078         TIMER_HANDLE syncTimer;
etisserant@240: 00079         UNS32 *COB_ID_Sync;
etisserant@240: 00080         UNS32 *Sync_Cycle_Period;
nico@215: 00081         /*UNS32 *Sync_window_length;;*/
etisserant@240: 00082         post_sync_t post_sync;
etisserant@240: 00083         post_TPDO_t post_TPDO;
nico@215: 00084         
etisserant@240: 00085         /* General */
etisserant@240: 00086         UNS8 toggle;
etisserant@240: 00087         CAN_HANDLE canHandle;   
etisserant@240: 00088         scanIndexOD_t scanIndexOD;
etisserant@240: 00089         storeODSubIndex_t storeODSubIndex; 
etisserant@240: 00090         
etisserant@240: 00091         /* DCF concise */
etisserant@240: 00092         UNS8* dcf_cursor;
etisserant@240: 00093         UNS32 dcf_count_targets;
etisserant@240: 00094         
etisserant@240: 00095 };
etisserant@240: 00096 
etisserant@240: 00097 #define NMTable_Initializer Unknown_state,
etisserant@240: 00098 
etisserant@240: 00099 #define s_transfer_Initializer {\
etisserant@240: 00100                 0,          /* nodeId */\
etisserant@240: 00101                 0,          /* wohami */\
etisserant@240: 00102                 SDO_RESET,  /* state */\
etisserant@240: 00103                 0,          /* toggle */\
etisserant@240: 00104                 0,          /* abortCode */\
etisserant@240: 00105                 0,          /* index */\
etisserant@240: 00106                 0,          /* subIndex */\
etisserant@240: 00107                 0,          /* count */\
etisserant@240: 00108                 0,          /* offset */\
etisserant@240: 00109                 {0},        /* data (static use, so that all the table is initialize at 0)*/\
etisserant@240: 00110                 0,          /* dataType */\
etisserant@240: 00111                 -1,         /* timer */\
etisserant@240: 00112                 NULL        /* Callback */\
etisserant@240: 00113           },
etisserant@240: 00114 
etisserant@240: 00115 /* A macro to initialize the data in client app.*/
etisserant@240: 00116 /* CO_Data structure */
etisserant@240: 00117 #define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\
etisserant@240: 00118         /* Object dictionary*/\
etisserant@240: 00119         & NODE_PREFIX ## _bDeviceNodeId,     /* bDeviceNodeId */\
etisserant@240: 00120         NODE_PREFIX ## _objdict,             /* objdict  */\
etisserant@240: 00121         NODE_PREFIX ## _PDO_status,          /* PDO_status */\
etisserant@240: 00122         & NODE_PREFIX ## _firstIndex,        /* firstIndex */\
etisserant@240: 00123         & NODE_PREFIX ## _lastIndex,         /* lastIndex */\
etisserant@240: 00124         & NODE_PREFIX ## _ObjdictSize,       /* ObjdictSize */\
etisserant@240: 00125         & NODE_PREFIX ## _iam_a_slave,       /* iam_a_slave */\
etisserant@240: 00126         NODE_PREFIX ## _valueRangeTest,      /* valueRangeTest */\
etisserant@240: 00127         \
etisserant@240: 00128         /* SDO, structure s_transfer */\
etisserant@240: 00129         {\
etisserant@240: 00130           REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\
etisserant@240: 00131         },\
etisserant@240: 00132         \
etisserant@240: 00133         /* State machine*/\
etisserant@240: 00134         Unknown_state,      /* nodeState */\
etisserant@240: 00135         /* structure s_state_communication */\
etisserant@240: 00136         {\
etisserant@240: 00137                 0,          /* csBoot_Up */\
etisserant@240: 00138                 0,          /* csSDO */\
etisserant@240: 00139                 0,          /* csEmergency */\
etisserant@240: 00140                 0,          /* csSYNC */\
etisserant@240: 00141                 0,          /* csHeartbeat */\
etisserant@240: 00142                 0           /* csPDO */\
etisserant@240: 00143         },\
etisserant@240: 00144         _initialisation,     /* initialisation */\
etisserant@240: 00145         _preOperational,     /* preOperational */\
etisserant@240: 00146         _operational,        /* operational */\
etisserant@240: 00147         _stopped,            /* stopped */\
etisserant@240: 00148         \
etisserant@240: 00149         /* NMT-heartbeat */\
etisserant@240: 00150         & NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
etisserant@240: 00151         NODE_PREFIX ## _obj1016,                   /* ConsumerHeartbeatEntries */\
etisserant@240: 00152         NODE_PREFIX ## _heartBeatTimers,           /* ConsumerHeartBeatTimers  */\
etisserant@240: 00153         & NODE_PREFIX ## _obj1017,                 /* ProducerHeartBeatTime */\
etisserant@240: 00154         TIMER_NONE,                                /* ProducerHeartBeatTimer */\
etisserant@240: 00155         _heartbeatError,           /* heartbeatError */\
etisserant@240: 00156         \
etisserant@240: 00157         {REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)},\
etisserant@240: 00158                                                    /* is  well initialized at "Unknown_state". Is it ok ? (FD)*/\
nico@215: 00159         \
etisserant@240: 00160         /* SYNC */\
etisserant@240: 00161         TIMER_NONE,                                /* syncTimer */\
etisserant@240: 00162         & NODE_PREFIX ## _obj1005,                 /* COB_ID_Sync */\
etisserant@240: 00163         & NODE_PREFIX ## _obj1006,                 /* Sync_Cycle_Period */\
etisserant@240: 00164         /*& NODE_PREFIX ## _obj1007, */            /* Sync_window_length */\
etisserant@240: 00165         _post_sync,                 /* post_sync */\
etisserant@240: 00166         _post_TPDO,                 /* post_TPDO */\
etisserant@240: 00167         \
etisserant@240: 00168         /* General */\
etisserant@240: 00169         0,                                         /* toggle */\
etisserant@240: 00170         NULL,                   /* canSend */\
etisserant@240: 00171         NODE_PREFIX ## _scanIndexOD,                /* scanIndexOD */\
etisserant@240: 00172         _storeODSubIndex,                /* storeODSubIndex */\
etisserant@240: 00173         NULL,           /*dcf_cursor*/\
etisserant@240: 00174         1               /*dcf_count_targets*/\
etisserant@240: 00175 }
etisserant@240: 00176 
etisserant@240: 00177 #endif /* __data_h__ */
etisserant@240: 00178 
etisserant@240: 00179 
etisserant@240: 

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