TDRV002-SW-82. Linux Device Driver. Multi-Channel Serial Interface Version 1.8.x. User Manual. Issue November 2017

Similar documents
TPMC860-SW-82. Linux Device Driver. 4 Channel Isolated Serial Interface RS232 Version 1.4.x. User Manual. Issue 1.4.

TPMC917-SW-82. Linux Device Driver. User Manual. The Embedded I/O Company. 4 MB SRAM with Battery Backup and 4 Channel Serial Interface Version 1.0.

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC

TCP866-SW-82. Linux Device Driver. User Manual. The Embedded I/O Company. 8 Channel Serial PMC Version 1.0.x. Issue 1.

TIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013

TDRV011-SW-82. Linux Device Driver. Extended CAN Bus Version 1.0.x. User Manual. Issue April 2018

CARRIER-SW-82. Linux Device Driver. IPAC Carrier Version 2.2.x. User Manual. Issue November 2017

TPMC680-SW-82. Linux Device Driver. 64 Digital Input/Output Version 1.1.x. User Manual. Issue April 2010

TDRV006-SW-42. VxWorks Device Driver. 64 Digital Inputs/Outputs (Bit I/O) Version 4.0.x. User Manual. Issue December 2017

TDRV010-SW-95. QNX6 - Neutrino Device Driver. Isolated 2x CAN Bus. Version 1.0.x. User Manual. Issue September 2016

TPMC810-SW-82. Linux Device Driver. User Manual. The Embedded I/O Company. Isolated 2x CAN Bus Version 1.2.x. Issue 1.2.

TIP866-SW-95. QNX-Neutrino Device Driver. 8 Channel Serial Interface IP. Version 2.1.x. User Manual. Issue October 2009

TPMC901-SW-95. QNX4 - Neutrino Device Driver. User Manual. The Embedded I/O Company. 6/4/2 Channel Extended CAN-Bus PMC

TPMC500-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. 32 Channel 12 Bit ADC. Version 2.0.x. Issue 2.0.

TIP700-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. Digital Output 24V DC. Version 2.0.x. Issue June 2008.

TPMC821-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. INTERBUS Master G4 PMC. Version 1.4. Issue 1.

TIP570-SW-95 QNX-Neutrino Device Driver TIP570 16/8 Channel 12 Bit ADC and 8 Channel 12 Bit DAC on SBS PCI40 Carrier

TPMC868-SW-42. VxWorks Device Driver. 16 Channel Serial PMC. Version 2.1.x. User Manual. Issue December 2011

TIP114-SW-72. LynxOS Device Driver. User Manual. The Embedded I/O Company. 10 Channel Absolute Encoder Interface (SSI) Version 1.0.

TIP120-SW-42. VxWorks Device Driver. Motion Controller with Incremental Encoder Interface. Version 2.1.x. User Manual. Issue 2.1.

TIP670-SW-95. QNX-Neutrino Device Driver. User Manual. The Embedded I/O Company. Digital I/O. Version 1.0.x. Issue August 2008.

TPMC Channel Isolated Serial Interface RS232. Version 1.0. User Manual. Issue August 2017

TPMC550-SW-12 OS-9 for PPC Device Driver 8 (4) Channels Isolated 12-bit D/A

TPMC815-SW-72. LynxOS Device Driver. User Manual. The Embedded I/O Company. ARCNET Controller. Version 1.0.x. Issue 1.0 May 2004

TPMC Channel Isolated Serial Interface RS422/RS485. Version 1.0. User Manual. Issue July 2009

TIP610-SW-95 QNX-Neutrino Device Driver TIP610 16/20 Channel Digital I/O on SBS PCI40 Carrier

TCP Channel Serial Interface RS232 / RS422 cpci Module. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.

TPMC Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

TPMC851-SW-42. VxWorks Device Driver. Multifunction I/O (16 bit ADC/DAC, TTL I/O, Counter) Version 2.0.x. User Manual. Issue 2.0.

TPMC310. Conduction Cooled PMC Isolated 2 x CAN Bus. Version 1.1. User Manual. Issue June 2014

CARRIER-SW-42. VxWorks Device Driver. IPAC Carrier. Version 4.2.x. User Manual. Issue July 2018

TXMC885. Four Channel 10/100/1000 Mbit/s Ethernet Adapter. Version 1.0. User Manual. Issue October 2011

TPMC810. Isolated 2x CAN Bus. Version 1.1. User Manual. Issue June 2009

TCP Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

TPMC Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

OPTO32A 24 Input Bit, 8 Output Bit Optical Isolator Board

TPMC Channel Motion Control. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.3 March 2003 D

TPMC815 ARCNET PMC. User Manual. The Embedded I/O Company. Version 2.0. Issue 1.2 November 2002 D

TPMC816. Two Independent Channels Extended CAN Bus PMC Module. Version 2.2. User Manual. Issue August 2014

Artisan Technology Group is your source for quality new and certified-used/pre-owned equipment

PCI, PCIe, cpci, and PC104+ Plus Modules

TPMC Digital Inputs/Outputs (Bit I/O) Version 2.0. User Manual. Issue February 2014

Low Profile 32-Bit PCI 4 Port Serial Card (16C FIFO)

PCI Express 4-Port Industrial Serial I/O Cards

Release Notes CCURDSCC (WC-AD3224-DS)

TIP SERCOS IP with 2 Encoder Interfaces. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.3 September 2006 D

TPMC /8 Digital Inputs (24V) 16/8 Digital Outputs (24V, 0.5A) Version 3.0. User Manual. Issue June 2014

TPCE260. PCI Express PMC Carrier. Version 1.0. User Manual. Issue August 2014

TIP550. Optically Isolated 8/4 Channel 12-bit D/A. Version 1.2. User Manual. Issue October 2009

Typical modules include interfaces to ARINC-429, ARINC-561, ARINC-629 and RS-422. Each module supports up to 8 Rx or 8Tx channels.

TIP815. ARCNET Controller. Version 1.0. User Manual. Issue September 2009

spwr_base & spwr_chan

Application Note AN-225

DYNAMIC ENGINEERING 150 DuBois, Suite C Santa Cruz, CA (831) Fax (831) Est

User Manual VScom PCI Cards VScom Industrial Card

TPMC376. Conduction Cooled 4 Channel RS232/RS422/RS485 Programmable Serial Interface. Version 1.0. User Manual. Issue September 2010 D

Release Notes CCURDSCC (WC-AD3224-DS)

DYNAMIC ENGINEERING 150 DuBois St. Suite C, Santa Cruz, CA Fax Est.

ICS-121. VxWORKS DEVICE DRIVER MANUAL

Korenix JetCard Series Multiport Serial Card/Ethernet Switch Card User s Manual

Xtreme/104. PC/104 Serial Communications. User Manual

TIP120. Motion Controller with Incremental Encoder Interface. Version 1.0. User Manual. Issue August 2014

PCI, PCIe, mpcie, cpci, and PC104+ Plus Modules

PMC and XMC Modules. Data Sheets of TEWS PMC Modules and Carrier

TPMC500. Optically Isolated 32 Channel 12 Bit ADC. Version 1.1. User Manual. Issue January 2014

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

CPCI-ASIO4 CAN - RS-232, RS-422, RS-485

sllin TTY discipline for UART-LIN device implementation P. Píša, R. Lisový, M. Sojka Czech Technical University in Prague DRAFT

TRP-C08. USB to RS232/422/485 Isolated Converter. User s Manual. Printed Sep.2014 Rev 1.4

PCI Express 16-Port Serial I/O Cards

TPMC x ADC, 16x/0x DAC and 8x Digital I/O. Version 1.0. User Manual. Issue May 2018

TDRV009-SW-42. VxWorks Device Driver. High Speed Synch/Asynch Serial Interface. Version 4.0.x. User Manual. Issue 4.0.

TXMC Channel RS232/RS422/RS485 Programmable Serial Interface. Version 1.0. User Manual. Issue July 2015

CLK+ CLK- Expansion Interface TX+ TX-

DYNAMIC ENGINEERING 435 Park Dr., Ben Lomond, Calif Fax Est

Janus-MM Basic CAN Driver For Linux 2.6.xx and Windows XP. User Manual Revision A

DM6420 Driver for Linux User s Manual Version 2.01.xx

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

TIP111. Motion Controller with Absolute Encoder Interface (SSI) User Manual. The Embedded I/O Company. Version 1.1. Issue 1.4 September 2005 D

DN120 DeviceNet Gateway User Manual

24DSI32 24DSI12 24-bit, 32 Channel Delta-Sigma A/D Boards

ControlLogix Multi-Vendor Interface Module DH-485 API

DATA COMMUNICATIONS APPLICATION NOTE DAN132

CPCI-HPDI32ALT High-speed 64 Bit Parallel Digital I/O PCI Board 100 to 400 Mbytes/s Cable I/O with PCI-DMA engine

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

CSC209 Review. Yeah! We made it!

MultiCom/MV 1.0. Comtrol RocketPort Guide. Copyright , Viewpoint Systems, Inc. All Rights Reserved

Advcan QNX Driver User Manual V1.02

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

DYNAMIC ENGINEERING 435 Park Dr., Ben Lomond, Calif Fax Est

Linux Kernel Modules & Device Drivers April 9, 2012

DYNAMIC ENGINEERING. 150 DuBois, Suite C Santa Cruz, CA (831) Fax (831) Est.

CS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014

82V391x / 8V893xx WAN PLL Device Families Device Driver User s Guide

DIO-BM(PCI/C-PCI)Linux/RT GPH-2X72C. Bus Master Digital Input/Output Board Driver Software for Linux/RTLinux. Help for Linux.

AMC data sheet. PMC Module with four CAN bus Nodes ARINC825 compliant for Testing & Simulation of Avionic CAN bus Systems

COSC Operating Systems Design, Fall Lecture Note: Unnamed Pipe and Shared Memory. Unnamed Pipes

UART Application Kit for Digi Embedded Linux User's Manual

Transcription:

The Embedded I/O Company TDRV002-SW-82 Linux Device Driver Multi-Channel Serial Interface Version 1.8.x User Manual Issue 1.8.3 November 2017 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek, Germany Phone: +49 (0) 4101 4058 0 Fax: +49 (0) 4101 4058 19 e-mail: info@tews.com www.tews.com

TDRV002-SW-82 Linux Device Driver Multi-Channel Serial Interface Supported Modules: TPMC37x TPMC46x TPMC47x TXMC37x TXMC46x TCP46x TCP47x This document contains information, which is proprietary to TEWS TECHNOLOGIES GmbH. Any reproduction without written permission is forbidden. TEWS TECHNOLOGIES GmbH has made any effort to ensure that this manual is accurate and complete. However TEWS TECHNOLOGIES GmbH reserves the right to change the product described in this document at any time without notice. TEWS TECHNOLOGIES GmbH is not liable for any damage arising out of the application or use of the device described herein. 2005-2017 by TEWS TECHNOLOGIES GmbH TDRV002-SW-82 - Linux Device Driver Page 2 of 26

Issue Description Date 1.0.0 First Issue February 21, 2005 1.1.0 Built-In-Self-Test (BIST) added March 11, 2005 1.1.1 depmod for driver installation added October 13, 2005 1.2.0 New module support and transceiver programming IOCTL added. ChangeLog.txt release history file added, file list modified. July 26, 2006 1.2.1 New Address TEWS LLC November 7, 2006 1.3.0 New IOCTL command TDRV002_IOCT_SPEED added January 10, 2007 1.4.0 New IOCTL command TDRV002_IOCQ_GET_SPEED, New IOCTL command TDRV002_IOCQ_GET_INFO, example file added to file list 1.4.1 TDRV002 device naming note added Source file archive extraction command line added March 01, 2007 June 20, 2007 1.4.2 File list changed, include path moved September 26, 2007 1.4.3 Address TEWS LLC removed, general Revision April 27, 2010 1.4.4 Chapter Installation modified January 24, 2011 1.4.5 New supported boards added to list August 1, 2011 1.5.0 New file list, diagnostic chapter modified December 20, 2011 1.6.0 New IOCTL command TDRV002_IOCT_SET_FIFOTRIG January 20, 2012 1.7.0 IOCTL command TDRV002_IOCQ_GET_INFO extended September 20, 2012 1.8.0 New board type TXMC375 added, Description of allowed values changed in TDRV002_IOCT_SET_FIFOTRIG, Chapter Special Baud Rates set via termios removed, Description Setting up Baud Rates modified 1.8.1 New board type TPMC378 added, Chapter Known Problem added 1.8.2 New board types TCP468, TXMC376, TXMC463, TXMC465 added, Table of Supported Modules renewed March 26, 2013 May 27, 2014 January 22, 2016 1.8.3 File-List modified November 24, 2017 TDRV002-SW-82 - Linux Device Driver Page 3 of 26

Table of Contents 1 INTRODUCTION... 5 2 INSTALLATION... 7 2.1 Build and Install the Device Driver...8 2.2 Uninstall the Device Driver...8 2.3 Install Device Driver into the running Kernel...8 2.4 Remove Device Driver from the running Kernel...9 2.5 Change Major Device Number...9 3 DEVICE DRIVER PROGRAMMING... 10 3.1 Setting up Baud Rates...10 3.2 ioctl...11 3.2.1 TDRV002_IOCQ_BIST...13 3.2.2 TDRV002_IOCT_CONF_TRANS...16 3.2.3 TDRV002_IOCT_SPEED...18 3.2.4 TDRV002_IOCQ_GET_SPEED...19 3.2.5 TDRV002_IOCQ_GET_INFO...20 3.2.6 TDRV002_IOCT_SET_FIFOTRIG...22 4 TDRV002CONFIG COMMAND LINE TOOL... 24 5 DIAGNOSTIC... 25 6 APPENDIX... 26 6.1 Known Problems...26 6.1.1 Open Device Multiple...26 TDRV002-SW-82 - Linux Device Driver Page 4 of 26

1 Introduction The TDRV002-SW-82 Linux device driver is a full-duplex serial driver which allows the operation of a supported serial PMC on Linux operating systems. The TDRV002-SW-82 device driver is based on the standard Linux serial device driver and supports all standard terminal functions (TERMIOS). Supported features: Extended baud rates up to 5.5296 Mbaud. Depending on the board, 64 Byte or 256 Byte transmit and receive hardware FIFO per channel Programmable trigger level for transmit and receive FIFO. Hardware (RTS/CTS) and software flow control (XON/XOFF) directly controlled by the serial controller. The advantage of this feature is that the transmission of characters will immediately stop as soon as a complete character is transmitted and not when the transmit FIFO is empty for handshake under software control. This will greatly improve flow control reliability. Direct support of different physical interfaces (e.g. RS-232, RS-422). Designed as Linux kernel module with dynamic loading. Supports shared IRQ s. Built on new style PCI driver layout Creates a TTY device ttytdrv002 and dial out device cuatdrv002 (Kernel 2.4.x) with dynamically allocated or fixed major device numbers. DEVFS and UDEV support for automatic device node creation The TDRV002-SW-82 device driver supports the modules listed below: Module Serial Interfaces Programmable Interfaces FIFO-Size (Bytes) Isolated Form Factor Conduction Cooled TPMC371 8 64 PMC TPMC372 4 64 PMC TPMC375 8 64 PMC TPMC376 4 64 PMC TPMC377 4 64 PMC TPMC378 8 64 PMC TPMC460 16 64 PMC TPMC461 8 64 PMC TPMC462 4 64 PMC TPMC463 4 64 PMC TPMC465 8 64 PMC TPMC466 4 64 PMC TPMC467 4 64 PMC TPMC470 4 64 PMC TXMC375 8 256 XMC TDRV002-SW-82 - Linux Device Driver Page 5 of 26

Module Serial Interfaces Programmable Interfaces FIFO-Size (Bytes) Isolated Form Factor Conduction Cooled TXMC376 4 256 XMC TXMC463 4 256 XMC TXMC465 8 256 XMC TCP460 16 64 cpci TCP461 8 64 cpci TCP462 4 64 cpci TCP463 4 64 cpci TCP465 8 64 cpci TCP466 4 64 cpci TCP467 4 64 cpci TCP468 4 64 cpci TCP469 8 64 cpci TCP470 4 64 cpci In this document all supported modules and devices will be called TDRV002. Specials for certain devices will be advised. To get more information about the features and use of the supported devices it is recommended to read the manuals listed below. Corresponding Modules Hardware User Manual Exar XR17D15x PCI UART or Exar XR17D35x PCIexpress UART User Manual TDRV002-SW-82 - Linux Device Driver Page 6 of 26

2 Installation The directory TDRV002-SW-82 on the distribution media contains the following files: TDRV002-SW-82-1.8.3.pdf TDRV002-SW-82-SRC.tar.gz Release.txt ChangeLog.txt This manual in PDF format GZIP compressed archive with driver source code Release information Release history The GZIP compressed archive TDRV002-SW-82-SRC.tar.gz contains the following files and directories: hal/ hal/makefile hal/tdrv002hal.c hal/tdrv002haldef.h serial/ serial/makefile serial/tdrv002serial.c serial /tdrv002serialdef.h serial/2.4.x serial/2.4.x/makefile serial/2.4.x/tdrv002serial.c serial/2.4.x/tdrv002serialdef.h serial/makenode serial/makenodefm24 include/tpmodule.c include/tpmodule.h include/config.h include/tpxxxhwdep.c include/tpxxxhwdep.h example/makefile example/tdrv002example.c example/tdrv002setspeed.c example/tdrv002bist.c example/tdrv002config.c example/tdrv002readinfo.c tdrv002.h tdrv002user.h Makefile COPYING Hardware abstraction layer driver needed for all kernel versions HAL driver makefile HAL driver source file HAL driver private header file UART driver directory (for Kernels 2.6.x and newer) Serial driver makefile Serial driver source file Serial driver private header file Kernel 2.4.x sources directory Serial driver makefile Serial driver source file Serial driver private header file Shell script to create devices nodes without a device FS Same as makenode with additional support for CUA devices Driver independent library Driver independent library header file Driver independent library header file HAL low level WINNT style hardware access functions source file Access functions header file Example application makefile Send and receive example application Speed configuration example application Example for using Built-In-Self-Test Command-Line Tool for transceiver programming Example displays hardware information of a channel Driver header file User application header file Top-level Makefile Copy of the GNU Public License (GPL) In order to perform an installation, extract all files of the archive TDRV002-SW-82-SRC.tar.gz to the desired target directory. (Note: to extract the archive file use # tar xvzf TDRV002-SW-82-SRC.tar.gz) Login as root and change to the target directory Copy tdrv002user.h to /usr/include TDRV002-SW-82 - Linux Device Driver Page 7 of 26

2.1 Build and Install the Device Driver Login as root Change to the tdrv002 target directory To create and install the HAL driver and SERIAL driver in the module directory /lib/modules/<version>/misc enter: # make install To update the device driver s module dependencies, enter: # depmod -aq 2.2 Uninstall the Device Driver Login as root Change to the tdrv002 target directory To remove the driver from the module directory /lib/modules/<version>/misc enter: # make uninstall 2.3 Install Device Driver into the running Kernel To load the device driver into the running kernel, login as root and execute the following commands: # modprobe tdrv002serialdrv After the first build or if you are using dynamic major device allocation it s necessary to create new device nodes on the file system. Please execute the script file makenode, which resides in serial/ directory, to do this. If your kernel has enabled the device file system (devfs, udev,...) then skip running the makenode script. Instead of creating device nodes from the script the driver itself takes creating and destroying of device nodes in its responsibility. # sh makenode On success the device driver will create a minor device for each compatible channel found. The first channel of the first PMC module can be accessed with device node /dev/ttystdrv002_0, the second channel with device node /dev/ttystdrv002_1 and so on. The assignment of device nodes to physical PMC modules depends on the search order of the PCI bus driver. TDRV002-SW-82 - Linux Device Driver Page 8 of 26

2.4 Remove Device Driver from the running Kernel To remove the device driver from the running kernel login as root and execute the following command: # modprobe r tdrv002serialdrv If your kernel has enabled a device file system (devfs, udev,...), all /dev/ttystdrv002_* nodes will be automatically removed from your file system after this. Be sure that the driver isn t opened by any application program. If opened you will get the response tdrv002serialdrv: Device or resource busy and the driver will still remain in the system until you close all opened files and execute modprobe r again. 2.5 Change Major Device Number This paragraph is only for Linux kernels without a device file system (devfs, udev,...) installed. The released TDRV002 driver uses dynamic allocation of major device numbers. If this isn t suitable for the application it s possible to define a major number separately for the TTY and CUA driver. To change the major number edit the file tdrv002serial.c, change the following symbols to appropriate values and enter make install to create a new driver. TDRV002_TTY_MAJOR TDRV002_CUA_MAJOR Defines the value for the terminal device. Valid numbers are in range between 0 and 255. A value of 0 means dynamic number allocation. Defines the value for the dial out device. Valid numbers are in range between 0 and 255. A value of 0 means dynamic number allocation. Example: #define TDRV002_TTY_MAJOR 122 #define TDRV002_CUA_MAJOR 123 Be sure that the desired major number isn t used by other drivers. Please check /proc/devices to see which numbers are free. Keep in mind that s necessary to create new device nodes if the major number for the TDRV002 driver has changed and the makenode script isn t used. TDRV002-SW-82 - Linux Device Driver Page 9 of 26

3 Device Driver Programming The TDRV002-SW-82 driver loosely bases on the standard Linux terminal driver. Due to this way of implementation the driver interface and functionality is compatible to the standard Linux terminal driver. Please refer to the TERMIOS man page and driver programming related man pages for more information about serial driver programming. 3.1 Setting up Baud Rates The driver allows setting all baud rates supported by the channel. Not only standard baud rates are supported, also special baud rates are supported. The driver will always try to set the best matching baud rate. There are two possibilities setting up baud rates: The first is used to setup predefined baud rates, this is the standard way by using the termios structure (e.g. using ssty). The second way allows the selection of all baud rates the module can support. This way uses the ioctl function TDRV002_IOCT_SPEED (please refer to the description of the ioctl function). TDRV002-SW-82 - Linux Device Driver Page 10 of 26

3.2 ioctl NAME ioctl() device control functions SYNOPSIS #include <sys/ioctl.h> #include <tdrv002.h> #include <tdrv002user.h> int ioctl(int filedes, int request [, void *argp]) DESCRIPTION The ioctl function sends a control code directly to a device, specified by filedes, causing the corresponding device to perform the requested operation. The argument request specifies the control code for the operation. The optional argument argp depends on the selected request and is described for each request in detail later in this chapter. The following ioctl codes are defined in tdrv002user.h: Value TDRV002_IOCQ_BIST TDRV002_IOCT_CONF_TRANS TDRV002_IOCT_SPEED TDRV002_IOCQ_GET_SPEED TDRV002_IOCQ_GET_INFO TDRV002_IOCT_SET_FIFOTRIG Meaning Start Built-In-Self-Test Configure transceiver (physical interface) Setup user defined baud rates Returns the current configured baud rate Reads out hardware information of a channel Configure FIFO trigger levels See below for more detailed information on each control code. To use these TDRV002 specific control codes the header file tdrv002user.h must be included in the application. RETURNS On success, zero is returned. In case of an error, a value of 1 is returned. The global variable errno contains the detailed error code. TDRV002-SW-82 - Linux Device Driver Page 11 of 26

ERRORS Error Code EINVAL Description Invalid argument. This error code is returned if the requested ioctl function is unknown. Please check the argument request. Other function dependent error codes will be described for each ioctl code separately. Note, the TDRV002 driver always returns standard Linux error codes. SEE ALSO ioctl man pages TDRV002-SW-82 - Linux Device Driver Page 12 of 26

3.2.1 TDRV002_IOCQ_BIST NAME TDRV002_IOCQ_BIST Start Built-In-Self-Test DESCRIPTION The TDRV002 driver (version 1.1.0 and higher) supports a special IOCTL function for testing module hardware and for system diagnostic. The optional argument can be omitted for this ioctl function. The functionality is called Built-In-Self-Test or BIST. With BIST you can test each channel of all your modules separately. There are three different test classes. First is a line test, second an interrupt test and the last a data integrity test. All tests run with local channel loopback enabled, so you don t need an external cable connection. The Fig. 3-1 describes the loop back configuration of an 8 channel UART, so all line arrays are index with [7:0]. For the two and four channel UARTs, the line arrays should be indexed with [1:0] or [3:0]. Fig. 3-1 TDRV002-SW-82 - Linux Device Driver Page 13 of 26

The line test contains a test of all modem lines (RTS/CTS, DTR/DSR, OP1/RI, OP2/CD). Only the static states for both electrical levels are tested on each sender receiver line pair. For testing interrupts the BIST transmits a test buffer with known data and size. All data should be received on same channel during internal loopback. If not, there is an interrupt error. The buffer size is 1024 BYTE. The baud rate has to be set through the standard terminal IOCTL functions. The last test verifies received data to assert data integrity. EXAMPLE #include <tdrv002user.h> int result, tty1; /* Start Built-In Selftest, */ result = ioctl(tty1, TDRV002_IOCQ_BIST, NULL); if (result < 0) { printf("errno %d - %s\n", errno, strerror(errno)); } else if (result > 0) { printf("bist detected a line error!\n"); if (result & TDRV002_ERTSCTS) printf("rts/cts line broken!\n"); if (result & TDRV002_EDTRDSR) printf("dtr/dsr line broken!\n"); if (result & TDRV002_ERI) printf("op1/ri line broken!\n"); if (result & TDRV002_ECD) printf("op2/dcd line broken!\n"); if (result & TDRV002_EDATA) printf("data integrity test failed!\n"); } else { printf("info: Port successfully tested.\n"); } TDRV002-SW-82 - Linux Device Driver Page 14 of 26

RETURNS If return value is > 0 one of three tests failed. Use the following flags to get a detailed error description. Return Code TDRV002_ERTSCTS TDRV002_EDTRDSR TDRV002_ERI TDRV002_ECD Description If set RTS/CTS line broken. If set DTR/DSR line broken. If set OP1/RI line broken. If set OP2/CD line broken. TDRV002_EDATA Data integrity test failed. No correct transmission possible. ERRORS Error Code ETIME EAGAIN ERESTARTSYS Description A timeout occurred during wait, interrupts do not work correctly. Your task should never been blocked. Change it to use the Built-In-Self-Test. Interrupted by external signal. TDRV002-SW-82 - Linux Device Driver Page 15 of 26

3.2.2 TDRV002_IOCT_CONF_TRANS NAME TDRV002_IOCT_CONF_TRANS Configure transceiver DESCRIPTION This ioctl function configures the transceiver circuit of all TDRV002 modules with a programmable physical interface. The configuration is passed by value by the parameter arg to the driver. The flags below are available and should be ORed to build a configuration value: Value TDRV002_CFG_RS485_RS232 TDRV002_CFG_HDPLX TDRV002_CFG_RENA TDRV002_CFG_RTERM Meaning Set to enable RS485 interface, clear to enable RS232 interface. Set to enable half-duplex interface, clear to enable full-duplex interface. Set to enable auto RS485 receiver enable feature, clear to disable it. Set to enable receiver termination, clear to disable it. TDRV002_CFG_TTERM Set to enable transmitter termination, clear to disable it. TDRV002_CFG_SLEWLIMIT TDRV002_CFG_SHDN TDRV002_CFG_AUTO_RS485 Set to enable slew limit mode, clear to disable it. Set to shutdown the whole transceiver circuit, clear to enable the transceiver. Set to enable UART Auto RS485 Mode, clear to disable it. (See UART XR17D15x Hardware User Manual) Beside the certain flags the tdrv002user.h header file offers a set of standard configurations that could be used alternatively. The following predefined macros could be used: Value TDRV002_INTF_OFF TDRV002_INTF_RS232 TDRV002_INTF_RS422 TDRV002_INTF_RS485FDM TDRV002_INTF_RS485FDS TDRV002_INTF_RS485HD Meaning Shutdown mode / disable interface RS232 RS422 (Multidrop / Full Duplex) RS485 Full Duplex (Master) RS485 Full Duplex (Slave) RS485 Half Duplex TDRV002-SW-82 - Linux Device Driver Page 16 of 26

EXAMPLE #include <tdrv002user.h> unsigned long config; int result; int tty1, tty2; /* device handles of modules with programmable transceivers */ /* Setup channel as RS485 Full Duplex (Master)*/ config = TDRV002_CFG_RS485_RS232 TDRV002_CFG_RTERM TDRV002_CFG_TTERM; result = ioctl(tty1, TDRV002_IOCT_CONF_TRANS, config); if (result < 0) { /* handle errors */ } /* Setup channel as RS485 Full Duplex (Master) (alternative way) */ config = TDRV002_INTF_RS485FDM; result = ioctl(tty1, TDRV002_IOCT_CONF_TRANS, config); if (result < 0) { /* handle errors */ } /* Shutdown the physical interface of certain channel */ config = TDRV002_INTF_OFF; result = ioctl(tty2, TDRV002_IOCT_CONF_TRANS, config); if (result < 0) { /* handle errors */ } ERRORS Error Code ENODEV Description The selected device has no programmable physical interface. See Hardware User Manual for detailed information about programmable transceivers. TDRV002-SW-82 - Linux Device Driver Page 17 of 26

3.2.3 TDRV002_IOCT_SPEED NAME TDRV002_IOCT_SPEED Setup user defined baud rates DESCRIPTION This ioctl function sets up a user defined baud rate. This allows using the TDRV002 device with every adjustable baud rate. The new baud rate is passed by value by the parameter arg to the driver. The baud rate limits are device and configuration dependent, so please refer to the suitable manual. The function tries to set the baud rate in X16-mode, if the nearest configurable baud rate has a difference greater than 3% to the chosen one, the driver will setup the baud rate in X8- mode or in X4-mode, if supported by hardware. If a user defined baud rate is set, standard tools (like stty) will return invalid information about the selected baud rate. EXAMPLE #include <tdrv002user.h> int result, tty1; /* Setup 14400 Baud */ result = ioctl(tty1, TDRV002_IOCT_SPEED, 14400); if (result < 0) { /* handle errors */ } TDRV002-SW-82 - Linux Device Driver Page 18 of 26

3.2.4 TDRV002_IOCQ_GET_SPEED NAME TDRV002_IOCQ_GET_SPEED Read the current configured baud rate DESCRIPTION This ioctl function returns the currently configured baud rate of the specified channel. This allows checking if a baud rate can be configured correctly or if it is substituted by the nearest configurable baud rate. The current baud rate is returned in the integer argument the parameter arg points on. EXAMPLE #include <tdrv002user.h> int result, tty1, baudrate; result = ioctl(tty1, TDRV002_IOCQ_GET_SPEED, &baudrate); if (result < 0) { /* handle errors */ } else { printf( Current Baudrate: %d\n, baudrate); } TDRV002-SW-82 - Linux Device Driver Page 19 of 26

3.2.5 TDRV002_IOCQ_GET_INFO NAME TDRV002_IOCQ_GET_INFO Reads information about the position and type of a channel DESCRIPTION This ioctl function reads the module position, module ID and the local channel number of a specified channel. This information may allow an easier module identification and configuration checking in the system. A pointer to the information buffer (TDRV002_GET_INFO_STRUCT) is passed by the parameter arg to the driver typedef struct { int int int int int int char int unsigned char pcibusno; pciparentbusno; pcideviceno; localchannelno; deviceid; subsystemid; typestr[20]; intfprogrammable; intfconfig; } TDRV002_GET_INFO_STRUCT; pcibusno Returns the PCI bus number the UART is mounted. Some TDRV002 supported modules have their own PCI bridge in this case the value is the number of the local PCI bus on the module. pciparentbusno Returns the PCI bus number of the parent PCI bus. This value may be interesting if a module type with an own PCI bridge is used. If there is no parent PCI bus, the value will be -1. pcideviceno Returns the PCI device number of the UART controller. This specifies a fix place on the PCI bus and may be used to identify a special module. The value returns the PCI device number of the UART not that one of the TDRV002 supported module. localchannelno Returns the local channel number of the specified device. The first channel on a module starts with 0, the second is 1 and so on. deviceid Returns the PCI device ID, this identifies the model type. TDRV002-SW-82 - Linux Device Driver Page 20 of 26

subsystemid Returns the PCI Subsystem ID, this identifies the model variant. typestr Returns a string with the product name, e.g. TPMC461-12 or TCP462-10 intfprogrammable Returns TRUE (1) if the specific channel offers a programmable interface. intfconfig Returns the current transceiver interface configuration. For a description of this value refer to function TDRV002_IOCT_CONF_TRANS. EXAMPLE #include <tdrv002user.h> int result, tty1; TDRV002_GET_INFO_STRUCT infobuf; /* Display channel position and Moduletype */ result = ioctl(tty1, TDRV002_IOCQ_GET_INFO, &infobuf); if (result < 0) { printf( Device: %d/%d/%d: %s\n, infobuf.pcibusno, infobuf.pcideviceno, infobuf.localchannelno, infobuf.typestr); if (infobuf.intfprogrammable) { printf( Interface configuration : %02Xh\n, infobuf.intfconfig); } else { printf( Interface is not configurable.\n ); } } TDRV002-SW-82 - Linux Device Driver Page 21 of 26

3.2.6 TDRV002_IOCT_SET_FIFOTRIG NAME TDRV002_IOCT_SET_FIFOTRIG Configure FIFO trigger levels DESCRIPTION This ioctl function configures the FIFO trigger levels for hardware receive and transmit FIFO. This allows optimizing interrupt load or data loss protection. The new FIFO trigger level must be specified in structure (TDRV002_SET_FIFO_STRUCT). The pointer of the structure must be passed by the parameter arg to the driver. typedef struct { unsigned int unsigned int } TDRV002_SET_FIFO_STRUCT; txfifotrig txfifotrig; rxfifotrig; This value specifies the new FIFO trigger level, which specifies the number of characters left in the transmit FIFO when the controller will generate an interrupt announcing that there is space in the transmit FIFO to be filled with more data ready to be transmitted. Allowed values are 0...64 (for all TPMC and TCP boards) and 0 255 (for TXMC boards), but 0 specifies to use the default value of 16. Increasing the value will increase interrupt load but the possibility of gaps in data transmission (while data is ready to send) will be decreased. Decreasing the value will decrease interrupt load but increase the risk of transmission gaps. rxfifotrig This value specifies the new FIFO trigger level, which specifies the number of characters in the receive FIFO when the controller will generate an interrupt announcing that data should be read. Allowed values are 0...64 (for all TPMC and TCP boards) and 0 255 (for TXMC boards), but 0 specifies to use the default value of 48. Increasing this value will decrease interrupt load, but will increase the risk of data loss, if hardware handshake is not used. Decreasing the value will increase interrupt load, but decrease the risk of data loss. TDRV002-SW-82 - Linux Device Driver Page 22 of 26

EXAMPLE #include <tdrv002user.h> int TDRV002_SET_FIFO_STRUCT result, tty1; fifobuf; /* Rx-FIFO-trigger: 32 */ /* Tx-FIFO-trigger: 40 */ fifobuf.rxfifotrig = 32; fifobuf.txfifotrig = 40; result = ioctl(tty1, TDRV002_IOCT_SET_FIFOTRIG, &fifobuf); if (result < 0) { /* handle errors */ } TDRV002-SW-82 - Linux Device Driver Page 23 of 26

4 tdrv002config Command Line Tool To setup the physical interface of a certain channel you can use example/tdrv002config for programming of the transceiver circuit. format : tdrv002config <minor1> <options> example: tdrv002config 0 crs485 crterm configures /dev/ttystdrv002_0 to RS422 full duplex master List of all options: crs485 chdplx crena crterm ctterm cslewlimit cshdn cautors485 For detailed configuration options information see TDRV002_IOCT_CONF_TRANS ioctl function description. TDRV002-SW-82 - Linux Device Driver Page 24 of 26

5 Diagnostic If the TDRV002 driver does not work properly it is helpful to get some status information from the driver respective kernel. The Linux /proc file system provides information about kernel, resources, driver, devices and so on. The following screen dumps display information of a correct running TDRV002 driver (see also the proc man pages). (The example output below has been created with kernel 3.1.5-2.fc16.x86_64 and an installed TPMC461.) # cat /proc/tty/driver/tdrv002serial serinfo:1.0 driver revision: 0: uart:xr17d15x mmio:0xfeb9f000 irq:16 tx:8192 rx:8192 1: uart:xr17d15x mmio:0xfeb9f200 irq:16 tx:1024 rx:1024 CTS 2: uart:xr17d15x mmio:0xfeb9f400 irq:16 tx:1024 rx:1024 CTS 3: uart:xr17d15x mmio:0xfeb9f600 irq:16 tx:1024 rx:1024 4: uart:xr17d15x mmio:0xfeb9f800 irq:16 tx:1024 rx:1024 5: uart:xr17d15x mmio:0xfeb9fa00 irq:16 tx:1024 rx:1024 6: uart:xr17d15x mmio:0xfeb9fc00 irq:16 tx:1024 rx:1024 7: uart:xr17d15x mmio:0xfeb9fe00 irq:16 tx:1024 rx:1024 # /proc/tty/drivers /dev/tty /dev/tty 5 0 system:/dev/tty /dev/console /dev/console 5 1 system:console /dev/ptmx /dev/ptmx 5 2 system /dev/vc/0 /dev/vc/0 4 0 system:vtmaster tdrv002serial /dev/ttystdrv002_ 250 0-127 serial usbserial /dev/ttyusb 188 0-253 serial serial /dev/ttys 4 64-95 serial pty_slave /dev/pts 136 0-1048575 pty:slave pty_master /dev/ptm 128 0-1048575 pty:master unknown /dev/tty 4 1-63 console # lspci v 04:01.0 Serial controller: TEWS Technologies GmbH Device 01cd (rev 02) (prog-if 02 [16550]) Subsystem: TEWS Technologies GmbH Device 000c Flags: fast devsel, IRQ 16 Memory at feb9f000 (32-bit, non-prefetchable) [size=4k] Kernel driver in use: TEWS TECHNOLOGIES - TDRV002HAL Driver Kernel modules: tdrv002haldrv TDRV002-SW-82 - Linux Device Driver Page 25 of 26

6 Appendix 6.1 Known Problems 6.1.1 Open Device Multiple A TDRV002 tty device should not be opened by multiple processes at the same time. The processes may affect each other and there may be problems accessing the device. TDRV002-SW-82 - Linux Device Driver Page 26 of 26