Home

User Manual - TEWS TECHNOLOGIES

image

Contents

1. 5 1 2 Closing a Device The CloseHandle function closes an open TDRVO10 handle BOOL CloseHandle HANDLE hDevice PARAMETERS hDevice Identifies an open TDRVO10 handle Return Value If the function succeeds the return value is nonzero If the function fails the return value is zero To get extended error information call GetLastError EXAMPLE HANDLE hDevice if CloseHandle hDevice ErrorHandler Could not close device process error SEE ALSO CreateFile Win32 documentation CloseHandle TDRV010 SW 65 Windows Device Driver Page 58 of 94 TEWS TECHNOLOGIES 5 1 3 TDRVO10 Device VO Control Functions The DeviceloControl function sends a control code directly to a specified device driver causing the corresponding device to perform the specified operation BOOL DeviceloControl HANDLE hDevice handle to device of interest DWORD dwloControlCode control code of operation to perform LPVOID lpinBuffer pointer to buffer to supply input data DWORD ninBufferSize size of input buffer LPVOID lpOutBuffer pointer to buffer to receive output data DWORD nOutBufferSize size of output buffer LPDWORD lpBytesReturned pointer to variable to receive output byte count LPOVERLAPPED pOverlapped pointer to overlapped structure for asynchronous operation PARAMETERS hDevice Handle to the TDRV010 that is to perform the operation dwloControlCo
2. TEWS The Embedded VO Company TECHNOLOGIES TDRV010 SW 65 Windows Device Driver Isolated 2 x CAN Bus Version 2 0 x User Manual Issue 2 0 0 January 2011 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 65 Windows Device Driver Isolated 2 x CAN Bus Supported Modules TEWS 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 2005 2011 by TEWS TECHNOLOGIES GmbH TPMC310 TPMC810 device described herein Issue Description 1 0 0 First Issue 1 0 1 IOCTL TDRVO10 READ function description added 1 0 2 New Address TEWS LLC 1 0 3 General Revision Return value of CloseHandle corrected 1 0 4 Files moved to subdirectory 2 0 0 Windows 7 64 bit support added API added Address TEWS LLC removed TDRV010 SW 65 Windows Device Driver Date January 1 2005 February 14 2006 February 28 2007 April 7 2008 June 23 2008 January 11 2011 Page 2 of 94 TEWS TECHNOLO
3. This function enables the listen only facility of the SJA1000 CAN controller for the specified channel 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 PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRV010 SW 65 Windows Device Driver Page 44 of 94 TEWS TECHNOLOGIES Enable listen only for channel 2 Wi errVal tdrv010ListenOnlyEnable FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function Other returne
4. Windows Device Driver Page 71 of 94 TEWS amp TECHNOLOGIES Go Bus on channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 BUSON amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O i if success printf nChanging to BUS ON completed n else d ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR IO DEVICE Error during Bus On seguence TDRVO10 SW 65 Windows Device Driver Page 72 of 94 TEWS TECHNOLOGIES 5 1 3 6 lOCTL_TDRV010_BUSOFF This TDRVO10 control function sets the channel into BUS OFF state The channel parameter is specified in an application supplied buffer 7DRVO10 DEFAULTBUF The parameter o nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used After execution of this control function the CAN controller is completely removed from the CAN bus and cannot communicate until the control function OCTL_TDRV010_BUSON is executed typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This parameter specifies the channel to use Allowed values are
5. 65 Windows Device Driver Page 65 of 94 if success printf nWrite Messag else ERROR CODES ERROR_INVALID_PARAMETER ERROR_FILE_NOT_FOUND ERROR_FILE_OFFLINE ERROR_NETWORK_BUSY ERROR_OPERATION_ABORTED ERROR_SEM_TIMEOUT ERROR_IO_DEVICE TDRV010 SW 65 Windows Device Driver TEWS TECHNOLOGIES successful completed Nn ErrorHandler Device I O control error process error This error will be returned if the size of the write buffer is too small Illegal channel number specified The channel must be in BUS ON state to transmit messages There is already another job waiting for message transmission on this channel The job has been canceled by Windows The specified timeout time has expired without successful transmission of the message An error occurred while starting the transmission Page 66 of 94 TEWS TECHNOLOGIES 5 1 3 3 IOCTL_TDRV010_BITTIMING This TDRV010 control function modifies the bit timing registers for the specified channel The new timing parameters are specified in an application supplied buffer 7DRVO10 TIMING The parameter lpinBuffer passes a pointer to the buffer to the device driver The parameter pOutBuffer is not used typedef struct UCHAR channel USHORT TimingValue BOOLEAN ThreeSamples TDRV010_TIMING PTDRV010_TIMING channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for c
6. OFF state to execute this function Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 47 of 94 TEWS TECHNOLOGIES 4 2 15 tdrv010SetLimit NAME tdrvO10SetLimit configure error warning limit of the specified device SYNOPSIS int tdrv010SetLimit TDRV010 HANDLE FileDescriptor UCHAR canChan UCHAR errorLimit DESCRIPTION This function sets a new error warning limit in the corresponding CAN controller register of the specified CAN channel This function must be executed in BUS OFF state PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to configure Allowed values are 1 for channel 1 and 2 for channel 2 errorLimit This parameter specifies the new warning limit Allowed values are between 0 and 255 TDRV010 SW 65 Windows Device Driver Page 48 of 94 TEWS amp TECHNOLOGIES EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result Set error warning limit to 100 for channel 2 ef errVal tdrv010SetLimit FileDescriptor 2 channel 100 if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the fu
7. Page 21 of 94 TEWS TECHNOLOGIES IOFlags This parameter specifies the I O flags for the message The following flags may be set Value Description TDRV010_EXTENDED Set if the transmit message is an extended message frame Reset for standard message frames TDRVO10 REMOTE FRAME Set if the transmit message is a remote transmission request RTR frame TDRV010_SINGLE_SHOT There will be no retry sending the message TDRVO10 SELF RECEPTION The message will be able to be received on the sending device length This parameter specifies the data length of the message data in bytes The length of the message can be 0 8 byte pData This parameter points to a buffer where the message data must be stored The number of used bytes must be specified in length EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result UCHAR dataBuf 8 123456 TDRVO10 SW 65 Windows Device Driver Page 22 of 94 TEWS amp TECHNOLOGIES Send a CAN message on channel 2 ee xtended identifier 42 SS timout after 5 seconds Wi errVal tdrv0l0Write FileDescriptor 2 channel Ds timeout 42 TDRVO10 EXTENDED 6 dataBuf if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Desc
8. TDRVO10 SW 65 Windows Device Driver Page 87 of 94 TEWS amp TECHNOLOGIES TDRVO10 handle contains the input data size of input buffer unused but required no overlapped I O successfully completed n ErrorHandler Device I O control error process error Set warning limit channel 1 LimitBuf channel 1 imitBuf limit 20 success DeviceloControl hDevice IOCTL TDRVO10 SETLIMIT amp LimitBuf sizeof LimitBuf NULL 0 amp NumWritten NULL i if success printf nChange Warning Limit else d ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR_FILE_NOT_FOUND Illegal channel number specified ERROR_OPEN_FILES The channel must be in BUS OFF state to execute this function TDRV010 SW 65 Windows Device Driver Page 88 of 94 TEWS TECHNOLOGIES 5 1 3 14 IOCTL TDRVO10 CAN RESET This TDRVO10 control function sets the specified CAN controller in reset or operating mode by controlling the external controller reset pin The new mode is specified in an application supplied buffer TDRVO10 PLDBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter pOutBuffer is not used This function is only supported by TPMC310 modules typedef struct UCHAR channel UCHAR bitvalue TDRV010_PLDBUF PTDRVO10 PL
9. 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 PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to start Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRV010_HANDLE FileDescriptor int result TDRV010 SW 65 Windows Device Driver Page 31 of 94 TEWS TECHNOLOGIES Start up channel 2 Wi errVal tdrv010Start FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR IO DEVICE Error during Bus On sequence Other returned error codes are system error conditions TDRV010 SW 65 Windows Device Driver Page 32 of 94 TEWS TECHNOLOGIES 4 2 8 tdrv010St
10. for channel 2 timeout This argument specifies the maximum time in seconds the function is willing to wait for an incoming message The time is specified in seconds pldentifier This parameter points to buffer where the message identifier of the received message will be stored to TDRV010 SW 65 Windows Device Driver Page 13 of 94 TEWS TECHNOLOGIES plOFlags This parameter points to buffer where the I O flag of the received message will be stored to The following flags may be set Value Description TDRV010_EXTENDED Set if the received message is an extended message frame Reset for standard message frames TDRVO10 REMOTE FRAME Set if the received message is a remote transmission reguest RTR frame pStatus This parameter points to buffer where the status information about overrun condition either in the CAN controller or intermediate software FIFO will be stored to Value Description TDRV010_ SUCCESS No messages lost TDRVO10 FIFO OVERRUN One or more messages have been overwritten in the receive gueue FIFO This problem occurs if the FIFO is too small for the application read interval TDRVO10 MSGOBJ OVERRUN One or more messages have been overwritten in the CAN controller message FIFO because the interrupt latency is too large Reduce the CAN bit rate or upgrade the system speed pLength This parameter points to buffer where the data length of the received message data in bytes will be stored to The
11. function must be executed in BUS OFF state typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 DEFAULTBUF defBuf TDRV010 SW 65 Windows Device Driver Page 79 of 94 TEWS amp TECHNOLOGIES Enable Selftest channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 ENABLE SELFTEST amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O i if success printf Enable Selftest mode completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function TDRVO10 SW 65 Windows Device Driver Page 80 of 94 TEWS TECHNOLOGIES 5 1 3 10 lOCTL_TDRV010_DISABLE_SELFTEST This TDRVO10 control function disables the self test facility of the SJA1000 CAN controller The channel parameter is specified in an application suppli
12. overlapped I O TDRV010 SW 65 Windows Device Driver Page 85 of 94 TEWS amp TECHNOLOGIES if success printf nDisable Listen only completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function TDRVO10 SW 65 Windows Device Driver Page 86 of 94 TEWS TECHNOLOGIES 5 1 3 13 IOCTL TDRVO10 SETLIMIT This TDRVO10 control function sets a new error warning limit in the corresponding CAN controller register of the specified channel The new limit parameters are specified in an application supplied buffer TDRVO10 LIMITBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter pOutBuffer is not used typedef struct UCHAR channel UCHAR limit TDRV010_LIMITBUF PTDRV010_LIMITBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 limit This parameter specifies the new warning limit Allowed values are between 0 and 255 This function must be executed in BUS OFF state EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumWritten TDRVO10 LIMITBUF LimitBuf
13. status PLD Functions external CAN Controller Reset Silent Mode and Interrupt Control TPMC310 only VVVVVVVVVVV The TDRV010 SW 65 device driver supports the modules listed below TPMC310 Isolated 2 x CAN Bus Conduction Cooled PMC 64 pin connector for Back lO TPMC810 Isolated 2 x CAN Bus PMC 2x SUBD 9 pin connectors for Front Panel I O 64 pin connector for Back WO 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 TPMC310 TPMC810 Engineering Manual SJA1000 Product Specification TDRV010 SW 65 Windows Device Driver Page 5 of 94 TEWS TECHNOLOGIES 2 Installation Following files are located in directory TDRV010 SW 65 on the distribution media i386 Directory containing driver files for 32bit Windows versions amd64 Directory containing driver files for 64bit Windows versions installer_32bit exe Installation tool for 32bit systems Windows XP or later installer_64bit exe Installation tool for 64bit systems Windows XP or later tdrvO10 inf Windows installation script tdrv010 h Header file with IOCTL codes and structure definitions api tdrv01Oapi h API include file api tdrv01Oapi c API source file example tdrv0 10exa c Example application TDRV010 SW 65 2 0 0 pdf This document Release t
14. that receives the operation s output data nOutBufferSize Specifies the size of the buffer in bytes pointed to by oOutBuffer lpBytesReturned Pointer to a variable that receives the size in bytes of the data stored into the buffer pointed to by oOutBuffer A valid pointer is required lpOverlapped Pointer to an overlapped structure Refer to the loctl specific manual section how this parameter must be set Return Value If the function succeeds the return value is nonzero If the function fails the return value is zero To get extended error information call GetLastError SEE ALSO Win32 documentation DeviceloControl TDRV010 SW 65 Windows Device Driver Page 60 of 94 TEWS TECHNOLOGIES 5 1 3 1 lOCTL_TDRV010_READ This control function reads a CAN message from the receive FIFO and returns it in an application supplied buffer TDRVO10_MSG_BUF The parameters p nBuffer and lpOutBuffer pass pointers to the buffer to the device driver typedef struct UCHAR channel BOOLEAN noWait ULONG Identifier UCHAR IOFlags UCHAR MsgLen UCHAR Data 8 ULONG Timeout UCHAR Status TDRV010_MSG_BUF PTDRV010_MSG_BUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 noWait This parameter specifies if the function shall wait for a message reception if no message is stored in the receive FIFO If this flag is set the function will return immed
15. 0 amp NumWritten unused but required NULL no overlapped I O i if success printf Enable disable interrupts completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small or the gain parameter is invalid ERROR FILE NOT FOUND Illegal channel number specified ERROR INVALID FUNCTION This function is only supported by TPMC310 modules TDRVO10 SW 65 Windows Device Driver Page 94 of 94
16. 0 handle IOCTL TDRVO10 CANSTATUS amp statusBuf contains the input data sizeof statusBuf size of message buffer amp statusBuf contains the received messag sizeof statusBuf size of message buffer amp NumWritten unused but required NULL no overlapped I O i if success printf nRead Status completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the read write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified TDRV010 SW 65 Windows Device Driver Page 78 of 94 TEWS TECHNOLOGIES 5 1 3 9 IlOCTL_TDRV010_ENABLE_SELFTEST This TDRV010 control function enables the self test facility of the SJA1000 CAN controller The channel parameter is specified in an application supplied buffer TDRVO10 DEFAULTBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used In this mode a full node test is possible without any other active node on the bus using the self reception 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
17. 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 DEFAULTBUF defBuf Go Bus off channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 BUSOFF amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O TDRV010 SW 65 Windows Device Driver Page 73 of 94 TEWS amp TECHNOLOGIES if success printf nChanging to BUS OFF completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR_FILE_NOT_FOUND ERROR_IO_DEVICE Illegal channel number specified Error during Bus Off sequence TDRV010 SW 65 Windows Device Driver Page 74 of 94 TEWS TECHNOLOGIES 5 1 3 7 lOCTL_TDRV010_FLUSH This TDRVO10 control function flushes the receive buffer of the specified channel The channe parameter is specified in an application supplied buffer TDRVO10 DEFAULTBUF The parameter lpinBuffer passes a pointer to the buffer to the device driver The parameter pOutBuffer is not used typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This paramete
18. AMETER This error will be returned if the size of the read write buffer is too small or a buffer pointer is NULL ERROR FILE NOT FOUND Illegal channel number specified ERROR FILE OFFLINE The channel must be in BUS ON state to receive messages ERROR NETWORK BUSY There is already another job waiting for message reception on this channel ERROR OPERATION ABORTED The job has been canceled by Windows Other returned error codes are system error conditions TDRV010 SW 65 Windows Device Driver Page 26 of 94 TEWS TECHNOLOGIES 4 2 5 tdrv010SetBitTiming NAME tdrv010SetBitTiming configure the bit timing of the specified device SYNOPSIS int tdrv010SetBitTiming TDRVO10 HANDLE FileDescriptor UCHAR canChan USHORT timingValue BOOLEAN useThreeSamples DESCRIPTION This function configures a new bit timing for the specified CAN channel This function must be executed in BUS OFF state PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to configure Allowed values are 1 for channel 1 and 2 for channel 2 timing Value This argument specifies 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 60 Kbit per second and 1 Mbit per second The include file tdrv010 h cont
19. D PARAMETER ERROR FILE NOT FOUND ERROR FILE OFFLINE ERROR NETWORK BUSY ERROR OPERATION ABORTED ERROR SEM TIMEOUT TEWS TECHNOLOGIES Description This error will be returned if the size of the read write buffer is too small or a buffer pointer is NULL Illegal channel number specified The channel must be in BUS ON state to receive messages There is already another job waiting for message reception on this channel The job has been canceled by Windows The specified timeout time has expired without receiving a message Other returned error codes are system error conditions TDRV010 SW 65 Windows Device Driver Page 16 of 94 TEWS TECHNOLOGIES 4 2 2 tdrvO10ReadNoWait NAME tdrv010ReadNoWait read a CAN message from device return immediately SYNOPSIS int tdrvO10ReadNoWsait TDRVO10 HANDLE FileDescriptor UCHAR canChan ULONG pldentifier UCHAR plOFlags UCHAR pStatus int pLength UCHAR pData DESCRIPTION This function reads a CAN message from a specified device This function will return immediately either if a message is available or not If no message has been received the function will return an error PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for chann
20. DBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 bitvalue This parameter specifies the new mode Allowed values are O to set the certain controller in reset mode and 1 to set it to operating mode EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 PLDBUF PldBuf TDRV010 SW 65 Windows Device Driver Page 89 of 94 TEWS TECHNOLOGIES Set CAN channel 1 to reset mode PldBuf channel 1 PldBuf bitvalue 0 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 CAN RESET amp P1dBuf contains the input data sizeof PldBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O i if success printf Setup reset operating mode completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR IO DEVICE Unable to reinitialize the certain CAN controller ERROR INVALID FUNCTION This function is only supported by TPMC310 modules TDRVO10 SW 65 Windows Device Driver Page 90 of 94 TEWS E TECHNOLOGIES 5 1 3 15 OCTL TDRVO10 CAN SEL This TDRVO10 control function sets the specified CAN
21. Driver Page 34 of 94 TEWS TECHNOLOGIES 4 2 9 tdrv010FlushReceiveFifo NAME tdrvO10FlushReceiveFifo flush receive buffer of CAN channel SYNOPSIS int tdrv010FlushReceiveFifo TDRV010 HANDLE FileDescriptor UCHAR canChan DESCRIPTION This function flushes the receive buffer of the specified channel and removes all previously received messages from the FIFO PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to stop Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 SW 65 Windows Device Driver Page 35 of 94 TEWS TECHNOLOGIES Flush receive FIFO of channel 2 errVal tdrv010FlushReceiveFifo FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 36 of 94 TEWS E TEC
22. FOUND Illegal channel number specified ERROR_FILE_OFFLINE The channel must be in BUS ON state to receive messages ERROR_MR_MID_NOT_FOUND There is no message in the FIFO buffer ERROR_NETWORK_BUSY There is already another job waiting for message reception on this channel ERROR_OPERATION_ABORTED The job has been canceled by Windows Other returned error codes are system error conditions TDRV010 SW 65 Windows Device Driver Page 20 of 94 TEWS TECHNOLOGIES 4 2 3 tdrv010Write NAME tdrvO10Write send a CAN message to device SYNOPSIS int tdrv010Write TDRVO10 HANDLE FileDescriptor UCHAR canChan ULONG timeout ULONG identifier UCHAR IOFlags int length UCHAR pData DESCRIPTION This function sends a CAN message to a specified device and waits until it is send If the message cannot be sent within a specified timeout time the function will return and indicate an error PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 timeout This argument specifies the maximum time in seconds the function is willing to wait for a successful sending acknowledge for the sent message identifier This argument specifies the message identifier of the message TDRV010 SW 65 Windows Device Driver
23. GIES Table of Contents 1 INTRODUCTION sesse see se ewe KEN KA We Ee We RANK KG Ee WK NE EE ew we NEK Ee ee ed de 5 2 INSTALLATION ssssiNasdk esse Ged see KAREN GN EG R GEN ENG NE N KEN ON Ee EN Na NARE KON GN ds GEUR NAE NAN es GN de diie 6 2 1 Software E EE E 6 2 1 1 Windows 2000 SP 6 2 V2 tele OWS Ff EE 7 2 2 Confirming Driver Installation ese Rae EE RE AR RA AR KEER ER EE AR KA AR RAAR ER KEER KEER AR REG AR RE R EE EE AR KA AR RAAR ER KEER 7 3 DRIVER CONFIGURATION esse sewes de si we We ek Ge Ke kk de ea N Ko de 8 3 1 Message FIFO Configuration u eeuse eene Rae KERE AR KA AR KEER ER EE AR KA AR RAAR ER KEER KEER REESEN RR Rae R ER EER RR AAR RA Ge NENNEN 8 4 API DOCUMENTATION KE 9 4 1 General FunclionS is de eege ege 9 4 14 drv01O pehn Es GH ee isle EE GR GE ee eee 9 S CH BEE 11 4 2 Device Access FunctiONS eers ee EER EE EE RE ER ER RE GE ER EE RE GE ER EE RE GE ER EE RE GE ER ER RE Ge ER ER EE Ge ER ER Ke Ge ER EE Ke Ge ER EE Ee 13 AD ie ol EG RE N A EE Ken 13 42 2 tdrv010ReadNoWait ecrini EA ae AA ee AA Ee ee AA ee ee ee AEEA 17 42 3 ve ie ke Ee ER N EE N EE 21 424 tdrvO1OWriteNoW ett etcetera teenth nent ee i KEEN ve 24 4 2 5 tdrvO10SetBitTiming AEN 27 4 26 ve ek kole GE EE 29 427 ve ek ooi Te RE ER ER EE aa EEEE 31 e ehre EE 33 429 tdrvO10FlushRecelveFIfO sasssa aA KARSE AEN 35 4 2 10 tdrvO10GetControllerStatus iese ee Ge AA AA ee RA Ge AA ee Re ee GRA
24. HNOLOGIES 4 2 10 tdrv010GetControllerStatus NAME tdrvO10GetControllerStatus returns the CAN controller state SYNOPSIS int tdrv010GetControllerStatus TDRVO10 HANDLE FileDescriptor UCHAR canChan TDRVO10 STATUS pCANStatus DESCRIPTION This function returns the actual contents of several CAN controller registers for diagnostic purposes in an application supplied buffer TDRVO010 STATUS PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 pCANStatus This argument points to a buffer TDRVO010 STATUS where the current status will be filled in typedef struct UCHAR channel UCHAR ArbitrationLostCapture UCHAR ErrorCodeCapture UCHAR TxErrorCounter UCHAR RxErrorCounter UCHAR ErrorWarningLimit UCHAR StatusRegister UCHAR ModeRegister UCHAR RxMessageCounterMax TDRV010_STATUS PTDRV010_STATUS TDRV010 SW 65 Windows Device Driver Page 37 of 94 TEWS TECHNOLOGIES channel This parameter is not used by this function Set to same value as canChan 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 inf
25. ISTENONLY This TDRVO10 control function enables the listen only facility of the SJA1000 CAN controller The channel parameter is specified in an application supplied buffer TDRVO10 DEFAULTBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used 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 function must be executed in BUS OFF state typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 DEFAULTBUF defBuf TDRV010 SW 65 Windows Device Driver Page 83 of 94 TEWS amp TECHNOLOGIES Enable Listen only mode channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 ENABLE LISTENONLY amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O i if success printf nEnable Listen only comple
26. ITE dwShareMode Set of bit flags that specify how the object can be shared Set to 0 TDRV010 SW 65 Windows Device Driver Page 56 of 94 TEWS TECHNOLOGIES lpSecurityAttributes This argument is a pointer to a security structure Set to NULL for TDRV010 devices dwCreationDistribution Specifies the action to take on existing files and which action to take when files do not exist TDRV010 devices must be always opened OPEN_EXISTING dwFlagsAndAttributes Specifies the file attributes and flags for the file This value must be set to FILE FLAG OVERLAPPED for TDRV010 devices hTemplateFile This value must be NULL for TDRV010 devices Return Value If the function succeeds the return value is an open handle to the specified TDRV010 device If the function fails the return value is INVALID HANDLE VALUE To get extended error information call GetLastError EXAMPLE HANDLE hDevice hDevice CreateFile W TDRVO10_1 GENERIC_READ GENERIC_WRITE 0 NULL no security attrs OPEN_EXISTING TDRVO10 device always open existing FILE_FLAG_OVERLAPPED overlapped I O NUL 1 if hDevice INVALID HANDLE VALUE ErrorHandler Could not open device process error SEE ALSO CloseHandle Win32 documentation CreateFile TDRV010 SW 65 Windows Device Driver Page 57 of 94 TEWS TECHNOLOGIES
27. OOLEAN success ULONG NumWritten TDRVO10 MSG BUF msgBuf int a Read message from FIFO channel 1 msgBuf channel 1 msgBuf noWait FALSE success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 READ amp msgBuf contains the input data sizeof msgBuf size of message buffer msgBuf contains the received messag sizeof msgBuf size of message buffer amp NumwWritten unused but required NULL no overlapped I O TDRV010 SW 65 Windows Device Driver Page 62 of 94 TEWS TECHNOLOGIES if success printf nRead Message successful completed n printf Ss s Id ld Ox 1x n msgBuf IOFlags amp TDRVO1O_EXTENDED Extended Standard msgBuf IOFlags amp TDRVO10 REMOTE FRAME Remote Frame Messag Message msgBuf Identifier msgBuf Identifier printf Sd data bytes received n msgBuf MsgLen for i 0 i lt msgBuf MsgLen i printf s02X msgBuf Data i printf nMessage status field d n msgBuf Status else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the read write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR_FILE_OFFLINE The channel must be in BUS ON state to receive messages ERROR_MR_MID_NOT_FOUND There
28. OR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function TDRVO10 SW 65 Windows Device Driver Page 68 of 94 TEWS TECHNOLOGIES 5 1 3 4 IlOCTL_TDRV010_SETFILTER This TDRV010 control function modifies the acceptance filter of the specified channel The acceptance filter parameters are specified in an application supplied buffer TDRVO10 FILTER The parameter lpinBuffer passes a pointer to the buffer to the device driver The parameter pOutBuffer is not used 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 a1 at a bit position means don t care typedef struct UCHAR channel BOOLEAN SingleFilter ULONG AcceptanceCode ULONG AcceptanceMask TDRV010_FILTER PTDRV010_FILTER channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 Si
29. R canChan BOOLEAN singleFilter ULONG acceptanceCode ULONG acceptanceMask DESCRIPTION This function configures the accaptance filtering of the specified CAN channel 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 detailed description of the acceptance filter and possible filter modes can be found in the SJA1000 Product Specification Manual This function must be executed in BUS OFF state PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to configure Allowed values are 1 for channel 1 and 2 for channel 2 singleFilter Set TRUE 1 for single filter mode set FALSE 0 for dual filter mode TDRV010 SW 65 Windows Device Driver Page 29 of 94 TEWS TECHNOLOGIES acceptanceCode The contents of this parameter will be written to acceptance code register of the controller ac
30. ROR FILE NOT FOUND Illegal channel number specified ERROR INVALID FUNCTION This function is only supported by TPMC310 modules TDRVO10 SW 65 Windows Device Driver Page 92 of 94 TEWS TECHNOLOGIES 5 1 3 16 IOCTL TDRVO10 CAN INT This TDRVO10 control function enables or disables the global interrupt of the specified CAN controller The new mode is specified in an application supplied buffer TDRVO10_PLDBUF The parameter lpinBuffer passes a pointer to the buffer to the device driver The parameter pOutBuffer is not used This function is only supported by TPMC310 modules typedef struct UCHAR channel UCHAR bitvalue TDRV010_PLDBUF PTDRV010_PLDBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 bitvalue This parameter specifies the new mode Allowed values are 0 to disable and 1 to enable all supported interrupts of the certain CAN controller EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 PLDBUF PldBuf TDRV010 SW 65 Windows Device Driver Page 93 of 94 TEWS amp TECHNOLOGIES Enable all interrupts for CAN channel 1 PldBuf channel 1 PldBuf bitvalue 1 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 CAN INT amp P1dBuf contains the input data sizeof PldBuf size of input buffer NULL
31. ains predefined transfer rate symbols TDRV010_100KBIT TDRVO10 1MBIT For other transfer rates please follow the instructions of the SJA1000 Product Specification which is also part of the corresponding hardware engineering documentation use ThreeSampes If this argument is TRUE 1 the CAN bus is sampled three times per bit time instead of once TDRV010 SW 65 Windows Device Driver Page 27 of 94 TEWS TECHNOLOGIES EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result Configure channel 2 for 250Kbit s S errVal tdrv010SetBitTiming FileDescriptor 25 channel TDRVO10 250KBIT FALSE if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 28 of 94 TEWS TECHNOLOGIES 4 2 6 tdrv010SetFilter NAME tdrv010SetFilter configure the acceptance filter SYNOPSIS int tdrvO10SetFilter TDRVO10 HANDLE FileDescriptor UCHA
32. ceptanceMask The contents of this parameter will be written to the acceptance mask register of the controller EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result Configure channel 2 to accept all incoming messages errVal tdrv010SetFilter FileDescriptor 2 channel FALSE 0x00000000 OxFFFFFFFF if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 30 of 94 TEWS E TECHNOLOGIES 4 2 7 tdrv010Start NAME tdrvO10Start sets the CAN channel to bus on mode SYNOPSIS int tdrv010Start TDRV010 HANDLE FileDescriptor UCHAR canChan DESCRIPTION This function starts the specified CAN channel and set it to bus on mode 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 function resets the reset mode bit in the mode register The CAN controller
33. controller to silent or operating mode The new mode is specified in an application supplied buffer TDRVO10_PLDBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used This function is only supported by TPMC310 modules typedef struct UCHAR channel UCHAR bitvalue TDRV010_PLDBUF PTDRV010_PLDBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 bitvalue This parameter specifies the new mode Allowed values are O to set the certain controller in silent mode and 1 to set it to operating mode EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 PLDBUF PldBuf TDRV010 SW 65 Windows Device Driver Page 91 of 94 TEWS amp TECHNOLOGIES Set CAN channel 2 to silent mode PldBuf channel 2 PldBuf bitvalue 0 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 CAN SEL amp P1dBuf contains the input data sizeof PldBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O i if success printf Setup silent operating mode completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ER
34. d error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 45 of 94 TEWS TECHNOLOGIES 4 2 14 tdrv010ListenOnlyDisable NAME tdrvO10ListenOnlyDisable disable the listen only facility of CAN channel SYNOPSIS int tdrvO10ListenOnlyDisable TDRV010 HANDLE FileDescriptor UCHAR canChan DESCRIPTION This function disables the listen only facility of the SJA1000 CAN controller for the specified channel PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 SW 65 Windows Device Driver Page 46 of 94 TEWS TECHNOLOGIES Disable listen only for channel 2 errVal tdrv010ListenOnlyDisable FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS
35. de Specifies the control code for the operation This value identifies the specific operation to be performed The following values are defined in tdrv010 h Value IOCTL TDRVO10 READ IOCTL TDRVO10 WRITE IOCTL TDRVO10 BITTIMING IOCTL TDRVO10 SETFILTER IOCTL TDRVO10 BUSON IOCTL TDRVO10 BUSOFF IOCTL TDRVO10 FLUSH IOCTL_TDRV010_CANSTATUS IOCTL_TDRV010_ENABLE_SELFTEST IOCTL_TDRV010_DISABLE_SELFTEST IOCTL_TDRV010_ENABLE_LISTENONLY IOCTL_TDRV010_DISABLE_LISTENONLY IOCTL_TDRV010_SETLIMIT IOCTL_TDRV010_CAN_RESET IOCTL_TDRV010_CAN_SEL IOCTL_TDRV010_CAN_INT Meaning Read CAN message from FIFO Send CAN Message Setup Bit timing Setup Acceptance Filter Enter Bus ON mode Enter Bus OFF mode Flush Receive FIFO Read CAN status from Controller Enable Selftest Mode Disable Selftest Mode Enable Listen Only Mode Disable Listen Only Mode Set Warning Limit Setup CAN Controller reset operating mode Setup CAN Controller silent operating mode Enable disable CAN Controller interrupts See below for more detailed information on each control code TDRV010 SW 65 Windows Device Driver Page 59 of 94 TEWS TECHNOLOGIES To use these TDRV010 specific control codes the header file tdrv010 h must be included in the application lolnBuffer Pointer to a buffer that contains the data required to perform the operation nlnBufferSize Specifies the size of the buffer pointed to by p nBuffer lpOutBuffer Pointer to a buffer
36. e module retrieved by a call to the corresponding open function canChan This argument specifies the channel to configure Allowed values are 1 for channel 1 and 2 for channel 2 canint This parameter specifies if the global interrupt of the CAN controller shall be enabled TRUE or disabled FALSE EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 SW 65 Windows Device Driver Page 54 of 94 TEWS TECHNOLOGIES Enable global interrupt on channel 2 Wi errVal tdrv010CanInt FileDescriptor 2 channel TRUE if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR INVALID FUNCTION This function is only supported by TPMC310 modules Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 55 of 94 TEWS TECHNOLOGIES 5 Device Driver Programming The TDRV010 SW 65 Windows device driver is a kernel mode device driver The standard file and device I O functions CreateFile CloseHandle and DeviceloControl provide the basic interface for opening and closing a r
37. ed buffer TDRVO10 DEFAULTBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used This function must be executed in BUS OFF state typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRV010_DEFAULTBUF defBuf Disable Selftest channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL_TDRV010_DISABLE_SELFTEST amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O TDRV010 SW 65 Windows Device Driver Page 81 of 94 TEWS amp TECHNOLOGIES if success printf Disable Selftest mode completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function TDRVO10 SW 65 Windows Device Driver Page 82 of 94 TEWS TECHNOLOGIES 5 1 3 11 IOCTL TDRVO10 ENABLE L
38. ee ee ee ee 79 5 1 3 10 IOCTL_TDRV010_ DISABLE SELFTEST ees esse ese ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee 81 5 1 3 11 IOCTL_TDRV010 ENABLE _LISTENONLY ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee 83 5 1 3 12 OCT TDRVO10 DISABLE LISTENONLY ees ee ee ee ee ee ee ee ee ee ee ee ee ee ee 85 5 1 3 13 OCT TDRVO10 GETUMIT ees ee ese ee ee ee ee ee 87 5 1 3 14 IOCTL_TDRV010 CAN RESET ee ees ee ee ee ee ee ee ee ee 89 5 1 3 15 IOCTL_TDRV010 CAN SEL 91 5 1 3 16 OCT TDRVO10 CAN INTE 93 TDRVO10 SW 65 Windows Device Driver Page 4 of 94 TEWS TECHNOLOGIES 1 Introduction The TDRVO10 SW 65 Windows device driver is a kernel mode driver which allows the operation of the supported hardware module on an Intel or Intel compatible Windows operating system Supported Windows versions are Windows 2000 Windows XP Windows XP Embedded Windows 7 32bit and 64bit VV VV The standard file and device VO functions CreateFile CloseHandle and DeviceloControl provide the basic interface for opening and closing a resource handle and for performing device UO control operations The TDRVO10 SW 65 device driver supports the following features Read received messages from input FIFO Send a message Set channel Bus On Off Configure Listen Only mode On Off Configure Selftest mode On Off Extended and Standard Identifiers Configure Bitrate Configure Receive Mask Flush receive FIFO Read CAN
39. ee ee ee ee eke 37 4 2 11 tdrv010SelftestEnable A 40 4 2 12 tdrv010SelftestDisable esse de RA anaana Ge AA de ee aaia aa 42 4 2 13 tdrvO10ListenOnlyEnable iese ee ee Ge AA Ge Ge aiian ee AA ee aai 44 4 2 14 tdrv010ListenOnlyDisable AA 46 4 2 15 el Oe AO RA EE EE oaii 48 4 2 16 tdrvO TOC ANRESCL EE EO OE EE EE a iaae 50 4 2 17 TOPVOTOG AN SEI EE 52 4 2 18 Golden EE 54 TDRV010 SW 65 Windows Device Driver Page 3 of 94 TEWS TECHNOLOGIES 5 DEVICE DRIVER PROGRAMMING ees ees eek ee ke ee se eek ees ee ee kk ee ke ee ke ee kk ee Ke eek ee 56 5 1 Files and Bled TE 56 5 1 1 Opening a Devce iese de aa AG AA Re RA a Re ee ee GR AA Ge ER 56 5 1 2 Closing Ao AR N RE EE EE 58 5 1 3 TDRVO10 Device VO Control Functions ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee 59 5 1 3 1 OCTL TDRVO10 READ ese esse ee ee a Eae a praana Sar aaa RE AE a A anaE 61 5 1 3 2 OCTL TDRVO10 WRITE ee ee 64 5 1 3 3 OCTL TDRVO10 BITTIMING ee ee ee ee 67 5 1 3 4 OCT TDRVO10 SETFILTER ees esse sees ee ee ee ee ee ee ee ee ee ee 69 5 1 3 5 IOCTL_TDRV010_ BUSON ee ee ee 71 5 1 3 6 OCTL TDRVO10 BUSOFF ee ee ee 73 51 87 OCT TDRVO10 FLUSH sisie es Gees eed eed ee ee ee ke ee ed ee We eke n ge de ee vee ee ee de dee Ge We ed Ad 75 5 1 3 8 IOCTL_TDRV010 CANSTATUS ee ee ee ee ee ee 77 5 1 3 9 IOCTL_TDRV010 ENABLE SELFTEST ee ees sees ee ee ee ee ee ee ee ee ee ee ee ee ee ee
40. el 2 pldentifier This parameter points to buffer where the message identifier of the received message will be stored to TDRV010 SW 65 Windows Device Driver Page 17 of 94 TEWS TECHNOLOGIES plOFlags This parameter points to buffer where the I O flag of the received message will be stored to The following flags may be set Value Description TDRV010_EXTENDED Set if the received message is an extended message frame Reset for standard message frames TDRVO10 REMOTE FRAME Set if the received message is a remote transmission reguest RTR frame pStatus This parameter points to buffer where the status information about overrun condition either in the CAN controller or intermediate software FIFO will be stored to Value Description TDRV010_ SUCCESS No messages lost TDRVO10 FIFO OVERRUN One or more messages was overwritten in the receive gueue FIFO This problem occurs if the FIFO is too small for the application read interval TDRVO10 MSGOBJ OVERRUN 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 pLength This parameter points to buffer where the data length of the received message data in bytes will be stored to The returned length will always be 0 8 pData This parameter points to a buffer where the received data bytes will stored to Th
41. esource handle and for performing device I O control operations All of these standard Win32 functions are described in detail in the Windows Platform SDK Documentation Windows base services Hardware Device Input and Output For details refer to the Win32 Programmers Reference of your used programming tools C Visual Basic etc 5 1 Files and VO Functions The following section does not contain a full description of the Win32 functions for interaction with the TDRVO10 device driver Only the required parameters are described in detail 5 1 1 Opening a Device Before you can perform any I O the TDRV010 device must be opened by invoking the CreateFile function CreateFile returns a handle that can be used to access the TDRV010 device HANDLE CreateFile LPCTSTR pFileName DWORD dwDesiredAccess DWORD dwShareMode LPSECURITY ATTRIBUTES pSecurityAtiributes DWORD dwCreationDistribution DWORD dwFlagsAndAttributes HANDLE ATemplateFile PARAMETERS lpFileName This parameter points to a null terminated string which specifies the name of the TDRV010 to open The pFileName string should be of the form NATDRVO10 x to open the device x The ending x is a one based number The first device found by the driver is TDRV010_1 the second WMTDRVO10 2 and so on dwDesiredAccess This parameter specifies the type of access to the TDRV010 For the TDRVO10 this parameter must be set to read write access GENERIC_READ GENERIC_WR
42. hannel 2 Timing Value 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 60 Kbit per second and 1 Mbit per second The include file tdrv010 h contains predefined transfer rate symbols TDRV010_100KBIT TDRVO10 1MBIT For other transfer rates please follow the instructions of the SJA1000 Product Specification which is also part of the corresponding hardware engineering documentation ThreeSamples If this parameter is TRUE 1 the CAN bus is sampled three times per bit time instead of one This function must be executed in BUS OFF state EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 TIMING TimingBuf Change bitrate channel 1 TimingBuf channel 1 TimingBuf TimingValue TDRVO10 SOOKBIT TimingBuf ThreeSamples FALSE TDRV010 SW 65 Windows Device Driver Page 67 of 94 TEWS TECHNOLOGIES success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 BITTIMING amp TimingBuf contains the input data sizeof TimingBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O i if success printf nChange Bitrate successfully completed n else ErrorHandler Device I O control error process error ERROR CODES ERR
43. iately Identifier Obtains the message identifier of the read CAN message IOFlags Obtains CAN message attributes as a set of bit flags The following attribute flags are possible Value Description TDRV010_EXTENDED Set if the received message is an extended message frame Reset for standard message frames TDRVO10 REMOTE FRAME Set if the received message is a remote transmission request RTR frame MsgLen Obtains the number of message data bytes 0 8 Data 8 This buffer receives up to 8 data bytes Data 0 receives message Data 0 Data 1 receives message Data 1 and so on TDRV010 SW 65 Windows Device Driver Page 61 of 94 TEWS TECHNOLOGIES Timeout Specifies the amount of time in seconds the caller is willing to wait for execution of read reguest This parameter is not used if the noWait option is enabled Status Obtains status information about overrun conditions either in the CAN controller or intermediate software FIFO Value Description TDRVO10 SUCCESS No messages lost TDRVO10 FIFO OVERRUN One or more messages was overwritten in the receive gueue FIFO This problem occurs if the FIFO is too small for the application read interval TDRVO10 MSGOBJ OVERRUN 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 HANDLE hDevice B
44. ices PARAMETERS FileDescriptor This value specifies the file descriptor to the hardware module retrieved by a call to the corresponding open function EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result close file descriptor to device Wi result tdrv010Close FileDescriptor if result lt 0 handle close error TDRV010 SW 65 Windows Device Driver Page 11 of 94 TEWS TECHNOLOGIES RETURNS Zero or a negative error code ERROR CODES The inverted error code is a standard error code set by the I O system TDRV010 SW 65 Windows Device Driver Page 12 of 94 TEWS TECHNOLOGIES 4 2 Device Access Functions 4 2 1 tdrv010Read NAME tdrvO10Read read a CAN message from device SYNOPSIS int tdrv010Read TDRVO10 HANDLE FileDescriptor UCHAR canChan ULONG timeout ULONG pldentifier UCHAR plOFlags UCHAR pStatus int pLength UCHAR pData DESCRIPTION This function reads a CAN message from a specified device If no message has been received the function will wait until a message is received or the function will timeout after the specified time PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2
45. is buffer must have a length of at least 8 byte Data 0 receives the first data byte Data 1 receives the second data byte and so on The number of valid bytes is specified by pLength EXAMPLE include tdrv01l0api h TDRVO10 HANDLE FileDescriptor int result i ULONG identifier UCHAR IOFlags UCHAR msgStatus int dataLen UCHAR dataBuf 8 TDRV010 SW 65 Windows Device Driver Page 18 of 94 TEWS amp TECHNOLOGIES D Read a CAN message from channel 2 wy result tdrv010ReadNoWait FileDescriptor 2 channel amp identifier amp IOFlags msgStatus amp dataLen dataBuf if result 0 handle error else successful printf s Sa Identifier ld n IOFlags amp TDRVOLO_EXTENDED Extd Stnd IOFlags amp TDRVO10_REMOTE_FRAME Remote Msg Msg identifier printf Sd data bytes received n dataLen for i 0 i lt dataLen i printf sS02X dataBuf i printf n RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function TDRV010 SW 65 Windows Device Driver Page 19 of 94 TEWS TECHNOLOGIES ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the read write buffer is too small or a buffer pointer is NULL ERROR FILE NOT
46. is no message in the FIFO buffer ERROR_NETWORK_BUSY There is already another job waiting for message reception on this channel ERROR_OPERATION_ABORTED The job has been canceled by Windows ERROR_SEM_TIMEOUT The specified timeout time has expired without receiving a message TDRV010 SW 65 Windows Device Driver Page 63 of 94 TEWS TECHNOLOGIES 5 1 3 2 lOCTL_TDRV010_WRITE This TDRV010 control function starts the transmission of a CAN message specified in an application supplied buffer TDRVO010 MSG BUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used typedef struct UCHAR channel BOOLEAN noWait ULONG Identifier UCHAR IOFlags UCHAR MsgLen UCHAR Data 8 ULONG Timeout UCHAR Status TDRV010_MSG_BUF PTDRV010_MSG_BUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 noWait This parameter specifies if the function shall wait for a message transmission acknowledge or not If this flag is set the function will return immediately Identifier Specifies the message identifier of the CAN message IOFlags Specifies CAN message attributes as a set of ORed bit flags The following attribute flags are possible Value Description TDRV010_ EXTENDED Set if the transmit message is an extended message frame Reset for standard message frames TDRVO10 REMOTE FRAME Set if the transmit mes
47. it or 64bit systems This will install all required driver files using an installation wizard Copy needed files tdrv010 h API files to desired target directory After successful installation a device is created for each module found TDRV010_1 TDRV010_2 2 2 Confirming Driver Installation To confirm that the driver has been properly loaded perform the following steps 1 Open the Windows Device Manager a For Windows 2000 XP open the Control Panel from My Computer and click the System icon and choose the Hardware tab and then click the Device Manager button b For Windows 7 open the Control Panel from My Computer and then click the Device Manager entry 2 Click the in front of Embedded I O The driver TEWS TECHNOLOGIES TDRV010 Extended CAN TPMC should appear for each installed device TDRVO10 SW 65 Windows Device Driver Page 7 of 94 TEWS TECHNOLOGIES 3 Driver Configuration 3 1 Message FIFO Configuration After Installation of the TDRV010 Device Driver the number of sequential CAN Messages is limited to 100 without the need to read from the certain device If the default values are not suitable the configuration can be changed by modifying the registry for instance with regedit To change the number of queue entries the following value must be modified HKEY_LOCAL_MACHINE System CurrentControlSet Services tdrv010 Parameters FlFODepth Valid values are in range bet
48. l ERROR_FILE_NOT_FOUND Illegal channel number specified ERROR_OPEN_FILES The channel must be in BUS OFF state to execute this function TDRV010 SW 65 Windows Device Driver Page 70 of 94 TEWS TECHNOLOGIES 5 1 3 5 lOCTL_TDRV010_BUSON This TDRVO1O control function sets the channel into BUS ON state The channel parameter is specified in an application supplied buffer 7DRVO10 DEFAULTBUF The parameter o nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used 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 typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 Before the driver is able to communicate over the CAN bus after driver startup this control function must be executed EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 DEFAULTBUF defBuf TDRV010 SW 65
49. l 2 canSel This parameter specifies if controller shall be in silent mode TRUE or in operating mode FALSE EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 SW 65 Windows Device Driver Page 52 of 94 TEWS TECHNOLOGIES Set channel 1 to silent mode Wi errVal tdrv010CanSel FileDescriptor 1 channel TRUE if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR INVALID FUNCTION This function is only supported by TPMC310 modules Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 53 of 94 TEWS TECHNOLOGIES 4 2 18 tdrv010Canint NAME tdrvO10Canlnt enable or disable the global interrupt of the CAN controller SYNOPSIS int tdrvO10Canlnt TDRVO10 HANDLE FileDescriptor UCHAR canChan BOOLEAN canlnt DESCRIPTION This function enables or disables the global interrupt of the specified CAN controller This function is only available for TPMC310 PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardwar
50. l 2 into reset Wi errVal tdrv010CanReset FileDescriptor 1 channel FALSE if result 0 handle error else successful errVal tdrv010CanReset FileDescriptor K channel TRUE if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR IO DEVICE Unable to reinitialize the certain CAN controller ERROR INVALID FUNCTION This function is only supported by TPMC310 modules Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 51 of 94 TEWS TECHNOLOGIES 4 2 17 tdrv010CanSel NAME tdrv010CanSel set CAN channel to silent mode SYNOPSIS int tdrv010CanSel TDRV010 HANDLE FileDescriptor UCHAR canChan BOOLEAN canSel DESCRIPTION This function sets the specified CAN channel in silent or operating mode This function is only available for TPMC310 PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to configure Allowed values are 1 for channel 1 and 2 for channe
51. lity of the SJA1000 CAN controller for the specified channel PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 SW 65 Windows Device Driver Page 42 of 94 TEWS TECHNOLOGIES Disable self test for channel 2 errVal tdrv010SelftestDisable FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 43 of 94 TEWS E TECHNOLOGIES 4 2 13 tdrv010ListenOnlyEnable NAME tdrvO10ListenOnlyEnable enable the listen only facility of CAN channel SYNOPSIS int tdrvO10ListenOnlyEnable TDRVO10 HANDLE FileDescriptor UCHAR canChan DESCRIPTION
52. n statusBuf ErrorWarningLimit printf Status register 0x 02X n statusBuf StatusRegister printf Mode register 0x 02X n statusBuf ModeRegister printf Peak value RX message counter Sd n statusBuf RxMessageCounterMax RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the read write buffer is too small or a buffer pointer is NULL ERROR FILE NOT FOUND Illegal channel number specified Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 39 of 94 TEWS TECHNOLOGIES 4 2 11 tdrv010SelftestEnable NAME tdrv010SelftestEnable enable the self test facility of CAN channel SYNOPSIS int tdrv010SelftestEnable TDRV010 HANDLE FileDescriptor UCHAR canChan DESCRIPTION This function enables the self test facility of the SJA1000 CAN controller for the specified channel In this mode a full node test is possible without any other active node on the bus using the self reception 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 con
53. nction ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR_FILE_NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 49 of 94 TEWS TECHNOLOGIES 4 2 16 tdrv010CanReset NAME tdrv010CanReset set CAN channel to reset operating mode SYNOPSIS int tdrv010CanReset TDRV010 HANDLE FileDescriptor UCHAR canChan BOOLEAN canReset DESCRIPTION This function sets the specified CAN controller in reset or operating mode by controlling the external controller reset pin of the specified CAN channel This function is only available for TPMC310 PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to configure Allowed values are 1 for channel 1 and 2 for channel 2 canReset This parameter specifies if controller shall be set in reset TRUE or in operating mode FALSE EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 SW 65 Windows Device Driver Page 50 of 94 TEWS TECHNOLOGIES Set channel 1 to operating mode and channe
54. nected PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRV010 SW 65 Windows Device Driver Page 40 of 94 TEWS TECHNOLOGIES Enable self test for channel 2 errVal tdrv010SelftestEnable FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device Driver Page 41 of 94 TEWS TECHNOLOGIES 4 2 12 tdrv010SelftestDisable NAME tdrv010SelftestDisable disable the self test facility of CAN channel SYNOPSIS int tdrv010SelftestDisable TDRV010 HANDLE FileDescriptor UCHAR canChan DESCRIPTION This function disables the self test faci
55. ngleFilter Set TRUE 1 for single filter mode set FALSE 0 for dual filter mode AcceptanceCode The contents of this parameter will be written to acceptance code register of the controller AcceptanceMask The contents 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 function must be executed in BUS OFF state TDRV010 SW 65 Windows Device Driver Page 69 of 94 TEWS amp TECHNOLOGIES EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumWritten TDRVO10 FILTI bi Kg FilterBuf Change acceptance mask channel 1 FilterBuf channel FilterBuf SingleFilter FilterBuf AcceptanceCod FilterBuf AcceptanceMask success DeviceloControl hDevice IOCTL TDRVO10 SETFILTER amp FilterBuf sizeof FilterBuf NULL 0 amp NumWritten NULL i if success 1 TRUE 0x00000000 OREEELEEEE TDRVO10 handle contains the input data size of input buffer unused but required no overlapped I O printf nChange Filter successfully completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR_INVALID_PARAMETER This error will be returned if the size of the write buffer is too smal
56. op NAME tdrv010Stop sets the CAN channel to bus off mode SYNOPSIS int tdrv010Stop TDRV010 HANDLE FileDescriptor UCHAR canChan DESCRIPTION This function stops the specified CAN channel and set it to bus off mode After execution of this function the CAN controller is completely removed from the CAN bus and cannot communicate until the function tdrv010Start is executed PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to stop Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv0l0api h TDRV010_HANDLE FileDescriptor int result TDRV010 SW 65 Windows Device Driver Page 33 of 94 TEWS TECHNOLOGIES Stop up channel 2 Wi errVal tdrv010Stop FileDescriptor 2 channel if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function ERROR CODES Error code Description ERROR INVALID PARAMETER This error will be returned if the size of the user buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR IO DEVICE Error during Bus Off seguence Other returned error codes are system error conditions TDRVO10 SW 65 Windows Device
57. ormation 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 RX 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 ModeRegister Contents of the mode register RxMessageCounterMax Contains the peak value of messages in the software receive FIFO This internal counter value will be reset to 0 after reading EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result TDRVO10 STATUS statusBuf TDRV010 SW 65 Windows Device Driver Page 38 of 94 TEWS amp TECHNOLOGIES Read a CAN controller status of channel 2 Wi result tdrv010GetControllerStatus FileDescriptor channel amp statusBuf if result 0 handle error else successful printf nArbitration lost capture register 0x 02X n statusBuf ArbitrationLostCapture printf Error code capture register 0x 02X n statusBuf ErrorCodeCapture printf TX error counter register 0x 02X n statusBuf TxErrorCounter printf RX error counter register 0x 02X n statusBuf RxErrorCounter printf Error warning limit register 0x 02X
58. r specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 DEFAULTBUF defBuf Flush buffer channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 FLUSH amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O TDRV010 SW 65 Windows Device Driver Page 75 of 94 TEWS TECHNOLOGIES if success printf nFlushing receive buffer completed n else ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR_FILE_NOT_FOUND Illegal channel number specified TDRV010 SW 65 Windows Device Driver Page 76 of 94 TEWS TECHNOLOGIES 5 1 3 8 lOCTL_TDRV010_CANSTATUS This TDRVO10 control function returns the actual contents of several CAN controller registers for diagnostic purposes in an application supplied buffer TDRVO10_MSG_BUF The parameters loInBuffer and lpOutBuffer pass pointers to the buffer to the device driver typedef struct UCHAR channel UCHAR ArbitrationLostCapture UCHAR ErrorCodeCapture UCHAR TxErrorCounter UCHAR RxErrorCoun
59. returned length will always be 0 8 pData This parameter points to a buffer where the received data bytes will stored to This buffer must have a length of at least 8 byte Data 0 receives the first data byte Data 1 receives the second data byte and so on The number of valid bytes is specified by pLength EXAMPLE include tdrv01l0api h TDRVO10 HANDLE FileDescriptor int result i ULONG identifier UCHAR IOFlags UCHAR msgStatus int dataLen UCHAR dataBuf 8 TDRV010 SW 65 Windows Device Driver Page 14 of 94 TEWS amp TECHNOLOGIES AN Read a CAN message from channel 2 SES timeout after 10 seconds Wi result tdrv010Read FileDescriptor 2 channel 10 timeout amp identifier amp IOFlags msgStatus amp dataLen dataBuf if result 0 handle error else successful printf s Sa Identifier ld n IOFlags amp TDRVO1LO_EXTENDED Extd Stnd IOFlags amp TDRVO10_REMOTE_FRAME Remote Msg Msg identifier printf Sd data bytes received n dataLen for i 0 i lt dataLen i printf sS02X dataBuf i printf n RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function TDRV010 SW 65 Windows Device Driver Page 15 of 94 ERROR CODES Error code ERROR INVALI
60. ription ERROR INVALID PARAMETER This error will be returned if the size of the read write buffer is too small or a buffer pointer is NULL ERROR FILE NOT FOUND Illegal channel number specified ERROR FILE OFFLINE The channel must be in BUS ON state to receive messages ERROR NETWORK BUSY There is already another job waiting for message reception on this channel ERROR OPERATION ABORTED The job has been canceled by Windows ERROR_SEM_TIMEOUT The specified timeout time has expired without receiving a message Other returned error codes are system error conditions TDRV010 SW 65 Windows Device Driver Page 23 of 94 TEWS TECHNOLOGIES 4 2 4 tdrv010WriteNoWait NAME tdrv010WriteNoWait send a CAN message to device return immediately SYNOPSIS int tdrv01 OWriteNoWait TDRV010 HANDLE FileDescriptor UCHAR canChan ULONG identifier UCHAR IOFlags int length UCHAR pData DESCRIPTION This function starts sending a CAN message to a specified device and returns The function will return immediately and will not wait until the message is send PARAMETERS FileDescriptor This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function canChan This argument specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 identifier This argument specifies the message identifier of the message IOFlags This parame
61. sage is a remote transmission request RTR frame TDRV010_SINGLE_SHOT There will be no retry sending the message TDRVO10 SELF RECEPTION The message will be able to be received on the sending device MsgLen Specifies the number of message data bytes 0 8 specified in Data Data 8 This buffer contains up to 8 data bytes Dataf0 will be transmitted as Data 0 Data 1 will be transmitted as Data 1 and so on TDRV010 SW 65 Windows Device Driver Page 64 of 94 TEWS TECHNOLOGIES Timeout Specifies the amount of time in seconds the caller is willing to wait for execution of the transmit request If the noWait option is enabled this parameter specifies the time in seconds the driver will try to transmit this message Status Parameter unused for this function EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 MSG BUF msgBuf Transmit message channel 1 msgBuf channel 1 msgBuf noWait FALSE msgBuf Identifier 1234 msgBuf Timeout 10 msgBuf IOFlags TDRVO10 EXTENDED TDRVO10 SINGLE SHOT msgBuf MsgLen 2 msgBuf Data 0 Oxaa msgBuf Data 1 0x55 success DeviceloControl hDevice TDRVO10 handle IOCTL TDRVO10 WRITE amp msgBuf contains the input data sizeof msgBuf size of message buffer NULL 0 amp NumWritten unused but required NULL no overlapped I O TDRV010 SW
62. ted n else d ErrorHandler Device I O control error process error ERROR CODES ERROR INVALID PARAMETER This error will be returned if the size of the write buffer is too small ERROR FILE NOT FOUND Illegal channel number specified ERROR OPEN FILES The channel must be in BUS OFF state to execute this function TDRVO10 SW 65 Windows Device Driver Page 84 of 94 TEWS TECHNOLOGIES 5 1 3 12 IOCTL TDRVO10 DISABLE LISTENONLY This TDRVO10 control function disables the listen only facility of the SJA1000 CAN controller The channel parameter is specified in an application supplied buffer TDRVO10 DEFAULTBUF The parameter p nBuffer passes a pointer to the buffer to the device driver The parameter oOutBuffer is not used This function must be executed in BUS OFF state typedef struct UCHAR channel TDRV010_DEFAULTBUF PTDRV010_DEFAULTBUF channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 DEFAULTBUF defBuf Disable Listen only mode channel 1 defBuf channel 1 success DeviceloControl hDevice TDRVO10 handle IOCTL_TDRV010_DISABLE_LISTENONLY amp defBuf contains the input data sizeof defBuf size of input buffer NULL 0 amp NumWritten unused but required NULL no
63. ter UCHAR ErrorWarningLimit UCHAR StatusRegister UCHAR ModeRegister UCHAR RxMessageCounterMax TDRV010_STATUS PTDRV010_STATUS channel This parameter specifies the channel to use Allowed values are 1 for channel 1 and 2 for channel 2 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 RX 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 ModeRegister Contents of the mode register RxMessageCounterMax Contains the peak value of messages in the software receive FIFO This internal counter value will be reset to 0 after reading TDRV010 SW 65 Windows Device Driver Page 77 of 94 TEWS amp TECHNOLOGIES EXAMPLE include tdrv010 h HANDLE hDevice BOOLEAN success ULONG NumWritten TDRVO10 STATUS statusBuf Read message from FIFO channel 1 aa statusBuf channel 1 success DeviceloControl hDevice TDRVO1
64. ter specifies the I O flags for the message The following flags may be set Value Description TDRV010_ EXTENDED Set if the transmit message is an extended message frame Reset for standard message frames TDRVO10 REMOTE FRAME Set if the transmit message is a remote transmission request RTR frame TDRV010_SINGLE_SHOT There will be no retry sending the message TDRVO10 SELF RECEPTION The message will be able to be received on the sending device TDRVO10 SW 65 Windows Device Driver Page 24 of 94 TEWS TECHNOLOGIES length This parameter specifies the data length of the message data in bytes The length of the message can be 0 8 byte pData This parameter points to a buffer where the message data must be stored to The number of used bytes must be specified in length EXAMPLE include tdrv0l0api h TDRVO10 HANDLE FileDescriptor int result UCHAR dataBuf 8 123456 Send a CAN message on channel 1 SC standard identifier 42 Wi errVal tdrv010WriteNoWait FileDescriptor 1 channel 42 TDRVO10_STANDARD 6 dataBuf if result 0 handle error else successful RETURN VALUE On success zero is returned In the case of an error the appropriate negative error code is returned by the function TDRV010 SW 65 Windows Device Driver Page 25 of 94 TEWS TECHNOLOGIES ERROR CODES Error code Description ERROR INVALID PAR
65. ween 1 1024 TDRV010 SW 65 Windows Device Driver Page 8 of 94 TEWS E TECHNOLOGIES 4 API Documentation 4 1 General Functions 4 1 1 tdrv0100pen NAME tdrvO10Open opens a device SYNOPSIS TDRVO10_HANDLE tdrv0100pen char DeviceName 1 DESCRIPTION Before I O can be performed to a device a file descriptor must be opened by a call to this function Make sure that this function is called with enough privileges especially for Windows 7 PARAMETERS DeviceName This parameter points to a null terminated string that specifies the name of the device EXAMPLE include tdrv0l0api h TDRVO1O_HANDLE FileDescriptor open file descriptor to device FileDescriptor tdrv0100pen TDRVO10_1 if FileDescriptor INVALID_HANDLE_VALUE handle open error TDRV010 SW 65 Windows Device Driver Page 9 of 94 TEWS TECHNOLOGIES RETURNS A device descriptor number or INVALID HANDLE VALUE if the function fails To get extended error information call GetLastError ERROR CODES The error code is a standard error code set by the I O system TDRVO10 SW 65 Windows Device Driver Page 10 of 94 TEWS TECHNOLOGIES 4 1 2 tdrv010Close NAME tdrv010Close closes a device SYNOPSIS int tdrv010Close TDRVO10 HANDLE FileDescriptor 1 DESCRIPTION This function closes previously opened dev
66. xt Information about the Device Driver Release ChangeLog txt Release history 2 1 Sof tware Installation 2 1 1 Windows 2000 XP This section describes how to install the TDRVO10 Device Driver on a Windows 2000 XP operating system After installing the hardware and boot up your system Windows 2000 XP setup will show a New hardware found dialog box 1 The Upgrade Device Driver Wizard dialog box will appear on your screen Click Next button to continue In the following dialog box choose Search for a suitable driver for my device Click Next button to continue In Drive A insert the TDRVO10 driver disk select Disk Drive in the dialog box Click Next button to continue Now the driver wizard should find a suitable device driver on the diskette Click Next button to continue Complete the upgrade device driver and click Finish to take all the changes effect Repeat the steps above for each found module of the TDRV010 product family Copy needed files tdrv010 h API files to desired target directory After successful installation a device is created for each module found TDRV010_1 TDRV010_2 TDRV010 SW 65 Windows Device Driver Page 6 of 94 TEWS TECHNOLOGIES 2 1 2 Windows 7 This section describes how to install the TDRV010 SW 65 Device Driver on a Windows 7 32bit or 64bit operating system Depending on the operating system type execute the installer binaries for either 32b

Download Pdf Manuals

image

Related Search

Related Contents

Smart-AVI RDU-2P    Quick Reference (extract from User Manual) PVI  取扱説明書/3.8MB - Kikusui Electronics Corp.  Guia de Configuração Wireless (X364dw)  Transition Networks F-SM-MM-06 User's Manual  Manipulation Concentrateur PerfectO2  VTech 80-232100 game console accessory  XCC Series PLC User Manual - SCANTECH  II64T INDUCTION COOKTOP USER MANUAL  

Copyright © All rights reserved.
Failed to retrieve file