CANfestival - an open source CANopen framework

Dependencies:   mbed

Committer:
sam_grove
Date:
Wed Sep 26 05:48:14 2012 +0000
Revision:
7:537bae5a6fc6
Parent:
0:9dd7c6129683
Pushing the project into the new repo

Who changed what in which revision?

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