author | edouard |
Fri, 04 Dec 2009 15:11:16 +0100 | |
changeset 223 | a09ed6620a7d |
parent 222 | 8b1757417a54 |
child 224 | 270ba3d91e59 |
child 225 | 36d05588f91b |
permissions | -rwxr-xr-x |
219 | 1 |
#ifndef __ACCESSOR_H |
2 |
#define __ACCESSOR_H |
|
3 |
||
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
4 |
|
219 | 5 |
// variable declaration macros |
6 |
#define __DECLARE_VAR(type, name)\ |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
7 |
__IEC_##type##_t name; |
219 | 8 |
#define __DECLARE_GLOBAL(type, resource, name)\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
9 |
__IEC_##type##_t resource##__##name;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
10 |
static __IEC_##type##_t *GLOBAL__##name = &resource##__##name; |
219 | 11 |
#define __DECLARE_GLOBAL_LOCATION(type, location)\ |
12 |
extern type *location; |
|
13 |
#define __DECLARE_GLOBAL_LOCATED(type, resource, name)\ |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
14 |
__IEC_##type##_p resource##__##name;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
15 |
static __IEC_##type##_p *GLOBAL__##name; |
219 | 16 |
#define __DECLARE_EXTERNAL(type, name)\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
17 |
__IEC_##type##_p name; |
219 | 18 |
#define __DECLARE_LOCATED(type, name)\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
19 |
__IEC_##type##_p name; |
219 | 20 |
|
21 |
||
22 |
// variable initialization macros |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
23 |
#define __INIT_STRUCT(name, initial, retained)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
24 |
name.value = initial;\ |
222 | 25 |
name.flags |= retained?RETAIN_FLAG:0; |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
26 |
#define __INIT_VAR(name, initial, retained)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
27 |
__INIT_STRUCT(name, initial, retained) |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
28 |
#define __INIT_GLOBAL(name, initial, retained)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
29 |
__INIT_STRUCT((*GLOBAL__##name), initial, retained) |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
30 |
#define __INIT_GLOBAL_LOCATED(resource, name, location, retained)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
31 |
__INIT_STRUCT(resource##__##name, location, retained) |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
32 |
#define __INIT_EXTERNAL(type, global, name, retained)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
33 |
{extern __IEC_##type##_t *GLOBAL__##global;\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
34 |
__INIT_STRUCT(name, &((*GLOBAL__##global).value), retained)} |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
35 |
#define __INIT_LOCATED(type, location, name, retained)\ |
219 | 36 |
{extern type *location;\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
37 |
__INIT_STRUCT(name, location, retained)} |
219 | 38 |
#define __INIT_LOCATED_VALUE(name, initial)\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
39 |
*(name.value) = initial; |
219 | 40 |
|
41 |
||
42 |
// variable getting macros |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
43 |
#define __GET_VAR(name, ...)\ |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
44 |
name.value __VA_ARGS__ |
219 | 45 |
#define __GET_EXTERNAL(name)\ |
222 | 46 |
name.flags & FORCE_FLAG ? name.fvalue : *(name.value) |
219 | 47 |
#define __GET_LOCATED(name)\ |
222 | 48 |
name.flags & FORCE_FLAG ? name.fvalue : *(name.value) |
219 | 49 |
#define __GET_VAR_BY_REF(name)\ |
50 |
&(name) |
|
51 |
#define __GET_EXTERNAL_BY_REF(name)\ |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
52 |
name.value |
219 | 53 |
#define __GET_LOCATED_BY_REF(name)\ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
54 |
name.value |
219 | 55 |
|
56 |
// variable setting macros |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
219
diff
changeset
|
57 |
#define __SET_VAR(name, new_value, ...)\ |
222 | 58 |
if (!(name.flags & FORCE_FLAG)) name.value __VA_ARGS__ = new_value |
219 | 59 |
#define __SET_EXTERNAL(name, new_value)\ |
222 | 60 |
if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value |
219 | 61 |
#define __SET_LOCATED(name, new_value)\ |
222 | 62 |
if (!(name.flags & FORCE_FLAG)) *(name.value) = new_value |
219 | 63 |
|
64 |
#endif //__ACCESSOR_H |