include/data.h
author lbessard
Thu, 25 Jan 2007 16:49:51 +0100
changeset 70 f36f09f08b62
parent 32 8afa33692372
child 71 95cd3376cc9f
permissions -rw-r--r--
Bug corrected on gen_cfile
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#ifndef __data_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
#define __data_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
// declaration of CO_Data type let us include all necessary headers
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
// struct struct_CO_Data can then be defined later
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
typedef struct struct_CO_Data CO_Data;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
#include <applicfg.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
#include "def.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
#include "can.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
#include "objdictdef.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
#include "objacces.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
#include "sdo.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
#include "pdo.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
#include "states.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
#include "lifegrd.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
#include "sync.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
#include "nmtMaster.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
// This structurs contains all necessary information for a CanOpen node
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
struct struct_CO_Data {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
	// Object dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
	UNS8 *bDeviceNodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
	const indextable *objdict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
	UNS8 *count_sync;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
	quick_index *firstIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
	quick_index *lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
	UNS16 *ObjdictSize;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
	const UNS8 *iam_a_slave;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
	valueRangeTest_t valueRangeTest;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
	// SDO
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
	s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
	SDOtimeoutError_t SDOtimeoutError;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
	//s_sdo_parameter *sdo_parameters;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
	// State machine
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
	e_nodeState nodeState;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
	s_state_communication CurrentCommunicationState;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
	initialisation_t initialisation;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
	preOperational_t preOperational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
	operational_t operational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
	stopped_t stopped;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
	// NMT-heartbeat
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
	UNS8 *ConsumerHeartbeatCount;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
	UNS32 *ConsumerHeartbeatEntries;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
	TIMER_HANDLE *ConsumerHeartBeatTimers;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
	UNS16 *ProducerHeartBeatTime;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
	TIMER_HANDLE ProducerHeartBeatTimer;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
	heartbeatError_t heartbeatError;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
	e_nodeState NMTable[NMT_MAX_NODE_ID]; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
	// SYNC
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
	TIMER_HANDLE syncTimer;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
	UNS32 *COB_ID_Sync;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
	UNS32 *Sync_Cycle_Period;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
	/*UNS32 *Sync_window_length*/;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
	post_sync_t post_sync;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
	post_TPDO_t post_TPDO;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
	// PDO
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
	s_process_var process_var;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
	// General
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
	UNS8 toggle;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
	canSend_t canSend;	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
	scanIndexOD_t scanIndexOD;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
// A macro to initialize the data in client app.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
#define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
	/* Object dictionary*/\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
	bDeviceNodeId:& NODE_PREFIX ## _bDeviceNodeId,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
	objdict: NODE_PREFIX ## _objdict,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
	count_sync: NODE_PREFIX ## _count_sync,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
	firstIndex: & NODE_PREFIX ## _firstIndex,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
	lastIndex: & NODE_PREFIX ## _lastIndex,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
	ObjdictSize: & NODE_PREFIX ## _ObjdictSize,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
	iam_a_slave: & NODE_PREFIX ## _iam_a_slave,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
	valueRangeTest: NODE_PREFIX ## _valueRangeTest,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
	\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
	/* SDO */\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
	transfers:{{\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
		nodeId: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
		index: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
		subIndex: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
		state: SDO_RESET,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
		toggle: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
		count: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
		offset: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
		data: {0,},\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
		dataType: 0,\
32
8afa33692372 SDO callbacks.
etisserant
parents: 0
diff changeset
   117
		timer: -1,\
8afa33692372 SDO callbacks.
etisserant
parents: 0
diff changeset
   118
		Callback: NULL},},\
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
	SDOtimeoutError: &NODE_PREFIX ## _SDOtimeoutError,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
	\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
	/* State machine */\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
	nodeState:Unknown_state,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
	CurrentCommunicationState:{\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
		csBoot_Up: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
		csSDO: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
		csEmergency: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
		csSYNC: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
		csHeartbeat: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
		csPDO: 0},\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
	initialisation: &NODE_PREFIX ## _initialisation,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
	preOperational: &NODE_PREFIX ## _preOperational,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
	operational: &NODE_PREFIX ## _operational,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
	stopped: &NODE_PREFIX ## _stopped,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
	\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
	/* NMT-heartbeat */\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
	ConsumerHeartbeatCount: & NODE_PREFIX ## _highestSubIndex_obj1016,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
	ConsumerHeartbeatEntries: NODE_PREFIX ## _obj1016,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
	ConsumerHeartBeatTimers: NODE_PREFIX ## _heartBeatTimers,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
	ProducerHeartBeatTime: & NODE_PREFIX ## _obj1017,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
	ProducerHeartBeatTimer: TIMER_NONE,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
	heartbeatError: NODE_PREFIX ## _heartbeatError,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
	NMTable:{Unknown_state,},\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
	\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
	/* SYNC */\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
	syncTimer: TIMER_NONE,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
	COB_ID_Sync: & NODE_PREFIX ## _obj1005,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
	Sync_Cycle_Period: & NODE_PREFIX ## _obj1006,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
	/*Sync_window_length: & NODE_PREFIX ## _obj1007,*/\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
	post_sync: NODE_PREFIX ## _post_sync,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
	post_TPDO: NODE_PREFIX ## _post_TPDO,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
	\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
	/* PDO */\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
	process_var: {\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
		count: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
		data: {0,}},\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
	\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
	/* General */\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
	toggle: 0,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
	canSend: NODE_PREFIX ## _canSend,\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
	scanIndexOD: NODE_PREFIX ## _scanIndexOD\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
#endif // __data_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165