VALUES (Default Value)

Supported by Ginmake 1.25 and later, Gin file version 3.21

Objects may be supplied with default values. For many objects, it is acceptable that they are initialized to zero. For others it is not so good (can result in damaging behaviour from the ECU).

Default values can be specified in one of two ways:

  • An initializer list:
1[VALUES={1, 2, 8, 16, 5}]
  • An expression:
1[VALUES=10]
2[VALUES=@8u:0xFFFFFFFFFFFFFFFF]
3[VALUES=_x \* _y]
4[VALUES=BILINEAR_INTERP(_x, _y, MAPSSTP, MAPLSTP, 10, 100, 80, 255)]

The specified values correspond to the raw values that would be expected in the ECU memory.

The VALUES clause must be placed after the object definition that it should be attached to.

Type specifiers may be used. Useful if the value cannot be reasonably represented using a 32bit signed integer.

Initializer lists should have the same number of elements as the underlying object. You may specify a different number, but you will get a compiler warning. You should use column-major ordering:

0 1
1 2 4
0 1 3

You would use: [VALUES={1, 2, 3, 4}]

Expressions can contain anything, providing they do not start with a curly brace (otherwise they will be interpreted as an initializer list).

In the above examples, the first and second expressions are simply numbers. This value is copied into all sites of the object.

The third expression uses the special _x and _y symbols. These correspond to the x and y position in the object being filled with data. So in this example, at position (0, 0) you would have a value of (0 * 0) = 0. at position (1, 1) you would have a value of (1 * 1) = 1.

The fourth example uses a function-like macro, which is defined as follows:

1#ifdef __GINMAKE__
2#define LINEAR_INTERP(x, width, x0, x1) (x0 + (x \* (x1 - x0)) / (width – 1))
3#define BILINEAR_INTERP(x, y, width, height, y0x0, y0x1, y1x0, y1x1) \
4 LINEAR_INTERP(y, height, \
5 LINEAR_INTERP(x, width, y0x0, y0x1), \
6 LINEAR_INTERP(x, width, y1x0, y1x1))
7#endif

It uses the _x and _y values to fill a map with the 4 specified corner values 10, 100, 80 and 255. These values are interpolated and is equivalent to the ‘calculate’ function in GW.

Ultimately a binary representation of the object is generated and stored in the Gin file.

Since Ginmake 1.38, it is possible to initialize a value with an address, with optional type discriminator:

1[VALUES=#Analog 00]
2[VALUES=#Analog 00:channel]