Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | |
| 3 | (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29 |
| 4 | www.systec-electronic.com |
| 5 | |
| 6 | Project: openPOWERLINK |
| 7 | |
| 8 | Description: definitions for generating instances |
| 9 | |
| 10 | License: |
| 11 | |
| 12 | Redistribution and use in source and binary forms, with or without |
| 13 | modification, are permitted provided that the following conditions |
| 14 | are met: |
| 15 | |
| 16 | 1. Redistributions of source code must retain the above copyright |
| 17 | notice, this list of conditions and the following disclaimer. |
| 18 | |
| 19 | 2. Redistributions in binary form must reproduce the above copyright |
| 20 | notice, this list of conditions and the following disclaimer in the |
| 21 | documentation and/or other materials provided with the distribution. |
| 22 | |
| 23 | 3. Neither the name of SYSTEC electronic GmbH nor the names of its |
| 24 | contributors may be used to endorse or promote products derived |
| 25 | from this software without prior written permission. For written |
| 26 | permission, please contact info@systec-electronic.com. |
| 27 | |
| 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 31 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 32 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 33 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 34 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 35 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 36 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 37 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 38 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 39 | POSSIBILITY OF SUCH DAMAGE. |
| 40 | |
| 41 | Severability Clause: |
| 42 | |
| 43 | If a provision of this License is or becomes illegal, invalid or |
| 44 | unenforceable in any jurisdiction, that shall not affect: |
| 45 | 1. the validity or enforceability in that jurisdiction of any other |
| 46 | provision of this License; or |
| 47 | 2. the validity or enforceability in other jurisdictions of that or |
| 48 | any other provision of this License. |
| 49 | |
| 50 | ------------------------------------------------------------------------- |
| 51 | |
| 52 | $RCSfile: EplInstDef.h,v $ |
| 53 | |
| 54 | $Author: D.Krueger $ |
| 55 | |
| 56 | $Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $ |
| 57 | |
| 58 | $State: Exp $ |
| 59 | |
| 60 | Build Environment: |
| 61 | ... |
| 62 | |
| 63 | ------------------------------------------------------------------------- |
| 64 | |
| 65 | Revision History: |
| 66 | |
| 67 | r.d.: first implementation |
| 68 | |
| 69 | ****************************************************************************/ |
| 70 | |
| 71 | #ifndef _EPLINSTDEF_H_ |
| 72 | #define _EPLINSTDEF_H_ |
| 73 | |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 74 | #include <linux/kernel.h> |
| 75 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 76 | // ========================================================================= |
| 77 | // types and macros for generating instances |
| 78 | // ========================================================================= |
| 79 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 80 | typedef enum { |
| 81 | kStateUnused = 0, |
| 82 | kStateDeleted = 1, |
| 83 | kStateUsed = 0xFF |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 84 | } tInstState; |
| 85 | |
| 86 | //------------------------------------------------------------------------------------------ |
| 87 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 88 | typedef void *tEplPtrInstance; |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 89 | typedef u8 tEplInstanceHdl; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 90 | |
| 91 | // define const for illegale values |
| 92 | #define CCM_ILLINSTANCE NULL |
| 93 | #define CCM_ILLINSTANCE_HDL 0xFF |
| 94 | |
| 95 | //------------------------------------------------------------------------------------------ |
| 96 | // if more than one instance then use this macros |
| 97 | #if (EPL_MAX_INSTANCES > 1) |
| 98 | |
| 99 | //-------------------------------------------------------------------------------------- |
| 100 | // macro definition for instance table definition |
| 101 | //-------------------------------------------------------------------------------------- |
| 102 | |
| 103 | // memory attributes for instance table |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 104 | #define STATIC // prevent warnings for variables with same name |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 105 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 106 | #define INSTANCE_TYPE_BEGIN typedef struct { |
| 107 | #define INSTANCE_TYPE_END } tEplInstanceInfo; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 108 | |
| 109 | //-------------------------------------------------------------------------------------- |
| 110 | // macro definition for API interface |
| 111 | //-------------------------------------------------------------------------------------- |
| 112 | |
| 113 | // declaration: |
| 114 | |
| 115 | // macros for declaration within function header or prototype of API functions |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 116 | #define CCM_DECL_INSTANCE_HDL tEplInstanceHdl InstanceHandle |
| 117 | #define CCM_DECL_INSTANCE_HDL_ tEplInstanceHdl InstanceHandle, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 118 | |
| 119 | // macros for declaration of pointer to instance handle within function header or prototype of API functions |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 120 | #define CCM_DECL_PTR_INSTANCE_HDL tEplInstanceHdl *pInstanceHandle |
| 121 | #define CCM_DECL_PTR_INSTANCE_HDL_ tEplInstanceHdl *pInstanceHandle, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 122 | |
| 123 | // macros for declaration instance as lokacl variable within functions |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 124 | #define CCM_DECL_INSTANCE_PTR_LOCAL tCcmInstanceInfo *pInstance; |
| 125 | #define CCM_DECL_PTR_INSTANCE_HDL_LOCAL tEplInstanceHdl *pInstanceHandle; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 126 | |
| 127 | // reference: |
| 128 | |
| 129 | // macros for reference of instance handle for function parameters |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 130 | #define CCM_INSTANCE_HDL InstanceHandle |
| 131 | #define CCM_INSTANCE_HDL_ InstanceHandle, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 132 | |
| 133 | // macros for reference of instance parameter for function parameters |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 134 | #define CCM_INSTANCE_PARAM(par) par |
| 135 | #define CCM_INSTANCE_PARAM_(par) par, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 136 | |
| 137 | // macros for reference of instance parameter for writing or reading values |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 138 | #define CCM_INST_ENTRY (*((tEplPtrInstance)pInstance)) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 139 | |
| 140 | // processing: |
| 141 | |
| 142 | // macros for process instance handle |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 143 | #define CCM_CHECK_INSTANCE_HDL() if (InstanceHandle >= EPL_MAX_INSTANCES) \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 144 | {return (kEplIllegalInstance);} |
| 145 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 146 | // macros for process pointer to instance handle |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 147 | #define CCM_CHECK_PTR_INSTANCE_HDL() if (pInstanceHandle == NULL) \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 148 | {return (kEplInvalidInstanceParam);} |
| 149 | |
| 150 | // This macro returned the handle and pointer to next free instance. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 151 | #define CCM_GET_FREE_INSTANCE_AND_HDL() pInstance = CcmGetFreeInstanceAndHandle (pInstanceHandle); \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 152 | ASSERT (*pInstanceHandle != CCM_ILLINSTANCE_HDL); |
| 153 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 154 | #define CCM_CHECK_INSTANCE_PTR() if (pInstance == CCM_ILLINSTANCE) \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 155 | {return (kEplNoFreeInstance);} |
| 156 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 157 | #define CCM_GET_INSTANCE_PTR() pInstance = CcmGetInstancePtr (InstanceHandle); |
| 158 | #define CCM_GET_FREE_INSTANCE_PTR() pInstance = GetFreeInstance (); \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 159 | ASSERT (pInstance != CCM_ILLINSTANCE); |
| 160 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 161 | //-------------------------------------------------------------------------------------- |
| 162 | // macro definition for stack interface |
| 163 | //-------------------------------------------------------------------------------------- |
| 164 | |
| 165 | // macros for declaration within the function header, prototype or local var list |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 166 | // Declaration of pointers within function paramater list must defined as void * |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 167 | // pointer. |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 168 | #define EPL_MCO_DECL_INSTANCE_PTR void *pInstance |
| 169 | #define EPL_MCO_DECL_INSTANCE_PTR_ void *pInstance, |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 170 | #define EPL_MCO_DECL_INSTANCE_PTR_LOCAL tEplPtrInstance pInstance; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 171 | |
| 172 | // macros for reference of pointer to instance |
| 173 | // These macros are used for parameter passing to called function. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 174 | #define EPL_MCO_INSTANCE_PTR pInstance |
| 175 | #define EPL_MCO_INSTANCE_PTR_ pInstance, |
| 176 | #define EPL_MCO_ADDR_INSTANCE_PTR_ &pInstance, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 177 | |
| 178 | // macro for access of struct members of one instance |
| 179 | // An access to a member of instance table must be casted by the local |
| 180 | // defined type of instance table. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 181 | #define EPL_MCO_INST_ENTRY (*(tEplPtrInstance)pInstance) |
| 182 | #define EPL_MCO_GLB_VAR(var) (((tEplPtrInstance)pInstance)->var) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 183 | |
| 184 | // macros for process pointer to instance |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 185 | #define EPL_MCO_GET_INSTANCE_PTR() pInstance = (tEplPtrInstance) GetInstancePtr (InstanceHandle); |
| 186 | #define EPL_MCO_GET_FREE_INSTANCE_PTR() pInstance = (tEplPtrInstance) GetFreeInstance (); \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 187 | ASSERT (pInstance != CCM_ILLINSTANCE); |
| 188 | |
| 189 | // This macro should be used to check the passed pointer to an public function |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 190 | #define EPL_MCO_CHECK_INSTANCE_STATE() ASSERT (pInstance != NULL); \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 191 | ASSERT (((tEplPtrInstance)pInstance)->m_InstState == kStateUsed); |
| 192 | |
| 193 | // macros for declaration of pointer to instance pointer |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 194 | #define EPL_MCO_DECL_PTR_INSTANCE_PTR void **pInstancePtr |
| 195 | #define EPL_MCO_DECL_PTR_INSTANCE_PTR_ void **pInstancePtr, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 196 | |
| 197 | // macros for reference of pointer to instance pointer |
| 198 | // These macros are used for parameter passing to called function. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 199 | #define EPL_MCO_PTR_INSTANCE_PTR pInstancePtr |
| 200 | #define EPL_MCO_PTR_INSTANCE_PTR_ pInstancePtr, |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 201 | |
| 202 | // macros for process pointer to instance pointer |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 203 | #define EPL_MCO_CHECK_PTR_INSTANCE_PTR() ASSERT (pInstancePtr != NULL); |
| 204 | #define EPL_MCO_SET_PTR_INSTANCE_PTR() (*pInstancePtr = pInstance); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 205 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 206 | #define EPL_MCO_INSTANCE_PARAM(a) (a) |
| 207 | #define EPL_MCO_INSTANCE_PARAM_(a) (a), |
| 208 | #define EPL_MCO_INSTANCE_PARAM_IDX_() EPL_MCO_INSTANCE_PARAM_ (EPL_MCO_GLB_VAR (m_bInstIndex)) |
| 209 | #define EPL_MCO_INSTANCE_PARAM_IDX() EPL_MCO_INSTANCE_PARAM (EPL_MCO_GLB_VAR (m_bInstIndex)) |
| 210 | #define EPL_MCO_WRITE_INSTANCE_STATE(a) EPL_MCO_GLB_VAR (m_InstState) = a; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 211 | |
| 212 | // this macro deletes all instance entries as unused |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 213 | #define EPL_MCO_DELETE_INSTANCE_TABLE() \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 214 | { \ |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 215 | tEplInstanceInfo * pInstance = &aEplInstanceTable_g[0]; \ |
| 216 | tFastByte InstNumber = 0; \ |
| 217 | tFastByte i = EPL_MAX_INSTANCES; \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 218 | do { \ |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 219 | pInstance->m_InstState = (u8) kStateUnused; \ |
| 220 | pInstance->m_bInstIndex = (u8) InstNumber; \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 221 | pInstance++; InstNumber++; i--; \ |
| 222 | } while (i != 0); \ |
| 223 | } |
| 224 | |
| 225 | // definition of functions which has to be defined in each module of CANopen stack |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 226 | #define EPL_MCO_DEFINE_INSTANCE_FCT() \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 227 | static tEplPtrInstance GetInstancePtr (tEplInstanceHdl InstHandle_p); \ |
| 228 | static tEplPtrInstance GetFreeInstance (void); |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 229 | #define EPL_MCO_DECL_INSTANCE_FCT() \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 230 | static tEplPtrInstance GetInstancePtr (tEplInstanceHdl InstHandle_p) { \ |
| 231 | return &aEplInstanceTable_g[InstHandle_p]; } \ |
| 232 | static tEplPtrInstance GetFreeInstance (void) { \ |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 233 | tEplInstanceInfo *pInstance = &aEplInstanceTable_g[0]; \ |
| 234 | tFastByte i = EPL_MAX_INSTANCES; \ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 235 | do { if (pInstance->m_InstState != kStateUsed) { \ |
| 236 | return (tEplPtrInstance) pInstance; } \ |
| 237 | pInstance++; i--; } \ |
| 238 | while (i != 0); \ |
| 239 | return CCM_ILLINSTANCE; } |
| 240 | |
| 241 | // this macro defines the instance table. Each entry is reserved for an instance of CANopen. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 242 | #define EPL_MCO_DECL_INSTANCE_VAR() \ |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 243 | static tEplInstanceInfo aEplInstanceTable_g [EPL_MAX_INSTANCES]; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 244 | |
| 245 | // this macro defines member variables in instance table which are needed in |
| 246 | // all modules of Epl stack |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 247 | #define EPL_MCO_DECL_INSTANCE_MEMBER() \ |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 248 | STATIC u8 m_InstState; \ |
| 249 | STATIC u8 m_bInstIndex; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 250 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 251 | #define EPL_MCO_INSTANCE_PARAM_IDX_() EPL_MCO_INSTANCE_PARAM_ (EPL_MCO_GLB_VAR (m_bInstIndex)) |
| 252 | #define EPL_MCO_INSTANCE_PARAM_IDX() EPL_MCO_INSTANCE_PARAM (EPL_MCO_GLB_VAR (m_bInstIndex)) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 253 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 254 | #else // only one instance is used |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 255 | |
| 256 | // Memory attributes for instance table. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 257 | #define STATIC static // prevent warnings for variables with same name |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 258 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 259 | #define INSTANCE_TYPE_BEGIN |
| 260 | #define INSTANCE_TYPE_END |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 261 | |
| 262 | // macros for declaration, initializing and member access for instance handle |
| 263 | // This class of macros are used by API function to inform CCM-modul which |
| 264 | // instance is to be used. |
| 265 | |
| 266 | // macros for reference of instance handle |
| 267 | // These macros are used for parameter passing to CANopen API function. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 268 | #define CCM_INSTANCE_HDL |
| 269 | #define CCM_INSTANCE_HDL_ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 270 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 271 | #define CCM_DECL_INSTANCE_PTR_LOCAL |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 272 | |
| 273 | // macros for declaration within the function header or prototype |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 274 | #define CCM_DECL_INSTANCE_HDL void |
| 275 | #define CCM_DECL_INSTANCE_HDL_ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 276 | |
| 277 | // macros for process instance handle |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 278 | #define CCM_CHECK_INSTANCE_HDL() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 279 | |
| 280 | // macros for declaration of pointer to instance handle |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 281 | #define CCM_DECL_PTR_INSTANCE_HDL void |
| 282 | #define CCM_DECL_PTR_INSTANCE_HDL_ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 283 | |
| 284 | // macros for process pointer to instance handle |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 285 | #define CCM_CHECK_PTR_INSTANCE_HDL() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 286 | |
| 287 | // This macro returned the handle and pointer to next free instance. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 288 | #define CCM_GET_FREE_INSTANCE_AND_HDL() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 289 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 290 | #define CCM_CHECK_INSTANCE_PTR() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 291 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 292 | #define CCM_GET_INSTANCE_PTR() |
| 293 | #define CCM_GET_FREE_INSTANCE_PTR() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 294 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 295 | #define CCM_INSTANCE_PARAM(par) |
| 296 | #define CCM_INSTANCE_PARAM_(par) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 297 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 298 | #define CCM_INST_ENTRY aCcmInstanceTable_g[0] |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 299 | |
| 300 | // macros for declaration, initializing and member access for instance pointer |
| 301 | // This class of macros are used by CANopen internal function to point to one instance. |
| 302 | |
| 303 | // macros for declaration within the function header, prototype or local var list |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 304 | #define EPL_MCO_DECL_INSTANCE_PTR void |
| 305 | #define EPL_MCO_DECL_INSTANCE_PTR_ |
| 306 | #define EPL_MCO_DECL_INSTANCE_PTR_LOCAL |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 307 | |
| 308 | // macros for reference of pointer to instance |
| 309 | // These macros are used for parameter passing to called function. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 310 | #define EPL_MCO_INSTANCE_PTR |
| 311 | #define EPL_MCO_INSTANCE_PTR_ |
| 312 | #define EPL_MCO_ADDR_INSTANCE_PTR_ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 313 | |
| 314 | // macros for process pointer to instance |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 315 | #define EPL_MCO_GET_INSTANCE_PTR() |
| 316 | #define EPL_MCO_GET_FREE_INSTANCE_PTR() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 317 | |
| 318 | // This macro should be used to check the passed pointer to an public function |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 319 | #define EPL_MCO_CHECK_INSTANCE_STATE() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 320 | |
| 321 | // macros for declaration of pointer to instance pointer |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 322 | #define EPL_MCO_DECL_PTR_INSTANCE_PTR void |
| 323 | #define EPL_MCO_DECL_PTR_INSTANCE_PTR_ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 324 | |
| 325 | // macros for reference of pointer to instance pointer |
| 326 | // These macros are used for parameter passing to called function. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 327 | #define EPL_MCO_PTR_INSTANCE_PTR |
| 328 | #define EPL_MCO_PTR_INSTANCE_PTR_ |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 329 | |
| 330 | // macros for process pointer to instance pointer |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 331 | #define EPL_MCO_CHECK_PTR_INSTANCE_PTR() |
| 332 | #define EPL_MCO_SET_PTR_INSTANCE_PTR() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 333 | |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 334 | #define EPL_MCO_INSTANCE_PARAM(a) |
| 335 | #define EPL_MCO_INSTANCE_PARAM_(a) |
| 336 | #define EPL_MCO_INSTANCE_PARAM_IDX_() |
| 337 | #define EPL_MCO_INSTANCE_PARAM_IDX() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 338 | |
| 339 | // macro for access of struct members of one instance |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 340 | #define EPL_MCO_INST_ENTRY aEplInstanceTable_g[0] |
| 341 | #define EPL_MCO_GLB_VAR(var) (var) |
| 342 | #define EPL_MCO_WRITE_INSTANCE_STATE(a) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 343 | |
| 344 | // this macro deletes all instance entries as unused |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 345 | #define EPL_MCO_DELETE_INSTANCE_TABLE() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 346 | |
| 347 | // definition of functions which has to be defined in each module of CANopen stack |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 348 | #define EPL_MCO_DEFINE_INSTANCE_FCT() |
| 349 | #define EPL_MCO_DECL_INSTANCE_FCT() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 350 | |
| 351 | // this macro defines the instance table. Each entry is reserved for an instance of CANopen. |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 352 | #define EPL_MCO_DECL_INSTANCE_VAR() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 353 | |
| 354 | // this macro defines member variables in instance table which are needed in |
| 355 | // all modules of CANopen stack |
Greg Kroah-Hartman | e0ca059 | 2008-12-19 17:09:38 -0800 | [diff] [blame] | 356 | #define EPL_MCO_DECL_INSTANCE_MEMBER() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 357 | |
| 358 | #endif |
| 359 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 360 | #endif // _EPLINSTDEF_H_ |
| 361 | |
| 362 | // Die letzte Zeile muß unbedingt eine leere Zeile sein, weil manche Compiler |
| 363 | // damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder). |