Acromag, Inc. 30765 S.Wixom Road P.O. Box 437 Wixom, Michigan 48393-7037 Phone: (248)295-0310 FAX: (248)624-9234 VxWorks Software Library Information File for IP445 Isolated Digital Output Board V3.0 10/01/01 The information in this manual is subject to change without notice. Acromag, Inc. makes no warranty of any kind with regard to this material and accompanying software, including, but not limited to , the implied warranties of merchantability and fitness for a particular purpose. Acromag, Inc. assumes no responsibility for any errors that may appear in this manual and accompanying software. Copyright 1998-2006, Acromag, Inc. Tornado, VxWorks, and the wind kernel are trademarks or registered trademarks of, and developed by Wind River Systems, Inc., Alameda, California, U.S.A. 1. Overview This "information" file contains a description of the Library programs used for the following Acromag Industrial I/O Board: IP445 Isolated Digital Output Board 2. Introduction The software for the IP445 Output board is implemented as a library of "C" functions. This will make it possible to utilize the board by simply linking the user's code with the provided library and making function calls for each "command" to be accomplished. Most of the function calls will require a few parameters or the address of a parameter block to be passed. The parameters will include the board address, data storage addresses, and status information. These functions accomplish the following tasks: - Read Status - Read Output Data Latch - Write Output Also included is a demonstration program which shows how the library routines are used. It is also a helpful program to use when first installing the board, checking it out and learning how it works. In this document, the term "port" is used to describe a block of 8 output channels numbered 0 through 7. Channels 0-7 correspond to port 0, 08-15 to port 1, 16-23 to port 2, and 24-31 to port 3. Individual output channels are referred to as "points". Points are numbered 0-7 within an individual port. 3. List of Files The library software for each Acromag I/O board is in a correspondingly named subdirectory on the supplied media. The files which make up the library for the IP445 boards are stored in the subdirectory named "IP445". There are two types of program files provided. Library program files are the files which make up the "library". Support program files contain example programs which show how to use the library programs. 1 3.1 Library Program Files The following files are included on the supplied media and make up the actual "library" software. ip445.h - include file rsts445.c - read ID rpnt445.c - read output point (from output data latch) rprt445.c - read output port (from output data latch) wpnt445.c - write an output point wprt445.c - write an output port wcntl445.c - write the control register 3.2 Support Program Files The following files are included on the supplied media. The test program demonstrates how the library programs may be used. drvr445.c - test program to demonstrate library programs. carrier.h - generic include file for carrier support. carrier.c - generic source - carrier support see infoCarrier.txt. bsp - source file that provides specific board support. 4. Software Installation It is strongly advised that the user make a backup copy of the distribution media and that the original media be stored in a safe place. The software is installed by simply copying the library files to the user's work directory and compiling and linking with the user's application program. 5. Hardware Installation For proper installation of each Acromag board the user should refer to the appropriate user's manual. 6. Usage of the Library and Support Programs The software is installed by copying the supplied files to your work directory and compiling and linking with your application program. It is recommended that the user read the User's Manual for the board and thoroughly familiarize themselves with the hardware. For a new user to become familiar with the Acromag Library it may be most "straight forward" to proceed in the following manner: (a) Become familiar with VxWorks Programmer's Guide and Tornado User's Guide. Of interest is the Chapter "Shell". (b) Build and execute the Acromag Library Demonstration as a task by following the steps outlined in the "Shell" section of the VxWorks Tornado Users Guide. 2 i) Copy the Acromag Library routines from the "Ip445" directory of the source media to a new directory under .\target\src\ip445 for VxWorks 5.5 or .\workspace\src\bsp for VxWorks 6.x. Edit the include file Ip445.h. Include or exclude ( by commenting in or out ) the definition of "BIG_ENDIAN" depending on the target architecture. ii) Copy the carrier support routines from the "carriers" directory of the source media to a new directory under .\target\src\carriers for VxWorks 5.5 or .\workspace\src\carriers for VxWorks 6.x. Selecting carrier support is accomplished by copying the specific carrier's source files to the generic names "carrier.c" and "carrier.h" in the carriers subdirectory. iii) Copy the board support files from the "bsp" directory of the source media to a new directory under .\target\src\bsp for VxWorks 5.5 or .\workspace\src\bsp for VxWorks 6.x. iv) Open a new project workspace. Select 'Create downloadable application modules for VxWorks'. Change project name to 'Ip445', change the project location name to 'Ip445' and change the workspace name to 'Ip445'. Select a toolchain that corresponds to the target under development. Next, from the Project dropdown select 'Add/Include' then 'File'. Use the navigation controls to locate the Ip445 library directory. Highlight and add all of the Ip445 'C' source files to the project. Next, from the Project dropdown select 'Add/Include' then 'File'. Use the navigation controls to locate the carriers directory. Highlight and add the generic "carrier.c" 'C' source file to the project. Now, from the Project dropdown select 'Add/Include' then 'File'. Use the navigation controls to locate the bsp directory. Highlight and add one board support 'C' source file to the project. To add files to a VxWorks 6.x project use 'File->Import->File system' then browse to the file location. Also generate a 'include search path' like '$(WIND_HOME)/workspace/src/carriers' to the location of the 'carrier.h' include file. v) From the Build dropdown select 'Build All'. vi) From the 'Files' tab of the Project workspace right click and select Download Ip445.out. vii) Launch the VxWorks shell, use the lkup "drvr445" command to locate the entry point of the demonstration program on the target. viii) Use the sp 0xZZZZ command ( where ZZZZ is the entry point) to spawn the Acromag Demonstration program. ix) The Acromag Demonstration program menu should appear on the target processor's console terminal. 3 The following menu is displayed: IP445 Library Demonstration Version A 1. Exit this Program 2. Set Carrier Base Address 3. Set IP Slot Letter 4. Read ID ROM Command 5. Read Output Point (from output data latch) 6. Read Output Port (from output data latch) 7. Write Output Point 8. Write Output Port 9. Perform a Software Reset Select: To perform digital output and readback, follow this sequence of main menu selections: Select 2: To set the carrier base address. Select 3: To set the IP module base address. Select 4: To read the board's ID ROM Select 5 or 6: To read data from the output port data latch. Select 7 or 8: To write output port data. To perform a software reset select option 9. 6.1 Explanation of Main Demonstration Menu Following is an explanation of each menu selection: 1. Exit this Program This selection causes execution to be returned to the shell. 2. Set Carrier Base Address This selection allows the user to set or change the address of the carrier board. 3. Set IP Slot Letter This selection allows the user to set or change the slot letter of the IP module being used. The value entered here will automatically be entered in the Status Block structure. 4. Read ID ROM Command This menu selection will call the rsts445() function and pass a pointer which points to the Status Block structure. The ID ROM information is read from the board and written into this structure by the rsts445() function. The information is then displayed by the example program. 4 5. Read Output Point (from output data latch) This command is used to read a single output point in any port. The user is prompted to enter the port number (0 to 3) and then the point number (0 to 7). The rpnt445() function is called and the result is displayed. 6. Read Output Port (from output data latch) This command is used to read a port. The user is prompted to enter the port number (0 to 3). The rprt445() library function is called and the result is displayed. 7. Write Output Point This command is used to write a single output point in any port. The user is prompted to enter the port number (0 to 3), the point number (0 to 7), and the value to write (0 or 1). The wpnt445() function is called. 8. Write Output Port This command is used to write a port. The user is prompted to enter the port number (0 to 3) and the value to write (0 to FF hex). The wprt445() function is called. 9. Perform a Software Reset This command is used to send a software reset to the IP445. It does so by calling the function wcntl445() which is used to write the control register on the IP445. A 1 is written to the least significant bit of the IP445 control register to issue a software reset. 7. Description of Library Programs. Following are descriptions of the routines and files which make up the library. ip445.h - Contains definitions and structures. rsts445.c - This module is used to perform the "read ID ROM" function. A pointer to the Status Block is passed to this routine. The routine uses a pointer within the Status Block to reference registers on the board and transfers the status information from the board to the Status Block. The ID space is assumed to start at the base address plus 128 (decimal). calling sequence: rsts445(ptr); where: ptr - (structure pointer) This is a pointer to the Status Block structure. 5 rpnt445.c - This module is used to perform the "Read Output Point" function for the IP445 board. A pointer to the board memory map structure, the port number, and the point number are passed to this routine. This information is used to read the output point value from the board. calling sequence: status = rpnt445(map_ptr,port,point); where: status - (long) Returned value of the output port. map_ptr - (structure pointer) Pointer to the board memory map structure. port - (unsigned) Target output port number. point - (unsigned) Target output point number. rprt445.c - This module is used to perform the "Read Output Port" function for the IP445 board. A pointer to the board memory map structure and the port number are passed to this routine. This information is used to read the output port data value from the board. calling sequence: status = rprt445(map_ptr,port); where: status - (long) Returned value of the output port. map_ptr - (structure pointer) Pointer to the board memory map structure. port - (unsigned) Target output port number. wpnt445.c - This module is used to perform the "Write Output Point" function for the IP445 board. A pointer to the board memory map structure, the port number, the point number and output point value to write are passed to this routine. This information is used to write the output point value to the board. calling sequence: status = wpnt445(map_ptr,port,point,value); where: status - (long) Returned error status of the function. map_ptr - (structure pointer) Pointer to the board memory map structure. port - (unsigned) Target output port number. point - (unsigned) Target output point number. value - (byte) Value to write to output point. 6 wprt445.c - This module is used to perform the "Write Output Port" function for the IP445 board. A pointer to the board memory map structure, the output port number, and port value to write are passed to this routine. This information is used to write the output port value to the board. calling sequence: status = wprt445(map_ptr,port,value); where: status - (long) Returned error status of the function. map_ptr - (structure pointer) Pointer to the board memory map structure. port - (unsigned) Target output port number. value - (byte) Value to write to output port. wcntl445.c - This module is used to perform the "Perform Software Reset" function for the IP445. A pointer to the board memory map structure, and the value to be written to the control register are passed to this routine. This information is used to write the control register on the IP445. calling sequence: status = wcntl445(map_ptr, value); where: status - (long) Returned error status of the function. map_ptr - (structure pointer) Pointer to the board memory map structure. value - (byte) Value to write to the control register. 8. Description of Support Programs Following is a description of the support files and program modules which provide an example of the usage of the library programs. bsp - Source files in the board support directory provide an interface to specific VxWorks board support package. drvr445.c - This is a program which demonstrates the usage of the library modules. This program is menu driven and allows the user to become familiar with the IP445 board and the library software. The user may, through menu selections, read from and write to the board. carrier.c - This file provides carrier support routines. Selecting carrier support is accomplished by copying the specific carrier's source files to the generic names "carrier.c" and "carrier.h" in the carriers subdirectory. 7