luis@284: /* luis@284: This file is part of CanFestival, a library implementing CanOpen Stack. luis@284: luis@284: Copyright (C): Edouard TISSERANT and Francis DUPIN luis@284: luis@284: See COPYING file for copyrights details. luis@284: luis@284: This library is free software; you can redistribute it and/or luis@284: modify it under the terms of the GNU Lesser General Public luis@284: License as published by the Free Software Foundation; either luis@284: version 2.1 of the License, or (at your option) any later version. luis@284: luis@284: This library is distributed in the hope that it will be useful, luis@284: but WITHOUT ANY WARRANTY; without even the implied warranty of luis@284: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU luis@284: Lesser General Public License for more details. luis@284: luis@284: You should have received a copy of the GNU Lesser General Public luis@284: License along with this library; if not, write to the Free Software luis@284: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA luis@284: */ luis@284: luis@284: /*! luis@284: ** @file emcy.h luis@284: ** @author Luis Jimenez luis@284: ** @date Wed Sep 26 2007 luis@284: ** luis@284: ** @brief Declarations of the functions that manage EMCY (emergency) messages luis@284: ** luis@284: ** luis@284: */ greg@528: greg@529: /** @defgroup emcyo Emergency Object greg@529: * Emergency Object is used to communicate device and application failures. greg@529: * @ingroup comobj greg@529: */ greg@529: luis@284: #ifndef __emcy_h__ luis@284: #define __emcy_h__ luis@284: luis@284: luis@284: #include luis@284: luis@284: /* The error states luis@284: * ----------------- */ luis@284: typedef enum enum_errorState { luis@284: Error_free = 0x00, luis@284: Error_occurred = 0x01 luis@284: } e_errorState; luis@284: luis@284: typedef struct { luis@284: UNS16 errCode; luis@284: UNS8 errRegMask; luis@284: UNS8 active; luis@284: } s_errors; luis@284: luis@284: #include "data.h" luis@284: luis@284: etisserant@378: typedef void (*post_emcy_t)(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg); etisserant@378: void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg); luis@284: luis@284: /************************************************************************* luis@284: * Functions luis@284: *************************************************************************/ luis@284: greg@528: /** greg@528: * @ingroup emcy greg@528: * @brief Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h) greg@528: * @param *d Pointer on a CAN object data structure greg@528: * @param errCode The error code greg@528: * @param errRegMask greg@528: * @param addInfo greg@528: * @return luis@284: */ luis@296: UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo); luis@284: greg@528: /** greg@528: * @ingroup emcy greg@528: * @brief Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h) greg@528: * @param *d Pointer on a CAN object data structure greg@528: * @param errCode The error code luis@284: */ luis@284: void EMCY_errorRecovered(CO_Data* d, UNS16 errCode); luis@284: greg@528: /** greg@528: * @ingroup emcy greg@528: * @brief Start EMCY consumer and producer greg@528: * @param *d Pointer on a CAN object data structure luis@284: */ luis@284: void emergencyInit(CO_Data* d); luis@284: greg@528: /** greg@528: * @ingroup emcy greg@528: * @brief Stop EMCY producer and consumer greg@528: * @param *d Pointer on a CAN object data structure luis@284: */ luis@284: void emergencyStop(CO_Data* d); luis@284: greg@528: /** greg@528: * @ingroup emcy greg@528: * @brief This function is responsible to process an EMCY canopen-message greg@528: * @param *d Pointer on a CAN object data structure greg@528: * @param *m Pointer on the CAN-message which has to be analysed. luis@284: */ luis@284: void proceedEMCY(CO_Data* d, Message* m); luis@284: luis@284: #endif /*__emcy_h__ */