]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - include/emcy.h
Bug with wxRadioButton on Windows fixed
[CanFestival-3.git] / include / emcy.h
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
23 /*!
24 ** @file   emcy.h
25 ** @author Luis Jimenez
26 ** @date   Wed Sep 26 2007
27 **
28 ** @brief Declarations of the functions that manage EMCY (emergency) messages
29 **
30 **
31 */
32  
33 /** @defgroup emcyo Emergency Object
34  *  Emergency Object is used to communicate device and application failures.
35  *  @ingroup comobj
36  */
37                                          
38 #ifndef __emcy_h__
39 #define __emcy_h__
40
41
42 #include <applicfg.h>
43
44 /* The error states 
45  * ----------------- */
46 typedef enum enum_errorState {
47   Error_free            = 0x00, 
48   Error_occurred        = 0x01
49 } e_errorState;
50
51 typedef struct {
52         UNS16 errCode;
53         UNS8 errRegMask;
54         UNS8 active;
55 } s_errors;
56
57 #include "data.h"
58
59
60 typedef void (*post_emcy_t)(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
61 void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
62
63 /*************************************************************************
64  * Functions
65  *************************************************************************/
66
67 /** 
68  * @ingroup emcy
69  * @brief Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h)
70  * @param *d Pointer on a CAN object data structure
71  * @param errCode The error code
72  * @param errRegMask
73  * @param addInfo
74  * @return
75  */
76 UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo);
77
78 /**
79  * @ingroup emcy 
80  * @brief Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h)
81  * @param *d Pointer on a CAN object data structure
82  * @param errCode The error code
83  */
84 void EMCY_errorRecovered(CO_Data* d, UNS16 errCode);
85
86 /**
87  * @ingroup emcy 
88  * @brief Start EMCY consumer and producer
89  * @param *d Pointer on a CAN object data structure
90  */
91 void emergencyInit(CO_Data* d);
92
93 /** 
94  * @ingroup emcy
95  * @brief Stop EMCY producer and consumer
96  * @param *d Pointer on a CAN object data structure 
97  */
98 void emergencyStop(CO_Data* d);
99
100 /** 
101  * @ingroup emcy
102  * @brief This function is responsible to process an EMCY canopen-message
103  * @param *d Pointer on a CAN object data structure 
104  * @param *m Pointer on the CAN-message which has to be analysed.
105  */
106 void proceedEMCY(CO_Data* d, Message* m);
107
108 #endif /*__emcy_h__ */