Can_open_masternode

Dependencies:   mbed

Committer:
sam_grove
Date:
Wed Sep 26 05:48:14 2012 +0000
Revision:
7:537bae5a6fc6
Parent:
0:9dd7c6129683
Pushing the project into the new repo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:9dd7c6129683 1 /*
sam_grove 0:9dd7c6129683 2 This file is part of CanFestival, a library implementing CanOpen Stack.
sam_grove 0:9dd7c6129683 3
sam_grove 0:9dd7c6129683 4 Copyright (C): Edouard TISSERANT and Francis DUPIN
sam_grove 0:9dd7c6129683 5
sam_grove 0:9dd7c6129683 6 See COPYING file for copyrights details.
sam_grove 0:9dd7c6129683 7
sam_grove 0:9dd7c6129683 8 This library is free software; you can redistribute it and/or
sam_grove 0:9dd7c6129683 9 modify it under the terms of the GNU Lesser General Public
sam_grove 0:9dd7c6129683 10 License as published by the Free Software Foundation; either
sam_grove 0:9dd7c6129683 11 version 2.1 of the License, or (at your option) any later version.
sam_grove 0:9dd7c6129683 12
sam_grove 0:9dd7c6129683 13 This library is distributed in the hope that it will be useful,
sam_grove 0:9dd7c6129683 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
sam_grove 0:9dd7c6129683 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
sam_grove 0:9dd7c6129683 16 Lesser General Public License for more details.
sam_grove 0:9dd7c6129683 17
sam_grove 0:9dd7c6129683 18 You should have received a copy of the GNU Lesser General Public
sam_grove 0:9dd7c6129683 19 License along with this library; if not, write to the Free Software
sam_grove 0:9dd7c6129683 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
sam_grove 0:9dd7c6129683 21 */
sam_grove 0:9dd7c6129683 22
sam_grove 0:9dd7c6129683 23 /** @defgroup statemachine State Machine
sam_grove 0:9dd7c6129683 24 * @ingroup userapi
sam_grove 0:9dd7c6129683 25 */
sam_grove 0:9dd7c6129683 26
sam_grove 0:9dd7c6129683 27 #ifndef __states_h__
sam_grove 0:9dd7c6129683 28 #define __states_h__
sam_grove 0:9dd7c6129683 29
sam_grove 0:9dd7c6129683 30 #include <applicfg.h>
sam_grove 0:9dd7c6129683 31
sam_grove 0:9dd7c6129683 32 /* The nodes states
sam_grove 0:9dd7c6129683 33 * -----------------
sam_grove 0:9dd7c6129683 34 * values are choosen so, that they can be sent directly
sam_grove 0:9dd7c6129683 35 * for heartbeat messages...
sam_grove 0:9dd7c6129683 36 * Must be coded on 7 bits only
sam_grove 0:9dd7c6129683 37 * */
sam_grove 0:9dd7c6129683 38 /* Should not be modified */
sam_grove 0:9dd7c6129683 39 enum enum_nodeState {
sam_grove 0:9dd7c6129683 40 Initialisation = 0x00,
sam_grove 0:9dd7c6129683 41 Disconnected = 0x01,
sam_grove 0:9dd7c6129683 42 Connecting = 0x02,
sam_grove 0:9dd7c6129683 43 Preparing = 0x02,
sam_grove 0:9dd7c6129683 44 Stopped = 0x04,
sam_grove 0:9dd7c6129683 45 Operational = 0x05,
sam_grove 0:9dd7c6129683 46 Pre_operational = 0x7F,
sam_grove 0:9dd7c6129683 47 Unknown_state = 0x0F
sam_grove 0:9dd7c6129683 48 };
sam_grove 0:9dd7c6129683 49
sam_grove 0:9dd7c6129683 50 typedef enum enum_nodeState e_nodeState;
sam_grove 0:9dd7c6129683 51
sam_grove 0:9dd7c6129683 52 typedef struct
sam_grove 0:9dd7c6129683 53 {
sam_grove 0:9dd7c6129683 54 INTEGER8 csBoot_Up;
sam_grove 0:9dd7c6129683 55 INTEGER8 csSDO;
sam_grove 0:9dd7c6129683 56 INTEGER8 csEmergency;
sam_grove 0:9dd7c6129683 57 INTEGER8 csSYNC;
sam_grove 0:9dd7c6129683 58 INTEGER8 csHeartbeat;
sam_grove 0:9dd7c6129683 59 INTEGER8 csPDO;
sam_grove 0:9dd7c6129683 60 INTEGER8 csLSS;
sam_grove 0:9dd7c6129683 61 } s_state_communication;
sam_grove 0:9dd7c6129683 62
sam_grove 0:9dd7c6129683 63 /**
sam_grove 0:9dd7c6129683 64 * @brief Function that user app can overload
sam_grove 0:9dd7c6129683 65 * @ingroup statemachine
sam_grove 0:9dd7c6129683 66 */
sam_grove 0:9dd7c6129683 67 typedef void (*initialisation_t)(CO_Data*);
sam_grove 0:9dd7c6129683 68 typedef void (*preOperational_t)(CO_Data*);
sam_grove 0:9dd7c6129683 69 typedef void (*operational_t)(CO_Data*);
sam_grove 0:9dd7c6129683 70 typedef void (*stopped_t)(CO_Data*);
sam_grove 0:9dd7c6129683 71
sam_grove 0:9dd7c6129683 72 /**
sam_grove 0:9dd7c6129683 73 * @ingroup statemachine
sam_grove 0:9dd7c6129683 74 * @brief Function that user app can overload
sam_grove 0:9dd7c6129683 75 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 76 */
sam_grove 0:9dd7c6129683 77 void _initialisation(CO_Data* d);
sam_grove 0:9dd7c6129683 78
sam_grove 0:9dd7c6129683 79 /**
sam_grove 0:9dd7c6129683 80 * @ingroup statemachine
sam_grove 0:9dd7c6129683 81 * @brief Function that user app can overload
sam_grove 0:9dd7c6129683 82 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 83 */
sam_grove 0:9dd7c6129683 84 void _preOperational(CO_Data* d);
sam_grove 0:9dd7c6129683 85
sam_grove 0:9dd7c6129683 86 /**
sam_grove 0:9dd7c6129683 87 * @ingroup statemachine
sam_grove 0:9dd7c6129683 88 * @brief Function that user app can overload
sam_grove 0:9dd7c6129683 89 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 90 */
sam_grove 0:9dd7c6129683 91 void _operational(CO_Data* d);
sam_grove 0:9dd7c6129683 92
sam_grove 0:9dd7c6129683 93 /**
sam_grove 0:9dd7c6129683 94 * @ingroup statemachine
sam_grove 0:9dd7c6129683 95 * @brief Function that user app can overload
sam_grove 0:9dd7c6129683 96 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 97 */
sam_grove 0:9dd7c6129683 98 void _stopped(CO_Data* d);
sam_grove 0:9dd7c6129683 99
sam_grove 0:9dd7c6129683 100 #include "data.h"
sam_grove 0:9dd7c6129683 101
sam_grove 0:9dd7c6129683 102 /************************* prototypes ******************************/
sam_grove 0:9dd7c6129683 103
sam_grove 0:9dd7c6129683 104 /**
sam_grove 0:9dd7c6129683 105 * @brief Called by driver/app when receiving messages
sam_grove 0:9dd7c6129683 106 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 107 * @param *m Pointer on a CAN message structure
sam_grove 0:9dd7c6129683 108 */
sam_grove 0:9dd7c6129683 109 void canDispatch(CO_Data* d, Message *m);
sam_grove 0:9dd7c6129683 110
sam_grove 0:9dd7c6129683 111 /**
sam_grove 0:9dd7c6129683 112 * @ingroup statemachine
sam_grove 0:9dd7c6129683 113 * @brief Returns the state of the node
sam_grove 0:9dd7c6129683 114 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 115 * @return The node state
sam_grove 0:9dd7c6129683 116 */
sam_grove 0:9dd7c6129683 117 e_nodeState getState (CO_Data* d);
sam_grove 0:9dd7c6129683 118
sam_grove 0:9dd7c6129683 119 /**
sam_grove 0:9dd7c6129683 120 * @ingroup statemachine
sam_grove 0:9dd7c6129683 121 * @brief Change the state of the node
sam_grove 0:9dd7c6129683 122 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 123 * @param newState The state to assign
sam_grove 0:9dd7c6129683 124 * @return
sam_grove 0:9dd7c6129683 125 */
sam_grove 0:9dd7c6129683 126 UNS8 setState (CO_Data* d, e_nodeState newState);
sam_grove 0:9dd7c6129683 127
sam_grove 0:9dd7c6129683 128 /**
sam_grove 0:9dd7c6129683 129 * @ingroup statemachine
sam_grove 0:9dd7c6129683 130 * @brief Returns the nodId
sam_grove 0:9dd7c6129683 131 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 132 * @return
sam_grove 0:9dd7c6129683 133 */
sam_grove 0:9dd7c6129683 134 UNS8 getNodeId (CO_Data* d);
sam_grove 0:9dd7c6129683 135
sam_grove 0:9dd7c6129683 136 /**
sam_grove 0:9dd7c6129683 137 * @ingroup statemachine
sam_grove 0:9dd7c6129683 138 * @brief Define the node ID. Initialize the object dictionary
sam_grove 0:9dd7c6129683 139 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 140 * @param nodeId The node ID to assign
sam_grove 0:9dd7c6129683 141 */
sam_grove 0:9dd7c6129683 142 void setNodeId (CO_Data* d, UNS8 nodeId);
sam_grove 0:9dd7c6129683 143
sam_grove 0:9dd7c6129683 144 /**
sam_grove 0:9dd7c6129683 145 * @brief Some stuff to do when the node enter in pre-operational mode
sam_grove 0:9dd7c6129683 146 * @param *d Pointer on a CAN object data structure
sam_grove 0:9dd7c6129683 147 */
sam_grove 0:9dd7c6129683 148 void initPreOperationalMode (CO_Data* d);
sam_grove 0:9dd7c6129683 149
sam_grove 0:9dd7c6129683 150 #endif