include/emcy.h
author etisserant
Wed, 04 Jun 2008 11:03:11 +0200
changeset 473 8cecdb44533e
parent 378 d2abf6c8c27b
child 528 0a30e161d63c
permissions -rw-r--r--
Added --binutils configure parameter : "--binutils=path Override binutils path detection (as regards $CC content) "
284
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     1
/*
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     3
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     5
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     6
See COPYING file for copyrights details.
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     7
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    12
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    16
Lesser General Public License for more details.
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    17
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    21
*/
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    22
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    23
/*!
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    24
** @file   emcy.h
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    25
** @author Luis Jimenez
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    26
** @date   Wed Sep 26 2007
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    27
**
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    28
** @brief Declarations of the functions that manage EMCY (emergency) messages
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    29
**
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    30
**
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    31
*/
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    32
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    33
#ifndef __emcy_h__
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    34
#define __emcy_h__
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    35
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    36
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    37
#include <applicfg.h>
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    38
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    39
/* The error states 
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    40
 * ----------------- */
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    41
typedef enum enum_errorState {
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    42
  Error_free		= 0x00, 
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    43
  Error_occurred	= 0x01
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    44
} e_errorState;
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    45
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    46
typedef struct {
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    47
	UNS16 errCode;
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    48
	UNS8 errRegMask;
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    49
	UNS8 active;
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    50
} s_errors;
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    51
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    52
#include "data.h"
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    53
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    54
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
    55
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
    56
void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
284
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    57
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    58
/*************************************************************************
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    59
 * Functions
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    60
 *************************************************************************/
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    61
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    62
/** Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h)
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    63
 */
296
03f2b8b8cb0b Solved a small bug in emcy.c (errRegMask was always '1' in EMCY_setError.
luis
parents: 284
diff changeset
    64
UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo);
284
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    65
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    66
/** Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h)
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    67
 */
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    68
void EMCY_errorRecovered(CO_Data* d, UNS16 errCode);
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    69
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    70
/** Start EMCY consumer and producer
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    71
 */
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    72
void emergencyInit(CO_Data* d);
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    73
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    74
/** Stop EMCY producer and consumer 
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    75
 */
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    76
void emergencyStop(CO_Data* d);
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    77
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    78
/** This function is responsible to process an EMCY canopen-message 
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    79
 *  \param Message The CAN-message which has to be analysed.
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    80
 */
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    81
void proceedEMCY(CO_Data* d, Message* m);
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    82
24bf3d692993 Implemented EMCY objects.
luis
parents:
diff changeset
    83
#endif /*__emcy_h__ */