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