lib/iec_types.h
changeset 904 423ea3749212
parent 903 f712705bef65
child 905 31224f8cac32
equal deleted inserted replaced
903:f712705bef65 904:423ea3749212
     1 #ifndef IEC_TYPES_H
       
     2 #define IEC_TYPES_H
       
     3 
       
     4 #include <limits.h>
       
     5 #include <float.h>
       
     6 #include <stdint.h>
       
     7 
       
     8 /*********************/
       
     9 /*  IEC Types defs   */
       
    10 /*********************/
       
    11 
       
    12 typedef uint8_t  IEC_BOOL;
       
    13 
       
    14 typedef int8_t    IEC_SINT;
       
    15 typedef int16_t   IEC_INT;
       
    16 typedef int32_t   IEC_DINT;
       
    17 typedef int64_t   IEC_LINT;
       
    18 
       
    19 typedef uint8_t    IEC_USINT;
       
    20 typedef uint16_t   IEC_UINT;
       
    21 typedef uint32_t   IEC_UDINT;
       
    22 typedef uint64_t   IEC_ULINT;
       
    23 
       
    24 typedef uint8_t    IEC_BYTE;
       
    25 typedef uint16_t   IEC_WORD;
       
    26 typedef uint32_t   IEC_DWORD;
       
    27 typedef uint64_t   IEC_LWORD;
       
    28 
       
    29 typedef float    IEC_REAL;
       
    30 typedef double   IEC_LREAL;
       
    31 
       
    32 /* WARNING: When editing the definition of IEC_TIMESPEC, take note that 
       
    33  *          if the order of the two elements 'tv_sec' and 'tv_nsec' is changed, then the macros 
       
    34  *          __time_to_timespec() and __tod_to_timespec() will need to be changed accordingly.
       
    35  *          (these macros may be found in iec_std_lib.h)
       
    36  */
       
    37 typedef struct {
       
    38     long int tv_sec;            /* Seconds.  */
       
    39     long int tv_nsec;           /* Nanoseconds.  */
       
    40 } /* __attribute__((packed)) */ IEC_TIMESPEC;  /* packed is gcc specific! */
       
    41 
       
    42 typedef IEC_TIMESPEC IEC_TIME;
       
    43 typedef IEC_TIMESPEC IEC_DATE;
       
    44 typedef IEC_TIMESPEC IEC_DT;
       
    45 typedef IEC_TIMESPEC IEC_TOD;
       
    46 
       
    47 #ifndef STR_MAX_LEN
       
    48 #define STR_MAX_LEN 126
       
    49 #endif
       
    50 
       
    51 #ifndef STR_LEN_TYPE
       
    52 #define STR_LEN_TYPE int8_t
       
    53 #endif
       
    54 
       
    55 #define __INIT_REAL 0
       
    56 #define __INIT_LREAL 0
       
    57 #define __INIT_SINT 0
       
    58 #define __INIT_INT 0
       
    59 #define __INIT_DINT 0
       
    60 #define __INIT_LINT 0
       
    61 #define __INIT_USINT 0
       
    62 #define __INIT_UINT 0
       
    63 #define __INIT_UDINT 0
       
    64 #define __INIT_ULINT 0
       
    65 #define __INIT_TIME (TIME){0,0}
       
    66 #define __INIT_BOOL 0
       
    67 #define __INIT_BYTE 0
       
    68 #define __INIT_WORD 0
       
    69 #define __INIT_DWORD 0
       
    70 #define __INIT_LWORD 0
       
    71 #define __INIT_STRING (STRING){0,""}
       
    72 //#define __INIT_WSTRING
       
    73 #define __INIT_DATE (DATE){0,0}
       
    74 #define __INIT_TOD (TOD){0,0}
       
    75 #define __INIT_DT (DT){0,0}
       
    76 
       
    77 typedef STR_LEN_TYPE __strlen_t;
       
    78 typedef struct {
       
    79     __strlen_t len;
       
    80     uint8_t body[STR_MAX_LEN];
       
    81 } /* __attribute__((packed)) */ IEC_STRING;  /* packed is gcc specific! */
       
    82 
       
    83 #endif /*IEC_TYPES_H*/