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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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.

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

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

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

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

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

OPTO32A 24 Input Bit, 8 Output Bit Optical Isolator Board

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

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.

Section 3: File I/O, JSON, Generics. Meghan Cowan

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

CSE 333 SECTION 3. POSIX I/O Functions

spwr_base & spwr_chan

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

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

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

Files. Eric McCreath

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls

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

Advcan QNX Driver User Manual V1.02

CSE 333 SECTION 3. POSIX I/O Functions

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

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

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

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

CMPS 105 Systems Programming. Prof. Darrell Long E2.371

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

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

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

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

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

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

Lecture files in /home/hwang/cs375/lecture05 on csserver.

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

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C

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

UNIX System Calls. Sys Calls versus Library Func

Experiment 6 The Real World Interface

File I/0. Advanced Programming in the UNIX Environment

OS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

NAME attr extended attributes on XFS filesystem objects. SYNOPSIS attr [ LRq ] s attrname [ V attrvalue ] pathname

File I/O - Filesystems from a user s perspective

ICS-121. VxWORKS DEVICE DRIVER MANUAL

User Programs. Computer Systems Laboratory Sungkyunkwan University

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

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

Standards / Extensions C or C++ Dependencies POSIX.1 XPG4 XPG4.2 Single UNIX Specification, Version 3

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

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

libnetfilter_log Reference Manual

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm

ADADIO 12 Channel, 16-bit A/D-D/A I/O With 8-bit Discrete Digital I/O

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

TIP Digital Inputs Optically Isolated Version 1.0 Revision A. User Manual. Issue May 1997 D

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

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

CS240: Programming in C

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Pci3Ip, Pci5Ip, Pc104pIp, Pc104p4Ip, cpci2ip, cpci4ip and PcieCar IndustryPack Carrier Device Drivers

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call

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

MaRTE OS Misc utilities

Lab 09 - Virtual Memory

Chapter 2: System Structures

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

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

CS 3013 Operating Systems WPI, A Term Assigned: Friday, August 31, 2007 Due: Monday, September 17, 2007

Operating systems. Lecture 7

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

M O T O R O L A C O M P U T E R G R O U P VME DRIVER FOR LINUX USER GUIDE

NPTEL Course Jan K. Gopinath Indian Institute of Science

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

Operating Systems II Systems Programming in C

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

Laboratory Assignment #3. Extending scull, a char pseudo-device. Summary: Objectives: Tasks:

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

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

Project #1 Exceptions and Simple System Calls

DRIVER AND LIBRARY FOR DB67 DSP BOARD DRIVER AND LIBRARY FOR DB67 DSP BOARD

Linux Kernel Modules & Device Drivers April 9, 2012

Objectives. Chapter 2: Operating-System Structures. 2.1 Operating System Services

Transcription:

The Embedded I/O Company TIP675-SW-82 Linux Device Driver 48 TTL I/O Lines with Interrupts Version 1.2.x User Manual Issue 1.2.5 November 2013 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

TIP675-SW-82 Linux Device Driver 48 TTL I/O Lines with Interrupts Supported Modules: TIP675 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. 2006-2013 by TEWS TECHNOLOGIES GmbH Issue Description Date 1.0 First Issue December 11, 2002 1.1 Support for DEVFS and SMP February 17, 2004 1.2.0 Kernel 2.6.x Support January 13, 2006 1.2.1 New Address TEWS LLC September 28, 2006 1.2.2 General revision February 13, 2008 1.2.3 Carrier Driver description added July 7, 2008 1.2.4 General revision, Address TEWS LLC removed, Avoiding undefined symbols warning note November 25, 2010 1.2.5 Build instructions modified, General Revision November 12, 2013 TIP675-SW-82 - Linux Device Driver Page 2 of 25

Table of Contents 1 INTRODUCTION... 4 1.1 Device Driver...4 1.2 IPAC Carrier Driver...5 2 INSTALLATION... 6 2.1 Build and install the Device Driver...6 2.2 Uninstall the Device Driver...7 2.3 Install Device Driver into the running Kernel...Fehler! Textmarke nicht definiert. 2.4 Remove Device Driver from the running Kernel...Fehler! Textmarke nicht definiert. 2.5 Change Major Device Number...Fehler! Textmarke nicht definiert. 3 DEVICE INPUT/OUTPUT FUNCTIONS... 9 3.1 open...9 3.2 close...11 3.3 read...12 3.4 write...14 3.5 ioctl...16 3.5.1 T675_IOCS_SET_DIR...18 3.5.2 T675_IOCS_ENA_EXCLK...20 3.5.3 T675_IOCS_DIS_EXCLK...21 3.5.4 T675_IOCX_WAIT_TRANS...22 4 DEBUGGING... 25 TIP675-SW-82 - Linux Device Driver Page 3 of 25

1 Introduction 1.1 Device Driver The TIP675-SW-82 Linux device driver allows the operation of a TIP675 IPAC module on Linux operating systems. Because the TIP675 device driver is stacked on the TEWS TECHNOLOGIES IPAC carrier driver, it s necessary to install also the appropriate IPAC carrier driver. Please refer to the IPAC carrier driver user manual for further information. The TIP675-SW-82 device driver includes the following features: reading the input register writing the output register programming direction of every I/O line configure simultaneous update feature waiting for a transition at a single input line or a group of input lines (OR ed) The TIP675-SW-82 supports the modules listed below: TIP675-10 48 TTL I/O Lines with Interrupts (IndustryPack ) To get more information about the features and use of the supported devices it is recommended to read the manuals listed below. TIP675 User Manual CARRIER-SW-82 IPAC Carrier User Manual TIP675-SW-82 - Linux Device Driver Page 4 of 25

1.2 IPAC Carrier Driver IndustryPack (IPAC) carrier boards have different implementations of the system to IndustryPack bus bridge logic, different implementations of interrupt and error handling and so on. Also the different byte ordering (big-endian versus little-endian) of CPU boards will cause problems on accessing the IndustryPack I/O and memory spaces. To simplify the implementation of IPAC device drivers which work with any supported carrier board, TEWS TECHNOLOGIES has designed a so called Carrier Driver that hides all differences of different carrier boards under a well-defined interface. The TEWS TECHNOLOGIES IPAC Carrier Driver CARRIER-SW-82 is part of this TIP675-SW-82 distribution. It is located in directory CARRIER-SW-82 on the corresponding distribution media. This IPAC Device Driver requires a properly installed IPAC Carrier Driver. Due to the design of the Carrier Driver, it is sufficient to install the IPAC Carrier Driver once, even if multiple IPAC Device Drivers are used. Please refer to the CARRIER-SW-82 User Manual for a detailed description how to install and setup the CARRIER-SW-82 device driver, and for a description of the TEWS TECHNOLOGIES IPAC Carrier Driver concept. TIP675-SW-82 - Linux Device Driver Page 5 of 25

2 Installation The directory TIP675-SW-82 on the distribution media contains the following files: TIP675-SW-82-1.2.5.pdf TIP675-SW-82-SRC.tar.gz ChangeLog.txt Release.txt This manual in PDF format GZIP compressed archive with driver source code Release history Release information The GZIP compressed archive TIP675-SW-82-SRC.tar.gz contains the following files and directories: All paths are relative to subdirectory tip675 : tip675.c tip675def.h tip675.h makenode Makefile example/tip675exa.c example/makefile include/config.h include/tpmodule.h include/tpmodule.c Driver source code Driver include file Driver include file for application program Script to create device nodes on the file system Device driver make file Example application Example application make file Driver independent library header file Kernel independent library header file Kernel independent library source code file In order to perform an installation, extract all files of the archive TIP675-SW-82-SRC.tar.gz to the desired target directory. The command tar -xzvf TIP675-SW-82-SRC.tar.gz will extract the files into the local directory. Before building a new device driver, the TEWS TECHNOLOGIES IPAC Carrier Driver must be installed properly, because this driver includes the header file ipac_carrier.h, which is part of the IPAC carrier driver distribution. Please refer to the IPAC Carrier Driver user manual in the directory path CARRIER-SW-82 on the distribution media. 2.1 Build and install the Device Driver Login as root Use the parameter CARRIERDIR to specify the location of the TEWS IPAC Carrier Driver. To create and install the driver in the module directory /lib/modules/<version>/misc assuming the carrier driver being located in /usr/project/ipac_carrier, enter: # make install CARRIERDIR=/usr/project/ipac_carrier If not specifying the CARRIERDIR parameter, there may be compiler warnings claiming some undefined ipac_* symbols. These warnings are caused by the IPAC Carrier Driver, which is unknown during compilation of this TIP driver. TIP675-SW-82 - Linux Device Driver Page 6 of 25

Also after the first build we have to execute depmod to create a new dependency description for loadable kernel modules. This dependency file is later used by modprobe to automatically load the correct IPAC carrier driver modules. # depmod aq 2.2 Uninstall the Device Driver Login as root Change to the target directory To remove the driver from the module directory /lib/modules/<version>/misc enter: # make uninstall Update kernel module dependency description file # depmod -aq 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 tip675drv After the first build or if you are using dynamic major device allocation it is necessary to create new device nodes on the file system. Please execute the script file makenode to do this. If your kernel has enabled a device file system (devfs or sysfs with udev) then you have to 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 TIP675 module found. The first TIP675 can be accessed with device node /dev/tip675_0, the second TIP675 with device node /dev/tip675_1, the third TIP675 with device node /dev/tip675_2 and so on. The allocation of device nodes to physical TIP675 modules depends on the search order of the IPAC carrier driver. Please refer to the IPAC carrier user manual. Loading of the TIP675 device driver will only work if kernel KMOD support is installed, necessary carrier board drivers already installed and the kernel dependency file is up to date. If KMOD support isn t available you have to build either a new kernel with KMOD installed or you have to install the IPAC carrier kernel modules manually in the correct order (please refer to the IPAC carrier driver user manual). TIP675-SW-82 - Linux Device Driver Page 7 of 25

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 tip675drv r If your kernel has enabled device file system (devfs, udev,...), all /dev/tip675_x 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 tip675drv: 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 TIP675 driver use dynamic allocation of major device numbers by default. If this isn t suitable for the application it s possible to define a major number for the driver. If the kernel has enabled devfs the driver will not use the symbol TIP675_MAJOR. To change the major number edit the file tip675drv.c, change the following symbol to appropriate value and enter make install to create a new driver. TIP675_MAJOR Valid numbers are in range between 0 and 255. A value of 0 means dynamic number allocation. Example: #define TIP675_MAJOR 122 TIP675-SW-82 - Linux Device Driver Page 8 of 25

3 Device Input/Output functions This chapter describes the interface to the device driver I/O system. 3.1 open NAME open() - open a file descriptor SYNOPSIS #include <fcntl.h> int open (const char *filename, int flags) DESCRIPTION The open function creates and returns a new file descriptor for the file named by filename. The flags argument controls how the file is to be opened. This is a bit mask; you create the value by the bitwise OR of the appropriate parameters (using the operator in C). See also the GNU C Library documentation for more information about the open function and open flags. EXAMPLE int fd; fd = open( /dev/tip675_0, O_RDWR); if (fd < 0) { /* handle error condition */ } RETURNS The normal return value from open is a non-negative integer file descriptor. In the case of an error, a value of 1 is returned. The global variable errno contains the detailed error code. TIP675-SW-82 - Linux Device Driver Page 9 of 25

ERRORS Error Code ENODEV Description The requested minor device does not exist. This is the only error code returned by the driver, other codes may be returned by the I/O system during open. SEE ALSO GNU C Library description Low-Level Input/Output TIP675-SW-82 - Linux Device Driver Page 10 of 25

3.2 close NAME close() close a file descriptor SYNOPSIS #include <unistd.h> int close (int filedes) DESCRIPTION The close function closes the file descriptor filedes. EXAMPLE int fd; if (close(fd)!= 0) { /* handle close error conditions */ } RETURNS The normal return value from close is 0. In the case of an error, a value of 1 is returned. The global variable errno contains the detailed error code. ERRORS Error Code ENODEV Description The requested minor device does not exist. This is the only error code returned by the driver, other codes may be returned by the I/O system during close. For more information about close error codes, see the GNU C Library description Low- Level Input/Output. SEE ALSO GNU C Library description Low-Level Input/Output TIP675-SW-82 - Linux Device Driver Page 11 of 25

3.3 read NAME read() read from a device SYNOPSIS #include <unistd.h> ssize_t read(int filedes, void *buffer, size_t size) DESCRIPTION This function attempts to read the input registers of the TIP675 associated with the file descriptor fildes into a structure (T675_BUFFER) pointed by buffer. The argument size specifies the length of the buffer and must be set to the length of the structure T675_BUFFER. typedef struct { } T675_BUFFER; line_1_16; line_17_32; line_33_48; line_1_16 line_17_32 line_33_48 This parameter returns the status of input lines 1 to 16. Where bit 2 0 corresponds to input line 1, bit 2 1 to input line 2, and so on. This parameter returns the status of input lines 17 to 32. Where bit 2 0 corresponds to input line 17, bit 2 1 to input line 18, and so on. This parameter returns the status of input lines 33 to 48. Where bit 2 0 corresponds to input line 33, bit 2 1 to input line 34, and so on. TIP675-SW-82 - Linux Device Driver Page 12 of 25

EXAMPLE #include <tip675.h> int fd; ssize_t num_bytes; T675_BUFFER io_buf; num_bytes = read(fd, &io_buf, sizeof(io_buf)); if (num_bytes!= sizeof(t675_buffer)) { // process error; } RETURNS On success read returns the number of byte read (always size of T675_BUFFER). In the case of an error, a value of 1 is returned. The global variable errno contains the detailed error code. ERRORS Error Code EINVAL Description This error code is returned if the size of the buffer is wrong. SEE ALSO GNU C Library description Low-Level Input/Output TIP675-SW-82 - Linux Device Driver Page 13 of 25

3.4 write NAME write() write to a device SYNOPSIS #include <unistd.h> ssize_t write(int filedes, void *buffer, size_t size) DESCRIPTION This function attempts to write to the output registers of the TIP675 associated with the file descriptor filedes from a structure (T675_BUFFER) pointed by buffer. The argument size specifies the length of the buffer and must be set to the length of the structure T675_BUFFER. typedef struct { } T675_BUFFER; line_1_16; line_17_32; line_33_48; line_1_16 line_17_32 line_33_48 This parameter holds the new value for output lines 1 to 16. Where bit 2 0 corresponds to output line 1, bit 2 1 to output line 2, and so on. This parameter holds the new value for output lines 17 to 32. Where bit 2 0 corresponds to output line 17, bit 2 1 to output line 18, and so on. This parameter holds the new value for output lines 33 to 48. Where bit 2 0 corresponds to output line 33, bit 2 1 to output line 34, and so on. TIP675-SW-82 - Linux Device Driver Page 14 of 25

EXAMPLE #include <tip675.h> int ssize_t T675_BUFFER fd; num_bytes; io_buf; /* set OUTPUT 1,16,31 and 48 to logic high */ io_buf.line_1_16 = 0x8001; io_buf.line_17_32 = 0x4000; io_buf.line_33_48 = 0x8000; num_bytes = write(fd, &io_buf, sizeof(t675_buffer)); if (num_bytes!= sizeof(t675_buffer)) { /* process error; */ } RETURNS On success write returns the size of bytes written (always the size of T675_BUFFER). In the case of an error, a value of 1 is returned. The global variable errno contains the detailed error code. ERRORS Error Code EINVAL Description This error code is returned if the size of the buffer is wrong. SEE ALSO GNU C Library description Low-Level Input/Output TIP675-SW-82 - Linux Device Driver Page 15 of 25

3.5 ioctl NAME ioctl() device control functions SYNOPSIS #include <sys/ioctl.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 tip675.h: Symbol T675_IOCS_SET_DIR T675_IOCS_ENA_EXCLK T675_IOC_DIS_EXCLK T675_IOCX_WAIT_TRANS Meaning Set direction of I/O lines Enable simultaneous update feature Disable simultaneous update feature Waiting for a transition at a single input line or a group of input lines (OR ed) See behind for more detailed information on each control code. To use these TIP675 specific control codes the header file tip675.h must be included in the application RETURNS On success, zero is returned. In the case of an error, a value of 1 is returned. The global variable errno contains the detailed error code. TIP675-SW-82 - Linux Device Driver Page 16 of 25

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 TIP675 driver always returns standard Linux error codes. SEE ALSO ioctl man pages TIP675-SW-82 - Linux Device Driver Page 17 of 25

3.5.1 T675_IOCS_SET_DIR NAME T675_IOCS_SET_DIR - Set direction of I/O lines DESCRIPTION With this ioctl function each of the 48 I/O lines may be individually set as input or output. To configure a line to be input, the corresponding bit in the mask must be set to 0. For output, the corresponding bit has to be set to 1. A pointer to the direction mask structure (T675_BUFFER) is passed by the parameter argp to the driver. typedef struct { } T675_BUFFER; line_1_16; line_17_32; line_33_48; line_1_16 line_17_32 line_33_48 This parameter holds the new direction for output lines 1 to 16. Where bit 2 0 corresponds to output line 1, bit 2 1 to output line 2, and so on. This parameter holds the new direction for output lines 17 to 32. Where bit 2 0 corresponds to output line 17, bit 2 1 to output line 18, and so on. This parameter holds the new direction for output lines 33 to 48. Where bit 2 0 corresponds to output line 33, bit 2 1 to output line 34, and so on. After driver startup all I/O lines are set to be inputs. TIP675-SW-82 - Linux Device Driver Page 18 of 25

EXAMPLE #include <tip675.h> int fd; int result; T675_BUFFER dir_buf; /* Set line 1...24 to be output and line 25...48 to be input */ dir_buf.line_1_16 = 0xFFFF; dir_buf.line_17_32 = 0x00FF; dir_buf.line_33_48 = 0x0000; result = ioctl(fd, T675_IOCS_SET_DIR, &dir_buf); if (result < 0) { /* handle ioctl error */ } ERRORS Error Code EFAULT Description Invalid pointer to the direction mask buffer. Please check the argument argp. TIP675-SW-82 - Linux Device Driver Page 19 of 25

3.5.2 T675_IOCS_ENA_EXCLK NAME T675_IOCS_ENA_EXCLK - Enable simultaneous update feature DESCRIPTION This ioctl function enables the simultaneous update feature of the TIP675. The argument argp passes a pointer to an unsigned long variable to the driver. Setting this variable to a 0 will cause the inputs and outputs to be latched on the rising edge of the external clock, while setting to a 1 will latch the inputs and outputs on the falling edge. After driver startup the simultaneous update feature is disabled. EXAMPLE #include <tip675.h> int fd; int result; unsigned long value; /* Enable simultaneous update on falling edge */ value = 1; result = ioctl(fd, T675_IOCS_ENA_EXCLK, &value); if (result < 0) { /* handle ioctl error */ } ERRORS Error Code EFAULT Description Invalid pointer. Please check the argument argp. TIP675-SW-82 - Linux Device Driver Page 20 of 25

3.5.3 T675_IOCS_DIS_EXCLK NAME T675_IOCS_DIS_EXCLK - Disable simultaneous update feature DESCRIPTION This ioctl function disables the simultaneous update feature of the TIP675. The argument argp is not needed and can be omitted. After driver startup the simultaneous update feature is disabled. EXAMPLE #include <tip675.h> int int fd; result; result = ioctl(fd, T675_IOCS_DIS_EXCLK); if (result < 0) { /* handle ioctl error */ } TIP675-SW-82 - Linux Device Driver Page 21 of 25

3.5.4 T675_IOCX_WAIT_TRANS NAME T675_IOCX_WAIT_TRANS - Waiting for a specified input line transition DESCRIPTION This ioctl function will be blocked until a specified transition on a selected input line has occurred or the maximum allowed time is elapsed. If more than one input line is selected at least one transition must occur (logical OR) to finish this function. On success this function returns the transition status to the caller. A pointer to the callers parameter buffer (T675_EVRD_BUFFER) is passed by the parameter argp to the driver. typedef struct { long long } T675_EVRD_BUFFER; mask_1_16; mask_17_32; mask_33_48; status_1_16; status_17_32; status_33_48; mode; timeout; mask_1_16, mask_17_32, mask_33_48 These parameters contain a bit mask to select a certain bit position or a group of bits for an input transition detection. Bits 2 0 to 2 15 of mask_1_16 correspond to Line 1 to 16, Bits 2 0 to 2 15 of mask_17_32 correspond to Line 17 to 32. A certain input line can be selected by setting the corresponding bit position to 1. status_1_16, status_17_32, status_33_48 These parameters receive a bit mask of the corresponding input lines, which can be used to determine the source of the event (interrupt). This is useful if more than one bit is selected. If the selected transition has occurred, the corresponding bit position contains a 1. TIP675-SW-82 - Linux Device Driver Page 22 of 25

mode Specifies the transition mode for this request: Value T675_HIGH_TR T675_LOW_TR T675_ANY_TR Description In this mode the ioctl function will be blocked until a high transition occurred at the selected input line(s). In this mode the ioctl function will be blocked until a low transition occurred at the selected input line(s). In this mode the ioctl function will be blocked until a low or high transition occurred at the selected input line(s). timeout This parameter specifies the amount of time (in ticks) the caller is willing to wait for the occurrence of the requested transition. A value of 0 means wait indefinitely. EXAMPLE #include <tip675.h> int fd; int result; T675_EVRD_BUFFER ev_buf; // Wait for any transition at line 1 or 48 ev_buf.mask_1_16 = 0x0001; ev_buf.mask_17_32 = 0x0000; ev_buf.mask_33_48 = 0x8000; ev_buf.mode = T675_ANY_TR; par.timeout = 1000; result = ioctl(fd, T675_IOCX_WAIT_TRANS, &ev_buf); if (result < 0) { /* handle ioctl error */ } TIP675-SW-82 - Linux Device Driver Page 23 of 25

ERRORS Error Code EFAULT EBUSY ETIME EINTR Description Invalid pointer. Please check the argument argp. The maximum number of concurrent read requests was exceeded. Increase the value of MAX_REQUESTS in tip675def.h. The allowed time to finish the read request is elapsed. Interrupted function call; an asynchronous signal occurred and prevented completion of the call. When this happens, you should try the call again. TIP675-SW-82 - Linux Device Driver Page 24 of 25

4 Debugging For debugging output see tip675.c. You will find the two following symbols: #undef TIP675_DEBUG_INTR #undef TIP675_DEBUG_VIEW To enable a debug output replace undef with define. The TIP675_DEBUG_INTR symbol controls debugging output from the ISR. TIP675 : interrupt entry TIP675 : IACK[0] vector = 0005 The TIP675_DEBUG_VIEW symbol controls debugging output from the remaining part of the driver. TIP675-48 TTL I/O Lines with Interrupts - version 1.2.4 (2010-11-25) TIP675 : Probe new TIP675 mounted on <TEWS TECHNOLOGIES - (Compact)PCI IPAC Carrier> at slot A TIP675 : Create minor node /dev/tip675_0 (devfs). TIP675 : IP I/O Memory Space 00000000 : FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00000010 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000020 : 00 00 00 00 00 00 00 00 00 00 00 00 00 05 TIP675 : IP ID Memory Space 00000000 : 00 49 00 50 00 41 00 43 00 B3 00 36 00 10 00 00 00000010 : 00 00 00 00 00 0C 00 D8 00 00 00 00 00 00 00 00 00000020 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000030 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 TIP675-SW-82 - Linux Device Driver Page 25 of 25