include/objacces.h
author Edouard Tisserant
Fri, 27 Nov 2015 16:27:46 +0100
changeset 795 8dc7a42d38b1
parent 629 b9274b595650
permissions -rwxr-xr-x
fixed static link of can driver
629
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     1
/*
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     3
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     5
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     6
See COPYING file for copyrights details.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     7
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     8
This library is free software; you can redistribute it and/or
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    10
License as published by the Free Software Foundation; either
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    12
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    13
This library is distributed in the hope that it will be useful,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    16
Lesser General Public License for more details.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    17
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    19
License along with this library; if not, write to the Free Software
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    21
*/
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    22
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    23
/** @file
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    24
 *  @brief Responsible for accessing the object dictionary.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    25
 *
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    26
 *  This file contains functions for accessing the object dictionary and
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    27
 *  variables that are contained by the object dictionary.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    28
 *  Accessing the object dictionary contains setting local variables
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    29
 *  as PDOs and accessing (read/write) all entries of the object dictionary
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    30
 *  @warning Only the basic entries of an object dictionary are included
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    31
 *           at the moment.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    32
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    33
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    34
/** @defgroup od Object Dictionary Management
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    35
 *  @brief The Object Dictionary is the heart of each CANopen device containing all communication and application objects.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    36
 *  @ingroup userapi
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    37
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    38
 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    39
#ifndef __objacces_h__
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    40
#define __objacces_h__
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    41
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    42
#include <applicfg.h>
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    43
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    44
588
ee181b4f177b Replace macro functions for setODentry and getODentry
greg
parents: 561
diff changeset
    45
#ifdef __cplusplus
ee181b4f177b Replace macro functions for setODentry and getODentry
greg
parents: 561
diff changeset
    46
extern "C" {
629
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    47
#endif
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    48
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    49
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    50
typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    51
typedef void (* storeODSubIndex_t)(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    52
void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    53
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    54
/**
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    55
 * @brief Print MSG_WAR (s) if error to the access to the object dictionary occurs.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    56
 * 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    57
 * You must uncomment the lines in the file objaccess.c :\n
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    58
 * //#define DEBUG_CAN\n
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    59
 * //#define DEBUG_WAR_CONSOLE_ON\n
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    60
 * //#define DEBUG_ERR_CONSOLE_ON\n\n
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    61
 * Beware that sometimes, we force the sizeDataDict or sizeDataGiven to 0, when we wants to use
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    62
 * this function but we do not have the access to the right value. One example is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    63
 * getSDOerror(). So do not take attention to these variables if they are null.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    64
 * @param index
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    65
 * @param subIndex
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    66
 * @param sizeDataDict Size of the data defined in the dictionary
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    67
 * @param sizeDataGiven Size data given by the user.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    68
 * @param code error code to print. (SDO abort code. See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    69
 * @return
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    70
 */ 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    71
UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    72
			   UNS32 sizeDataDict, UNS32 sizeDataGiven, UNS32 code);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    73
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    74
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    75
/* _getODentry() Reads an entry from the object dictionary.\n
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    76
 * 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    77
 *    use getODentry() macro to read from object and endianize
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    78
 *    use readLocalDict() macro to read from object and not endianize   
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    79
 *
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    80
 * @code
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    81
 * // Example usage:
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    82
 * UNS8  *pbData;
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    83
 * UNS8 length;
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    84
 * UNS32 returnValue;
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    85
 *
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    86
 * returnValue = getODentry( (UNS16)0x100B, (UNS8)1, 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    87
 * (void * *)&pbData, (UNS8 *)&length );
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    88
 * if( returnValue != SUCCESSFUL )
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    89
 * {
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    90
 *     // error handling
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    91
 * }
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    92
 * @endcode 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    93
 * @param *d Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    94
 * @param wIndex The index in the object dictionary where you want to read
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    95
 *               an entry
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    96
 * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    97
 *                  used to tell you how many valid entries you can find
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    98
 *                  in this index. Look at the canopen standard for further
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
    99
 *                  information
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   100
 * @param *pDestData Pointer to the pointer which points to the variable where
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   101
 *                   the value of this object dictionary entry should be copied
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   102
 * @param pExpectedSize This function writes the size of the copied value (in Byte)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   103
 *                      into this variable.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   104
 * @param *pDataType Pointer to the type of the data. See objdictdef.h
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   105
 * @param CheckAccess if other than 0, do not read if the data is Write Only
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   106
 *                    [Not used today. Put always 0].
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   107
 * @param Endianize  When not 0, data is endianized into network byte order
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   108
 *                   when 0, data is not endianized and copied in machine native
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   109
 *                   endianness 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   110
 * @return 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   111
 * - OD_SUCCESSFUL is returned upon success. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   112
 * - SDO abort code is returned if error occurs . (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   113
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   114
UNS32 _getODentry( CO_Data* d,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   115
                   UNS16 wIndex,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   116
                   UNS8 bSubindex,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   117
                   void * pDestData,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   118
                   UNS32 * pExpectedSize,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   119
                   UNS8 * pDataType,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   120
                   UNS8 checkAccess,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   121
                   UNS8 endianize);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   122
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   123
/** 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   124
 * @ingroup od
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   125
 * @brief getODentry() to read from object and endianize
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   126
 * @param OD Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   127
 * @param wIndex The index in the object dictionary where you want to read
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   128
 *                an entry
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   129
 * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   130
 *                  used to tell you how many valid entries you can find
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   131
 *                  in this index. Look at the canopen standard for further
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   132
 *                  information
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   133
 * @param *pDestData Pointer to the pointer which points to the variable where
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   134
 *                   the value of this object dictionary entry should be copied
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   135
 * @param pExpectedSize This function writes the size of the copied value (in Byte)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   136
 *                      into this variable.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   137
 * @param *pDataType Pointer to the type of the data. See objdictdef.h
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   138
 * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   139
 * @param endianize  Set to 1 : endianized into network byte order 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   140
 * @return 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   141
 * - OD_SUCCESSFUL is returned upon success. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   142
 * - SDO abort code is returned if error occurs . (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   143
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   144
#define getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   145
		          pDataType,  checkAccess)                         \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   146
       _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   147
		          pDataType,  checkAccess, 1)            
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   148
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   149
/** 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   150
 * @ingroup od
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   151
 * @brief readLocalDict() reads an entry from the object dictionary, but in 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   152
 * contrast to getODentry(), readLocalDict() doesn't endianize entry and reads
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   153
 * entry in machine native endianness. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   154
 * @param OD Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   155
 * @param wIndex The index in the object dictionary where you want to read
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   156
 *                an entry
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   157
 * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   158
 *                  used to tell you how many valid entries you can find
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   159
 *                  in this index. Look at the canopen standard for further
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   160
 *                  information
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   161
 * @param *pDestData Pointer to the pointer which points to the variable where
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   162
 *                   the value of this object dictionary entry should be copied
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   163
 * @param pExpectedSize This function writes the size of the copied value (in Byte)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   164
 *                      into this variable.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   165
 * @param *pDataType Pointer to the type of the data. See objdictdef.h
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   166
 * @param checkAccess if other than 0, do not read if the data is Write Only
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   167
 *                    [Not used today. Put always 0].
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   168
 * @param endianize Set to 0, data is not endianized and copied in machine native
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   169
 *                  endianness 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   170
 * @return 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   171
 * - OD_SUCCESSFUL is returned upon success. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   172
 * - SDO abort code is returned if error occurs . (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   173
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   174
#define readLocalDict( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   175
		          pDataType,  checkAccess)                         \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   176
       _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   177
		          pDataType,  checkAccess, 0)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   178
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   179
/* By this function you can write an entry into the object dictionary
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   180
 * @param *d Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   181
 * @param wIndex The index in the object dictionary where you want to write
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   182
 *               an entry
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   183
 * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   184
 *                  used to tell you how many valid entries you can find
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   185
 *                  in this index. Look at the canopen standard for further
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   186
 *                  information
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   187
 * @param *pSourceData Pointer to the variable that holds the value that should
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   188
 *                     be copied into the object dictionary
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   189
 * @param *pExpectedSize The size of the value (in Byte).
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   190
 * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   191
 * @param endianize When not 0, data is endianized into network byte order
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   192
 *                  when 0, data is not endianized and copied in machine native
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   193
 *                  endianness   
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   194
 * @return 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   195
 * - OD_SUCCESSFUL is returned upon success. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   196
 * - SDO abort code is returned if error occurs . (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   197
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   198
UNS32 _setODentry( CO_Data* d,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   199
                   UNS16 wIndex,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   200
                   UNS8 bSubindex,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   201
                   void * pSourceData,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   202
                   UNS32 * pExpectedSize,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   203
                   UNS8 checkAccess,
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   204
                   UNS8 endianize);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   205
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   206
/**
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   207
 * @ingroup od
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   208
 * @brief setODentry converts SourceData from network byte order to machine native 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   209
 * format, and writes that to OD.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   210
 * @code
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   211
 * // Example usage:
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   212
 * UNS8 B;
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   213
 * B = 0xFF; // set transmission type
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   214
 *
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   215
 * retcode = setODentry( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 );
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   216
 * @endcode
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   217
 * @param d Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   218
 * @param wIndex The index in the object dictionary where you want to write
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   219
 *               an entry
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   220
 * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   221
 *                  used to tell you how many valid entries you can find
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   222
 *                  in this index. Look at the canopen standard for further
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   223
 *                  information
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   224
 * @param *pSourceData Pointer to the variable that holds the value that should
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   225
 *                     be copied into the object dictionary
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   226
 * @param *pExpectedSize The size of the value (in Byte).
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   227
 * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   228
 * @param endianize Set to 1 : endianized into network byte order
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   229
 * @return 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   230
 * - OD_SUCCESSFUL is returned upon success. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   231
 * - SDO abort code is returned if error occurs . (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   232
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   233
#define setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   234
                  checkAccess) \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   235
       _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   236
                  checkAccess, 1)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   237
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   238
/** @fn UNS32 writeLocalDict(d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   239
 * @ingroup od
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   240
 * @hideinitializer
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   241
 * @brief Writes machine native SourceData to OD.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   242
 * @param d Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   243
 * @param wIndex The index in the object dictionary where you want to write
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   244
 *               an entry
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   245
 * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   246
 *                  used to tell you how many valid entries you can find
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   247
 *                  in this index. Look at the canopen standard for further
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   248
 *                  information
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   249
 * @param *pSourceData Pointer to the variable that holds the value that should
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   250
 *                     be copied into the object dictionary
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   251
 * @param *pExpectedSize The size of the value (in Byte).
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   252
 * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   253
 * @param endianize Data is not endianized and copied in machine native endianness 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   254
 * @return 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   255
 * - OD_SUCCESSFUL is returned upon success. 
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   256
 * - SDO abort code is returned if error occurs . (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   257
 * \n\n
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   258
 * @code
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   259
 * // Example usage:
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   260
 * UNS8 B;
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   261
 * B = 0xFF; // set transmission type
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   262
 *
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   263
 * retcode = writeLocalDict( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 );
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   264
 * @endcode
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   265
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   266
#define writeLocalDict( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess) \
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   267
       _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess, 0)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   268
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   269
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   270
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   271
/**
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   272
 * @brief Scan the index of object dictionary. Used only by setODentry and getODentry.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   273
 * @param *d Pointer to a CAN object data structure
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   274
 * @param wIndex
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   275
 * @param *errorCode :  OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h)
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   276
 * @param **Callback
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   277
 * @return NULL if index not found. Else : return the table part of the object dictionary.
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   278
 */
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   279
 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   280
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   281
UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback);
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   282
588
ee181b4f177b Replace macro functions for setODentry and getODentry
greg
parents: 561
diff changeset
   283
#ifdef __cplusplus
ee181b4f177b Replace macro functions for setODentry and getODentry
greg
parents: 561
diff changeset
   284
}
629
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   285
#endif
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   286
b9274b595650 CosateQ contribution.
edouard
parents: 594
diff changeset
   287
#endif /* __objacces_h__ */