SEGGER Simulation Integration Guide

From SEGGER Wiki
Jump to: navigation, search

This article describes how various SEGGER embedded software simulations for Windows and Visual Studio can be integrated into a single project.

embOS & emWin Trial Integration

Information and Requirements

This user guide uses:

  • Microsoft Visual Studio 2010
  • embOS Sim Visual Studio V5.8.2.0
  • emWin Simulation Trial V6.12

Newer Visual Studio versions can be used, but need some minor adjustments to the used project. For further information take a look into the file HowTo_RunSimulationUnderVS2015_2017.txt contained in the root directory of the emWin trial shipment.

Integration Steps

  1. Extract the embOS and emWin shipments into a directory of your choice. In the following, the embOS Sim VisualStudio shipment directory path is referred to as <embOSDirectory> and the emWin shipment directory path as <emWinDirectory>.
  2. The emWin simulation project shipped with emWin will be used as a start project. Open the emWin simulation project <emWinDirectory>/SimulationTrial.sln with Visual Studio 2010.
  3. Add the <emWinDirectory>/Sample/GUI_X/GUI_X_embOS.c file to the project. Usually, this file replaces the GUI_X_Win32.c, however, in the emWin trial shipment, GUI_X_Win32.c is built into the emWin library. The functions in GUI_X_embOS.c will take precedence over the ones in the library.
  4. Add following files from the embOS shipment to the solution explorer:
    • <embOSDirectory>/Start/Lib/embOSDP.lib
    • <embOSDirectory>/Start/BoardSupport/Simulation/Setup/RTOSInit.c
    • <embOSDirectory>/Start/BoardSupport/Simulation/Setup/OS_Error.c
    • <embOSDirectory>/Start/BoardSupport/Simulation/Setup/UDP_Sim_Process.c
  5. Delete the <emWinDirectory>/GUI/Include/Global.h and <emWinDirectory>/GUI/Include/SEGGER.h files. These files are used by multiple SEGGER products and will be here used from the embOS shipment.
  6. Add all C files contained in <embOSDirectory>/Start/BoardSupport/Simulation/SEGGER to the project.
  7. Add following paths to the include directories of the project:
    • <embOSDirectory>/Start/BoardSupport/Simulation/SEGGER
    • <embOSDirectory>/Start/Inc
  8. Set the define _CRT_SECURE_NO_WARNINGS in the preprocessor settings of the project.
  9. Create a new file in your Visual Studio project and name it main.c. This file will contain a main() function which will serve as the main entry point of the simulated application. We will use the main() function to initialize embOS, create a task, start embOS and let the task call the MainTask() function, which is the actual function that is used in the emWin simulation to handle the graphical user interface.
    Copy the following code into the “main.c” file:
    /*********************************************************************
    *                   (c) SEGGER Microcontroller GmbH                  *
    *                        The Embedded Experts                        *
    *                           www.segger.com                           *
    **********************************************************************
    */
    
    #include "RTOS.h"
    
    extern void MainTask(void);
    
    static OS_STACKPTR int Stack[128];
    static OS_TASK         TCB;
    
    static void Task(void) {
      MainTask();
      while (1) {
        OS_TASK_Delay(50);
      }
    }
    
    int main(void) {
      OS_Init();    // Initialize embOS
      OS_InitHW();  // Initialize required hardware
      OS_TASK_CREATE(&TCB, "GUI Task", 100, Task, Stack);
      OS_Start();   // Start embOS
      return 0;
    }
    
    /*************************** End of file ****************************/
    
  10. Now, your project is ready to be compiled and executed. After starting the application, a window will appear on your screen displaying the emWin sample application.