author | Christian Taedcke <hacking@taedcke.com> |
Thu, 27 Jan 2011 17:45:48 +0100 | |
changeset 654 | fc9af616633d |
parent 530 | 458418d7e10f |
child 750 | bfb63ff7106e |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
|
3 |
||
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
5 |
||
6 |
See COPYING file for copyrights details. |
|
7 |
||
8 |
This library is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU Lesser General Public |
|
10 |
License as published by the Free Software Foundation; either |
|
11 |
version 2.1 of the License, or (at your option) any later version. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
*/ |
|
22 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
23 |
/** @defgroup statemachine State Machine |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
24 |
* @ingroup userapi |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
25 |
*/ |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
26 |
|
0 | 27 |
#ifndef __states_h__ |
28 |
#define __states_h__ |
|
29 |
||
30 |
#include <applicfg.h> |
|
31 |
||
71 | 32 |
/* The nodes states |
33 |
* ----------------- |
|
34 |
* values are choosen so, that they can be sent directly |
|
35 |
* for heartbeat messages... |
|
36 |
* Must be coded on 7 bits only |
|
37 |
* */ |
|
0 | 38 |
/* Should not be modified */ |
39 |
enum enum_nodeState { |
|
40 |
Initialisation = 0x00, |
|
41 |
Disconnected = 0x01, |
|
42 |
Connecting = 0x02, |
|
43 |
Preparing = 0x02, |
|
44 |
Stopped = 0x04, |
|
45 |
Operational = 0x05, |
|
46 |
Pre_operational = 0x7F, |
|
357
838e5397ae67
Fixed some build errors and warnigs, thanks to Martin Hollenweger (geautomotive.eu)
etisserant
parents:
343
diff
changeset
|
47 |
Unknown_state = 0x0F |
0 | 48 |
}; |
49 |
||
50 |
typedef enum enum_nodeState e_nodeState; |
|
51 |
||
52 |
typedef struct |
|
53 |
{ |
|
291
6165554cbfe9
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
etisserant
parents:
150
diff
changeset
|
54 |
INTEGER8 csBoot_Up; |
6165554cbfe9
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
etisserant
parents:
150
diff
changeset
|
55 |
INTEGER8 csSDO; |
6165554cbfe9
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
etisserant
parents:
150
diff
changeset
|
56 |
INTEGER8 csEmergency; |
6165554cbfe9
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
etisserant
parents:
150
diff
changeset
|
57 |
INTEGER8 csSYNC; |
6165554cbfe9
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
etisserant
parents:
150
diff
changeset
|
58 |
INTEGER8 csHeartbeat; |
6165554cbfe9
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
etisserant
parents:
150
diff
changeset
|
59 |
INTEGER8 csPDO; |
343 | 60 |
INTEGER8 csLSS; |
0 | 61 |
} s_state_communication; |
62 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
63 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
64 |
* @brief Function that user app can overload |
529
c171e11707c5
Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
528
diff
changeset
|
65 |
* @ingroup statemachine |
0 | 66 |
*/ |
378
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
357
diff
changeset
|
67 |
typedef void (*initialisation_t)(CO_Data*); |
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
357
diff
changeset
|
68 |
typedef void (*preOperational_t)(CO_Data*); |
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
357
diff
changeset
|
69 |
typedef void (*operational_t)(CO_Data*); |
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
357
diff
changeset
|
70 |
typedef void (*stopped_t)(CO_Data*); |
0 | 71 |
|
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
72 |
/** |
530
458418d7e10f
Third time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
529
diff
changeset
|
73 |
* @ingroup statemachine |
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
74 |
* @brief Function that user app can overload |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
75 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
76 |
*/ |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
77 |
void _initialisation(CO_Data* d); |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
78 |
|
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
79 |
/** |
530
458418d7e10f
Third time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
529
diff
changeset
|
80 |
* @ingroup statemachine |
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
81 |
* @brief Function that user app can overload |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
82 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
83 |
*/ |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
84 |
void _preOperational(CO_Data* d); |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
85 |
|
530
458418d7e10f
Third time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
529
diff
changeset
|
86 |
/** |
458418d7e10f
Third time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
529
diff
changeset
|
87 |
* @ingroup statemachine |
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
88 |
* @brief Function that user app can overload |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
89 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
90 |
*/ |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
91 |
void _operational(CO_Data* d); |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
92 |
|
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
93 |
/** |
530
458418d7e10f
Third time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
529
diff
changeset
|
94 |
* @ingroup statemachine |
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
95 |
* @brief Function that user app can overload |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
96 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
97 |
*/ |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
98 |
void _stopped(CO_Data* d); |
149 | 99 |
|
0 | 100 |
#include "data.h" |
101 |
||
102 |
/************************* prototypes ******************************/ |
|
103 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
104 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
105 |
* @brief Called by driver/app when receiving messages |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
106 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
107 |
* @param *m Pointer on a CAN message structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
108 |
*/ |
0 | 109 |
void canDispatch(CO_Data* d, Message *m); |
110 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
111 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
112 |
* @ingroup statemachine |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
113 |
* @brief Returns the state of the node |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
114 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
115 |
* @return The node state |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
116 |
*/ |
0 | 117 |
e_nodeState getState (CO_Data* d); |
118 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
119 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
120 |
* @ingroup statemachine |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
121 |
* @brief Change the state of the node |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
122 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
123 |
* @param newState The state to assign |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
124 |
* @return |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
125 |
*/ |
0 | 126 |
UNS8 setState (CO_Data* d, e_nodeState newState); |
127 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
128 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
129 |
* @ingroup statemachine |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
130 |
* @brief Returns the nodId |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
131 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
132 |
* @return |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
133 |
*/ |
0 | 134 |
UNS8 getNodeId (CO_Data* d); |
135 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
136 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
137 |
* @ingroup statemachine |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
138 |
* @brief Define the node ID. Initialize the object dictionary |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
139 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
140 |
* @param nodeId The node ID to assign |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
141 |
*/ |
0 | 142 |
void setNodeId (CO_Data* d, UNS8 nodeId); |
143 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
144 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
145 |
* @brief Some stuff to do when the node enter in pre-operational mode |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
381
diff
changeset
|
146 |
* @param *d Pointer on a CAN object data structure |
0 | 147 |
*/ |
148 |
void initPreOperationalMode (CO_Data* d); |
|
149 |
||
150 |
#endif |