author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 05 Apr 2024 13:23:53 +0200 | |
changeset 1103 | f3c6c938d5ff |
parent 1100 | f7cc4f6ce756 |
permissions | -rwxr-xr-x |
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
59
diff
changeset
|
1 |
#ifndef IEC_TYPES_H |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
59
diff
changeset
|
2 |
#define IEC_TYPES_H |
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
59
diff
changeset
|
3 |
|
59
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
4 |
#include <limits.h> |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
5 |
#include <float.h> |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
6 |
#include <stdint.h> |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
7 |
|
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
8 |
/*********************/ |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
9 |
/* IEC Types defs */ |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
10 |
/*********************/ |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
11 |
|
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
12 |
typedef uint8_t IEC_BOOL; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
13 |
|
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
14 |
typedef int8_t IEC_SINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
15 |
typedef int16_t IEC_INT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
16 |
typedef int32_t IEC_DINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
17 |
typedef int64_t IEC_LINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
18 |
|
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
19 |
typedef uint8_t IEC_USINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
20 |
typedef uint16_t IEC_UINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
21 |
typedef uint32_t IEC_UDINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
22 |
typedef uint64_t IEC_ULINT; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
23 |
|
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
24 |
typedef uint8_t IEC_BYTE; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
25 |
typedef uint16_t IEC_WORD; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
26 |
typedef uint32_t IEC_DWORD; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
27 |
typedef uint64_t IEC_LWORD; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
28 |
|
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
29 |
typedef float IEC_REAL; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
30 |
typedef double IEC_LREAL; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
31 |
|
900
1e749c7b70f8
Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents:
818
diff
changeset
|
32 |
/* WARNING: When editing the definition of IEC_TIMESPEC, take note that |
1e749c7b70f8
Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents:
818
diff
changeset
|
33 |
* if the order of the two elements 'tv_sec' and 'tv_nsec' is changed, then the macros |
1e749c7b70f8
Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents:
818
diff
changeset
|
34 |
* __time_to_timespec() and __tod_to_timespec() will need to be changed accordingly. |
1e749c7b70f8
Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents:
818
diff
changeset
|
35 |
* (these macros may be found in iec_std_lib.h) |
1e749c7b70f8
Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents:
818
diff
changeset
|
36 |
*/ |
254 | 37 |
typedef struct { |
59
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
38 |
long int tv_sec; /* Seconds. */ |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
39 |
long int tv_nsec; /* Nanoseconds. */ |
742 | 40 |
} /* __attribute__((packed)) */ IEC_TIMESPEC; /* packed is gcc specific! */ |
59
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
41 |
|
254 | 42 |
typedef IEC_TIMESPEC IEC_TIME; |
43 |
typedef IEC_TIMESPEC IEC_DATE; |
|
44 |
typedef IEC_TIMESPEC IEC_DT; |
|
45 |
typedef IEC_TIMESPEC IEC_TOD; |
|
59
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
46 |
|
161
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
47 |
#ifndef STR_MAX_LEN |
170 | 48 |
#define STR_MAX_LEN 126 |
161
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
49 |
#endif |
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
50 |
|
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
51 |
#ifndef STR_LEN_TYPE |
1100
f7cc4f6ce756
Change STRING length from int8_t to uint8_t.
Edouard Tisserant <edouard@beremiz.fr>
parents:
904
diff
changeset
|
52 |
#define STR_LEN_TYPE uint8_t |
161
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
53 |
#endif |
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
54 |
|
818
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
55 |
#define __INIT_REAL 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
56 |
#define __INIT_LREAL 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
57 |
#define __INIT_SINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
58 |
#define __INIT_INT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
59 |
#define __INIT_DINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
60 |
#define __INIT_LINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
61 |
#define __INIT_USINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
62 |
#define __INIT_UINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
63 |
#define __INIT_UDINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
64 |
#define __INIT_ULINT 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
65 |
#define __INIT_TIME (TIME){0,0} |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
66 |
#define __INIT_BOOL 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
67 |
#define __INIT_BYTE 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
68 |
#define __INIT_WORD 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
69 |
#define __INIT_DWORD 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
70 |
#define __INIT_LWORD 0 |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
71 |
#define __INIT_STRING (STRING){0,""} |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
72 |
//#define __INIT_WSTRING |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
73 |
#define __INIT_DATE (DATE){0,0} |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
74 |
#define __INIT_TOD (TOD){0,0} |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
75 |
#define __INIT_DT (DT){0,0} |
2a3f34967cae
Moved __INIT_* defines within type definition headers files
Edouard Tisserant
parents:
742
diff
changeset
|
76 |
|
161
a27957e13d42
STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents:
137
diff
changeset
|
77 |
typedef STR_LEN_TYPE __strlen_t; |
59
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
78 |
typedef struct { |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
79 |
__strlen_t len; |
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
80 |
uint8_t body[STR_MAX_LEN]; |
742 | 81 |
} /* __attribute__((packed)) */ IEC_STRING; /* packed is gcc specific! */ |
59
37ba6f9e51e2
Splitted type declaration out of iec std lib, to avoid DWORD, BOOL, TIME ,... clash with windows.h
etisserant
parents:
diff
changeset
|
82 |
|
137
9ceda59abd27
Re-organized types headers, to ease debug code generation
etisserant
parents:
59
diff
changeset
|
83 |
#endif /*IEC_TYPES_H*/ |