# HG changeset patch # User frdupin # Date 1166015658 -3600 # Node ID 73bc47a0db55fe332d790cd7975b3fc98b7ed323 # Parent 1dc256e8e49aa4889566546f75311b129a4864a3 Add prototypes diff -r 1dc256e8e49a -r 73bc47a0db55 include/sdo.h --- a/include/sdo.h Tue Dec 12 17:32:05 2006 +0100 +++ b/include/sdo.h Wed Dec 13 14:14:18 2006 +0100 @@ -83,6 +83,11 @@ typedef struct struct_s_SDO s_SDO; +/** Reset of a SDO exchange on timeout. + * Send a SDO abort + */ +void SDOTimeoutAlarm(CO_Data* d, UNS32 id); + /** Reset all sdo buffers */ void resetSDO (CO_Data* d); @@ -202,7 +207,12 @@ */ UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data); - +/** Used to send a SDO request frame to write in a distant node dictionnary. + * The function Callback which must be defined in the user code is called at the + * end of the exchange. (on succes or abort). + */ +UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, + UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback); /** Used by the application to send a SDO request frame to read * in the dictionary of a server node whose node_id is ID * at the index and subIndex indicated @@ -212,6 +222,12 @@ */ UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType); + +/** Used to send a SDO request frame to read in a distant node dictionnary. + * The function Callback which must be defined in the user code is called at the + * end of the exchange. (on succes or abort). + */ +UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback); /** Use this function after a readNetworkDict to get the result. Returns : SDO_FINISHED // data is available @@ -249,4 +265,7 @@ */ UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode); + + + #endif diff -r 1dc256e8e49a -r 73bc47a0db55 src/lifegrd.c --- a/src/lifegrd.c Tue Dec 12 17:32:05 2006 +0100 +++ b/src/lifegrd.c Wed Dec 13 14:14:18 2006 +0100 @@ -23,12 +23,19 @@ #include #include "lifegrd.h" +// Prototypes for internals functions +void ConsumerHearbeatAlarm(CO_Data* d, UNS32 id); +void ProducerHearbeatAlarm(CO_Data* d, UNS32 id); + + +/*****************************************************************************/ e_nodeState getNodeState (CO_Data* d, UNS8 nodeId) { e_nodeState networkNodeState = d->NMTable[nodeId]; return networkNodeState; } +/*****************************************************************************/ // The Consumer Timer Callback void ConsumerHearbeatAlarm(CO_Data* d, UNS32 id) { @@ -38,7 +45,7 @@ (*d->heartbeatError)((UNS8)( ((d->ConsumerHeartbeatEntries[id]) & (UNS32)0x00FF0000) >> (UNS8)16 )); } -/* Retourne le node-id */ +/*****************************************************************************/ void proceedNODE_GUARD(CO_Data* d, Message* m ) { UNS8 nodeId = (UNS8) GET_NODE_ID((*m)); @@ -100,6 +107,7 @@ } } +/*****************************************************************************/ // The Consumer Timer Callback void ProducerHearbeatAlarm(CO_Data* d, UNS32 id) { @@ -122,7 +130,7 @@ } } - +/*****************************************************************************/ void heartbeatInit(CO_Data* d) { UNS8 index; // Index to scan the table of heartbeat consumers @@ -146,7 +154,7 @@ } } - +/*****************************************************************************/ void heartbeatStop(CO_Data* d) { UNS8 index; diff -r 1dc256e8e49a -r 73bc47a0db55 src/sdo.c --- a/src/sdo.c Tue Dec 12 17:32:05 2006 +0100 +++ b/src/sdo.c Wed Dec 13 14:14:18 2006 +0100 @@ -26,6 +26,17 @@ #include "objacces.h" #include "sdo.h" +/*Internals prototypes*/ + +/** Called by writeNetworkDict */ +inline UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, + UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback); + +/** Called by readNetworkDict */ +inline UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, + UNS8 dataType, SDOCallback_t Callback); + + /***************************************************************************/ // SDO (un)packing macros @@ -1151,12 +1162,17 @@ d->transfers[line].Callback = Callback; return 0; } + +/*--------------------------------------------------------------------------*/ + UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data) { return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, NULL); } +/*--------------------------------------------------------------------------*/ + UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback) { @@ -1165,7 +1181,7 @@ /***************************************************************************/ -UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) +inline UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) { UNS8 err; UNS8 SDOfound = 0; @@ -1250,15 +1266,19 @@ return 0; } +/*--------------------------------------------------------------------------*/ + UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType) { return _readNetworkDict (d, nodeId, index, subIndex, dataType, NULL); } +/*--------------------------------------------------------------------------*/ UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) { return _readNetworkDict (d, nodeId, index, subIndex, dataType, Callback); } + /***************************************************************************/ UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size, diff -r 1dc256e8e49a -r 73bc47a0db55 src/states.c --- a/src/states.c Tue Dec 12 17:32:05 2006 +0100 +++ b/src/states.c Wed Dec 13 14:14:18 2006 +0100 @@ -31,12 +31,17 @@ #define led_set_state(a,b) #endif - +// Prototypes for internals functions +void switchCommunicationState(CO_Data* d, + s_state_communication *newCommunicationState); + +/*****************************************************************************/ e_nodeState getState(CO_Data* d) { return d->nodeState; } +/*****************************************************************************/ void canDispatch(CO_Data* d, Message *m) { switch(m->cob_id.w >> 7) @@ -92,7 +97,8 @@ FuncStop;\ } #define None - + +/*****************************************************************************/ void switchCommunicationState(CO_Data* d, s_state_communication *newCommunicationState) { StartOrStop(csSDO, None, resetSDO(d)) @@ -103,6 +109,7 @@ StartOrStop(csBoot_Up, None, slaveSendBootUp(d)) } +/*****************************************************************************/ UNS8 setState(CO_Data* d, e_nodeState newState) { while(newState != d->nodeState){ @@ -184,11 +191,13 @@ return 0; } +/*****************************************************************************/ UNS8 getNodeId(CO_Data* d) { return *d->bDeviceNodeId; } +/*****************************************************************************/ void setNodeId(CO_Data* d, UNS8 nodeId) { UNS16 offset = d->firstIndex->SDO_SVR; diff -r 1dc256e8e49a -r 73bc47a0db55 src/sync.c --- a/src/sync.c Tue Dec 12 17:32:05 2006 +0100 +++ b/src/sync.c Wed Dec 13 14:14:18 2006 +0100 @@ -23,11 +23,20 @@ #include "data.h" #include "sync.h" +// Prototypes for internals functions +void SyncAlarm(CO_Data* d, UNS32 id); +UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable, + UNS8 unsused_bSubindex); + + + +/*****************************************************************************/ void SyncAlarm(CO_Data* d, UNS32 id) { sendSYNC(d, *d->COB_ID_Sync & 0x1FFFFFFF) ; } +/*****************************************************************************/ // This is called when Index 0x1005 is updated. UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex) { @@ -35,6 +44,7 @@ return 0; } +/*****************************************************************************/ void startSYNC(CO_Data* d) { RegisterSetODentryCallBack(d, 0x1005, 0, &OnCOB_ID_SyncUpdate); @@ -55,6 +65,7 @@ } } +/*****************************************************************************/ void stopSYNC(CO_Data* d) { d->syncTimer = DelAlarm(d->syncTimer);