Sam Grove
/
canopen_slavenode
CANfestival - an open source CANopen framework
framework/include/emcy.h@0:6219434a0cb5, 2011-05-30 (annotated)
- Committer:
- sam_grove
- Date:
- Mon May 30 07:14:41 2011 +0000
- Revision:
- 0:6219434a0cb5
Initial public release of slave node framework port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove |
0:6219434a0cb5 | 1 | /* |
sam_grove |
0:6219434a0cb5 | 2 | This file is part of CanFestival, a library implementing CanOpen Stack. |
sam_grove |
0:6219434a0cb5 | 3 | |
sam_grove |
0:6219434a0cb5 | 4 | Copyright (C): Edouard TISSERANT and Francis DUPIN |
sam_grove |
0:6219434a0cb5 | 5 | |
sam_grove |
0:6219434a0cb5 | 6 | See COPYING file for copyrights details. |
sam_grove |
0:6219434a0cb5 | 7 | |
sam_grove |
0:6219434a0cb5 | 8 | This library is free software; you can redistribute it and/or |
sam_grove |
0:6219434a0cb5 | 9 | modify it under the terms of the GNU Lesser General Public |
sam_grove |
0:6219434a0cb5 | 10 | License as published by the Free Software Foundation; either |
sam_grove |
0:6219434a0cb5 | 11 | version 2.1 of the License, or (at your option) any later version. |
sam_grove |
0:6219434a0cb5 | 12 | |
sam_grove |
0:6219434a0cb5 | 13 | This library is distributed in the hope that it will be useful, |
sam_grove |
0:6219434a0cb5 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
sam_grove |
0:6219434a0cb5 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
sam_grove |
0:6219434a0cb5 | 16 | Lesser General Public License for more details. |
sam_grove |
0:6219434a0cb5 | 17 | |
sam_grove |
0:6219434a0cb5 | 18 | You should have received a copy of the GNU Lesser General Public |
sam_grove |
0:6219434a0cb5 | 19 | License along with this library; if not, write to the Free Software |
sam_grove |
0:6219434a0cb5 | 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
sam_grove |
0:6219434a0cb5 | 21 | */ |
sam_grove |
0:6219434a0cb5 | 22 | |
sam_grove |
0:6219434a0cb5 | 23 | /*! |
sam_grove |
0:6219434a0cb5 | 24 | ** @file emcy.h |
sam_grove |
0:6219434a0cb5 | 25 | ** @author Luis Jimenez |
sam_grove |
0:6219434a0cb5 | 26 | ** @date Wed Sep 26 2007 |
sam_grove |
0:6219434a0cb5 | 27 | ** |
sam_grove |
0:6219434a0cb5 | 28 | ** @brief Declarations of the functions that manage EMCY (emergency) messages |
sam_grove |
0:6219434a0cb5 | 29 | ** |
sam_grove |
0:6219434a0cb5 | 30 | ** |
sam_grove |
0:6219434a0cb5 | 31 | */ |
sam_grove |
0:6219434a0cb5 | 32 | |
sam_grove |
0:6219434a0cb5 | 33 | /** @defgroup emcyo Emergency Object |
sam_grove |
0:6219434a0cb5 | 34 | * Emergency Object is used to communicate device and application failures. |
sam_grove |
0:6219434a0cb5 | 35 | * @ingroup comobj |
sam_grove |
0:6219434a0cb5 | 36 | */ |
sam_grove |
0:6219434a0cb5 | 37 | |
sam_grove |
0:6219434a0cb5 | 38 | #ifndef __emcy_h__ |
sam_grove |
0:6219434a0cb5 | 39 | #define __emcy_h__ |
sam_grove |
0:6219434a0cb5 | 40 | |
sam_grove |
0:6219434a0cb5 | 41 | |
sam_grove |
0:6219434a0cb5 | 42 | #include <applicfg.h> |
sam_grove |
0:6219434a0cb5 | 43 | |
sam_grove |
0:6219434a0cb5 | 44 | /* The error states |
sam_grove |
0:6219434a0cb5 | 45 | * ----------------- */ |
sam_grove |
0:6219434a0cb5 | 46 | typedef enum enum_errorState { |
sam_grove |
0:6219434a0cb5 | 47 | Error_free = 0x00, |
sam_grove |
0:6219434a0cb5 | 48 | Error_occurred = 0x01 |
sam_grove |
0:6219434a0cb5 | 49 | } e_errorState; |
sam_grove |
0:6219434a0cb5 | 50 | |
sam_grove |
0:6219434a0cb5 | 51 | typedef struct { |
sam_grove |
0:6219434a0cb5 | 52 | UNS16 errCode; |
sam_grove |
0:6219434a0cb5 | 53 | UNS8 errRegMask; |
sam_grove |
0:6219434a0cb5 | 54 | UNS8 active; |
sam_grove |
0:6219434a0cb5 | 55 | } s_errors; |
sam_grove |
0:6219434a0cb5 | 56 | |
sam_grove |
0:6219434a0cb5 | 57 | #include "data.h" |
sam_grove |
0:6219434a0cb5 | 58 | |
sam_grove |
0:6219434a0cb5 | 59 | |
sam_grove |
0:6219434a0cb5 | 60 | typedef void (*post_emcy_t)(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg); |
sam_grove |
0:6219434a0cb5 | 61 | void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg); |
sam_grove |
0:6219434a0cb5 | 62 | |
sam_grove |
0:6219434a0cb5 | 63 | /************************************************************************* |
sam_grove |
0:6219434a0cb5 | 64 | * Functions |
sam_grove |
0:6219434a0cb5 | 65 | *************************************************************************/ |
sam_grove |
0:6219434a0cb5 | 66 | |
sam_grove |
0:6219434a0cb5 | 67 | /** |
sam_grove |
0:6219434a0cb5 | 68 | * @ingroup emcy |
sam_grove |
0:6219434a0cb5 | 69 | * @brief Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h) |
sam_grove |
0:6219434a0cb5 | 70 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:6219434a0cb5 | 71 | * @param errCode The error code |
sam_grove |
0:6219434a0cb5 | 72 | * @param errRegMask |
sam_grove |
0:6219434a0cb5 | 73 | * @param addInfo |
sam_grove |
0:6219434a0cb5 | 74 | * @return |
sam_grove |
0:6219434a0cb5 | 75 | */ |
sam_grove |
0:6219434a0cb5 | 76 | UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo); |
sam_grove |
0:6219434a0cb5 | 77 | |
sam_grove |
0:6219434a0cb5 | 78 | /** |
sam_grove |
0:6219434a0cb5 | 79 | * @ingroup emcy |
sam_grove |
0:6219434a0cb5 | 80 | * @brief Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h) |
sam_grove |
0:6219434a0cb5 | 81 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:6219434a0cb5 | 82 | * @param errCode The error code |
sam_grove |
0:6219434a0cb5 | 83 | */ |
sam_grove |
0:6219434a0cb5 | 84 | void EMCY_errorRecovered(CO_Data* d, UNS16 errCode); |
sam_grove |
0:6219434a0cb5 | 85 | |
sam_grove |
0:6219434a0cb5 | 86 | /** |
sam_grove |
0:6219434a0cb5 | 87 | * @ingroup emcy |
sam_grove |
0:6219434a0cb5 | 88 | * @brief Start EMCY consumer and producer |
sam_grove |
0:6219434a0cb5 | 89 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:6219434a0cb5 | 90 | */ |
sam_grove |
0:6219434a0cb5 | 91 | void emergencyInit(CO_Data* d); |
sam_grove |
0:6219434a0cb5 | 92 | |
sam_grove |
0:6219434a0cb5 | 93 | /** |
sam_grove |
0:6219434a0cb5 | 94 | * @ingroup emcy |
sam_grove |
0:6219434a0cb5 | 95 | * @brief Stop EMCY producer and consumer |
sam_grove |
0:6219434a0cb5 | 96 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:6219434a0cb5 | 97 | */ |
sam_grove |
0:6219434a0cb5 | 98 | void emergencyStop(CO_Data* d); |
sam_grove |
0:6219434a0cb5 | 99 | |
sam_grove |
0:6219434a0cb5 | 100 | /** |
sam_grove |
0:6219434a0cb5 | 101 | * @ingroup emcy |
sam_grove |
0:6219434a0cb5 | 102 | * @brief This function is responsible to process an EMCY canopen-message |
sam_grove |
0:6219434a0cb5 | 103 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:6219434a0cb5 | 104 | * @param *m Pointer on the CAN-message which has to be analysed. |
sam_grove |
0:6219434a0cb5 | 105 | */ |
sam_grove |
0:6219434a0cb5 | 106 | void proceedEMCY(CO_Data* d, Message* m); |
sam_grove |
0:6219434a0cb5 | 107 | |
sam_grove |
0:6219434a0cb5 | 108 | #endif /*__emcy_h__ */ |