CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
int_date_definition.h
Go to the documentation of this file.
1#ifndef __int_date_definition
2#define __int_date_definition
3
4/// \file
5
6/*! \page date_construction FW release construction
7
8
9 This file defines a macro that returns the current date during the build (compilation) of the project.
10 \n The macro is __INT_DATE__ and returns a 32-bit integer in the format YYYYMMDD (decimal).
11 \n Use the variable #FW_version, to be defined in the main as a global.
12 \n N.B.: the project must be rebuilt completely (not just F7) in order to update the macro.
13 \n The macro is developed around the pre-processor __DATE__ that expands to current date (at compile time)
14 in the form mmm dd yyyy (e.g. "Jan 14 2012"),
15 as a string. The __DATE__ macro can be used to provide information about the particular moment a binary was built.
16
17*\snippetlineno int_date_definition.h date_code
18
19*/
20// OTHER DEFINITIONS
21
22extern unsigned int FW_version;
23
24//! <!-- [date_code] -->
25#define BUILD_YEAR_CH0 (__DATE__[ 7] - 0x30)
26#define BUILD_YEAR_CH1 (__DATE__[ 8] - 0x30)
27#define BUILD_YEAR_CH2 (__DATE__[ 9] - 0x30)
28#define BUILD_YEAR_CH3 (__DATE__[10] - 0x30)
29
30
31#define BUILD_MONTH_IS_JAN (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n')
32#define BUILD_MONTH_IS_FEB (__DATE__[0] == 'F')
33#define BUILD_MONTH_IS_MAR (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r')
34#define BUILD_MONTH_IS_APR (__DATE__[0] == 'A' && __DATE__[1] == 'p')
35#define BUILD_MONTH_IS_MAY (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y')
36#define BUILD_MONTH_IS_JUN (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n')
37#define BUILD_MONTH_IS_JUL (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l')
38#define BUILD_MONTH_IS_AUG (__DATE__[0] == 'A' && __DATE__[1] == 'u')
39#define BUILD_MONTH_IS_SEP (__DATE__[0] == 'S')
40#define BUILD_MONTH_IS_OCT (__DATE__[0] == 'O')
41#define BUILD_MONTH_IS_NOV (__DATE__[0] == 'N')
42#define BUILD_MONTH_IS_DEC (__DATE__[0] == 'D')
43
44
45#define BUILD_MONTH_CH0 \
46 ((BUILD_MONTH_IS_OCT || BUILD_MONTH_IS_NOV || BUILD_MONTH_IS_DEC) ? 1 : 0)
47
48#define BUILD_MONTH_CH1 \
49 ( \
50 (BUILD_MONTH_IS_JAN) ? 1 : \
51 (BUILD_MONTH_IS_FEB) ? 2 : \
52 (BUILD_MONTH_IS_MAR) ? 3 : \
53 (BUILD_MONTH_IS_APR) ? 4 : \
54 (BUILD_MONTH_IS_MAY) ? 5 : \
55 (BUILD_MONTH_IS_JUN) ? 6 : \
56 (BUILD_MONTH_IS_JUL) ? 7 : \
57 (BUILD_MONTH_IS_AUG) ? 8 : \
58 (BUILD_MONTH_IS_SEP) ? 9 : \
59 (BUILD_MONTH_IS_OCT) ? 0 : \
60 (BUILD_MONTH_IS_NOV) ? 1 : \
61 (BUILD_MONTH_IS_DEC) ? 2 : \
62 /* error default */ 0 \
63 )
64
65#define BUILD_DAY_CH0 ((__DATE__[4] >= '0') ? (__DATE__[4] - 0x30) : 0)
66#define BUILD_DAY_CH1 (__DATE__[ 5] - 0x30)
67
68// DATE MACRO
69
70/*! \brief Here the fw version is created that coincides with the date of compilation
71
72*/
73#define __INT_DATE__ \
74 ( \
75 BUILD_YEAR_CH0 * 10000000 + \
76 BUILD_YEAR_CH1 * 1000000 + \
77 BUILD_YEAR_CH2 * 100000 + \
78 BUILD_YEAR_CH3 * 10000 + \
79 BUILD_MONTH_CH0 * 1000 + \
80 BUILD_MONTH_CH1 * 100 + \
81 BUILD_DAY_CH0 * 10 + \
82 BUILD_DAY_CH1 * 1 \
83 )
84
85#endif
86//! <!-- [date_code] -->
87
unsigned int FW_version
This is where the FW version is stored.