author | etisserant |
Tue, 17 Mar 2009 00:04:24 +0100 | |
changeset 540 | 6857b6ffb7a7 |
parent 529 | c171e11707c5 |
permissions | -rw-r--r-- |
284 | 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 |
*/ |
|
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
32 |
|
529
c171e11707c5
Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
528
diff
changeset
|
33 |
/** @defgroup emcyo Emergency Object |
c171e11707c5
Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
528
diff
changeset
|
34 |
* Emergency Object is used to communicate device and application failures. |
c171e11707c5
Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
528
diff
changeset
|
35 |
* @ingroup comobj |
c171e11707c5
Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
528
diff
changeset
|
36 |
*/ |
c171e11707c5
Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
528
diff
changeset
|
37 |
|
284 | 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 |
||
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:
296
diff
changeset
|
60 |
typedef void (*post_emcy_t)(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg); |
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:
296
diff
changeset
|
61 |
void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg); |
284 | 62 |
|
63 |
/************************************************************************* |
|
64 |
* Functions |
|
65 |
*************************************************************************/ |
|
66 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
67 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
68 |
* @ingroup emcy |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
69 |
* @brief Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h) |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
70 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
71 |
* @param errCode The error code |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
72 |
* @param errRegMask |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
73 |
* @param addInfo |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
74 |
* @return |
284 | 75 |
*/ |
296
03f2b8b8cb0b
Solved a small bug in emcy.c (errRegMask was always '1' in EMCY_setError.
luis
parents:
284
diff
changeset
|
76 |
UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo); |
284 | 77 |
|
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
78 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
79 |
* @ingroup emcy |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
80 |
* @brief Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h) |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
81 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
82 |
* @param errCode The error code |
284 | 83 |
*/ |
84 |
void EMCY_errorRecovered(CO_Data* d, UNS16 errCode); |
|
85 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
86 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
87 |
* @ingroup emcy |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
88 |
* @brief Start EMCY consumer and producer |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
89 |
* @param *d Pointer on a CAN object data structure |
284 | 90 |
*/ |
91 |
void emergencyInit(CO_Data* d); |
|
92 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
93 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
94 |
* @ingroup emcy |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
95 |
* @brief Stop EMCY producer and consumer |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
96 |
* @param *d Pointer on a CAN object data structure |
284 | 97 |
*/ |
98 |
void emergencyStop(CO_Data* d); |
|
99 |
||
528
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
100 |
/** |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
101 |
* @ingroup emcy |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
102 |
* @brief This function is responsible to process an EMCY canopen-message |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
103 |
* @param *d Pointer on a CAN object data structure |
0a30e161d63c
Re-write doxygen tags in headers files to generate User API documentation
greg
parents:
378
diff
changeset
|
104 |
* @param *m Pointer on the CAN-message which has to be analysed. |
284 | 105 |
*/ |
106 |
void proceedEMCY(CO_Data* d, Message* m); |
|
107 |
||
108 |
#endif /*__emcy_h__ */ |