Difference between revisions of "SEGGER Simulation Integration Guide"

From SEGGER Wiki
Jump to: navigation, search
(Requirements)
(embOS & emWin Integration)
 
Line 1: Line 1:
 
This article describes how various SEGGER embedded software simulations for Windows and Visual Studio can be integrated into a single project.
 
This article describes how various SEGGER embedded software simulations for Windows and Visual Studio can be integrated into a single project.
   
= embOS & emWin Integration =
+
= embOS & emWin Trial Integration =
=== Requirements ===
+
=== Information and Requirements ===
   
 
This user guide uses:
 
This user guide uses:
 
* Microsoft Visual Studio 2010
 
* Microsoft Visual Studio 2010
* embOS Sim Visual Studio V5.8.2.0 shipment
+
* embOS Sim Visual Studio V5.8.2.0
* emWin V612 shipment
+
* emWin Simulation Trial V6.12
   
Newer Visual Studio version can be used, but might need some minor adjustments.
+
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 <span style="font-family:Courier;">HowTo_RunSimulationUnderVS2015_2017.txt</span> contained in the root directory of the emWin trial shipment.
   
=== Guide ===
+
=== Integration Steps ===
# 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 <span style="font-family:Courier;"><embOSDirectory></span> and the emWin shipment directory path as <span style="font-family:Courier;"><emWinDirectory></span>. The screenshot shows the embOS and emWin shipment extracted into a directory named <span style="font-family:Courier;">Work</span>.
+
# 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 <span style="font-family:Courier;"><embOSDirectory></span> and the emWin shipment directory path as <span style="font-family:Courier;"><emWinDirectory></span>.
  +
# The emWin simulation project shipped with emWin will be used as a start project. Open the emWin simulation project <span style="font-family:Courier;"><emWinDirectory>/SimulationTrial.sln</span> with Visual Studio 2010.
#;[[File: embOSemWinSim_WorkDirectory.png | Extracted shipments ]]
 
  +
# Add the <span style="font-family:Courier;"><emWinDirectory>/Sample/GUI_X/GUI_X_embOS.c</span> file to the project. Usually, this file replaces the <span style="font-family:Courier;">GUI_X_Win32.c</span>, however, in the emWin trial shipment, <span style="font-family:Courier;">GUI_X_Win32.c</span> is built into the emWin library. The functions in <span style="font-family:Courier;">GUI_X_embOS.c</span> will take precedence over the ones in the library.
# The emWin simulation project shipped with emWin will be used as a start project. Open the emWin simulation project <span style="font-family:Courier;"><emWinDirectory>/Start/Simulation.sln</span> with Visual Studio 2010.
 
#;[[File: embOSemWinSim_Project.png | Opened project ]]
 
# Exclude or remove the <span style="font-family:Courier;">GUI_X_Win32.c</span> from the <span style="font-family:Courier;">Config</span> directory in the project’s solution explorer. This file is only needed if the emWin simulation is running standalone using Win32 threads instead of the embOS simulation. For using the embOS simulation, add the <span style="font-family:Courier;"><emWinDirectory>/Sample/GUI_X/GUI_X_embOS.c</span> to the solution explorer.
 
#;[[File: embOSemWinSim_SolutionExplorer1.png | Solution explorer should look like this ]]
 
 
# Add following files from the embOS shipment to the solution explorer:
 
# Add following files from the embOS shipment to the solution explorer:
 
#* <span style="font-family:Courier;"><embOSDirectory>/Start/Lib/embOSDP.lib</span>
 
#* <span style="font-family:Courier;"><embOSDirectory>/Start/Lib/embOSDP.lib</span>
Line 23: Line 20:
 
#* <span style="font-family:Courier;"><embOSDirectory>/Start/BoardSupport/Simulation/Setup/OS_Error.c</span>
 
#* <span style="font-family:Courier;"><embOSDirectory>/Start/BoardSupport/Simulation/Setup/OS_Error.c</span>
 
#* <span style="font-family:Courier;"><embOSDirectory>/Start/BoardSupport/Simulation/Setup/UDP_Sim_Process.c</span>
 
#* <span style="font-family:Courier;"><embOSDirectory>/Start/BoardSupport/Simulation/Setup/UDP_Sim_Process.c</span>
  +
# Delete the <span style="font-family:Courier;"><emWinDirectory>/GUI/Include/Global.h</span> and <span style="font-family:Courier;"><emWinDirectory>/GUI/Include/SEGGER.h</span> files. These files are used by multiple SEGGER products and will be here used from the embOS shipment.
#; [[File: embOSemWinSim_SolutionExplorer2.png | Solution explorer should look like this ]]
 
#Add the path <span style="font-family:Courier;"><embOSDirectory>/Start/Inc</span> to the include directories of the project.
+
# Add all C files contained in <span style="font-family:Courier;"><embOSDirectory>/Start/BoardSupport/Simulation/SEGGER</span> to the project.
  +
# Add following paths to the include directories of the project:
#;[[File: embOSemWinSim_IncludeDirectories.png | Include directories ]]
 
  +
#* <span style="font-family:Courier;"><embOSDirectory>/Start/BoardSupport/Simulation/SEGGER</span>
# Create a new file in your Visual Studio project and name it <span style="font-family:Courier;">main.c</span>. This file will contain a <span style="font-family:Courier;">main()</span> function which will serve as the main entry point of the simulated application. The actual entry point of the emWin simulation without embOS is the <span style="font-family:Courier;">MainTask()</span> function contained in the <span style="font-family:Courier;">MainTask.c</span>. We will use the <span style="font-family:Courier;">main()</span> function to initialize embOS, create a task, start embOS and let the task call the <span style="font-family:Courier;">MainTask()</span> function, which then executes the GUI sample application. <br />Copy the following code into the “main.c” file: <source lang="C">/*********************************************************************
 
  +
#* <span style="font-family:Courier;"><embOSDirectory>/Start/Inc</span>
  +
# Set the define <span style="font-family:Courier;">_CRT_SECURE_NO_WARNINGS</span> in the preprocessor settings of the project.
  +
# Create a new file in your Visual Studio project and name it <span style="font-family:Courier;">main.c</span>. This file will contain a <span style="font-family:Courier;">main()</span> function which will serve as the main entry point of the simulated application. We will use the <span style="font-family:Courier;">main()</span> function to initialize embOS, create a task, start embOS and let the task call the <span style="font-family:Courier;">MainTask()</span> function, which is the actual function that is used in the emWin simulation to handle the graphical user interface. <br />Copy the following code into the “main.c” file: <source lang="C">/*********************************************************************
 
* (c) SEGGER Microcontroller GmbH *
 
* (c) SEGGER Microcontroller GmbH *
 
* The Embedded Experts *
 
* The Embedded Experts *
Line 56: Line 56:
   
 
/*************************** End of file ****************************/</source>
 
/*************************** End of file ****************************/</source>
# 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. After the <span style="font-family:Courier;">MainTask()</span> function has returned, the window will look like in the screenshot below.
+
# 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.
#;[[File: embOSemWinSim_Application.png | Running application ]]
 

Latest revision as of 11:40, 17 April 2020

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.