NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
app.c
Go to the documentation of this file.
1
15//STM Remote Module
16#include "ObjDict.h"
17#include "states.h"
18#include "app.h"
19#include "main.h"
20
21#include "can_stm.h"
22
23//Application Specific
24volatile UNS8 f_syncPulse = 0;
25
33void initAppTask( void )
34{
35 //Initialize any required variables or peripherals here
36}
37
46{
47 //This function gets called in the main.c while loop
48
49 UNS32 i = 0x00;
50
51 runAppTask(i);
52}
53
59void runAppTask( UNS32 param )
60{
61 // Rate limit the task so its not running constantly
62 static UNS8 taskDelaySecsApp = 1; // Can be linked to the OD
63 static UNS32 tDelayRefApp = 0;
64 CO_Data * d = &ObjDict_Data;
65
66 if( !isTimedOut( &tDelayRefApp, TIMEOUT_sec( taskDelaySecsApp ) ) )
67 {
68 return;
69 }
70 //ELSE.. reading delay is over
71 resetTimeOut( &tDelayRefApp );
72
73 // Continue onto do the rest of the application task
74 // Update or read from the OD to cause changes in program
75
76 if(f_syncPulse){
77 // Runs on sync pulse in the main application loop
78 // Can either process sync pulse in the applicaiton, or in processSYNCMessageForApp
79 f_syncPulse = 0;
80 }
81
82
83 switch( d->nodeState )
84 {
85 case Waiting:
86 break;
87 case Stopped:
88 break;
89 case Mode_Patient_Control:
90 break;
91 case Mode_Patient_Manual:
92 break;
93 case Mode_X_Manual:
94 break;
95 case Mode_Produce_X_Manual:
96 break;
97 case Mode_Y_Manual:
98 break;
99 case Mode_Record_X:
100 break;
101 default:
102 break;
103 }
104}
105
113{
114 // syncPulse is included as an example of setting a flag
115 // to be used in the app task and is not required for functionality
116 f_syncPulse = 1;
117}
118
125{
126
127}
128
137{
138 f_syncPulse = 0;
139}
140
148{
149 if ( d->nodeState == Hibernate)
150 setState(d,Waiting);
151 else
152 setState(d,Unknown_state);
153}
154
162{
163 //no restrictions on state entry
164 setState(d,Stopped);
166}
167
175{
176 //no restrictions on state entry
177 setState(d,Waiting);
178 StopWatchDog( d );
180}
181
189{
190 if (d->nodeState == Waiting && (*m).data[1] == 0) //must be NMT broadcast and in waiting
191 {
192 setState(d, Mode_Patient_Control);
193 }
194}
195
203{
204 if (d->nodeState == Waiting) //must be in waiting
205 {
206 setState(d, Mode_X_Manual);
207 StartWatchDog(d, 10000);
208 }
209}
210
218{
219 if (d->nodeState == Waiting) //must be in waiting
220 {
221 setState(d, Mode_Y_Manual);
222 StartWatchDog(d, 10000);
223 }
224}
225
233{
234 //no restrictions on state entry
235 setState(d, Stopped);
237}
238
246{
247 if (d->nodeState == Waiting && (*m).data[1] == 0) //must be NMT broadcast and in waiting
248 {
249 setState(d, Mode_Patient_Manual);
250 StartWatchDog(d, 10000);
251 }
252}
253
261{
262 if (d->nodeState == Waiting && (*m).data[1] == 0) //must be NMT broadcast and in waiting
263 {
264 setState(d, Mode_Produce_X_Manual);
265 }
266}
267
275{
276 if (d->nodeState == Waiting) //must be in waiting
277 {
278 setState(d, Mode_Record_X);
279 }
280}
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 UNS32
Unsigned int32 representation in CANFest.
Definition applicfg.h:27
void EnterProduceXManualFunc(CO_Data *d, Message *m)
Lets application process NMT_Produce_X_Manual.
Definition app.c:260
void EnterPatientOperationFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_Patient_Operation.
Definition app.c:188
void EnterStopStimFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_Stop_Stim.
Definition app.c:232
void EnterYManualFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_Y_Manual.
Definition app.c:217
void EnterPatientManualFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_Patient_Manual.
Definition app.c:245
void EnterRecordXFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_Record_X.
Definition app.c:274
void StopNodesFunc(CO_Data *d, Message *m)
Lets application process NMT_Stop_Nodes.
Definition app.c:161
void EnterWaitingFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_Waiting.
Definition app.c:174
void StartNodesFunc(CO_Data *d, Message *m)
Lets application process NMT_Start_Nodes (unused)
Definition app.c:147
void EnterXManualFunc(CO_Data *d, Message *m)
Lets application process NMT_Enter_X_Manual.
Definition app.c:202
void processSYNCMessageForApp(Message *m)
Lets application process SYNC message if necessary.
Definition app.c:112
void runAppTask(UNS32 param)
This task is run on the background thread to update parameters.
Definition app.c:59
void sleepApplication(void)
This function is called when the module recieves an NMT to enter low power mode.
Definition app.c:124
void initAppTask(void)
Function called at the initialization of program.
Definition app.c:33
void InitAppTaskValues(void)
Reinitializes application values when necessary.
Definition app.c:136
void updateAppTask()
Main application loop called from main.c.
Definition app.c:45
void StartWatchDog(CO_Data *d, UNS16 timebase)
Starts watchdog on slave.
Definition nmtSlave.c:262
void StopWatchDog(CO_Data *d)
Stops watchdog on slave.
Definition nmtSlave.c:272
UNS8 setState(CO_Data *d, e_nodeState newState)
Change the state of the node.
Definition states.c:161
: Header for main.c file. This file contains the common defines of the application.
Definition can.h:13
This structure contains all necessary informations to define a CANOpen node.
Definition data.h:44
UNS8 isTimedOut(UNS32 *tRef, UNS32 tAlarm)
Checks if a timer has timed out.
Definition timer_stm.c:41
void resetTimeOut(UNS32 *tRef)
Resets a timed out timer.
Definition timer_stm.c:56