Home

TDRV011-SW-42

image

Contents

1. cccccceeeeeeeeeeeeeeeeeeaeeeeeeeeeeeeesaeeesaaeeeeaeeseeeesaeeeeaeeeeneeee 32 3 2 9 tdrv011DefineTransmitMSQOb j ccceeeeeeeeeee cece ee eeeeeeeeeeeeeeeeeaeeeeaaeseeaeeseeeeseaeeesaeeeeneeee 34 3 2 10 tdrv011DefineRemoteMsgOb c ccceeeeeeeeeeeeeeeeeeeeceeeeeceaeeesaaeeeeaeeseeeeeseaeeeseaeeseaeeeeaes 37 3 2 11 Fdrv 1 Update TransmmtMsoCpt A0 3 2 12 tdrv011UpdateRemoteMSgOh cceccceeeeeeeeeeeeeeeeeeeeeeseaeeeeaaeeeeaeeseeeeesaeeesaeeneaeeeeees 43 3 2 13 tdrv011RequestRemoteData A 46 3 2 14 tdrv011ReleaseMsgObj cceceeeeeeeceeeeeeeeeeeeeaeeeeaae sense seaeeesaaeeseaeeseeeeseaeeesaeeneaeeeeaes 48 3 2 15 tdrv011 GetMsgObjStatus 0 22 eee ceeeeeeeeeeeneeeeaeeeeeeeseneeeceaeeesaaeeseaeeseeeeeseaeeesaeeseaeeeeees 50 3 2 16 e anta BEI 52 3 2 17 OVO T e BEE 54 3 2 18 tawO11FlushReceiveF i Oe cnnan S 56 3 2 19 tdrv011GetControllerStatus A 58 4 LEGACY I O SYSTEM FUNCTIONS sssssnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 60 Reck DT AYA E 60 4 2 tdrvOTIDEVGreate E E EAE E E E EEE 62 GS do avoin UA E 64 eeh lu err EE E EE E E E E E E T 65 5 BASIG VO FUNCTIONS wicsssssacecentsdcncencsdcnsancsadecantuaderanduacesancuddecendeacseenesddanentvasenczexens 67 5 1 ORD CT UE E 67 2 e oT 1 O sates cases E E E cs suuncececsevat es ctuneuseccuees ss aucemes cues E E E E E E T 69 SS OCCU E 71 5 3 1 TDORVOTI E RE 73 53 2 RI TONI RN EE 75 53 3 TDORVOTI FLUSH E
2. TDRV011_IO_BUFFER rw I O parameter block for read Read a message from a TDRV011 device flush the input ring buffer before reading if there is no message in the read buffer the read request times out after 500 ticks Wi rw flags TDRVO11_F_ FLUSH 500 ticks rw timeout retval ioctl fd TDRVO11_ READ int rw if retval ERROR process received message printf Message received n printf Identifier td rw identifier printf Message length d byte n rw length printf Message data for i 0 i lt lt rw length i printf 02Xh rw data i printf n else handle error ERROR CODES Error code Description S_tdrv011Drv_BUSOFF The device is in BUS OFF state S_tdrv011Drv_NODATA No data is available S_tdrv011Drv_TIMEOUT The read request timed out TDRV011 SW 42 VxWorks Device Driver Page 74 of 96 TEWS amp TECHNOLOGIES 5 3 2 TDRV011_WRITE This I O control function writes a CAN message to specified device The function specific control parameter arg is a pointer on a TDRVO11_ O_BUFFER structure for this function If the device is blocked by another write request the requesting task will be blocked until the request times out If the flag TDRVO11_F_NOWAIT is set write returns immediately typedef struct unsigned long flags unsigned long timeout unsigned long identifier unsigned char
3. TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result int msgNum unsigned long msgIdentifier int msgExtended int msgLength unsigned char msgData TDRV0O11_MSG_LEN Define a transmit buffer object to send the CAN message immediately msgNum 2 msgIidentifier 1234 msgExtended TRUE msgLength 2 msgData 0 0xaa msgData 1 Oxbb result tdrv011DefineTransmitMsgObj pDev msgNum msgIidentifier msgExtended msgLength msgData 0 i if result ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 35 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified e g transmit message object number S_tdrv0i11Drv_MSGBUSY The specified message is already in use TDRV011 SW 42 VxWorks Device Driver Page 36 of 96 TEWS amp TECHNOLOGIES 3 2 10 tdrv011DefineRemoteMsgObj Name tdrv011DefineRemoteMsgObj setup a remote transmit buffer message object Synopsis STATUS tdrv01 1 DefineRemoteMs
4. 31 of this parameter The Message 15 Mask is ANDed with the Global Mask This means that any bit defined as don t care in the Global Mask will automatically be a don t care bit for message 15 See also Intel 82527 Architectural Overview EXAMPLE include tdrv011 h int Sch int retval TDRVO11_ACCEPT_MASKS acceptMasks retval ioctl fd TDRVO11_GETFILTER int amp acceptMasks if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 80 of 96 TENSE TECHNOLOGIES 5 3 6 TDRV011_BITTIMING This UO control function modifies the bit timing register of the CAN controller The function specific control parameter arg is a pointer on a TDRV011_ARGS structure for this function typedef struct unsigned long cmd unsigned long flags unsigned long arg TDRV011_ARGS cmd The cmd argument is not used flags If the I O flag TDRV011_F_THREE_SAMPLES is set in the flags argument the CAN bus is sampled three times per bit time instead of one time arg The parameter arg holds the new values for the bit timing register 0 bit 8 15 and for the bit timing register 1 bit 0 7 Possible transfer rates are between 20 KBit per second and 1 0 MBit per second The include file tdrv011 h contains predefined transfer rates For other transfer rates please follow the instructions of the Intel 82527 Architectural Overview EXAMPLE include tdrv0
5. TENSE The Embedded I O Company TECHNOLOGIES TDRV011 SW 42 VxWorks Device Driver Extended CAN Bus Version 2 0 x User Manual Issue 2 0 0 June 2010 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek Germany Phone 49 0 4101 40580 Fax 49 0 4101 4058 19 e mail info tews com www tews com TDRV011 SW 42 VxWorks Device Driver Extended CAN Bus Supported Modules TEWS amp TECHNOLOGIES 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 2010 by TEWS TECHNOLOGIES GmbH TPMC316 TPMC816 TPMC901 Issue Description 1 0 0 First Issue 1 0 1 Description BSP dependent adjustment added 1 0 2 Description BSP dependent adjustment changed 1 1 0 BUSOFF function added 1 2 0 Transmit Message Object configuration added 2 0 0 VxBus SMP Support and API description added TDRV011 SW 42 VxWorks Device Driver Date December 21 2006 January 25 2007 January 29 2007 November 21 2008 April 23 2009 June 7 2010 Page 2 of 96 TEWS amp TECHNOLOGIES Table of Conte
6. 1 means that the incoming bit value must match identically to the corresponding bit in the message identifier Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pGlobalMaskStandard This parameter is a pointer to an unsigned short 16bit value where the contents of the Global Mask Standard Register is stored The 11 bit identifier appears in bit position 5 15 pGlobalMaskExtended This parameter is a pointer to an unsigned long 32bit value where the contents of the Global Mask Extended Register is stored The 29 bit identifier appears in bit position 3 31 pMessage15Mask This parameter is a pointer to an unsigned long 32bit value where the contents of the Message 15 Mask Register is stored The 29 bit identifier appears in bit position 3 31 A detailed description of the acceptance filter can be found in the Intel 82527 Architectural Overview Acceptance Filtering Implications TDRV011 SW 42 VxWorks Device Driver Page 28 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result unsigned short globalMaskStandard unsigned long globalMaskExtended unsigned long messagel5Mask Set acceptance filter Wi result tdrv011GetFilter pDev amp globalMaskStandard amp globalMaskExtended messagel5Mask i if resu
7. DevId 0x9050 VenId 0x10b5 Init OK vxDev 0x4bb218 1 TPMC316 Bus 4 Dev 2 DevId 0x013c VenId 0x1498 Init OK vxDev 0x4bb318 Associated Devices 0 TPMC901 tdrv011 0 0 tdrv011 0 1 tdrv011 0 2 tdrv011 0 3 tdrv011 0 4 tdrv011 0 5 1 TPMC316 tdrv011 1 0 tdrv011 1 1 Device Statistics tdrv011 0 0 open count 0 Il N interrupt count bus off count 0 receive count 0 transmit count 2 object overrun 0 fifo overrun 0 timing value 0x14 global standard mask Oxffff global extended mask Oxffffffff local message 15 mask 0x0 tdrv011 0 1 open count 0 Il N interrupt count bus off count 0 receive count 2 transmit count 0 object overrun 0 fifo overrun 0 timing value 0x14 global standard mask Oxffff global extended mask Oxffffffff local message 15 mask 0x0 TDRV011 SW 42 VxWorks Device Driver Page 95 of 96 7 Appendix 7 1 Additional Error Codes Error code S_tdrv011Drv_IDLE S_tdrv011Drv_NXIO S_tdrv011Drv_IDEVICE S_tdrv011Drv_ICMD S_tdrv011Drv_NOTINIT S_tdrv011Drv_ _NOMEM S_tdrv011Drv_TIMEOUT S_tdrv011Drv_BUSY S_tdrv011Drv_NOSEM S_tdrv011Drv_NODATA S_tdrv011Drv_IPARAM S_tdrv011Drv_PARAM_MISMATCH S_tdrv011Drv_OVERRUN S_tdrv011Drv_BUSOFF S_tdrv011Drv_IMSGNUM S_tdrv011Drv_MSGBUSY S_tdrv011Drv_MSGNOTDEF S_tdrv011Drv_NODRV TDRV011 SW 42 VxWorks Device Driver Error value 0x00000000 0x00110001 0x001 10002 0x001 10003 0x001 10004
8. increase the according values in your project TDRV011 SW 42 VxWorks Device Driver Page 10 of 96 TEWS amp TECHNOLOGIES 3 API Documentation 3 1 General Functions 3 1 1 tdrv0110Open Name tdrv011Open opens a device Synopsis TDRV011_DEV tdrv0110pen char DeviceName Description Before I O can be performed to a device a file descriptor must be opened by a call to this function Parameters DeviceName This parameter points to a null terminated string that specifies the name of the device The naming convention for Legacy and VxBus devices is slightly differently Basically the device name consists of the three parts a prefix and a 0 based module and channel number separated by slash characters e g tdrv011 0 0 tdrv011 0 1 etc For the VxBus driver the first probed TDRV011 module gets the module number 0 the second probed TDRV011 module gets module number 1 and so forth The CAN channels on those TDRV011 modules are numbered from 0 for the first channel to lt n gt for the last channel where lt n gt depends on the number CAN channels provided by the TDRV011 module For a configuration with a 2 channel TPMC816 first module and a 6 channel TPMC901 the following devices will be created TPMC816 tdrv01 1 0 0 tdrv011 0 1 TPMC901 tdrvO1 1 1 0 tdrv011 1 1 tdrv011 1 2 tdrv01 1 1 83 tdrv011 1 4 tdrv011 1 5 For the Legacy driver the device name is specified by the a
9. specific control parameter arg is a pointer to an unsigned long value which will be set to the registers content EXAMPLE include tdrv011 h int fd int retval unsigned long canStat retval if ioctl fd retval ERROR handle error printf CAN state Xh TDRV011 SW 42 VxWorks Device Driver TDRVO11_CAN_STATUS canStat int amp canStat Page 94 of 96 TEWS amp TECHNOLOGIES 6 Debugging and Diagnostic Especially the TDRV011 VxBus device driver provides functions and debug statements to display versatile information of the driver installation and status on the debugging console By default the TDRV011 show routine is included in the driver and can be called from the VxWorks shell If this function is not needed or program space is rare the function can be removed from the code by un defining the macro INCLUDE_TDRV011_SHOW in tdrv01 1drv c The tdrv011 Show function displays detailed information about probed modules assignment of devices respective device names to probed TRDV011 modules and device statistics If TDRVO11 modules were probed but no devices were created it may helpful to enable debugging code inside the driver code by defining the macro TDRV011_DEBUG in tdrv011drv c Certain debug information can be selected by assigning one or more logical OR TDRV_DBD_xxx values to variable tdrv011 Debug gt tdrv011Show Probed Modules 0 TPMC901 Bus 4 Dev 1
10. 1 2 tdrv011Close Name tdrv011Close closes a device Synopsis int tdrv011Close TDRV011_DEV pDev Description This function closes previously opened devices Parameters pDev This value specifies the file descriptor pointer to the hardware module retrieved by a call to the corresponding open function Example include tdrv011 h TDRV0O11_DEV pDev int result close file descriptor to device result tdrv011Close pDev if result lt 0 handle close error RETURNS Zero or 1 if the function fails An error code will be stored in errno TDRV011 SW 42 VxWorks Device Driver Page 13 of 96 TEWS amp TECHNOLOGIES ERROR CODES The error codes are stored in errno The error code is a standard error code set by the I O system TDRV011 SW 42 VxWorks Device Driver Page 14 of 96 TEWS amp TECHNOLOGIES 3 2 Device Access Functions 3 2 1 tdrv011Read Name tdrv011Read read a CAN message Synopsis STATUS tdrv011Read TDRV011_DEV pDev Int flushBeforeRead int timeout unsigned long pldentifier int pExtended int pLength unsigned char pData Description This function reads a CAN message from the specified channel If no message is available the call is blocked until a message is received or the request times out Before the driver can receive CAN messages it s necessary to define at least one receive messa
11. 3 5 TDRV011_GETFILTER This I O control function reads the acceptance filter masks from the CAN Controller The function specific control parameter arg is a pointer on a TDRVO11_ACCEPT_MASKS structure for this function The acceptance masks allow message objects to receive messages with a range of message identifiers instead of just a single message identifier A 0 value means don t care or accept a 0 or 1 for that bit position A value of 1 means that the incoming bit value must match identically to the corresponding bit in the message identifier typedef struct unsigned short GlobalMaskStandard unsigned long GlobalMaskExtended unsigned long Message15Mask TDRV011_ACCEPT_MASKS GlobalMaskStandard The parameter GlobalMaskStandard returns the value for the Global Mask Standard Register The Global Mask Standard Register applies only to messages using the standard CAN identifier This 11 bit identifier appears in bit 5 15 of this parameter GlobalMaskExtended The parameter GlobalMaskExtended returns the value for the Global Mask Extended Register The Global Mask Extended Register applies only to messages using the extended CAN identifier This 29 bit identifier appears in bit 3 31 of this parameter Message 15Mask The parameter Message15Mask returns the value for the Message 15 Mask Register The Message 15 Mask Register is a local mask for message object 15 This 29 bit identifier appears in bit 3
12. 8 9 10 bitTiming This parameter specifies the initial bit timing of the device Standard values are defined in tdrv011 h EXAMPLE include tdrv011 h STATUS result Create the device tdrv011 0 0 for the first CAN device Tnitial Bittiming 250 KBps result tdrv011DevCreate tdrv011 0 0 0 TDRV011_250KBIT if result ERROR Error handling RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error codes are stored in errno and can be read with the function errnoGet Error code Description S_tdrv011Drv_NODRV The driver has not been started S_tdrv011Drv_NXIO The specified device is not available SEE ALSO VxWorks Programmer s Guide I O System TDRV011 SW 42 VxWorks Device Driver Page 63 of 96 TEWS amp TECHNOLOGIES 4 3 tdrv011Pcilnit NAME tdrv011Pcilnit Generic PCI device initialization SYNOPSIS void tdrv011 Pcilnit DESCRIPTION This function is required only for Intel x86 VxWorks platforms The purpose is to setup the MMU mapping for all required TDRV011 PCI spaces base address register and to enable the TDRV011 device for access The global variable tdrv011Status obtains the result of the device initialization and can be polled later by the application before the driver will be installed Value Meaning gt 0 Initialization successful completed The value of tdrv0
13. Driver TDRV011 device driver source TDRV011 driver include file Controller definitions TDRV011 include file for driver and application TDRV011 device driver source for x86 based systems TDRV011 API file Example application Hardware dependent interface functions and definitions Page 6 of 96 TEWS amp TECHNOLOGIES 2 1 Legacy vs VxBus Driver In later VxWorks 6 x releases the old VxWorks 5 x legacy device driver model was replaced by VxBus enabled device drivers Legacy device drivers are tightly coupled with the BSP and the board hardware The VxBus infrastructure hides all BSP and hardware differences under a well defined interface which improves the portability and reduces the configuration effort A further advantage is the improved performance of API calls by using the method interface and bypassing the VxWorks basic I O interface VxBus enabled device drivers are the preferred driver interface for new developments The checklist below will help you to make a decision which driver model is suitable and possible for your application Legacy Driver VxBus Driver VxWorks 5 x releases VxWorks 6 6 and later releases VxWorks 6 5 and earlier ma xBus POI Bug releases SMP systems only the VxBus i i VxWorks 6 x releases without driver is SMP satel VxBus PCI bus support TEWS TECHNOLOGIES recommends not using the VxBus Driver before VxWorks release 6 6 In previous releases required header files are mi
14. TDRVO11_ARGS argBuf Update message object 3 and start transmission Ld argBuf arg unsigned long amp MsgDef argBuf flags 0 MsgDef MsgNum 3 MsgDef length 1 MsgDef data 0 y retval ioctl fd TDRVO11_UPDATE_MSG int amp argBuf if retval ERROR handle error ERROR CODES Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified e g transmit message object S_tdrv011Drv_MSGBUSY The specified message is in use S_tdrv011Drv_MSGNOTDEF The message object has not been defined TDRV011 SW 42 VxWorks Device Driver Page 88 of 96 5 3 9 TDRV011_CANCEL MSG TEWS amp TECHNOLOGIES This I O control function marks the specified message object as invalid and stops transaction regarding the object The function specific control parameter arg specifies the new message object number Allowed message numbers are 1 15 EXAMPLE include tdrv011 h int Edi int retval Cancel messag object 3 TDRV0O11_CANCEL_MSG ERROR retval if ioctl fd retval handle error ERROR CODES Error code S_tdrv011Drv_IMSGNUM TDRV011 SW 42 VxWorks Device Driver SL Description Illegal message number specified Page 89 of 96 5 3 10 TDRV011_BUSON TENSE TECHNOLOGIES This function set the specified device to buson state The function specific control parameter arg is not used for this function Af
15. close a device or file SYNOPSIS STATUS close int fd DESCRIPTION This function closes opened devices PARAMETER fd This file descriptor specifies the device to be closed The file descriptor has been returned by the open function EXAMPLE int fd STATUS retval AN xx close the device retval close fd if retval ERROR Handle error TDRV011 SW 42 VxWorks Device Driver Page 69 of 96 TENSE TECHNOLOGIES RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error code can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual SEE ALSO ioLib basic I O routine close TDRV011 SW 42 VxWorks Device Driver Page 70 of 96 5 3 ioctl NAME ioctl performs an I O control function SYNOPSIS include tdrv011 h int ioctl int fd int request int arg DESCRIPTION TEWS amp TECHNOLOGIES Special I O operation that do not fit to the standard basic I O calls read write will be performed by calling the ioctl function PARAMETER fd This file descriptor specifies the device to be used The file descriptor has been returned by the open function request This argument specifies the function that shall be executed Following functions are defined Function TDRV011_READ TDRV011_WRITE TDRV011_
16. for a description of possible error codes TDRV011 SW 42 VxWorks Device Driver Page 66 of 96 TEWS amp TECHNOLOGIES 5 Basic I O Functions The VxWorks basic I O interface functions are useable with the TDRV011 legacy and VxBus enabled driver in a uniform manner 5 1 open NAME open open a device or file SYNOPSIS int open const char name int flags int mode DESCRIPTION Before I O can be performed to the TDRV011 device a file descriptor must be opened by invoking the basic I O function open PARAMETER name This parameter points to a null terminated string that specifies the name of the device See also 3 1 1 tdrv0110pen for the device naming convention for TDRV011 devices flags Not used mode Not used TDRV011 SW 42 VxWorks Device Driver Page 67 of 96 TEWS amp TECHNOLOGIES EXAMPLE int fd open the device named tdrv011 0 0 for I O SEH fd open tdrv011 0 0 0 0 if fd ERROR Handle error RETURNS A device descriptor number or ERROR If the function fails an error code will be stored in errno ERROR CODES The error code can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual SEE ALSO ioLib basic I O routine open TDRV011 SW 42 VxWorks Device Driver Page 68 of 96 TEWS amp TECHNOLOGIES 5 2 close NAME close
17. for this function If the device is blocked by another read request or no message is available in the read buffer the requesting task will be blocked until a message is received or the request times out If the flag TDRV011_F_NOWAIT is set read returns immediately typedef struct unsigned long flags unsigned long timeout unsigned long identifier unsigned char extended unsigned char length unsigned char data 8 TDRV011_IO_BUFFER flags The parameter flags define a flag field used to control the read operation If the flag TDRVO11_F_FLUSH is set a flush of the device message FIFO will be performed before initiating the read request If the flag TDRVO11_F_NOWAIT is set read returns immediately if the device is blocked by another read request or no message is available timeout The parameter timeout specifies the timeout interval in units of clock ticks A timeout value of 0 means wait indefinitely identifier The parameter identifier returns the message identifier standard or extended of the message received extended The parameter extended is TRUE 1 for extended identifier and FALSE 0 for standard identifier length The parameter length returns the size of message data received in bytes data The data bytes of the message received will be returned in data TDRV011 SW 42 VxWorks Device Driver Page 73 of 96 TENSE TECHNOLOGIES EXAMPLE include tdrv011 h int fd int retval int i
18. messages with a range of message identifiers instead of just a single message identifier A 0 value means don t care or accept a 0 or 1 for that bit position A value of 1 means that the incoming bit value must match identically to the corresponding bit in the message identifier Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function globalMaskStandard This parameter contains the value for the Global Mask Standard Register The Global Mask Standard Register applies only to messages using the standard CAN identifier The 11 bit identifier appears in bit position 5 15 globalMaskExtended This parameter contains the value for the Global Mask Extended Register The Global Mask Extended Register applies only to messages using the extended CAN identifier The 29 bit identifier appears in bit position 3 31 message 15Mask This parameter contains the value for the Message 15 Mask Register The Message 15 Mask Register is a local mask for message object 15 The 29 bit identifier appears in bit position 3 31 The Message 15 Mask is ANDed with the Global Mask This means that any bit defined as don t care in the Global Mask will automatically be a don t care bit for message 15 TDRV011 SW 42 VxWorks Device Driver Page 26 of 96 TENSE TECHNOLOGIES A detailed description of the acceptance filter can be found in the Int
19. msgLength unsigned char msgData TDRVO11_MSG_LEN xx Write a CAN message to the device Wi msgIldentifier 1234 msgExtended TRUE msgLength 2 msgData 0 Oxaa msgData 1 Oxbb result tdrv011WriteNoWait pDev msgidentifier msgExtended msgLength msgData 0 i if result ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 24 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_BUSOFF The device is in BUS OFF state S_tdrv011Drv_IPARAM Illegal parameter value specified S_tdrv011Drv_TIMEOUT The device is busy and cannot send the message immediatly TDRV011 SW 42 VxWorks Device Driver Page 25 of 96 TEWS amp TECHNOLOGIES 3 2 5 tdrv011SetFilter Name tdrv011SetFilter set acceptance filter masks Synopsis STATUS tdrv011SetFilter TDRV011_DEV pDev unsigned short globalMaskStandard unsigned long globalMaskExtended unsigned long message15Mask Description This function modifies the acceptance filter masks of the specified CAN controller The acceptance masks allow message objects to receive
20. number of message data bytes 0 8 TDRV011 SW 42 VxWorks Device Driver Page 20 of 96 TEWS amp TECHNOLOGIES pData This buffer contains up to 8 data bytes pData 0 contains message Data 0 pData 1 contains message Data 1 and so on Example TDRVO11_DEV STATUS unsigned long int int unsigned char include tdrv011 h pDev result msgidentifier msg msg msg xx Write a CAN message Wi msgIidentifier 1234 msgExtended TRUE msgLength 2 msgData 0 Oxaa msgData 1 Oxbb result tdrv011Write if result ERROR Extended Length Data TDRVO11_MSG_LEN pDev 120 msgIidentifier msgExtended msgLength msgData 0 i handle error TDRV011 SW 42 VxWorks Device Driver Page 21 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_BUSOFF The device is in BUS OFF state S_tdrv011Drv_IPARAM Illegal parameter value specified S_tdrv011Drv_TIMEOUT The write request timed out TDRV011 SW 42 VxWorks Device Driver Page 22 of 96 TEWS amp TECHN
21. specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified e g transmit message object number S_tdrv011Drv_MSGBUSY The specified message is already in use TDRV011 SW 42 VxWorks Device Driver Page 33 of 96 TEWS amp TECHNOLOGIES 3 2 9 tdrv011DefineTransmitMsgObj Name tdrv011DefineTransmitMsgObj setup a message object for transmit Synopsis STATUS tdrv01 1 Define TransmitMsgObj TDRV011_DEV pDev int messageNumber unsigned long identifier int extended int length unsigned char pData Description This function setup a free controller message object to transmit CAN messages immediately without waiting for an acknowledge Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the message object to define Valid numbers are in the range between 1 and 14 identifier Contains the message identifier of the CAN message to write extended Set this parameter to TRUE to send an extended message frame or to FALSE to send a standard message frame length Contains the number of message data bytes 0 8 pData This buffer contains up to 8 data bytes pData 0 contains message Data 0 pData 1 contains message Data 1 and so on TDRV011 SW 42 VxWorks Device Driver Page 34 of 96
22. 0x00110005 0x001 10006 0x00110009 0x0011000A 0x00110010 0x00110013 0x00110014 0x00110015 0x00110016 0x00110017 0x00110018 0x00110019 0x0011001A TEWS amp TECHNOLOGIES Description Status of the message object is idle No TDRV011 device found at the specified base address Invalid or duplicate minor device number Unknown ioctl function code Device was not initialized Unable to allocate memory I O request times out The device or message object is busy Unable to create a semaphore No data available only possible if TDRVO11_F_NOWAIT option selected Invalid device initialization data Mismatch of initialization parameter common Data overrun Controller is in busoff state Invalid message object number Message object already defined Message object not defined Driver has not been installed Page 96 of 96
23. 11 h int fd int retval TDRVO11_ARGS argBuf Setup the transfer rate to 500 KBit s S argBuf arg TDRVO11_500KBIT 0 argBuf flags retval ioctl fd TDRVO11_BITTIMING int amp argBuf if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 81 of 96 TEWS amp TECHNOLOGIES 5 3 7 TDRV011_DEFINE_MSG This I O control function allocates and defines parameters of a CAN message object User definable message objects are message object 1 15 One of the message objects is reserved for internal use of the device driver write By default message object 1 is used for transmission This can be changed as stated in chapter Fehler Verweisquelle konnte nicht gefunden werden Fehler Verweisquelle konnte nicht gefunden werden The function specific control parameter arg is a pointer on a TDRV0O11_ARGS structure for this function A defined message object will be active until the I O control function TDRVO11_CANCEL_MSG marks it as invalid to stop communication transactions One of the first things the application has to do after device initialization is to define one or more receive message objects with specific identifiers that should be received by this device See also Intel 82527 Architectural Overview Message Objects Message objects programmed to transmit are also affected by the Global Masks standard and extended The 82527 uses the Global Mask registers t
24. 11Status is equal to the number of mapped PCI spaces 0 No TDRV011 device found lt 0 Initialization failed The value of tdrv011Status amp OxFF is equal to the number of mapped spaces until the error occurs Possible cause Too few entries for dynamic mappings in sysPhysMemDesc Remedy Add dummy entries as necessary syslib c EXAMPLE extern void tdrv011PcilInit tdrv011PcilInit TDRV011 SW 42 VxWorks Device Driver Page 64 of 96 TEWS amp TECHNOLOGIES 4 4 tdrv011Init NAME tdrv011Init initialize TDRVO11 driver and devices SYNOPSIS include tdrv011 h STATUS tdrv01 1 Init void DESCRIPTION This function is used by the TDRV011 example application to install the driver and to add all available devices to the VxWorks system See also 3 1 1 tdrv0110Open for the device naming convention for legacy devices After calling this function it is not necessary to call tdrv011Drv and tdrv011DevCreate explicitly EXAMPLE include tdrv011 h STATUS result result tdrv0OllInit if result ERROR Error handling TDRV011 SW 42 VxWorks Device Driver Page 65 of 96 TEWS amp TECHNOLOGIES RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES Error codes are only set by system functions The error codes are stored in errno and can be read with the function errnoGet See 4 1 and 4 2
25. 2 VxWorks Device Driver Page 57 of 96 TENSE TECHNOLOGIES 3 2 19 tdrv011GetControllerStatus Name tdrv011GetControllerStatus get contents of the CAN controller status register Synopsis STATUS tdrv011GetControllerStatus TDRV011_DEV pDev unsigned long pControllerStatus Description This function returns the contents of the CAN controller status register for diagnostic purposes Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pControllerStatus This parameter is a pointer to an unsigned long 32bit value which returns the contents of the CAN controller status register TDRV011 SW 42 VxWorks Device Driver Page 58 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_ DEV pDev STATUS result unsigned long controllerStatus Read the CAN controller Status register Wi result tdrv011GetControllerStatus pDev amp controllerStatus i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet This function returns no driver specific error codes TDRV011 SW 42 VxWorks Device Driver Page 59 of 96 TEWS amp TECHNOLOGIES 4 Legacy I O system functions This chapter describes the legacy driver level interface t
26. DRV0O11_F_RECEIVE TDRV0O11_F_TRANSMIT and TDRV011_F_REMOTE the application can select one of four possible types of message objects Value TDRV011_F_RECEIVE TDRV011_F_RECEIVE TDRV011_F_REMOTE TDRV011_F_TRANSMIT TDRV011_F_TRANSMIT TDRV011_F_REMOTE arg Description This is a receive message object that will receive just a single message identifier or a range of message identifiers see also Acceptance Mask Receive message data can be read by the standard read function This is also a receive object but a remote frame is sent to request a remote node to send the corresponding data This is a transmit object The transmission of the message data starts immediately after definition of the message object This is also a transmit object but the transmission of the message data will be started if the corresponding remote frame same identifier was received A pointer to a message object description data structure TDRV011_MSGDEF is passed to the driver by the function dependent parameter arg typedef struct unsigned char MsgNum unsigned long identifier unsigned char extended unsigned char length unsigned char data 8 TDRV011_MSGDEF MsgNum The parameter MsgNum specifies the number of the message object to define 1 13 and 15 identifier The parameter identifier specifies the message identifier standard or extended TDRV011 SW 42 VxWorks Device Driver Page 83 of 96 TENSE TECH
27. E 77 534 TDRVOTI SETFILTER WEE 78 TDRV011 SW 42 VxWorks Device Driver Page 3 of 96 TEWS amp TECHNOLOGIES 5 3 5 TDRV011_GETFILTER cc cceesecesesssssseeeeeeeseeeeeeeseeeeeeeeeeeaeaeaeaeaeaeaeaeaeaeaeaeaeaeananaeanaeaes 80 5 3 6 TDRV0O11_BITTIMING 2 ceceesesscscesseeeeseseeeeeeeseeeseeeeeeuaeeeaeaeaeaeauaeaeaeaeaeaeaeaeaeaeaeaeananaes 81 5 3 7 TDRV011_ DEFINE Mc 82 5 3 8 TDRV011_ UPDATE MG 87 5 3 9 TDRV011_ CANCEL M 89 5 3 10 TORV011 BUSON iassieetsavaiavetavaisdcvavansvendvatvartvaiarantvanddevaviwavantvadddcvavisavedsedddenaenaeseateacieds 90 5 3 11 TORNYOT BUSOFF gioii aa a a 91 5 3 12 TORVOT T STATUS cine a a a a 92 5 3 13 RSIC VK CAN MEHR MH 94 6 DEBUGGING AND DIAGNOSTIC cccccceecceeeceeeeeeesceeeeeeseeeeeeeeenesenseeeeeeeneseeeenees 95 7 APPENDIX wesaiiescdcacacastecvincudedvandsciscuntvcndcaiaataceundccaciauasaudsuadencdveiauancventcanscaiavandvuntesedeus 96 7 1 Additional Error COdGS 2099 deeg dE EENEG ENNER 96 TDRV011 SW 42 VxWorks Device Driver Page 4 of 96 TEWS amp TECHNOLOGIES 1 Introduction 1 1 Device Driver The TDRV011 SW 42 VxWorks device driver software allows the operation of the supported PMC conforming to the VxWorks I O system specification The TDRV011 SW 42 release contains independent driver sources for the old legacy pre VxBus and the new VxBus enabled driver model The VxBus enabled driver is recommended for new developments with later VxWorks 6 x release a
28. Example include tdrv011 h TDRVO0O11_DEV pDev STATUS result Enter the BUSOFF state result tdrv011Stop pDev if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet This function returns no driver specific error codes TDRV011 SW 42 VxWorks Device Driver Page 55 of 96 TEWS amp TECHNOLOGIES 3 2 18 tdrv011FlushReceiveFifo Name tdrv011FlushReceiveFifo discard all messages in the receive FIFO Synopsis STATUS tdrv011FlushReceiveFifo TDRV011_DEV pDev Description This function flushes the CAN message receive FIFO All messages will be discarded Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function TDRV011 SW 42 VxWorks Device Driver Page 56 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO0O11_DEV pDev STATUS result zx Flush the CAN message receive FIFO S result tdrv011FlushReceiveFifo pDev if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet This function returns no driver specific error codes TDRV011 SW 4
29. Example include tdrv011 h TDRVO0O11_DEV pDev STATUS result Enter the BUSON state result tdrv011Start pDev if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_BUSOFF Unable to enter the BUSON state the CAN controller is still offline and unable to communicate over the CAN bus TDRV011 SW 42 VxWorks Device Driver Page 53 of 96 TEWS amp TECHNOLOGIES 3 2 17 tdrv011Stop Name tdrv011 Stop set the CAN controller offline Synopsis STATUS tdrv011Stop TDRV011_DEV pDev Description This function sets the specified CAN controller associated with the specified device 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 tdrvO1OStart is executed Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function TDRV011 SW 42 VxWorks Device Driver Page 54 of 96 TEWS amp TECHNOLOGIES
30. FLUSH TDRV011_SETFILTER TDRV011_GETFILTER TDRV011_BITTIMING TDRV011_DEFINE_MSG TDRV011_UPDATE_MSG TDRV011_CANCEL_MSG TDRV011_BUSON TDRV011_BUSOFF TDRV011_STATUS TDRV011_CAN_STATUS TDRV011 SW 42 VxWorks Device Driver Description Read received CAN message Write CAN message Flush receive FIFO Set acceptance filter Get current acceptance filter setting Set new bit timing Define a CAN message object Update a CAN message object Cancel a CAN message object Set device BUS ON Set device BUS OFF Get state of a CAN message object Get state of the CAN controller Page 71 of 96 TENSE TECHNOLOGIES arg This parameter depends on the selected function request How to use this parameter is described below with the function RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error code can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual Function specific error codes will be described with the function Error code Description S_tdrv011Drv_ICMD Unknown ioctl command specified SEE ALSO ioLib basic I O routine ioctl TDRV011 SW 42 VxWorks Device Driver Page 72 of 96 TEWS amp TECHNOLOGIES 5 3 1 TDRV011_READ This I O control function reads a CAN message from the specified device The function specific control parameter arg is a pointer on a TDRVO11_ O_BUFFER structure
31. NOLOGIES extended If the parameter extended is TRUE 1 an extended frame message identifier will be used If extended is FALSE 0 a standard frame message identifier will be used length The parameter length is only necessary for transmit message objects if TDRV011_F_TRANSMIT is set The parameter length specifies the number of bytes in data data The parameter data is only used for transmit objects it holds the message data EXAMPLE include tdrv011 h int fd int retval TDRVO11_MSGDEF MsgDef TDRVO11_ARGS argBuf Define message object 2 5 1 receive message object us xtended message identifier wait for receiving of a message with specified identifier 2 receive message object use standard message identifier send a remote frame to request a remote node to send th corresponding data 3 transmit message object use standard message identifier start transmission 4 transmit message object us xtended message identifier start transmission if the corresponding remote frame same identifier was received RE argBuf arg unsigned long amp MsgDef argBuf flags TDRVO11_F_ RECEIVE MsgDef MsgNum 2 MsgDef identifier 10 MsgDef extended TRUE retval ioctl fd TDRVO11_DEFINE_MSG int amp argBuf if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 84 of 96 TEWS a
32. OLOGIES 3 2 4 tdrv011WriteNoWait Name tdrv011WriteNoWait write a CAN message non blocked Synopsis STATUS tdrv011WriteNoWait TDRV011_DEV pDev unsigned long identifier int extended int length unsigned char pData Description This function writes a messages to the specified device for subsequent transmission on the CAN bus The call will return immediately after the message was written to the CAN controller or an error occurred By default the write function use message object 1 for transmit If this isn t suitable the default transmit message object can be changed by redefining the macro TX_MSG_OBJ in tdrv011def h Valid message object are in the range between 1 and 14 Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function identifier Contains the message identifier of the CAN message to write extended Set this parameter to TRUE to send an extended message frame or to FALSE to send a standard message frame length Contains the number of message data bytes 0 8 pData This buffer contains up to 8 data bytes pData 0 contains message Data 0 pData 1 contains message Data 1 and so on TDRV011 SW 42 VxWorks Device Driver Page 23 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result unsigned long msgIidentifier int msgExtended int
33. OOL diab To compile SMP enabled libraries the argument VXBUILD SMP must be added to the command line C gt make CPU PENTIUM4 TOOL diab VXBUILD SMP To integrate the TDRVO11 driver with the VxWorks development tools Workbench the component configuration file 40tdrv011 cdf must be copied to the directory installDir vxworks 6 x target contig comps VxWorks C gt cd WindRiver vxworks 6 7 target 3rdparty tews tdrv011 C gt copy 40tdrv01l cdf Windriver vxworks 6 7 target config comps vxWorks In VxWorks 6 7 and newer releases the kernel configuration tool scans the CDF file automatically and updates the CxrCat txt cache file to provide component parameter information for the kernel configuration tool as long as the timestamp of the copied CDF file is newer than the one of the CxrCat txt If your copy command preserves the timestamp force to update the timestamp by a utility such as touch In earlier VxWorks releases the CxrCat txt file may not be updated automatically In this case remove or rename the original CxrCat txt file and invoke the make command to force recreation of this file C gt cd Windriver vxworks 6 7 target config comps vxWorks C gt del CxrCat txt C gt make After successful completion of all steps above and restart of the Wind River Workbench the TDRV011 driver and API can be included in VxWorks projects by selecting the TEWS TDRV011 Driver and TEWS TDRV011 API components in the h
34. The value of this definition must be set to the offset between CPU Bus and PCl Bus Address for PCI I O space access USERDEFINED_LEV2VEC The value of this definition must be set to the difference of the interrupt vector used to connect the ISR and the interrupt level stored to the PCI header Another definition allows a simple adaptation for BSPs that utilize a pcilntConnect function to connect shared PCI interrupts If this function is defined in the used BSP the definition of USERDEFINED_SEL_PCIINTCONNECT should be enabled The definition by command line option is made by D lt definition gt Please refer to the BSP documentation and header files to get information about the interrupt connection function and the required offset values 2 3 4 System resource requirement The table gives an overview over the system resources that will be needed by the driver Resource Driver requirement Devices requirement Memory lt 1KB lt 1KB Stack lt 1KB Semaphores 2 1 Memory and Stack usage may differ from system to system depending on the used compiler and its setup The following formula shows the way to calculate the common requirements of the driver and devices lt total requirement gt lt driver requirement gt lt number of devices gt lt device requirement gt The maximum usage of some resources is limited by adjustable parameters If the application and driver exceed these limits
35. age 43 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result int msgNum int msgLength unsigned char msgData TDRV0O11_MSG_LEN Update a remote buffer message object Wi msgNum 2 msgLength 2 msgData 0 0x12 msgData 1 0x34 result tdrv011UpdateRemoteMsgOb J if result ERROR handle error pDev msgNum msgLength msgData 0 i TDRV011 SW 42 VxWorks Device Driver Page 44 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified S_tdrv011Drv_MSGNOTDEF The message is not properly setup for transmit S_tdrv011Drv_MSGBUSY The specified message is already in use TDRV011 SW 42 VxWorks Device Driver Page 45 of 96 TEWS amp TECHNOLOGIES 3 2 13 tdrv011RequestRemoteData Name tdrv011RequestRemoteData request a remote CAN message Synopsis STATUS tdrv01 1 RequestRemoteData TDRV011_DEV pDev int messageNumber Description This function transmits a CAN message with the RTR bit set to request a remote
36. ansmit message object Synopsis STATUS tdrv011GetMsgObjStatus TDRV011_DEV pDev int messageNumber unsigned long pMsgStatus Description This function returns the state of the specified transmit message object Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the previous defined transmit message object Valid numbers are in the range between 1 and 14 pMsgStatus This parameter is a pointer to an unsigned long 32bit value which returns the current state of the specified message object Status code Description S_tdrv011Drv_IDLE The transmit message object is idle and ready to transmit new data S_tdrv011Drv_BUSY The transmit message object is busy transmitting data S_tdrv011Drv_MSGNOTDEF The message object has not been defined S_tdrv011Drv_IMSGNUM This is not a transmit message object TDRV011 SW 42 VxWorks Device Driver Page 50 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_ DEV pDev STATUS result int msgNum unsigned long msgStatus Get the message object status S msgNum 2 result tdrv011GetMsgObjStatus pDev msgNum msgStatus i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can
37. ardware default Device Drivers folder with the kernel configuration tool 2 2 1 Direct BSP Builds In development scenarios with the direct BSP build method without using the Workbench or the vxprj command line utility the TDRV011 configuration stub files must be copied to the directory installDir vxworks 6 x target contig comps src hwif Afterwards the vxbUsrCmdLine c file must be updated by invoking the appropriate make command C gt cd WindRiver vxworks 6 7 target 3rdparty tews tdrv011 C gt copy tdrv0ll de Windriver vxworks 6 7 target config comps src hwif C gt copy tdrv0ll dr Windriver vxworks 6 7 target config comps src hwif C gt cd Windriver vxworks 6 7 target config comps src hwif C gt make vxbUsrCmdLine c TDRV011 SW 42 VxWorks Device Driver Page 8 of 96 TEWS amp TECHNOLOGIES 2 3 Legacy Driver Installation 2 3 1 Include device driver in VxWorks projects For including the TDRV011 SW 42 device driver into a VxWorks project e g Tornado IDE or Workbench follow the steps below 1 Extract all files from the archive TDRV011 SW 42 LEGACY zip to your project directory 2 Add the device drivers C files to your project Make a right click to your project in the Workspace window and use the Add Files topic A file select box appears and the driver files in the tdrv011 directory can be selected 3 Now the driver is included in the project and will be built with the proje
38. be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified TDRV011 SW 42 VxWorks Device Driver Page 51 of 96 TEWS amp TECHNOLOGIES 3 2 16 tdrv011 Start Name tdrv011 Start set the CAN controller online Synopsis STATUS tdrv01 1Start TDRV011_DEV pDev Description This function sets the CAN controller associated with the specified device online to enter the BUSON state After an abnormal rate of occurrences of errors on the CAN bus the CAN controller enters the BUSOFF state This I O control function resets the init bit in the Control register The CAN controller begins the bus recovery sequence The bus recovery sequence resets transmit and receive error counters If the CAN controller counts 128 packets of 11 consecutive recessive bits on the CAN bus the BUSOFF state is exited Before the CAN controller can communicate over the CAN after driver start up or a previous BUSOFF error condition this control function must be executed Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function TDRV011 SW 42 VxWorks Device Driver Page 52 of 96 TEWS amp TECHNOLOGIES
39. cifies the value for the Global Mask Standard Register The Global Mask Standard Register applies only to messages using the standard CAN identifier This 11 bit identifier appears in bit 5 15 of this parameter GlobalMaskExtended The parameter GlobalMaskExtended specifies the value for the Global Mask Extended Register The Global Mask Extended Register applies only to messages using the extended CAN identifier This 29 bit identifier appears in bit 3 31 of this parameter Message 15Mask The parameter Message15Mask specifies the value for the Message 15 Mask Register The Message 15 Mask Register is a local mask for message object 15 This 29 bit identifier appears in bit 3 31 of this parameter The Message 15 Mask is ANDed with the Global Mask This means that any bit defined as don t care in the Global Mask will automatically be a don t care bit for message 15 See also Intel 82527 Architectural Overview TDRV011 SW 42 VxWorks Device Driver Page 78 of 96 TENSE TECHNOLOGIES EXAMPLE include tdrv011 h int fd int retval TDRV011_ACCEPT_MASKS acceptMasks acceptMasks GlobalMaskStandard Oxfe00 acceptMasks GlobalMaskExtended Oxffffff80 acceptMasks Messagel5Mask Oxfffff800 retval ioctl fd TDRVO11_SETFILTER int amp acceptMasks if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 79 of 96 TEWS amp TECHNOLOGIES 5
40. ct For a more detailed description of the project facility please refer to your VxWorks User s Guide e g Tornado Workbench etc 2 3 2 Special installation for Intel x86 based targets The TDRV011 device driver is fully adapted for Intel x86 based targets This is done by conditional compilation directives inside the source code and controlled by the VxWorks global defined macro CRU FAMILY If the content of this macro is equal to 80X86 special Intel x86 conforming code and function calls will be included The second problem for Intel x86 based platforms can t be solved by conditional compilation directives Due to the fact that some Intel x86 BSP s doesn t map PCI memory spaces of devices which are not used by the BSP the required device memory spaces can t be accessed To solve this problem a MMU mapping entry has to be added for the required TDRV011 PCI memory spaces prior the MMU initialization usrMmulInit is done The C source file tdrv011pci c contains the function tdrv0O11Pcilnit This routine finds out all TDRV011 devices and adds MMU mapping entries for all used PCI memory spaces Please insert a call to this function after the PCI initialization is done and prior to MMU initialization usrMmulnit The right place to call the function tdrv0717Pcilnit is at the end of the function sysHwinit in sysLib c it can be opened from the project Files window Be sure that the function is called prior to MMU ini
41. d SEE ALSO VxWorks Programmer s Guide I O System TDRV011 SW 42 VxWorks Device Driver Page 61 of 96 TEWS amp TECHNOLOGIES 4 2 tdrv011DevCreate NAME tdrv011DevCreate Add a TDRV011 device to the VxWorks system SYNOPSIS include tdrv011 h STATUS tdrv011DevCreate char name int devidx bitTiming DESCRIPTION This routine adds the selected device to the VxWorks system The device hardware will be setup and prepared for use This function must be called before performing any I O request to this device PARAMETER name This string specifies the name of the device that will be used to identify the device for example for open calls See also 3 1 1 tdrv011Open for the preferred device naming convention for legacy devices devidx This index number specifies the device to add to the system The number depends on the search priority of the modules The modules will be searched in the following order TPMC316 xx TPMC816 xx TPMC901 xx If modules of the same type are installed the channel numbers will be assigned in the order the VxWorks pciFindDevice function will find the devices Example A system with 1 TPMC901 10 1 TPMC816 11 and 2 TPMC316 10 will assign the following device indexes Module Device Index TPMC316 10 1 0 1 TPMC316 10 Gm 2 3 TDRV011 SW 42 VxWorks Device Driver Page 62 of 96 TEWS amp TECHNOLOGIES TPMC816 11 4 TPMC901 10 5 6 7
42. ding xx If no message is available the read request times out after 120 ticks S result tdrv011Read pDev FALSE 120 msgidentifier msgExtended msgLength msgData 0 i if result ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 16 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_BUSOFF The device is in BUS OFF state S_tdrv011Drv_TIMEOUT The read request timed out TDRV011 SW 42 VxWorks Device Driver Page 17 of 96 TEWS amp TECHNOLOGIES 3 2 2 tdrv011ReadNoWait Name tdrv011ReadNoWait read a CAN message non blocked Synopsis STATUS tdrv011ReadNoWait TDRV011_DEV pDev unsigned long pldentifier int pExtended int pLength unsigned char pData Description This function reads a CAN message from the specified channel If no message is available the call returns immediately Before the driver can receive CAN messages it s necessary to define at least one receive message object Parameters pDev This parameter specifies the device descriptor to the hardware mo
43. dule retrieved by a call to the corresponding open function pldentifier This parameter is a pointer to an unsigned long 32bit value where the received CAN message identifier is stored pExtended This parameter is a pointer to an int value The value is set to O if a standard message frame was received and gt 0 if an extended message frame was received pLength This parameter is a pointer to an int value where the length of the received CAN message number of bytes is stored Possible values are 0 8 pData This parameter is a pointer to an unsigned char array where the received CAN message is stored This buffer receives up to 8 data bytes pData 0 receives message Data 0 pData 1 receives message Data 1 and so on TDRV011 SW 42 VxWorks Device Driver Page 18 of 96 TENSE TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result unsigned long msgIidentifier int msgExtended int msgLength unsigned char msgData TDRVO11_MSG_LEN Read a CAN message from the device result tdrv011ReadNoWait pDev msgidentifier msgExtended msgLength msgData 0 i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Ma
44. eNumber This parameter contains the number of the message object to define Valid numbers are in the range between 1 and 15 with exception of the number of the default transmit object usually 1 identifier This parameter specifies the message identifier that should be received by this message object Depending on the acceptance filter configuration this initial message identifier value may be changed by other accepted messages with different identifiers This may cause confusion after changing the acceptance filter masks without redefining the receive message objects extended Set to TRUE to receive extended message frames or to FALSE to receive standard message frames TDRV011 SW 42 VxWorks Device Driver Page 32 of 96 TENSE TECHNOLOGIES Example include tdrv011 h TDRVO11_ DEV pDev STATUS result int msgNum unsigned long msgIdentifier Define message object 15 to receiv xtended messages with the specified identifier msgNum 15 msgIldentifier 1 result tdrv011DefineReceiveMsgObj pDev msgNum msgIidentifier TRUE i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function
45. ed by use of the I O control function TDRV0O11_STATUS typedef struct unsigned long message_sel unsigned long status TDRV011_STAT message_sel The number of the message object must be set in message_sel Additional to the user definable message objects 1 13 and 15 the function TDRVO11_STATUS returns the status of the internal used message object 14 by selecting either message object number 14 or 0 This facility is important for write request with the I O flag TDRVO11_F_NOWAIT set status The message state is returned in status The returned values are the same as used for error and status codes EXAMPLE include tdrv011 h int fd int retval TDRVO11_STAT msgStat Get state of message object 3 msgStat message_sel 3 retval ioctl fd TDRVO11_STATUS int amp msgStat if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 92 of 96 TENSE TECHNOLOGIES ERROR CODES Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified S_tdrv011Drv_MSGNOTDEF The message object has not been defined S_tdrv011Drv_IDLE Status of the message object is idle S_tdrv011Drv_BUSY The device or message object is busy TDRV011 SW 42 VxWorks Device Driver Page 93 of 96 5 3 13 TDRV011_CAN_STATUS TEWS amp TECHNOLOGIES This I O control function returns the contents of the CAN controller status register The function
46. el 82527 Architectural Overview Acceptance Filtering Implications Example include tdrv011 h TDRV011_DEV pDev STATUS result unsigned short globalMaskStandard unsigned long globalMaskExtended unsigned long messagel5Mask Set acceptance filter Wi globalMaskStandard Oxffff globalMaskExtended Oxffffffff messagel5Mask 0 result tdrv011SetFilter pDev globalMaskStandard globalMaskExtended messagel5Mask i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet This function returns no driver specific error codes TDRV011 SW 42 VxWorks Device Driver Page 27 of 96 TEWS amp TECHNOLOGIES 3 2 6 tdrv011GetFilter Name tdrv011GetFilter get acceptance filter masks Synopsis STATUS tdrv01 1 GetFilter TDRV011_DEV_ pDev unsigned short pGlobalMaskStandard unsigned long pGlobalMaskExtended unsigned long pMessage1 5Mask Description This function reads the acceptance filter masks from the specified CAN controller The acceptance masks allow message objects to receive messages with a range of message identifiers instead of just a single message identifier A 0 value means don t care or accept a 0 or 1 for that bit position A value of
47. essageNumber int length unsigned char pData Description This function writes new data into the previous allocated transmit message object and starts the transmission immediately Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the previous defined transmit message object Valid numbers are in the range between 1 and 14 length Contains the number of message data bytes 0 8 pData This buffer contains up to 8 data bytes pData 0 contains message Data 0 pData 1 contains message Data 1 and so on TDRV011 SW 42 VxWorks Device Driver Page 40 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result int msgNum int msgLength unsigned char msgData TDRV0O11_MSG_LEN Update a transmit buffer object and start transmission immediately 7 msgNum 2 msgLength 2 msgData 0 0x12 msgData 1 0x34 result tdrv011UpdateTransmitMsgObj pDev msgNum msgLength msgData 0 i if result ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 41 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard e
48. extended unsigned char length unsigned char data 8 TDRV011_IO_BUFFER flags The parameter flags define a flag field used to control the write operation If the flag TDRVO11_F_NOWAIT is set write returns immediately if the device is blocked by another write request timeout The parameter timeout specifies the timeout interval in units of clock ticks A timeout value of 0 means wait indefinitely identifier The parameter identifier specifies the message identifier standard or extended of the message received extended The parameter extended is TRUE 1 for extended identifier and FALSE 0 for standard identifier length The parameter length specifies the size of message data in bytes data The data bytes that shall be send with the message TDRV011 SW 42 VxWorks Device Driver Page 75 of 96 TEWS amp TECHNOLOGIES EXAMPLE include tdrv011 h define HELLO HELLOOOO int gek int retval int S TDRVO11_IO_BUFFER rw I O parameter block for write Write a message to a TDRV011 device if there is a problem with the transmitter the write request times out rw flags 0 rw timeout 100 rw identifier 1234 extended identifier rw extended TRUE rw length 8 memcpy rw data HELLO 8 retval ioctl fd TDRVO11_WRITE int amp rw if retval ERROR handle error ERROR CODES Error code Descripti
49. gObj TDRV011_DEV pDev int messageNumber unsigned long identifier int extended int length unsigned char pData Description This function setup a free controller message object as remote transmission buffer A remote transmit buffer object is similar to normal transmission object with exception that the CAN message is transmitted only after receiving of a remote frame with the same identifier This type of message object can be used to make process data available for other nodes which can be polled around the CAN bus without any action of the provider node The message data remain available for other CAN nodes until this message object is updated with tdrv011UpdateRemoteMsgObj or released with tdrv01 1 ReleaseMsgObj Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the message object to define Valid numbers are in the range between 1 and 14 identifier Contains the message identifier of the CAN message to write extended Set this parameter to TRUE to send extended message frames or to FALSE to send standard message frames TDRV011 SW 42 VxWorks Device Driver Page 37 of 96 TENSE TECHNOLOGIES length Contains the number of message data bytes 0 8 pData This buffer contains up to 8 data bytes pData 0 contains message Data 0 pData 1 contains messa
50. ge Data 1 and so on Example include tdrv011 h TDRVO11_DEV pDev STATUS result int msgNum unsigned long msgIdentifier int msgExtended int msgLength unsigned char msgData TDRVO11_MSG_LEN AN Define a remote buffer message object Ay msgNum 4 msgldentifier 1234 msgExtended TRUE msgLength 2 msgData 0 Oxaa msgData 1 Oxbb result tdrv011DefineRemoteMsgObj pDev msgNum msgIidentifier msgExtended msgLength msgData 0 i if result ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 38 of 96 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified e g transmit message object number S_tdrv0i11Drv_MSGBUSY The specified message is already in use TDRV011 SW 42 VxWorks Device Driver Page 39 of 96 TENSE TECHNOLOGIES 3 2 11 tdrv011UpdateTransmitMsgObj Name tdrv011UpdateTransmitMsgObj update transmit message object data Synopsis STATUS tdrv01 1UpdateTransmitMsgObj TDRV011_DEV pDev int m
51. ge object Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function flushBeforeRead If the message FIFO should be flushed before initiating the read sequence this parameter must be set to TRUE otherwise to FALSE timeout The parameter timeout specifies the timeout interval in units of clock ticks A timeout value of 0 means wait indefinitely pldentifier This parameter is a pointer to an unsigned long 32bit value where the received CAN message identifier is stored TDRV011 SW 42 VxWorks Device Driver Page 15 of 96 TEWS amp TECHNOLOGIES pExtended This parameter is a pointer to an int value The value is set to O if a standard message frame was received and gt 0 if an extended message frame was received pLength This parameter is a pointer to an int value where the length of the received CAN message number of bytes is stored Possible values are 0 8 pData This parameter is a pointer to an unsigned char array where the received CAN message is stored This buffer receives up to 8 data bytes pData 0 receives message Data 0 pData 1 receives message Data 1 and so on Example include tdrv011 h TDRVO11_DEV pDev STATUS result unsigned long msgIidentifier int msgExtended int msgLength unsigned char msgData TDRV0O11_MSG_LEN Read a CAN message from the device Don t flush before rea
52. lt ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet This function returns no driver specific error codes TDRV011 SW 42 VxWorks Device Driver Page 29 of 96 TEWS amp TECHNOLOGIES 3 2 7 tdrv011SetBitTiming Name tdrv011SetBitTiming set bit timing register Synopsis STATUS tdrv011SetBitTiming TDRV011_DEV pDev unsigned short timingValue int useThreeSamples Description This function modifies the bit timing register of the CAN controller to setup a new CAN bus transfer speed Keep in mind to setup a valid bit timing before entering the BUSON state Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function timing Value This parameter contains the new value for the bit timing register O bit 8 15 and bit timing register 1 bit 0 7 Possible transfer rates are between 20 KBit per second and 1 0 MBit per second The include file tdrv011 h contains predefined transfer rates For other transfer rates please follow the instructions of the Intel 82527 Architectural Overview use ThreeSamples If this parameter is set to TRUE the CAN bus is sampled three times per bit time instead of one time FALSE NOTE Use one sample point for faster bit rates and three sample points for slower bi
53. message from other CAN nodes The requesting receive message object must be previously defined with tdrv01 1 DefineReceiveMsgObj Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the previous defined receive message object Valid numbers are in the range between 1 and 15 TDRV011 SW 42 VxWorks Device Driver Page 46 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO0O11_DEV pDev STATUS result int msgNum Request a remote CAN message via message object 2 Wi msgNum 2 result tdrv011lRequestRemoteData pDev msgNum i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified S_tdrv011Drv_MSGNOTDEF The message is not properly setup for transmit TDRV011 SW 42 VxWorks Device Driver Page 47 of 96 TEWS amp TECHNOLOGIES 3 2 14 tdrv011ReleaseMsgObj Name tdrv011ReleaseMsgObj release a previous defined mes
54. mp TECHNOLOGIES argBuf arg unsigned long amp MsgDef argBuf flags TDRVO11_F RECEIVE TDRVO11_F REMOTE MsgDef MsgNum 3 MsgDef identifier 100 MsgDef extended FALSE retval ioctl fd TDRVO11_DEFINE_MSG int amp argBuf if retval ERROR handle error argBuf arg unsigned long amp MsgDef argBuf flags TDRVO11_F_TRANSMIT MsgDef MsgNum 4 MsgDef identifier 50 MsgDef extended FALSE MsgDef length 1 MsgDef data 0 Isi retval ioctl fd TDRV0O11_DEFINE_MSG int amp argBuf if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 85 of 96 TEWS amp TECHNOLOGIES argBuf arg unsigned long amp MsgDef argBuf flags TDRVO11_F_TRANSMIT TDRV0O11_F_REMOTE MsgDef MsgNum 5 MsgDef identifier 500 MsgDef extended TRUE MsgDef length 1 MsgDef data 0 0 retval ioctl fd TDRVO11_DEFINE_MSG int amp argBuf if retval ERROR handle error ERROR CODES Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified e g transmit message object number S_tdrv011Drv_MSGBUSY The specified message is already in use TDRV011 SW 42 VxWorks Device Driver Page 86 of 96 5 3 8 TDRV011_UPDATE_MSG This I O control function updates the message data of a previously defined transmission object or s
55. nd mandatory for VxWorks SMP systems Both drivers legacy and VxBus share the same application programming interface API and device independent basic UO interface with open close and ioctl functions The basic I O interface is only for backward compatibility with existing applications and should not be used for new developments Both drivers invoke a mutual exclusion and binary semaphore mechanism to prevent simultaneous requests by multiple tasks from interfering with each other To prevent the application program from losing data incoming messages will be stored in a message FIFO with a depth of 100 messages The TDRV011 SW 42 device driver supports the following features sending and receiving CAN messages extended and standard message frames acceptance filtering message objects remote frame requests VVVVV The TDRV011 SW 42 supports the modules listed below TPMC316 xx 2 Channel Extended CAN PMC Conduction Cooled TPMC816 10 2 Channel Extended CAN PMC TPMC816 11 1 Channel Extended CAN PMC TPMC901 10 6 Channel Extended CAN PMC TPMC901 11 4 Channel Extended CAN PMC TPMC901 12 2 Channel Extended CAN PMC In this document all supported modules and devices will be called TDRV011 Specials for certain devices will be advised To get more information about the features and use of supported devices it is recommended to read the manuals listed below User manual of the appropriate hardware Engineeri
56. ng Manual of the appropriate hardware Architectural Overview of the Intel 82527 CAN controller TDRV011 SW 42 VxWorks Device Driver Page 5 of 96 TEWS amp TECHNOLOGIES 2 Installation Following files are located on the distribution media Directory path TDRV011 SW 42 TDRV011 SW 42 2 0 0 pdf PDF copy of this manual TDRV011 SW 42 VXBUS zip Zip compressed archive with VxBus driver sources TDRV011 SW 42 LEGACY zip Zip compressed archive with legacy driver sources ChangeLog txt Release history Release txt Release information The archive TDRV011 SW 42 VXBUS zip contains the following files and directories Directory path tews tdrv01 1 tdrvO11drv c TDRV011 device driver source tdrvO11def h TDRV011 driver include file tdrv011 h TDRV011 include file for driver and application tdrv011api c TDRVO011 API file i82527 h Controller definitions Makefile Driver Makefile A40tdrv011 cdf Component descriptions file for VxWorks development tools tdrv011 dc Configuration stub file for direct BSP builds tdrv011 dr Configuration stub file for direct BSP builds include tvxbHal h Hardware dependent interface functions and definitions apps tdrv01 1exa c Example application The archive TDRV011 SW 42 LEGACY zip contains the following files and directories Directory path tdrvO1 1 tdrvO11drv c tdrvO11def h i82527 h tdrv011 h tdrvO11pci c tdrvO1 1 api c tdrv011exa c include tdhal h TDRV011 SW 42 VxWorks Device
57. nts 1 INTRODUCTION E 5 Wel Device Huet EE 5 s INSTALLATION scicsiscscscsecescscucdesenceeccrencscssenceanssencuaderenceadsrencuadesancuadsesncuadsuencuenanawancee 6 2 1 Legacy Vs VXBUS ln EE 7 2 2 VXBUS Driver Installation eseuen 7 2 2 1 Direct TI EE 8 2 3 Legacy Driver Installation ccceeseceeeeeeeeeeeeeeeseeeenenseeeeneeseeeeneeseeesneeseeesneeseeesneeseeesneeseeesnenseeseees 9 2 3 1 Include device driver in VxWorks projects cc cceeeeeeeeeeenne cece eae eeeeeaeeeeetaaeeeeetaeeeeeeaeeeeneaa 9 2 3 2 Special installation for Intel x86 based targets cccccccsceeeeeeeeeeeeeeeaeeeeeeeseeeeeseaeeeeaaeeeeeeeeed 9 2 3 3 BSP dependent adjustment AA 9 2 3 4 System resource reoulrement nern nernnennnennnsen neen n enn 10 3 APIDOCUMENTATION geet 11 3 1 Ge eral butter deed 11 23 11 tdVO1TOPON A E E A E 11 e E o LOA AoE O E A E E E dang adddeenesces dant aw duceeeatzcndt addagdapisteusatdedsskepeatedesences 13 3 2 Device Access Dn et e 15 sl TOVOTT REA enin tienoon aaia a aa aaee a eaaa eta ouaaa aes 15 3 2 2 tdrv011 ReadhoW an 18 323 TOPVOTT WINGS anias aidian Seed d ene Deegeh dd encunpap Zeeche Sd dee dd eacwavuhluqeaseddeeskensianenn d e 20 3 2 4 dnv i1Wrtehouw an 23 3 25 tAVOVT SFIS R iiescccc cdeciaccdesecancedetscs cctseiaadescetaa cctdattucesdaiaadedsbtaacasdtaadoubeitiadesdatnddeasbinacesdaaaces 26 B26 rein TE CT 28 3 2 7 AMET EI TIMING EE 20 3 2 8 tdrv011DefineReceiveMsgOh
58. nual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_BUSOFF The device is in BUS OFF state S_tdrv011Drv_ NODATA No data available TDRV011 SW 42 VxWorks Device Driver Page 19 of 96 TEWS amp TECHNOLOGIES 3 2 3 tdrv011Write Name tdrv011Write write a CAN message Synopsis STATUS tdrv011Write TDRV011_DEV pDev int timeout unsigned long identifier int extended int length unsigned char pData Description This function writes a messages to the specified device for subsequent transmission on the CAN bus The request will be blocked until the message was send or an error occurs By default the write function uses message object 1 for transmit If this isn t suitable the default transmit message object can be changed by redefining the macro TX_MSG_OB4J in tdrv011def h Valid message objects are in the range between 1 and 14 Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function timeout The parameter timeout specifies the timeout interval in units of clock ticks A timeout value of 0 means wait indefinitely identifier Contains the message identifier of the CAN message to write extended Set this parameter to TRUE to send an extended message frame or to FALSE to send a standard message frame length Contains the
59. o identify which of its message objects transmitted a message If two 82527 transmit message objects have message IDs that are non distinct in all must match bit locations a successful transmission of the higher numbered message object will not be recognized by the 82527 The lower numbered message object will be falsely identified as the transmit message object and its transmit request bit will be reset and its interrupt pending bit set The actual transmit message object will re transmit without end because its transmit request bit will not be reset This could result in a catastrophic condition since the higher numbered message object may dominate the CAN bus by resending its message without end To avoid this condition applications should require all transmit message objects to use message IDs that are unique with respect to the mustmatch bits If this is not possible the application should disable lower numbered message objects with similar message IDs until the higher numbered message object has transmitted successfully For further information about this problem please refer to the Intel 82527 Architectural Overview chapter Acceptance Filtering Implications TDRV011 SW 42 VxWorks Device Driver Page 82 of 96 typedef struct unsigned long cmd unsigned long flags unsigned long arg TDRV011_ARGS cmd The cmd argument is not used flags TEWS amp TECHNOLOGIES By combination binary OR of the I O flags T
60. o the I O system The purpose of these functions is to install the driver in the I O system add and initialize devices The legacy I O system functions are only relevant for the legacy TDRV011 driver For the VxBus enabled TDRV011 driver the driver will be installed automatically in the I O system and devices will be created as needed for detected CAN channels 4 1 tdrv011Drv NAME tdrvO11Drv installs the TDRV011 driver in the I O system SYNOPSIS include tdrv011 h STATUS tdrv011 Drv void DESCRIPTION This function searches for devices on the PCI bus installs the TDRVO0O11 driver in the I O system A call to this function is the first thing the user has to do before adding any device to the system or performing any UO request EXAMPLE include tdrv011 h STATUS result Initialize Driver Si result tdrv011Drv if result ERROR Error handling TDRV011 SW 42 VxWorks Device Driver Page 60 of 96 TENSE TECHNOLOGIES RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES Error codes are only set by system functions The error codes are stored in errno and can be read with the function errnoGet The error codes are stored in errno and can be read with the function errnoGet Error code Description S_tdrv011Drv_NOMEM Can t allocate memory for devices S_tdrv011Drv_NXIO No supported module foun
61. on S_tdrv011Drv_BUSOFF The device is in BUS OFF state S_tdrv011Drv_IPARAM Illegal parameter value specified S_tdrv011Drv_TIMEOUT The write request timed out TDRV011 SW 42 VxWorks Device Driver Page 76 of 96 TENSE TECHNOLOGIES 5 3 3 TDRV011_FLUSH This I O control function flushes the receive FIFO All messages in the FIFO will be discarded The function specific control parameter arg is not used for this function EXAMPLE include tdrv011 h int fd int retval retval ioctl fd TDRVO11_ FLUSH 0 if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 77 of 96 TEWS amp TECHNOLOGIES 5 3 4 TDRV011_SETFILTER This I O control function modifies the acceptance filter masks of the CAN Controller The function specific control parameter arg is a pointer on a TDRVO11_ACCEPT_MASKS structure for this function The acceptance masks allow message objects to receive messages with a range of message identifiers instead of just a single message identifier A 0 value means don t care or accept a 0 or 1 for that bit position A value of 1 means that the incoming bit value must match identically to the corresponding bit in the message identifier typedef struct unsigned short GlobalMaskStandard unsigned long GlobalMaskExtended unsigned long Message15Mask TDRV011_ACCEPT_MASKS GlobalMaskStandard The parameter GlobalMaskStandard spe
62. pplication program during device creation with the function tdrv011DevCreate For devices created by the TDRV011 example application the module number is always 0 and the channels are numbered from 0 for the first channel on the first TDRVO11 module to lt n gt for the last channel on the last TDRV011 module where lt n gt depends on the overall number of CAN channels provided by all TDRV011 modules For the example configuration above the following devices will be created TPMC8 16 tdrv01 1 0 0 tdrv011 0 1 TPMC901 tdrv01 1 0 2 tdrv011 0 3 tdrv011 0 4 tdrv011 0 5 tdrv011 0 6 tdrv011 0 7 TDRV011 SW 42 VxWorks Device Driver Page 11 of 96 TENSE TECHNOLOGIES To see which TDRV011 devices are available in the system call the devs command from the VxWorks shell To get detailed information of associated TDRV011 devices the tdrv011Show function only VxBus driver can be called form the VxWorks shell Example include tdrv011 h TDRVO0O11_DEV pDev open file descriptor to a device pDev tdrv0110pen tdrv011 0 0 if pDev NULL handle open error RETURNS A device descriptor pointer or NULL if the function fails An error code will be stored in errno ERROR CODES The error codes are stored in errno The error code is a standard error code set by the I O system TDRV011 SW 42 VxWorks Device Driver Page 12 of 96 TEWS amp TECHNOLOGIES 3
63. rror code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified S_tdrv011Drv_MSGNOTDEF The message is not properly setup for transmit S_tdrv011Drv_MSGBUSY The specified message is already in use TDRV011 SW 42 VxWorks Device Driver Page 42 of 96 TENSE TECHNOLOGIES 3 2 12 tdrv011UpdateRemoteMsgObj Name tdrv011UpdateRemoteMsgObj update remote buffer message object data Synopsis STATUS tdrv01 1UpdateRemoteMsgObj TDRVO011_DEV pDev int messageNumber int length unsigned char pData Description This function writes only new data into the previous allocated remote buffer message object without starting transmission The data can be requested by other CAN nodes by sending a RTR message with the same identifier Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the previous defined remote buffer message object Valid numbers are in the range between 1 and 14 length Contains the number of message data bytes 0 8 pData This buffer contains up to 8 data bytes pData 0 contains message Data 0 pData 1 contains message Data 1 and so on TDRV011 SW 42 VxWorks Device Driver P
64. sage object Synopsis STATUS tdrv011ReleaseMsgObj TDRV011_DEV pDev int messageNumber Description This function marks the specified message object invalid and stops any transaction with this message object Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messageNumber This parameter contains the number of the previous defined message object Valid numbers are in the range between 1 and 15 TDRV011 SW 42 VxWorks Device Driver Page 48 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO0O11_DEV pDev STATUS result int msgNum Release a previous defined message object Wi msgNum 2 result tdrv011ReleaseMsgObj pDev msgNum i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description S_tdrv011Drv_IMSGNUM Illegal message number specified TDRV011 SW 42 VxWorks Device Driver Page 49 of 96 TEWS amp TECHNOLOGIES 3 2 15 tdrv011GetMsgObjStatus Name tdrv011GetMsgObjStatus get the status of a tr
65. ssing and the support for 27 party drivers may not be available 2 2 VxBus Driver Installation Because Wind River doesn t provide a standard installation method for 3 party VxBus device drivers the installation procedure needs to be done manually In order to perform a manual installation extract all files from the archive TDRV011 SW 42 VXBUS zip to the typical gn party directory installDir vxworks 6 x target 3rdparty whereas installDir must be substituted by the VxWorks installation directory After successful installation the TDRV011 device driver is located in the vendor and driver specific directory installDir vxworks 6 x target 3rdparty tews tdrv01 1 At this point the TDRVO011 driver is not configurable and cannot be included with the kernel configuration tool in a Wind River Workbench project To make the driver configurable the driver library for the desired processer CPU and build tool TOOL must be built in the following way 1 Open a VxWorks development shell e g C WindRiver wrenv exe p vxworks 6 7 2 Change into the driver installation directory installDir vxworks 6 x target 3rdparty tews tdrv01 1 3 Invoke the build command for the required processor and build tool make CPU cpuName TOOL tool For Windows hosts this may look like this C gt cd WindRiver vxworks 6 7 target 3rdparty tews tdrv011 TDRV011 SW 42 VxWorks Device Driver Page 7 of 96 TENSE TECHNOLOGIES C gt make CPU PENTIUM4 T
66. t rate to make the CAN bus more immune against noise spikes TDRV011 SW 42 VxWorks Device Driver Page 30 of 96 TEWS amp TECHNOLOGIES Example include tdrv011 h TDRVO11_DEV pDev STATUS result Set CAN bus bit timing S result tdrv011SetBitTiming pDev TDRVO0O11_100KBIT FALSE i if result ERROR handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet This function returns no driver specific error codes TDRV011 SW 42 VxWorks Device Driver Page 31 of 96 TEWS amp TECHNOLOGIES 3 2 8 tdrv011DefineReceiveMsgObj Name tdrv0O1 1 DefineReceiveMsgObj setup a message object for receive Synopsis STATUS tdrv01 1 DefineReceiveMsgObj TDRV011_DEV pDev int messageNumber unsigned long identifier int extended Description This function setup a free controller message object to receive CAN messages with the specified identifier Before the driver can receive CAN messages it s necessary to define at least one receive message object If only one receive message object is defined at all preferably message object 15 should be used because this message object is double buffered Parameters pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function messag
67. tarts transmission of a remote frame for receive message objects The function specific control parameter arg is a pointer on a TDRVO11_ARGS structure for this function TEWS amp TECHNOLOGIES The status of message object for example transmission completed can be determined by use of the I O control function TDRV0O11_STATUS typedef struct unsigned long cmd unsigned long flags unsigned long arg TDRV011_ARGS cmd The cmd argument is not used flags If the I O flags TDRVO11_REMOTE is set transmission will be started by a request of a remote node otherwise transmission of the message data starts immediately arg A pointer to a message object description data structure TDRV0O11_MSGDEF is passed to the driver by the function dependent parameter arg typedef struct unsigned char unsigned long unsigned char unsigned char unsigned char TDRV011_MSGDEF MsgNum MsgNum identifier extended length data 8 The parameter MsgNum specifies the number of the message object 1 13 and 15 identifier The parameter is unused extended The parameter is unused length This parameter specifies the number of bytes the new data contains data The buffer data contains the new message data TDRV011 SW 42 VxWorks Device Driver Page 87 of 96 TENSE TECHNOLOGIES EXAMPLE include tdrv011 h int fd int retval TDRVO11_MSGDEF MsgDef
68. ter an abnormal rate of occurrences of errors on the CAN bus the CAN controller enters the busoff state This I O control function resets the init bit in the Control register The CAN controller begins the busoff recovery sequence The bus recovery sequence resets transmit and receive error counters If the CAN controller counts 128 packets of 11 consecutive recessive bits on the CAN bus the busoff state is exited EXAMPLE include tdrv011 h int gek int retval retval ioctl fd TDRV0O11_BUSON 0 if retval ERROR handle error ERROR CODES Error code S_tdrv011Drv_BUSOFF TDRV011 SW 42 VxWorks Device Driver Description The device can not be set buson Page 90 of 96 TENSE TECHNOLOGIES 5 3 11 TDRV011_BUSOFF This function set the specified device to busoff state The function specific control parameter arg is not used for this function EXAMPLE include tdrv011 h int fd int retval retval ioctl fd TDRV0O11_BUSOFF 0 if retval ERROR handle error TDRV011 SW 42 VxWorks Device Driver Page 91 of 96 TENSE TECHNOLOGIES 5 3 12 TDRV011_STATUS This I O control function returns the actual state of the specified transmit message object The function specific control parameter arg is a pointer on a TDRVO11_STAT structure for this function The status of message object for example transmission completed can be determin
69. tialization otherwise the TDRV011 PCI spaces remains unmapped and an access fault occurs during driver initialization Please insert the following call at a suitable place in sysLib c tdrv011PcilInit Modifying the sysLib c file will change the sysLib c in the BSP path Remember this for future projects and recompilations 2 3 3 BSP dependent adjustments The driver includes a file called include tdhal h which contains functions and definitions for BSP adaptation It may be necessary to modify them for BSP specific settings Most settings can be made TDRV011 SW 42 VxWorks Device Driver Page 9 of 96 TEWS amp TECHNOLOGIES automatically by conditional compilation set by the BSP header files but some settings must be configured manually There are two way of modification first you can change the include tdhal h and define the corresponding definition and its value or you can do it using the command line option D There are 3 offset definitions USERDEFINED_MEM_OFFSET USERDEFINED_IO_OFFSET and USERDEFINED_LEV2VEC that must be configured if a corresponding warning message appears during compilation These definitions always need values Definition values can be assigned by command line option D lt definition gt lt value gt definition description USERDEFINED_MEM_ OFFSET The value of this definition must be set to the offset between CPU Bus and PCl Bus Address for PCI memory space access USERDEFINED_lIO OFFSET

Download Pdf Manuals

image

Related Search

TDRV011 SW 42

Related Contents

BIBLIOGRAPHIE - Les thèses de l`Université Lumière Lyon 2    HP S2031a User Guide Manual - Downloaded from ManualMonitor  HP CP6015de User's Manual  Epson 1000 ICS All-in-One Printer Basic Guide  User manual  ASRock P85 Pro3 Quick Start Manual  

Copyright © All rights reserved.
Failed to retrieve file