include/objdictdef.h
author etisserant
Tue, 13 Feb 2007 16:36:44 +0100
changeset 91 ed2612282988
parent 71 95cd3376cc9f
child 161 c4908cc776a9
permissions -rw-r--r--
- Better array initialization in data.h CANOPEN_NODE_DATA_INITIALIZER macro. Use a little hack with configure and config.h to create the "pure Ansi C" initializer.
- Workaround for the compiler compatibility with empty arrays (i.e. Index 1016).
- Some fixes in Makefile.in
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
#ifndef __objdictdef_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#define __objdictdef_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
/************************* CONSTANTES **********************************/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
/** this are static defined datatypes taken fCODE the canopen standard. They
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
 *  are located at index 0x0001 to 0x001B. As described in the standard, they
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
 *  are in the object dictionary for definition purpose only. a device does not
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
 *  to support all of this datatypes.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
#define boolean         0x01
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
#define int8            0x02
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
#define int16           0x03
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
#define int32           0x04
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
#define uint8           0x05
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
#define uint16          0x06
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
#define uint32          0x07
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
#define real32          0x08
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
#define visible_string  0x09
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
#define octet_string    0x0A
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
#define unicode_string  0x0B
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
#define time_of_day     0x0C
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
#define time_difference 0x0D
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
#define domain          0x0F
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
#define int24           0x10
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
#define real64          0x11
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
#define int40           0x12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
#define int48           0x13
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
#define int56           0x14
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
#define int64           0x15
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
#define uint24          0x16
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
#define uint40          0x18
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
#define uint48          0x19
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
#define uint56          0x1A
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
#define uint64          0x1B
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
#define pdo_communication_parameter 0x20
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
#define pdo_mapping                 0x21
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
#define sdo_parameter               0x22
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
#define identity                    0x23
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    65
/* CanFestival is using 0x24 to 0xFF to define some types containing a 
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    66
 value range (See how it works in objdict.c)
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    67
 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
/** definitions of the different types of PDOs' transmission
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
 * 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
 * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
#define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
#define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
#define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
#define TRANS_RTR_SYNC        252  /* Transmission on request */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
#define TRANS_RTR             253  /* Transmission on request */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
#define TRANS_EVENT           255  /* Transmission on event */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
/** Each entry of the object dictionary can be READONLY (RO), READ/WRITE (RW),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
 *  WRITE-ONLY (WO)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
#define RW     0x00  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
#define WO     0x01
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
#define RO     0x02
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
#define TO_BE_SAVED  0x04
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
/************************ STRUCTURES ****************************/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
/** This are some structs which are neccessary for creating the entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
 *  of the object dictionary.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
typedef struct td_subindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
    UNS8                    bAccessType;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    98
    UNS8                    bDataType; /* Defines of what datatype the entry is */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    99
    UNS8                    size;      /* The size (in Byte) of the variable */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   100
    void*                   pObject;   /* This is the pointer of the Variable */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
} subindex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
/** Struct for creating entries in the communictaion profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
typedef struct td_indextable
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
{
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   107
    subindex*   pSubindex;   /* Pointer to the subindex */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   108
    UNS8   bSubCount;   /* the count of valid entries for this subindex
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   109
                         * This count here defines how many memory has been
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   110
                         * allocated. this memory does not have to be used.
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   111
                         */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
    UNS16   index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
} indextable;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
typedef struct s_quick_index{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
	UNS16 SDO_SVR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
	UNS16 SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
	UNS16 PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
	UNS16 PDO_RCV_MAP;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
	UNS16 PDO_TRS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
	UNS16 PDO_TRS_MAP;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
}quick_index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   125
/*typedef struct struct_CO_Data CO_Data; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
typedef UNS32 (*ODCallback_t)(CO_Data* d, const indextable *, UNS8 bSubindex);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
typedef const indextable * (*scanIndexOD_t)(UNS16 wIndex, UNS32 * errorCode, ODCallback_t **Callback);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
/************************** MACROS *********************************/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   131
/* CANopen usefull helpers */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
#define GET_NODE_ID(m)         (m.cob_id.w & 0x7f)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
#define GET_FUNCTION_CODE(m)     (m.cob_id.w >> 7)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   135
#endif /* __objdictdef_h__ */