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

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

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

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

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

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

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

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

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.

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

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

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

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.

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

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.

TPMC821-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. INTERBUS Master G4 PMC. Version 1.4. 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

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

TDRV002-SW-82. Linux Device Driver. Multi-Channel Serial Interface Version 1.8.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

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

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

Advcan QNX Driver User Manual V1.02

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

TDRV009-SW-95. QNX6 - Neutrino Device Driver. High Speed Sync/Async Serial Interface Version 1.0.x. User Manual. Issue 1.0.

TDRV009-SW-95. QNX6 - Neutrino Device Driver. User Manual. The Embedded I/O Company. High Speed Sync/Async Serial Interface Version 1.0.

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.

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.

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

OPTO32A 24 Input Bit, 8 Output Bit Optical Isolator Board

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

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

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

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

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

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

in Berlin (Germany) Sponsored by Motorola Semiconductor NEC Electronics (Europe) Siemens Semiconductors Organized by

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

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

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

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

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

spwr_base & spwr_chan

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

Files. Eric McCreath

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

AN Philips LPC2000 CAN driver. Document information

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

Operating Systems II Systems Programming in C

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

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

Socket programming in C

ICS-121. VxWORKS DEVICE DRIVER MANUAL

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

QNX Software Development Platform 6.6. OpenWF Display Configuration Developer's Guide: Modifying the Wfdcfg library

Gryphon Hardware Information: Dual SJA1000 Fault Tolerant CAN card

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

Experiment 6 The Real World Interface

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

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

CS240: Programming in C

JetBox 8152 User Manual. WinCE 6.0 Canbus.

SpiNNaker Application Programming Interface (API)

File Descriptors and Piping

UNIX System Calls. Sys Calls versus Library Func

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories

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

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

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

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

QNX Momentics DDK. Input Devices. For targets running QNX Neutrino or later. 2004, QNX Software Systems Ltd.

MaRTE OS Misc utilities

CANopen Manager. Software Manual. CANopen Manager Manual Doc.-No.: C / Rev esd gmbh Page 1 of 44

CSE 410: Systems Programming

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

10. I/O System Library

PCAN-PCI PCI to CAN Interface. User Manual V2.1.0

NT 200/420. Communication in Gateway Setup SOFTWARE DESIGN GUIDE ENGLISH

CSC 271 Software I: Utilities and Internals

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

ELLSI. EtherCAN Low Level Socket Interface. Software Manual. to Product C.2050.xx and C.2051.xx

ECEN 449 Microprocessor System Design. Review of C Programming

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

libnetfilter_log Reference Manual

PCAN-PCI/104-Express PCI/104-Express to CAN Interface. User Manual V2.1.0

CS , Spring Sample Exam 3

ENGR 3950U / CSCI 3020U (Operating Systems) Simulated UNIX File System Project Instructor: Dr. Kamran Sartipi

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

PCAN-PCI Express PCI Express to CAN Interface. User Manual V2.0.0

PCAN-LIN Interface for LIN, CAN, and RS-232. User Manual. Document version ( )

Naked C Lecture 6. File Operations and System Calls

The Log packing plugin PRINTED MANUAL

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

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

Unlike the methods of all other objects in the MPI, Control object methods are not thread-safe. Error Messages

RX Family APPLICATION NOTE. I 2 C Bus Interface (RIIC) Module Using Firmware Integration Technology. Introduction. Target Device.

PCAN-PC/104-Plus Quad Four-Channel CAN Interface for PC/104-Plus. User Manual V1.0.1

ECE 650 Systems Programming & Engineering. Spring 2018

Shared Memory Memory mapped files

Transcription:

The Embedded I/O Company TDRV010-SW-95 QNX6 - Neutrino Device Driver Isolated 2x CAN Bus Version 1.0.x User Manual Issue 1.0.2 September 2016 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

TDRV010-SW-95 QNX6 - Neutrino Device Driver Isolated 2x CAN Bus Supported Modules: TPMC810 TPMC310 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. 2009-2016 by TEWS TECHNOLOGIES GmbH Issue Description Date 1.0.0 First Issue March 19, 2009 1.0.1 Update Contact Information December 21, 2010 1.0.2 Chapter for Driver Installation with Momentics added September 8, 2016 TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 2 of 36

Table of Contents 1 INTRODUCTION... 4 2 INSTALLATION... 5 2.1 Building Executables on Native Systems...5 2.1.1 Build the Device Driver...5 2.1.2 Build the Example Application...5 2.2 Building Executables with Momentics IDE...6 2.2.1 Build the Device Driver...6 2.2.2 Build the Example Application...6 2.2.3 Integrate the Device Driver Files to a QNX-Image...6 2.3 Start the Driver Process...7 2.4 Receive Queue Configuration...8 3 DEVICE INPUT/OUTPUT FUNCTIONS... 9 3.1 open...9 3.2 close...11 3.3 devctl...12 3.3.1 DCMD_TDRV010_READ(_NOWAIT)...14 3.3.2 DCMD_TDRV010_WRITE...17 3.3.3 DCMD_TDRV010_BITTIMING...19 3.3.4 DCMD_TDRV010_SETFILTER...21 3.3.5 DCMD_TDRV010_BUSON...23 3.3.6 DCMD_TDRV010_BUSOFF...24 3.3.7 DCMD_TDRV010_FLUSH...25 3.3.8 DCMD_TDRV010_CANSTATUS...26 3.3.9 DCMD_TDRV010_ENABLE_SELFTEST...28 3.3.10 DCMD_TDRV010_DISABLE_SELFTEST...29 3.3.11 DCMD_TDRV010_ENABLE_LISTENONLY...30 3.3.12 DCMD_TDRV010_DISABLE_LISTENONLY...31 3.3.13 DCMD_TDRV010_SETLIMIT...32 3.3.14 DCMD_TDRV010_TRANSCEIVER_OPERATING...34 3.3.15 DCMD_TDRV010_TRANSCEIVER_SILENT...35 4 STEP BY STEP DRIVER INITIALIZATION... 36 TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 3 of 36

1 Introduction The TDRV010-SW-95 QNX-Neutrino device driver allows the operation of the TDRV010 CAN Bus devices on QNX-Neutrino operating systems. The TDRV010 device driver is basically implemented as a user installable Resource Manager. The standard file (I/O) functions (open, close and devctl) provide the basic interface for opening and closing a file descriptor and for performing device I/O and control operations. The TDRV010-SW-95 device driver supports the following features: Transmission and receive of Standard and Extended Identifiers Standard bit rates from 50 kbit up to 1 Mbit and user defined bit rates Message acceptance filtering Single-Shot transmission Listen only mode Message self-reception Programmable error warning limit The TDRV010-SW-95 device driver supports the modules listed below: TPMC310 Isolated 2 x CAN Bus (PMC, Conduction Cooled) TPMC810 Isolated 2 x CAN Bus (PMC) In this document all supported modules and devices will be called TDRV010. Specials for certain devices will be advised. To get more information about the features and use of TDRV010 devices it is recommended to read the manuals listed below. TPMC310, TPMC810 User Manual SJA1000 CAN Controller Manual TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 4 of 36

2 Installation Following files are located in the directory TDRV010-SW-95 on the distribution media: TDRV010-SW-95-SRC.tar.gz TDRV010-SW-95-1.0.2.pdf ChangeLog.txt Release.txt GZIP compressed archive with driver source code This manual in PDF format Release history Information about the Device Driver Release The GZIP compressed archive TDRV010-SW-95-SRC.tar.gz contains the following files and directories: Directory path tdrv010 : /driver/tdrv010.c /driver/tdrv010.h /driver/tdrv010def.h /driver/ sja1000.h /driver/node.c /driver/node.h /driver/nto/* /example/example.c /example/nto/* Driver source code Definitions and data structures for driver and application Device driver include Philips SJA1000 CAN controller definitions Queue management source code Queue management definitions Build path Example application Build path 2.1 Building Executables on Native Systems For installation copy the tar-archive into the /usr/src directory and unpack it (e.g. tar xzvf TDRV010-SW-95-SRC.tar.gz). After that the necessary directory structure for the automatic build and the source files are available underneath the new directory called tdrv010. It is absolutely important to extract the TDRV010 tar archive in the /usr/src directory. Otherwise the automatic build with make will fail. 2.1.1 Build the Device Driver Change to the /usr/src/tdrv010/driver directory Execute the Makefile: # make install After successful completion the driver binary (tdrv010) will be installed in the /bin directory. 2.1.2 Build the Example Application Change to the /usr/src/tdrv010/example directory Execute the Makefile: # make install After successful completion the example binary (tdrv010exa) will be installed in the /bin directory. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 5 of 36

2.2 Building Executables with Momentics IDE This chapter gives just a simple description how to build the drivers with the Momentics IDE, for more detailed information please refer to the appropriate Documentation. For installation unpack the tar-archive into the desired working directory. After that the necessary directory structure for the automatic build and the source files are available underneath the new directory called tdrv010. 2.2.1 Build the Device Driver Create a new project ( Makefile Project with Existing Code ) in your workspace: - Select a Project Name (e.g. TDRV010) - Select the path tdrv010\driver in the working directory as Existing Code Location - Select the Toolchain for Indexer Settings (e.g. QNX Multi-toolchain ) Now the device driver can be built by Building the Project. After successful completion the IDE show a Binaries -path containing the built binary of tdrv010 device driver. (e.g. tdrv010 [x86/le] ) 2.2.2 Build the Example Application Create a new project ( Makefile Project with Existing Code ) in your workspace: - Select a Project Name (e.g. TDRV010-Example) - Select the path tdrv010\example in the working directory as Existing Code Location - Select the Toolchain for Indexer Settings (e.g. QNX Multi-toolchain ) Now the example can be built by Building the Project. After successful completion the IDE show a Binaries -path containing the built binary of tdrv010 example application. (e.g. tdrv010exa [x86/le] ) 2.2.3 Integrate the Device Driver Files to a QNX-Image To add the device driver file and the example application file to a QNX-Image, just a view steps are necessary. Copy the desired binary files of the device driver and example project into sbin below of the install - path of the target project using the Momentics-IDE. Add the filenames of the added files into the build-file (e.g. x86-generic.build ) in images. For example the filenames (e.g. tdrv010, tdrv010exa) can be inserted behind the serial driver names. (Insert each filename in a separate line.) After a rebuild of the QNX-Image, the driver files will be available on the disk and can be used after booting. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 6 of 36

2.3 Start the Driver Process To start the TDRV010 device driver, you have to enter the process name with optional parameter from the command shell or in the startup script. tdrv010 [-v] & The TDRV010 Resource Manager creates one device for each CAN channel, and registers the created devices in the Neutrinos pathname space under following names. /dev/tdrv010_0 /dev/tdrv010_1 /dev/tdrv010_x The reference between the created device names and the physical devices depends on the search order of the PCI bus driver. The TDRV010 searches for supported devices in the following order: TPMC810, TPMC310. Example: A system with 1x TPMC810-10, and 2x TPMC316-10 will create the following devices: Module Local Channel Device Name TPMC810-10 1 /dev/tdrv010_0 TPMC810-10 2 /dev/tdrv010_1 TPMC310-10 (1 st ) 1 /dev/tdrv010_2 TPMC310-10 (1 st ) 2 /dev/tdrv010_3 TPMC310-10 (2 nd ) 1 /dev/tdrv010_4 TPMC310-10 (2 nd ) 2 /dev/tdrv010_5 The pathname must be used in the application program to open a path to the desired TDRV010 device. fd = open( /dev/tdrv010_0, O_RDWR); For debugging, you can start the TDRV010 Resource Manager with the v option. Now the Resource Manager will print versatile information about TDRV010 configuration and command execution on the terminal window. tdrv010 v & Make sure that only one instance of the device driver process is started. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 7 of 36

2.4 Receive Queue Configuration Received CAN messages will be stored in a FIFO buffer. The depth of the FIFO can be adapted by changing the following symbol in tdrv010def.h. TDRV010_RX_FIFO_SIZE Defines the depth of the message FIFO buffer (default = 100). Valid numbers are in range between 1 and MAXINT. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 8 of 36

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 <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int open (const char *pathname, int flags) DESCRIPTION The open function creates and returns a new file descriptor for the TDRV010 device named by pathname. The flags argument controls how the file is to be opened. TDRV010 devices must be opened O_RDWR. EXAMPLE int fd; fd = open( /dev/tdrv010_0, O_RDWR); if (fd == -1) { /* Handle error */ } 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. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 9 of 36

ERRORS Returns only Neutrino specific error codes, see Neutrino Library Reference. SEE ALSO Library Reference - open() TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 10 of 36

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 Returns only Neutrino specific error code, see Neutrino Library Reference. SEE ALSO Library Reference - close() TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 11 of 36

3.3 devctl NAME devctl() device control functions SYNOPSIS #include <sys/types.h> #include <unistd.h> #include <devctl.h> int devctl ( int int void size_t int ) filedes, dcmd, *data_ptr, n_bytes, *dev_info_ptr DESCRIPTION The devctl function sends a control code directly to a device, specified by filedes, causing the corresponding device to perform the requested operation. The argument dcmd specifies the control code for the operation. The arguments data_ptr and n_bytes depends on the command and will be described for each command in detail later in this chapter. Usually data_ptr points to a buffer that passes data between the user task and the driver and n_bytes defines the size of this buffer. The argument dev_info_ptr is unused for the TDRV010 driver and should be set to NULL. The following devctl command codes are defined in tdrv010.h: Value DCMD_TDRV010_READ DCMD_TDRV010_READ_NOWAIT DCMD_TDRV010_WRITE DCMD_TDRV010_BITTIMING DCMD_TDRV010_SETFILTER DCMD_TDRV010_BUSON DCMD_TDRV010_BUSOFF DCMD_TDRV010_FLUSH Description Read a CAN message from the specified queue Read CAN message from the specified queue and return immediately if queue is empty Write message to the CAN bus Setup a new bit timing Setup acceptance filter Enter the bus on state Enter the bus off state Flush one or all receive queues TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 12 of 36

DCMD_TDRV010_CANSTATUS DCMD_TDRV010_ENABLE_SELFTEST DCMD_TDRV010_DISABLE_SELFTEST DCMD_TDRV010_ENABLE_LISTENONLY DCMD_TDRV010_DISABLE_LISTENONLY DCMD_TDRV010_SETLIMIT DCMD_TDRV010_TRANSCEIVER_OPERATING DCMD_TDRV010_TRANSCEIVER_SILENT Returns CAN controller status information Enable self-test mode Disable self-test mode Enable listen only mode Disable listen only mode Set new error warning limit Set transceivers to operating state (TPMC310 only) Set transceivers to silent state (TPMC310 only) See behind for more detailed information on each control code. To use these TDRV010 specific control codes the header file tdrv010.h must be included in the application. RETURNS On success, EOK is returned. In the case of an error, the appropriate error code is returned by the function (not in errno!). ERRORS Returns only Neutrino specific error codes, see Neutrino Library Reference. Other function dependent error codes will be described for each devctl code separately. Note, the TDRV010 driver always returns standard QNX error codes. SEE ALSO Library Reference - devctl() TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 13 of 36

3.3.1 DCMD_TDRV010_READ(_NOWAIT) NAME DCMD_TDRV010_READ(_NOWAIT) Read a CAN message DESCRIPTION The read function reads a CAN message from the driver receive queue. A pointer to the callers message buffer (TDRV010_MSG_BUF) and the size of this structure are passed by the parameters data_ptr and n_bytes to the device. typedef struct { unsigned long unsigned char unsigned char unsigned char long unsigned char Identifier; IOFlags; MsgLen; Data[8]; Timeout; Status; } TDRV010_MSG_BUF, *PTDRV010_MSG_BUF; Identifier IOFlags Receives the message identifier of the read CAN message. Receives CAN message attributes as a set of bit flags. The following attribute flags are possible: Value TDRV010_EXTENDED TDRV010_REMOTE_FRAME Description Set if the received message is an extended message frame. Reset for standard message frames. Set if the received message is a remote transmission request (RTR) frame. MsgLen Data[8] Timeout Receives the number of message data bytes (0...8). This buffer receives up to 8 data bytes. Data[0] receives message Data 0, Data[1] receives message Data 1 and so on. Specifies the amount of time (in seconds) the caller is willing to wait for execution of read. A value of 0 means wait indefinitely. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 14 of 36

Status Receives status information about overrun conditions either in the CAN controller or intermediate software FIFO. Value TDRV010_SUCCESS TDRV010_FIFO_OVERRUN TDRV010_MSGOBJ_OVERRUN Description No messages lost One or more messages were overwritten in the receive queue FIFO. This problem occurs if the FIFO is too small for the application read interval. One or more messages were overwritten in the CAN controller message FIFO because the interrupt latency is too large. Reduce the CAN bit rate or upgrade the system speed. EXAMPLE #include tdrv010.h int int TDRV010_MSG_BUF fd; result; MsgBuf; MsgBuf.Timeout = 10; /* seconds */ result = devctl( fd, DCMD_TDRV010_READ, &MsgBuf, sizeof(msgbuf), NULL); if (result!= EOK) { /* process devctl() error */ } TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 15 of 36

ERRORS EINVAL ENOMEM ECONNREFUSED Invalid argument. This error code is returned if the size of the message buffer is too small. No memory available to allocated resources to handle the read command. The controller is in bus OFF state and no message is available in the specified receive queue. Note, as long as CAN messages are available in the receive queue FIFO, bus OFF conditions were not reported by a read function. This means you can read all CAN messages out of the receive queue FIFO during bus OFF state without an error result. ENODATA Currently no CAN message available for read (only DCMD_TDRV010_READ_NOWAIT). ETIMEDOUT The allowed time to finish the read request is elapsed. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 16 of 36

3.3.2 DCMD_TDRV010_WRITE NAME DCMD_TDRV010_WRITE - Write a CAN message DESCRIPTION This devctl function writes a message to the CAN bus. A pointer to the callers message buffer (TDRV010_MSG_BUF) and the size of this structure are passed by the parameters data_ptr and n_bytes to the device. If the CAN controller is busy transmitting a message the caller becomes blocked until all previous pending requests are serviced or a timeout occurs. typedef struct { unsigned long unsigned char unsigned char unsigned char long unsigned char Identifier; IOFlags; MsgLen; Data[8]; Timeout; Status; } TDRV010_MSG_BUF, *PTDRV010_MSG_BUF; Identifier IOFLags MsgLen Contains the message identifier of the CAN message to write. Contains a set of bit flags, which define message attributes and controls the write operation. To set more than one bit flag the predefined macros must be binary OR ed. Value TDRV010_EXTENDED TDRV010_REMOTE_FRAME Description Transmit an extended message frame. If this macro isn't set or the "dummy" macro TDRV010_STANDARD is set a standard frame will be transmitted. A remote transmission request (RTR bit is set) will be transmitted. TDRV010_SINGLE_SHOT No re-transmission will be performed if an error occurred or the arbitration will be lost during transmission (single-shot transmission). TDRV010_SELF_RECEPTION Contains the number of message data bytes (0...8). The message will be transmitted and simultaneously received if the acceptance filter is set to the corresponding identifier. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 17 of 36

Data[8] Timeout Status This buffer contains up to 8 data bytes. Data[0] contains message Data 0, Data[1] contains message Data 1 and so on. Specifies the amount of time (in seconds) the caller is willing to wait for execution of write. Unused for this control function. EXAMPLE #include tdrv010.h int int TDRV010_MSG_BUF fd; result; MsgBuf; MsgBuf.Identifier = 1234; MsgBuf.Timeout = 2; /* sec*/ MsgBuf.IOFlags = TDRV010_EXTENDED; MsgBuf.MsgLen = 2; MsgBuf.Data[0] = 0xaa; MsgBuf.Data[1] = 0x55; result = devctl( fd, DCMD_TDRV010_WRITE, &MsgBuf, sizeof(msgbuf), NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EINVAL ENOMEM ECONNREFUSED Invalid argument. This error code is returned if the size of the message buffer is too small. No memory available to allocated resources to handle the read command. The controller is in bus OFF state and unable to transmit messages. EMSGSIZE Invalid message size. MsgBuf.MsgLen must be in range between 0 and 8. ETIMEDOUT The allowed time to finish the write request is elapsed. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 18 of 36

3.3.3 DCMD_TDRV010_BITTIMING NAME DCMD_TDRV010_BITTIMING Setup new bit timing DESCRIPTION This devctl function modifies the bit timing register of the CAN controller to setup a new CAN bus transfer speed. A pointer to the callers parameter buffer (TDRV010_TIMING) and the size of this structure are passed by the parameters data_ptr and n_bytes to the device. Keep in mind to setup a valid bit timing value before changing into the Bus On state. typedef struct { unsigned short unsigned short TimingValue; ThreeSamples; }TDRV010_TIMING, *PTDRV010_TIMING; TimingValue This parameter holds the new value for the bit timing register 0 (bit 0...7) and for the bit timing register 1 (bit 8...15). Possible transfer rates are between 50 Kbit per second and 1 Mbit per second. The include file 'tdrv010.h' contains predefined transfer rate symbols (TDRV010_50KBIT... TDRV010_1MBIT). For other transfer rates please follow the instructions of the SJA1000 Product Specification. ThreeSamples If this parameter is TRUE (1) the CAN bus is sampled three times per bit time instead of one. Use one sample point for faster bit rates and three sample points for slower bit rate to make the CAN bus more immune against noise spikes. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 19 of 36

EXAMPLE #include tdrv010.h int int TDRV010_TIMING fd; result; BitTimingParam; BitTimingParam.TimingValue = TDRV010_100KBIT; BitTimingParam.ThreeSamples = FALSE; result = devctl( fd, DCMD_TDRV010_BITTIMING, &BitTimingParam, sizeof(bittimingparam), NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EACCES Permission denied. The controller is currently in BUS ON state. Please enter the BUS OFF state before changing the bit timing. SEE ALSO tdrv010.h for predefined bus timing constants. SJA1000 Product Specification Manual 6.5.1/2 BUS TIMING REGISTER. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 20 of 36

3.3.4 DCMD_TDRV010_SETFILTER NAME DCMD_TDRV010_SETFILTER - Setup acceptance filter DESCRIPTION This devctl function modifies the acceptance filter of the specified CAN controller device. The acceptance filter compares the received identifier with the acceptance filter and decides whether a message should be accepted or not. If a message passes the acceptance filter it is stored in the receive FIFO. The acceptance filter is defined by the acceptance code registers and the acceptance mask registers. The bit patterns of messages to be received are defined in the acceptance code register. The corresponding acceptance mask registers allow defining certain bit positions to be "don't care" (a 1 at a bit position means "don't care"). A pointer to the callers parameter buffer (TDRV010_FILTER) and the size of this structure are passed by the parameters data_ptr and n_bytes to the device. typedef struct { int unsigned long unsigned long SingleFilter; AcceptanceCode; AcceptanceMask; } TDRV010_FILTER, *PTDRV010_FILTER; SingleFilter Set TRUE (1) for single filter mode. Set FALSE (0) for dual filter mode. AcceptanceCode The content of this parameter will be written to acceptance code register of the controller. AcceptanceMask The content of this parameter will be written to the acceptance mask register of the controller. A detailed description of the acceptance filter and possible filter modes can be found in the SJA1000 Product Specification Manual. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 21 of 36

EXAMPLE #include tdrv010.h int int TDRV010_FILTER fd; result; AcceptFilter; /* Not relevant because all bits are "don't care" */ AcceptFilter.AcceptanceCode = 0x0; /* Mark all bit position don't care */ AcceptFilter.AcceptanceMask = 0xffffffff; /* Single Filter Mode */ AcceptFilter.SingleFilter = 1; // TRUE result = devctl( fd, DCMD_TDRV010_SETFILTER, & AcceptFilter, sizeof(acceptfilter), NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EACCES Permission denied. The controller is currently in BUS ON state. Please enter the BUS OFF state before changing the acceptance filter. SEE ALSO SJA1000 Product Specification Manual 6.4.15 ACCEPTANCE FILTER TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 22 of 36

3.3.5 DCMD_TDRV010_BUSON NAME DCMD_TDRV010_BUSON - Enter the bus ON state DESCRIPTION This devctl function sets the specified CAN controller into the bus ON state. After an abnormal rate of occurrences of errors on the CAN bus or after driver startup, the CAN controller enters the Bus OFF state. This control function resets the "reset mode" bit in the mode register. The CAN controller begins the Bus OFF recovery sequence and resets the transmit and receive error counters. If the CAN controller counts 128 packets of 11 consecutive recessive bits on the CAN bus, the Bus OFF state is exited. Before the driver is able to communicate over the CAN bus after driver startup, this control function must be executed. EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_BUSON, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS ECONNREFUSED Unable to enter the Bus ON mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD). TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 23 of 36

3.3.6 DCMD_TDRV010_BUSOFF NAME DCMD_TDRV010_BUSOFF - Enter the bus OFF state DESCRIPTION This devctl function sets the specified CAN controller into the bus OFF state. After execution of this control function the CAN controller is completely removed from the CAN bus and cannot communicate until the control function DCMD_TDRV010_BUSON is executed. EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_BUSOFF, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EIO Unable to enter the bus OFF mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD). TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 24 of 36

3.3.7 DCMD_TDRV010_FLUSH NAME DCMD_TDRV010_FLUSH - Flush the received message FIFO DESCRIPTION This devctl function flushes the FIFO buffer of received CAN messages. EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_FLUSH, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 25 of 36

3.3.8 DCMD_TDRV010_CANSTATUS NAME DCMD_TDRV010_CANSTATUS - Returns CAN controller status information DESCRIPTION This devctl function returns the actual contents of several CAN controller registers for diagnostic purposes. A pointer to the callers status buffer (TDRV010_STATUS) and the size of this structure are passed by the parameters data_ptr and n_bytes to the device. typedef struct { unsigned char unsigned char unsigned char unsigned char unsigned char unsigned char unsigned char unsigned char ArbitrationLostCapture; ErrorCodeCapture; TxErrorCounter; RxErrorCounter; ErrorWarningLimit; StatusRegister; ModeRegister; RxMessageCounterMax; } TDRV010_STATUS, *PTDRV010_STATUS; ArbitrationLostCapture Contents of the arbitration lost capture register. This register contains information about the bit position of losing arbitration. ErrorCodeCapture Contents of the error code capture register. This register contains information about the type and location of errors on the bus. TxErrorCounter Contents of the TX error counter register. This register contains the current value of the transmit error counter. RxErrorCounter Contents of the TX error counter register. This register contains the current value of the receive error counter. ErrorWarningLimit Contents of the error warning limit register. StatusRegister Contents of the status register. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 26 of 36

ModeRegister Contents of the mode register. RxMessageCounterMax Contains the peak value of messages in the receive FIFO. This internal counter value will be reset to 0 after reading. EXAMPLE #include tdrv010.h int int TDRV010_STATUS fd; result; CanStatus; result = devctl( fd, DCMD_TDRV010_CANSTATUS, &CanStatus, sizeof(canstatus), NULL); if (result!= EOK) { /* process devctl() error */ } SEE ALSO SJA1000 Product Specification Manual TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 27 of 36

3.3.9 DCMD_TDRV010_ENABLE_SELFTEST NAME DCMD_TDRV010_ENABLE_SELFTEST - Enable self-test mode DESCRIPTION This devctl function enables the self-test facility of the SJA1000 CAN controller. In this mode a full node test is possible without any other active node on the bus using the selfreception facility. The CAN controller will perform a successful transmission even if there is no acknowledge received. Also in self-test mode the normal functionality is given, that means the CAN controller is able to receive messages from other nodes and can transmit message to other nodes if any connected. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_ENABLE_SELFTEST, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EACCES The CAN controller is in operating mode. This mode can be changed only in reset mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD) TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 28 of 36

3.3.10 DCMD_TDRV010_DISABLE_SELFTEST NAME DCMD_TDRV010_DISABLE_SELFTEST - Disable self-test mode DESCRIPTION This devctl function disables the self-test facility of the SJA1000 CAN controller, which has been enabled before with the devctl command DCMD_TDRV010_ENABLE_SELFTEST. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_DISABLE_SELFTEST, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EACCES The CAN controller is in operating mode. This mode can be changed only in reset mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD) TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 29 of 36

3.3.11 DCMD_TDRV010_ENABLE_LISTENONLY NAME DCMD_TDRV010_ENABLE_LISTENONLY - Enable listen only mode DESCRIPTION This devctl function enables the listen only facility of the SJA1000 CAN controller. In this mode the CAN controller would give no acknowledge to the CAN-bus, even if a message is received successfully. Message transmission is not possible. All other functions can be used like in normal mode. This mode can be used for software driver bit rate detection and 'hot-plugging'. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_ENABLE_LISTENONLY, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EACCES The CAN controller is in operating mode. This mode can be changed only in reset mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD) TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 30 of 36

3.3.12 DCMD_TDRV010_DISABLE_LISTENONLY NAME DCMD_TDRV010_DISABLE_LISTENONLY - Disable listen only mode DESCRIPTION This devctl function disables the listen only facility of the SJA1000 CAN controller, which has been enabled before with the devctl command DCMD_TDRV010_ENABLE_LISTENONLY. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_DISABLE_LISTENONLY, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS EACCES The CAN controller is in operating mode. This mode can be changed only in reset mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD) TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 31 of 36

3.3.13 DCMD_TDRV010_SETLIMIT NAME DCMD_TDRV010_SETLIMIT - Disable listen only mode DESCRIPTION This devctl function sets a new error warning limit in the corresponding CAN controller register. The default value (after hardware reset) is 96. The new error warning limit will be set in an unsigned char variable. A pointer to this variable is passed by the parameters data_ptr to the driver. The size of this variable is passed by the parameter n_bytes to the driver. This devctl command will be accepted only in reset mode (BUSOFF). Enter DCMD_TDRV010_BUSOFF first otherwise you will get an error (EACCES). EXAMPLE #include tdrv010.h int fd; int result; unsigned char ErrorLimit ErrorLimit = 20; result = devctl( fd, DCMD_TDRV010_SETLIMIT, &ErrorLimit, sizeof(errorlimit), NULL); if (result!= EOK) { /* process devctl() error */ } TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 32 of 36

ERRORS EACCES The CAN controller is in operating mode. This mode can be changed only in reset mode. SEE ALSO SJA1000 Product Specification Manual 6.4.3 MODE REGISTER (MOD) TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 33 of 36

3.3.14 DCMD_TDRV010_TRANSCEIVER_OPERATING NAME DCMD_TDRV010_TRANSCEIVER_OPERATING Switch transceiver into Operating Mode DESCRIPTION This devctl function switches the onboard transceivers for the specific channel into Operating Mode. This function is only supported by TPMC310 modules. EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_TRANSCEIVER_OPERATING, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS ENOTSUP Function is not supported by hardware. SEE ALSO TPMC310 Hardware User Manual TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 34 of 36

3.3.15 DCMD_TDRV010_TRANSCEIVER_SILENT NAME DCMD_TDRV010_TRANSCEIVER_SILENT Switch transceiver into Silent Mode DESCRIPTION This devctl function switches the onboard transceivers for the specific channel into Silent Mode. This function is only supported by TPMC310 modules. EXAMPLE #include tdrv010.h int fd; int result; result = devctl( fd, DCMD_TDRV010_TRANSCEIVER_SILENT, NULL, 0, NULL); if (result!= EOK) { /* process devctl() error */ } ERRORS ENOTSUP Function is not supported by hardware. SEE ALSO TPMC310 Hardware User Manual TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 35 of 36

4 Step by Step Driver Initialization The following code example illustrates all necessary steps to initialize a CAN device for communication, assuming the device is in BUSOFF state. /* ** ( 1.) Setup CAN bus bit timing */ BitTimingParam.TimingValue = TDRV010_100KBIT; BitTimingParam.ThreeSamples = 0; /* FALSE */ result = devctl( fd, DCMD_TDRV010_BITTIMING, &BitTimingParam, sizeof(bittimingparam), NULL); /* ** ( 2.) Setup acceptance filter masks */ AcceptFilter.AcceptanceCode = 0x0; AcceptFilter.AcceptanceMask = 0xFFFFFFFF; AcceptFilter.SingleFilter = 1; result = devctl( fd, DCMD_TDRV010_SETFILTER, & AcceptFilter, sizeof(acceptfilter), NULL); /* ** ( 3.) Enter Bus On State */ result = devctl( fd, DCMD_TDRV010_BUSON, NULL, 0, NULL); Now you should be able to send and receive CAN messages with appropriate calls to DCMD_TDRV010_WRITE and DCMD_TDRV010_READ functions. TDRV010-SW-95 QNX6 - Neutrino Device Driver Page 36 of 36