2 This file is part of CanFestival, a library implementing CanOpen Stack.
4 Copyright (C): Edouard TISSERANT and Francis DUPIN
6 See COPYING file for copyrights details.
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.
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.
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
23 /** @defgroup statemachine State Machine
34 * values are choosen so, that they can be sent directly
35 * for heartbeat messages...
36 * Must be coded on 7 bits only
38 /* Should not be modified */
40 Initialisation = 0x00,
46 Pre_operational = 0x7F,
50 typedef enum enum_nodeState e_nodeState;
61 } s_state_communication;
64 * @brief Function that user app can overload
65 * @ingroup statemachine
67 typedef void (*initialisation_t)(CO_Data*);
68 typedef void (*preOperational_t)(CO_Data*);
69 typedef void (*operational_t)(CO_Data*);
70 typedef void (*stopped_t)(CO_Data*);
73 * @ingroup statemachine
74 * @brief Function that user app can overload
75 * @param *d Pointer on a CAN object data structure
77 void _initialisation(CO_Data* d);
80 * @ingroup statemachine
81 * @brief Function that user app can overload
82 * @param *d Pointer on a CAN object data structure
84 void _preOperational(CO_Data* d);
87 * @ingroup statemachine
88 * @brief Function that user app can overload
89 * @param *d Pointer on a CAN object data structure
91 void _operational(CO_Data* d);
94 * @ingroup statemachine
95 * @brief Function that user app can overload
96 * @param *d Pointer on a CAN object data structure
98 void _stopped(CO_Data* d);
102 /************************* prototypes ******************************/
105 * @brief Called by driver/app when receiving messages
106 * @param *d Pointer on a CAN object data structure
107 * @param *m Pointer on a CAN message structure
109 void canDispatch(CO_Data* d, Message *m);
112 * @ingroup statemachine
113 * @brief Returns the state of the node
114 * @param *d Pointer on a CAN object data structure
115 * @return The node state
117 e_nodeState getState (CO_Data* d);
120 * @ingroup statemachine
121 * @brief Change the state of the node
122 * @param *d Pointer on a CAN object data structure
123 * @param newState The state to assign
126 UNS8 setState (CO_Data* d, e_nodeState newState);
129 * @ingroup statemachine
130 * @brief Returns the nodId
131 * @param *d Pointer on a CAN object data structure
134 UNS8 getNodeId (CO_Data* d);
137 * @ingroup statemachine
138 * @brief Define the node ID. Initialize the object dictionary
139 * @param *d Pointer on a CAN object data structure
140 * @param nodeId The node ID to assign
142 void setNodeId (CO_Data* d, UNS8 nodeId);
145 * @brief Some stuff to do when the node enter in pre-operational mode
146 * @param *d Pointer on a CAN object data structure
148 void initPreOperationalMode (CO_Data* d);