This shows you the differences between two versions of the page.
robots:hako:firmware:welcome [2012/09/26 18:44] karina [Mainboard - Software - Notation - Types and prefixes] |
robots:hako:firmware:welcome [2021/08/14 04:21] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Hako Firmware ====== | ||
- | |||
- | ===== ESX 3XL ===== | ||
- | ==== Hallo World Example ==== | ||
- | Download this as pfd: {{: | ||
- | |||
- | |||
- | **Step 1: Install the GNU toolchain**\\ | ||
- | Install the STW TriCore Software Tools by following the wizards instructions. This will install among other things the GNU compiler for TriCore and the Code:: | ||
- | |||
- | **Step 2: Open the ESX-3XL "Hello world!" | ||
- | Start Code:: | ||
- | |||
- | <sxh c> | ||
- | int main(void) { | ||
- | T_x_sys_system_information tSys; | ||
- | sint32 s32_Error; | ||
- | |||
- | s32_Error = x_sys_init(& | ||
- | if (s32_Error == C_NO_ERR) | ||
- | { | ||
- | // init serial interface X_SER_01 (19200, 8N1) | ||
- | s32_Error = x_ser_init(X_SER_01, | ||
- | // init X_SER_01 TX buffer | ||
- | s32_Error |= x_ser_init_tx_buf(X_SER_01, | ||
- | } | ||
- | |||
- | if (s32_Error == C_NO_ERR) | ||
- | { | ||
- | x_ser_write_string(X_SER_01, | ||
- | x_sys_set_beeper(1000); | ||
- | x_sys_delay_us(200000); | ||
- | } else { | ||
- | x_sys_set_beeper(200); | ||
- | x_sys_delay_us(1000000); | ||
- | } | ||
- | x_sys_set_beeper(X_OFF); | ||
- | |||
- | while (true) { // main loop... | ||
- | led1_change_color(); | ||
- | x_sys_delay_us(10000); | ||
- | } | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | The program starts with a call of x_sys_init, the hardware initialization of the ESX-3XL main board. Each ESX-3XL application should start with this function call. Further hardware initialization may follow when a ESX-3XL controller is equipped with expansion boards. This example program use the serial interface as output and therefore the interface must be initialized and a TX buffer must be prepared. If anything is OK it writes the "Hello world!" | ||
- | Afterwards it changes the color of LED1 in the main infinite loop. | ||
- | |||
- | **Step 3: Build the project for RAM debugging**\\ | ||
- | To link the application into RAM space we have to use the ' | ||
- | Check the setting for the linker command inside " | ||
- | Select the build target ' | ||
- | **Debugging the executable in RAM:**\\ | ||
- | Be sure the debugger hardware is connected and the power supply for the debugger as well as for the ESX-3XL is switched on. | ||
- | Make sure that the **Debug** build target is active in Code:: | ||
- | |||
- | **Step 4: Build the project to be stored permanently into flash ROM**\\ | ||
- | To link the application into flash ROM space we have to use the ' | ||
- | Check the setting for the linker command inside " | ||
- | Select the build target ' | ||
- | Additionally the application will be converted to a so-called **HEX file** " | ||
- | **Debugging the executable in flash ROM:**\\ | ||
- | Be sure the debugger hardware is still connected and the power supply for the debugger as well as for the ESX-3XL is switched on. Make sure that the **Release** build target is active in Code:: | ||
- | Now you can step through your program, set breakpoints, | ||
- | |||
- | **See also:** | ||
- | |Quick start: "Hello world!" | ||
- | |Floating point arithmetic | | ||
- | |Interrupt handler and callback functions | | ||
- | |Hardware traps | | ||
- | |Stack size analysis| | ||
- | ==== Mainboard - Software - Notation - Types and prefixes ==== | ||
- | |||
- | * Unordered List ItemTypes/ | ||
- | * Typedef prefixes | ||
- | * Definition prefixes | ||
- | * Modifier refixes | ||
- | * Validity prefixes | ||
- | * [[robots: | ||
- | |||
- | |||
- | Header file: " | ||
- | |||
- | In the past used type names like ' | ||
- | E.g. ' | ||
- | That is why STW introduced unambiguous types like ' | ||
- | |||
- | **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< | ||
- | |float64|f64_|64 bit|[ ≈ ±2< | ||
- | |float80|f80_|80 bit|[ ≈ ±2< | ||
- | |||
- | |||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ^STW type^Prefix^Size^Range (hexadecimal - HEX)^Range (decimal - DEC)^C equivalent^ | ||
- | |charn|cn_|8 bit |0x80 .. 0x7F|-128 .. +127|char| | ||
- | |uintn|un_|32 bit| 0x00000000 .. 0xFFFFFFFF|0 .. 4294967295|unsigned int| | ||
- | |sintn|sn_|32 bit| 0x80000000 .. 0x7FFFFFFF|-2147483648 .. +2147483647| signed int| | ||
- | |||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | ^STW type^Prefix^Size^Range (hexadecimal - HEX)^Range (decimal - DEC)^C equivalent^ | ||
- | |boolean|q_|C: | ||
- | |int8 |i8_ |8 bit |0x80 .. 0x7F | -128 .. +127|(signed) char| | ||
- | |int16|i16_|16 bit|0x8000 .. 0x7FFF|-32768 .. +32767|(signed) short int| | ||
- | |int32|i32_|32 bit|0x80000000 .. 0x7FFFFFFF|-2147483648 .. +2147483647|(signed) long int| | ||
- | |int64|i64_|64 bit|0x8000000000000000 .. 0x7FFFFFFFFFFFFFFF|-9223372036854775808 .. +9223372036854775807|(signed) long long int| | ||
- | |||
- | |||
- | **Type definition (typedef) prefixes** | ||
- | ^Prefix^Example^Description^ | ||
- | |T_|typedef struct { ... } T_Struct; | ||
- | |U_|typedef union { ... } U_Union; | ||
- | |E_|typedef enum { ... } E_Enum; | ||
- | |PR_|typedef void (*PR_Function)( const uint8 ou8_Parameter );| type definition for function pointer| | ||
- | |||
- | **Definition prefixes** | ||
- | ^Prefix^Example^Description^ | ||
- | |t_|T_Struct t_Struct;| structure (or bitfield)| | ||
- | |u_|U_Union u_Union;| union | | ||
- | |e_|E_Enum e_Enum;| enum | | ||
- | |pr_|PR_Function pr_FunctionPointer; | ||
- | |pv_|void *pv_VoidPointer; | ||
- | |s_|charn s_Text[3]=" | ||
- | |||
- | |||
- | |||
- | **Modifier prefixes** | ||
- | ^Prefix^Example^Description^ | ||
- | |p<type prefix> | ||
- | |a<type prefix> | ||
- | |||
- | **Area of validity prefixes** | ||
- | ^Prefix^Example^Description^ | ||
- | |g<type prefix>| uint8 gu8_Global; |global| | ||
- | |m<type prefix>| static uint8 mu8_ModuleGlobal; | ||
- | |h<type prefix>| static uint8 hu8_Example; | ||
- | |o<type prefix>| void Callback( const uint8 ou8_Parameter ); |function parameter (operand)| | ||
- | |||
- | **Examples** | ||
- | <sxh c> | ||
- | //Prefix examples | ||
- | /* local variable sint16 */ | ||
- | sint16 s16_VariableName; | ||
- | |||
- | /* function internal array of pointers to uint8 with MAX_MESSAGES elements */ | ||
- | uint8 *apu8_Messages[MAX_MESSAGES]; | ||
- | |||
- | /* Module global variable of type uint32 */ | ||
- | static uint32 mu32_Index; | ||
- | |||
- | /* typedef for structure */ | ||
- | typedef struct | ||
- | |||
- | { | ||
- | uint8 u8_Element1; | ||
- | uint32 *pu32_Element2; | ||
- | } T_StructType; | ||
- | |||
- | /* modul globale pointer to structure defined by typdedef */ | ||
- | static T_StructType *mpt_PointerToMyStructType; | ||
- | |||
- | /* function internal used structure */ | ||
- | T_StructType t_MyStructObject; | ||
- | |||
- | /* module global structure variable */ | ||
- | static T_StructType mt_MyStruct; | ||
- | |||
- | /* typedef for function pointer for a module ' | ||
- | typedef void (*PR_DIN_CallBack)(const uint8 ou8_Parameter); | ||
- | |||
- | /* global function pointer in module ' | ||
- | PR_DIN_CallBack gpr_DIN_CallBack; | ||
- | </ | ||
- | |||
- | |||