Sam Grove / Mbed 2 deprecated canopen_slavenode

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers emcy.h Source File

emcy.h

Go to the documentation of this file.
00001 /*
00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
00003 
00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
00005 
00006 See COPYING file for copyrights details.
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 /*!
00024 ** @file   emcy.h
00025 ** @author Luis Jimenez
00026 ** @date   Wed Sep 26 2007
00027 **
00028 ** @brief Declarations of the functions that manage EMCY (emergency) messages
00029 **
00030 **
00031 */
00032  
00033 /** @defgroup emcyo Emergency Object
00034  *  Emergency Object is used to communicate device and application failures.
00035  *  @ingroup comobj
00036  */
00037                      
00038 #ifndef __emcy_h__
00039 #define __emcy_h__
00040 
00041 
00042 #include <applicfg.h>
00043 
00044 /* The error states 
00045  * ----------------- */
00046 typedef enum enum_errorState {
00047   Error_free        = 0x00, 
00048   Error_occurred    = 0x01
00049 } e_errorState;
00050 
00051 typedef struct {
00052     UNS16 errCode;
00053     UNS8 errRegMask;
00054     UNS8 active;
00055 } s_errors;
00056 
00057 #include "data.h"
00058 
00059 
00060 typedef void (*post_emcy_t)(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
00061 void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
00062 
00063 /*************************************************************************
00064  * Functions
00065  *************************************************************************/
00066 
00067 /** 
00068  * @ingroup emcy
00069  * @brief Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h)
00070  * @param *d Pointer on a CAN object data structure
00071  * @param errCode The error code
00072  * @param errRegMask
00073  * @param addInfo
00074  * @return
00075  */
00076 UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo);
00077 
00078 /**
00079  * @ingroup emcy 
00080  * @brief Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h)
00081  * @param *d Pointer on a CAN object data structure
00082  * @param errCode The error code
00083  */
00084 void EMCY_errorRecovered(CO_Data* d, UNS16 errCode);
00085 
00086 /**
00087  * @ingroup emcy 
00088  * @brief Start EMCY consumer and producer
00089  * @param *d Pointer on a CAN object data structure
00090  */
00091 void emergencyInit(CO_Data* d);
00092 
00093 /** 
00094  * @ingroup emcy
00095  * @brief Stop EMCY producer and consumer
00096  * @param *d Pointer on a CAN object data structure 
00097  */
00098 void emergencyStop(CO_Data* d);
00099 
00100 /** 
00101  * @ingroup emcy
00102  * @brief This function is responsible to process an EMCY canopen-message
00103  * @param *d Pointer on a CAN object data structure 
00104  * @param *m Pointer on the CAN-message which has to be analysed.
00105  */
00106 void proceedEMCY(CO_Data* d, Message* m);
00107 
00108 #endif /*__emcy_h__ */