This is an old revision of the document!
Download Hello World Example (29 KB)
<sxh c> int main(void) { T_x_sys_system_information tSys; sint32 s32_Error; s32_Error = x_sys_init(&tSys); init ESX-3XL hardware, this function call is mandatory if (s32_Error == C_NO_ERR) { system init OK? init serial interface X_SER_01 (19200, 8N1) s32_Error = x_ser_init(X_SER_01, 19200, X_SER_MODE_8DB_NO_PARITY, 1u, 0u, NULL); init X_SER_01 TX buffer s32_Error |= x_ser_init_tx_buf(X_SER_01, 100u, 0u, NULL); } if (s32_Error == C_NO_ERR) { x_ser_write_string(X_SER_01, “Hello world!”);
</sxh>
Header file: “xll_stwtypes.h”
In the past used type names like 'word', 'long' or 'dword' are mistakeable. They can have a different meaning dependent to the platform where they are used. E.g. 'word' means 16 bits at a 16-bit controller like the Infineon C167 or a 16/32-bit controller as the Freescale 68k. At a 32-bit controller like the used TriCore TC1796 it would mean 32 bits. There 16 bits are called a 'halfword' instead. That is why STW introduced unambiguous types like 'uint16' to avoid confusions in future.
Recommended unambiguous type definitions and prefixes
STW type | Prefix | Size | Range (hexadecimal - HEX) | Range (decimal - DEC) | C equivalent |
---|---|---|---|---|---|
uint8 | u8_ | 8 bit | 0x00 .. 0xFF | 0 .. 255 | unsigned char |
sint8 | s8_ | 8 bit | 0x80 .. 0x7F | -128 .. +127 | signed char |
uint16 | u16_ | 16 bit | 0x0000 .. 0xFFFF | 0 .. 65535 | unsigned short int |
sint16 | s16_ | 16 bit | 0x8000 .. 0x7FFF | -32768 .. +32767 | signed short int |
uint32 | u32_ | 32 bit | 0x00000000 .. 0xFFFFFFFF | 0 .. 4294967295 | unsigned long int |
sint32 | s32_ | 32 bit | 0x80000000 .. 0x7FFFFFFF | -2147483648 .. +2147483647 | signed long int |
uint64 | u64_ | 64 bit | 0x0000000000000000 .. 0xFFFFFFFFFFFFFFFF | 0 .. 18446744073709551615 | unsigned long long int |
sint64 | s64_ | 64 bit | 0x8000000000000000 .. 0x7FFFFFFFFFFFFFFF | -9223372036854775808 .. +9223372036854775807 | signed long long int |
float32 | f32_ | 32 bit | [ ≈ ±2-126 .. ±2127 ] | 0, ≈ ±1.18E-38 .. ±3.4E38 (decimal places 6..7) | float (FPU: IEEE-754) single precision |
float64 | f64_ | 64 bit | [ ≈ ±2-1022 .. ±21023 ] |
15..16)|double (SW: IEEE- 754)|
float80 | f80_ | 80 bit | [ ≈ ±2-16382 .. ±216383 ] | 0, ≈ ±3.362E-4932 .. ±1.190E+4932 (decimal places 18..19) | long double (SW: IEEE-754) double extended precision |
Not recommended mistakable NATIVE type definitions (PLATFORM DEPENDENT!)