NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
sync.c
Go to the documentation of this file.
1
13#include "data.h"
14#include "sync.h"
15#include "canfestival.h"
16#include "sysdep.h"
17#include "ObjDict.h"
18
19#include "app.h"
20
21/* Prototypes for internals functions */
22void SyncAlarm(CO_Data* d, UNS32 id);
23UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable,
24 UNS8 unsused_bSubindex);
25
26
34{
35 sendSYNC(d) ;
36}
37
38
47UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex)
48{
49 startSYNC(d);
50 return 0;
51}
52
59{
60 if(d->syncTimer != TIMER_NONE){
61 stopSYNC(d);
62 }
63
66
67 if(*d->COB_ID_Sync & 0x00000080ul && *d->Sync_Cycle_Period)
68 {
69 d->syncTimer = SetAlarm(
70 d,
71 0 /*No id needed*/,
72 &SyncAlarm,
73 MS_TO_TIMEVAL(*d->Sync_Cycle_Period),
74 MS_TO_TIMEVAL(*d->Sync_Cycle_Period));
75 }
76}
77
84{
85 RegisterSetODentryCallBack(d, 0x1005, 0, NULL);
86 RegisterSetODentryCallBack(d, 0x1006, 0, NULL);
87 d->syncTimer = DelAlarm(d->syncTimer);
88}
89
90
98{
99 Message m;
100
101 MSG_WAR(0x3001, "sendSYNC ", 0);
102
103 m.cob_id = UNS16_LE(*d->COB_ID_Sync);
104 m.rtr = NOT_A_REQUEST;
105 m.len = 0;
106
107 return canSend(d->canHandle, &m);
108}
109
110
118{
119 UNS8 res;
120 res = sendSYNCMessage(d);
121 processSYNC(d, NULL) ;
122 return res ;
123}
124
136{
137
138 UNS8 res;
139
140 MSG_WAR(0x3002, "SYNC received. Proceed. ", 0);
141
142 (*d->post_sync)(d);
143
144 /* only operational state allows PDO transmission */
145 if(! d->CurrentCommunicationState.csPDO)
146 return 0;
147
148 if(m) //if there is a non-NULL message, let the App use the message
150
151 res = _sendPDOevent(d, 1 /*isSyncEvent*/ );
152
153 /*Call user app callback*/
154 (*d->post_TPDO)(d);
155
156 return res;
157
158}
159
166
This file is generated by the NNP Tool – Object Dictionary Editor, as originally developed by CAN Fes...
Header file for app.c.
#define UNS8
Unsigned int8 representation in CANFest.
Definition applicfg.h:25
#define MSG_WAR(num, str, val)
Definition of MSG_WAR.
Definition applicfg.h:64
#define UNS32
Unsigned int32 representation in CANFest.
Definition applicfg.h:27
void processSYNCMessageForApp(Message *m)
Lets application process SYNC message if necessary.
Definition app.c:112
UNS32 RegisterSetODentryCallBack(CO_Data *d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback)
<BRIEF>
Definition objacces.c:357
UNS8 _sendPDOevent(CO_Data *d, UNS8 isSyncEvent)
Function iterates on all TPDO and look TPDO transmit type and content change before sending it.
Definition pdo.c:512
UNS8 sendSYNCMessage(CO_Data *d)
Transmit a SYNC message on CAN bus.
Definition sync.c:97
void startSYNC(CO_Data *d)
<BRIEF> startSYNC
Definition sync.c:58
void stopSYNC(CO_Data *d)
<BRIEF> stopSYNC
Definition sync.c:83
void _post_sync(CO_Data *d)
<BRIEF> _post_sync
Definition sync.c:165
UNS8 processSYNC(CO_Data *d, Message *m)
This function is called when the node is receiving a SYNC message (cob-id = 0x80).
Definition sync.c:135
UNS32 OnCOB_ID_SyncUpdate(CO_Data *d, const indextable *unsused_indextable, UNS8 unsused_bSubindex)
This is called when Index 0x1005 is updated.
Definition sync.c:47
void SyncAlarm(CO_Data *d, UNS32 id)
<BRIEF> SyncAlarm
Definition sync.c:33
void _post_TPDO(CO_Data *d)
<BRIEF> _post_TPDO
Definition sync.c:172
UNS8 sendSYNC(CO_Data *d)
Transmit a SYNC message and trigger sync TPDOs.
Definition sync.c:117
TIMER_HANDLE SetAlarm(CO_Data *d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)
Set an alarm to execute a callback function when expired.
Definition timer.c:37
TIMER_HANDLE DelAlarm(TIMER_HANDLE handle)
Delete an alarm before expiring.
Definition timer.c:83
Definition can.h:13
UNS16 cob_id
Definition can.h:14
UNS8 rtr
Definition can.h:15
UNS8 len
Definition can.h:16
This structure contains all necessary informations to define a CANOpen node.
Definition data.h:44