IAR visualSTATE® Version 5 IAR visualSTATE Sample Code IAR visualSTATE is supplied with a set of sample code files that you can use as a source of reference in your development projects. The sample code files can be opened via the Examples directory of the visualSTATE software and comprise the following: ● Sample code for the AVSystem example included with the visualSTATE software. ● Sample code for a (simple) LED application example. ● Sample code for implementing TCP/IP RealLink communication in a MFC/C++ application. ● Generic sample code for event queue handling. This document briefly describes the sample code files and how to use them. AVSystemSampleCode This sample code can be used if you want to test a small example of visualSTATE generated code, as follows: 1 Launch the Navigator. Open the visualSTATE workspace AVSystem.vnw (found in the Examples\AVSystem directory) and generate code for the AVSystem Project. 2 Launch your integrated development environment (IDE), for example IAR Embedded Workbench, create a new project, and add the following files to the project: a The visualSTATE generated code, by default CD_Deck.c and CD_DeckData.c in the AVSystem directory. b The visualSTATE Basic API file SEMLibB.c in the visualSTATE installation directory. c Your manually written code for: i) visualSTATE mainloop: mainloop.c in the AVSystemSampleCode directory. ii) Event queue handling: advancedEventHandler.c in the GenericSampleCode directory. 1 IAR visualSTATE® Version 5 Sample Code Description iii) Input device driver (event processing). This code is contained in the mainloop file. iv) Output device driver (action functions): actionFunctions.c in the AVSystemSampleCode directory. Note: The files actionFunctions.c and mainloop.c contain calls that use stdin and stdout. If these streams do not exist in your target, replace the calls with appropriate code. 3 Configure the compiler include path, and make sure that your compiler can find the required header files in all the above-mentioned directories. 4 Compile, link, and run the application. LEDSampleCode This sample code contains visualSTATE files for an LED application, and a main loop source file targeted for an Atmel AVR Mega103 microcontroller (mainloop.c). The main loop file contains an implementation for a main loop using the visualSTATE Basic API. The code uses a static queue for storing events. The functions for interfacing to the queue are described in the sample code file simpleEventHandler.h. To complete the application: 1 Launch the Navigator. Open the visualSTATE workspace MY_NavWorkspace.vnw (found in the Examples\SampleCode\LEDSampleCode directory) and generate code for the MY_Project Project. 2 Launch your integrated development environment (IDE), for example IAR Embedded Workbench, create a new project, and add the following files to the project: a The visualSTATE generated code, by default MY_System.c and MY_SystemData.c in the LEDSampleCode directory. b The visualSTATE Basic API file SEMLibB.c in the visualSTATE installation directory. c Your manually written code for: i) visualSTATE mainloop: mainloop.c in the LEDSampleCode directory. ii) Event queue handling: simpleEventHandler.c in the GenericSampleCode directory. iii) Input device driver (event processing): Inputs_to_Events.c in the LEDSampleCode directory. 2 IAR visualSTATE® Version 5 Sample Code Description iv) Output device driver (action functions): actionFunctions.c in the LEDSampleCode directory. Note: The main loop file contains calls that use stdin and stdout. If these streams do not exist in your target, replace the calls with appropriate code. 3 Configure the compiler include path, and make sure that your compiler can find the required header files in all the above-mentioned directories. 4 Compile, link, download, and run the application. Figure 1 shows the files required for the implementation. API files User-written code Coder-generated files SEMLibB.h eventHandler.h MY_SystemAction.h VSTypes.h ledsys_drivers.h MY_System.h simpleEventHandler.h MY_SystemData.h simpleEventHandler.c SEMBDef.h actionFunctions.c SEMTypes.h Inputs_to_Events.c MY_System.c main.c MY_SystemData.c SEMLibB.c COMPILE & LINK Target Executable Figure 1: Files required for LED application RLTCPIPSampleCode The file RL_TCPIP.cpp is intended to use in a target that is to connect to the Validator via RealLink. The file uses the Windows Sockets API to implement the TCP/IP communication on the target side and also uses, to some extend, the Microsoft MFC framework. 3 IAR visualSTATE® Version 5 Sample Code Description As the file uses the Berkeley function set to the widest possible degree, it will probably be relatively easy to port the RL_TCPIP.cpp file to other development tools and platforms. To use the file: ● ● include the file in your project. call the function CommunicationInit() in the thread that handles your visualSTATE system. The function should be called before entering the main loop. Your application will contain a thread that waits for a connection to be established from the Validator. GenericSampleCode This code is intended for your inspiration if you want to apply event queue handling in your application. The code shows the implementation of a simple and an advanced event queue. Files required for implementation of a simple event queue: ● ● ● eventHandler.h simpleEventHandler.c simpleEventHandler.h Files required for implementation of an advanced event queue: ● ● ● eventHandler.h advancedEventHandler.c advancedEventHandler.h For detailed information about the use of these files, see the descriptions in the files. COPYRIGHT NOTICE © Copyright 2003 IAR Systems. All rights reserved. No part of this document may be reproduced without the prior written consent of IAR Systems. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. 4 IAR visualSTATE® Version 5 Sample Code Description TRADEMARKS IAR visualSTATE is a registered trademark owned by IAR Systems. IAR, and IAR Embedded Workbench are trademarks owned by IAR Systems. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE Second edition: August 2003. This document applies to version 5.0 of the IAR visualSTATE software. Part number: VS50SC-2. 5
© Copyright 2024