Home
TDRV009-SW-65 - TEWS Support Website in Taiwan
Contents
1. TEWS amp TECHNOLOGIES if success Process DeviceloControl error Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is invalid ERROR_INVALID_PARAMETER The specified offset address is invalid or read only All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 49 of 63 TEWS amp TECHNOLOGIES 4 1 3 16 IOCTL_TDRV009_EEPROM_READ This TDRVOO9 control function reads one 16bit word from the onboard EEPROM The parameter lolnBuffer passes a pointer to the user buffer TDRVO09_EEPROM_BUFFER to the device driver The oOutBuffer parameter is not used for this function typedef struct ULONG Offset USHORT Value TDRVO09_EEPROM_BUFFER Offset This parameter specifies a 16bit word offset into the EEPROM Following offsets are available Offset Access 00h GEN R 60h 7Fh R W Value This parameter returns the 16bit word from the EEPROM at the given offset Example include tdrv009 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumBytes TDRV009_EEPROM_BUFFER EepromBuf Read a 16bit value from the EEPROM offset 0 ZS EepromBuf Offset 0 success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV0O09_EEPROM_WRITE control code amp EepromBuf input buffer buffer sizeof TDRVO09_EEPROM_BUFFER NULL 0 amp NumB
2. include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_ADDR_STRUCT AddrBuf Read a 32bit value Status Register K AddrBuf Offset 0x0004 success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV009_SCC_REG_READ control code NULL 0 amp AddrBuf output buffer sizeof TDRV009_ADDR_STRUCT amp NumBytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 42 of 63 TEWS amp TECHNOLOGIES if success Process DeviceloControl error else printf Value 0x 1X n AddrBuf Value Error Codes ERROR_INVALID_USER_BUFFER The size of the input buffer is too small ERROR_INVALID_ PARAMETER The specified offset is invalid too large All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 43 of 63 TEWS amp TECHNOLOGIES 4 1 3 13 IOCTL_TDRV009_GLOB_REG WRITE This TDRVOO9 control function writes one 32bit word to the communication controller s register space relative to the beginning of the register set The parameter p nBuffer passes a pointer to the configuration buffer TDRV009_ADDR_STRUCT to the device driver A verification of the written data is not performed The oOutBuffer parameter is not used for this function typedef struct unsigned long Offset unsigned long Value TDRVOO9_ADDR_STRUCT Off
3. Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is too small ERROR_ACCESS_DENIED A ringbuffer is already registered Unregister it first ERROR_NO_SYSTEM_RESOURCES Not enough resources available while building ScatterGather list DMA error All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 35 of 63 TEWS amp TECHNOLOGIES 4 1 3 7 lIOCTL_TDRVO009_RINGBUF_UNREGISTER This TDRVOO9 control function unregisters a formerly registered ringbuffer The driver uses its internal receive buffer structure again No additional parameter is required for this function Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRVO09_RINGBUF_UNREGISTER control code NULL 0 NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_ACCESS_DENIED No ringbuffer is registered at the moment TDRV009 SW 65 Windows 2000 XP Device Driver Page 36 of 63 TEWS amp TECHNOLOGIES 4 1 3 8 lOCTL_TDRV009 SET RECEIVER STATE This TDRVO0O9 control function sets the state of the receiver module The parameter o nBuffer passes a pointer to a ULONG value containing the new receiver state to the device driver The oOutBuffer parameter is not use
4. TEWS amp The Embedded I O Company TECHNOLOGIES TDRV009 SW 65 Windows 2000 XP Device Driver High Speed Sync Async Serial Interface Version 1 0 x User Manual Issue 1 0 2 June 2008 TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC Am Bahnhof 7 Phone 49 0 4101 4058 0 9190 Double Diamond Parkway Phone 1 775 850 5830 25469 Halstenbek Germany Fax 49 0 4101 4058 19 Suite 127 Reno NV 89521 USA Fax 1 775 201 0347 www tews com e mail info tews com www tews com e mail usasales tews com TDRV009 SW 65 Windows 2000 XP Device Driver High Speed Sync Async Serial Interface 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 Dats complete However TEWS TECHNOLOGIES GmbH TCP863 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 2007 2008 by TEWS TECHNOLOGIES GmbH Issue Date 1 0 0 May 21 2007 1 0 1 Description of missing ioctl functions added RTS CTS DTR DSR June 19 2007 1 0 2 Files moved to subdirectory June 23 2008 TDRV009 SW 65 Windows 2000 XP Device Driver Page 2 of 63 TEWS amp TECHNOLOGIES Table of Content
5. CtsState else Process DevicelIoControl error Error Codes All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 60 of 63 TEWS amp TECHNOLOGIES 4 1 3 23 IOCTL_TDRV009 DTR_SET This TDRVO0O9 control function sets the DTR signal line to HIGH This function is only available for local module channel 3 No additional parameter is needed for this call Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_DTR_SET control code NULL 0 NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_ACCESS_DENIED This function is not supported by the specific channel All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 61 of 63 TEWS amp TECHNOLOGIES 4 1 3 24 IOCTL_TDRV009 DTR_CLEAR This TDRVO0O9 control function sets the DTR signal line to LOW This function is only available for local module channel 3 No additional parameter is needed for this call Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV009_DTR_CLE
6. CTS Staus Change CSC interrupt a WaitStruct Interrupts 1 lt lt 14 WaitSrtuct Timeout 5 success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRVO09_WAITFORINTERRUPT control code amp WaitStruct input buffer buffer sizeof TDRVO09_WAIT STRUCT amp WaitStruct output buffer sizeof TDRVO009_WAIT_ STRUCT amp NumBytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 52 of 63 TEWS amp TECHNOLOGIES if success Process DevicelIoControl error else printf Interrupt Event occurred n Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is invalid ERROR_BUSY Too many simultaneous wait jobs active All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 53 of 63 TEWS amp TECHNOLOGIES 4 1 3 18 IOCTL_TDRV009_EVENT_REGISTER This TDRV009 control function registers an event which is signaled by the driver for some reason The event TDRV009_RX_EVENT is signaled every time a new data buffer is received The parameter o nBuffer passes a pointer to the registration buffer TDRVO09_EVENT_STRUCT to the device driver The joOutBuffer parameter is not used for this function typedef struct HANDLE hEvent ULONG type TDRV009_EVENT_STRUCT hEvent This parameter specifies the event which should be signaled by the driver This e
7. TDRV009 SW 65 Windows 2000 XP Device Driver Page 55 of 63 TEWS amp TECHNOLOGIES 4 1 3 19 IOCTL_TDRVO009_EVENT_UNREGISTER This TDRVOO9 control unregisters an event which has been registered by a previous call to IOCTL_TDRV009_EVENT_REGISTER The parameter o nBuffer passes a pointer to the registration buffer TDRV009_EVENT_STRUCT to the device driver The oOutBuffer parameter is not used for this function typedef struct HANDLE hEvent ULONG type TDRV009_EVENT_STRUCT hEvent This parameter specifies the event which should be signaled by the driver This event must be created by a call to CreateEvent This parameter is not evaluated by the device driver type This parameter specifies the event type The only event type possible is TDRV009_RX_EVENT refer to tdrv009 h for definition Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_EVENT_STRUCT EventStruct init event structure EventStruct type TP862_RX_EVENT success DeviceloControl hDevice TDRV009 handle IOCTL_TDRV009_EVENT_UNREGISTER control code amp EventStruct input buffer buffer sizeof TDRVO09_EVENT_STRUCT NULL 0 amp NumBytes number of bytes transferred NULL i if success TDRV009 SW 65 Windows 2000 XP Device Driver Page 56 of 63 TEWS amp TECHNOLOGIES Pr
8. ULONG NumBytes success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_CLEAR_RX_BUFFER control code NULL 0 NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_ACCESS_DENIED There is a registered ringbuffer in use All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 38 of 63 TEWS amp TECHNOLOGIES 4 1 3 10 IOCTL_TDRV009_SET_EXT_XTAL This TDRV009 control function sets the frequency of an externally supplied frequency This frequency is used for baudrate calculation and describes the input frequency to the Baud Rate Generator BRG The external frequency may be supplied either at input line TxC or RxC The parameter lplnBuffer passes a pointer to a ULONG value containing the new clock frequency to the device driver The oOutBuffer parameter is not used for this function Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes ULONG ExtXtal specify an external frequency of 1 MHz ExtXtal 1000000 success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV0O09_SET_EXT_XTAL control code amp ExtXtal input buffer sizeof ULONG NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERR
9. as input to the transmit engine Valid values are Value TDRV009_TXCSRC_BRG TDRV009_TXCSRC_BRGDIV16 TDRV009_TXCSRC_RXCEXTERN TDRV009_TXCSRC_TXCEXTERN TDRV009_TXCSRC_DPLL TDRV009 SW 65 Windows 2000 XP Device Driver Description Baud Rate Generator output used for Tx clock BRG output divided by 16 used for Tx clock External clock at RxC input used for Tx clock External clock at TxC input used for Tx clock DPLL output used for Tx clock Page 17 of 63 TxClkOutput TEWS amp TECHNOLOGIES This parameter specifies which output lines are used to output the transmit clock e g for synchronous communication The given values can be binary OR ed Valid values are Value TDRV009_TXCOUT_TXC TDRV009_TXCOUT_RTS RxClkSource Description Transmit clock available at TxC output line Transmit clock available at RTS output line This parameter specifies the frequency source used as input to the receive engine Valid values are Value TDRV009_RXCSRC_BRG TDRV009_RXCSRC_RXCEXTERN TDRV009_RXCSRC_DPLL ClockMultiplier Description Baud Rate Generator output used for Rx clock External clock at RxC input used for Rx clock DPLL output used for Rx clock This parameter specifies the multiplier used for BRG clock input Valid values are Value TDRVO009_CLKMULT_X1 TDRV009_ CLKMULT_X4 Description Clock multiplier disabled Selected input clock is multiplied by 4 Baudrate This parameter specifies the desired frequency
10. communication Possible values are 1 or 2 Databits This parameter specifies the number of data bits to use for asynchronous communication Possible values are 5 to 8 UseTermChar This parameter enables or disables the usage of a termination character for asynchronous communication Valid values are Value Description TDRVO009_ DISABLED A termination character is not used TDRVO009_ ENABLED A termination character is used TermChar This parameter specifies the termination character After receiving this termination character the communication controller will forward the received data packet immediately to the host system and use a new data packet for further received data Any 8bit value may be used for this parameter HwHs This parameter enables or disables the hardware handshaking mechanism using RTS CTS Valid values are Value Description TDRV009_ DISABLED Hardware handshaking is not used TDRV009_ ENABLED Hardware handshaking is used TDRVO009 SW 65 Windows 2000 XP Device Driver Page 19 of 63 Cre TEWS amp TECHNOLOGIES This parameter is a structure describing the CRC checking configuration typedef struct TDRV009_CRC_TYPE Type TDRV009_ENABLE_DISABLE RxChecking TDRVO0O9_ ENABLE DISABLE TxGeneration TDRV009_CRC_RESET ResetValue TDRV009_CRC Type This parameter describes the CRC type to be used Possible values are Value Description TDRVO09_CRC_16 16bit CRC algorithm is used for checksum TDRVO009_C
11. only specific values depending on the selected oscillator are valid This frequency is internally multiplied by 16 if oversampling shall be used ClockInversion This parameter specifies the inversion of the transmit and or the receive clock This value can be binary OR ed Possible values are Value Description TDRV009_CLKINV_NONE no clock inversion TDRV009_CLKINV_TXC transmit clock is inverted TDRV009_ CLKINV_RXC receive clock is inverted Encoding This parameter specifies the data encoding used for communication Valid values are Value Description TDRV009_ ENC_NRZ NRZ data encoding TDRVO09_ENC_NRZI NRZI data encoding TDRV0O09_ENC_FMO FMO data encoding TDRV009_ENC_FM1 FM1 data encoding TDRV009_ ENG MANCHESTER Manchester data encoding TDRV009 SW 65 Windows 2000 XP Device Driver Page 25 of 63 TEWS amp TECHNOLOGIES Parity This parameter specifies the parity bit generation used for asynchronous communication Valid values are Value Description TDRV009_PAR_DISABLED No parity generation is used TDRVO009_PAR_EVEN EVEN parity bit TDRV009_PAR_ODD ODD parity bit TDRV009_PAR_SPACE SPACE parity bit always insert 0 TDRV009_PAR_MARK MARK parity bit always insert 1 Stopbits This parameter specifies the number of stop bits to use for asynchronous communication Possible values are 1 or 2 Databits This parameter specifies the number of data bits to use for asynchronous communication Possible values are 5 to 8
12. to guarantee the correct 4byte alignment for DMA operations The received data is copied into the user supplied buffer by the driver For high speed transfers better use a ringbuffer refer to chapter 4 1 3 6 typedef struct ULONG NumberOfBytes ULONG Valid ULONG Overflow UCHAR pData 1 _ dynamically expandable TDRVOO9_RX_BUFFER NumberOfBytes Returns the amount of valid bytes inside the buffer Valid This OR ed value describes if the returned buffer contains valid data Additionally the FrameEnd status is returned This value consists of the following OR ed values defined in tdrv009 h Value Description TDRVO009_ RXBUF_DATAVALID The data buffer contains valid data TDRV009_ RXBUF_FRAMEEND The data buffer contains a FrameEnd mark Overflow This value marks an internal buffer overflow pData The received values are copied into this buffer It must be large enough to hold all data Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes unsigned long BufferSize TDRVOO9_RX_BUFFER pRxBuf xx read one buffer with up to 100 data bytes 27 BufferSize 100 sizeof unsigned char sizeof TDRV009_RX_BUFFER TDRV009 SW 65 Windows 2000 XP Device Driver Page 12 of 63 TEWS amp TECHNOLOGIES pRxBuf TDRVO09_RX_BUFFER malloc BufferSize success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_READ co
13. 001 control function registers a ringbuffer structure for received data directly accessible from user space The parameters po nBuffer and pOutBuffer passes pointers to the ringbuffer structure TDRV009_RINGBUFFER to the device driver Only call this function in OVERLAPPED file mode otherwise the application will wait indefinitely for return typedef struct ULONG BufferSize ULONG PacketSize ULONG NumberOfEntries ULONG get ULONG put ULONG Overflow RINGBUFFER_HEADER BufferSize Total size of memory available for data user defined PacketSize Typical size of one data packet user defined adjusted by driver NumberOfEntries Nmber of entries available in the ringbuffer get Index where new data can be read put Index where new data is filled in by the driver Overflow TRUE if a buffer overflow has happened The receiver must be enabled again TDRV009 SW 65 Windows 2000 XP Device Driver Page 30 of 63 TEWS amp TECHNOLOGIES typedef struct ULONG NumberOfBytes ULONG Size ULONG Offset ULONG DmadAddress ULONG Valid RINGBUFFER_ENTRY NumberOfBytes This value specifies the number of valid bytes inside the corresponding buffer Size This value specifies the total size of the corresponding buffer Offset This value specifies the offset relative to the beginning of DataSection for the corresponding data buffer DmaAddress This value specifies the physical address used by the DMA controlle
14. 9_TRNSCVR _RS530 TDRV009_TRNSCVR _X21 TDRV009_TRNSCVR _V35 TDRV009_TRNSCVR _RS449 TDRVO009_TRNSCVR _V36 TDRV009_TRNSCVR _RS232 TDRV009_TRNSCVR _V28 TDRV009_TRNSCVR _NO_CABLE Oversampling This parameter enables or disables 16t TEWS amp TECHNOLOGIES mode of the programmable multi protocol Description Default V 11 EIA 530A V 11 V 10 EIA 530 V 11 also suitable for RS422 X 21 V 11 V 35 V 35 V 28 EIA 449 V 11 V 36 V 11 EIA 232 V 28 V 28 V 28 High impedance imes oversampling used for asynchronous communication For communication with standard UARTs it is recommended to enable this feature Valid values are Value Description TDRV009_ DISABLED The 16 times oversampling is not used TDRV009_ENABLED The 16 times oversampling is used BrgSource This parameter specifies the frequency source used as input to the BRG Baud Rate Generator Valid values are Value TDRV009_BRGSRC_XTAL1 TDRV009_BRGSRC_XTAL2 TDRV009_BRGSRC_XTAL3 TDRV009_BRGSRC_RXCEXTERN TDRV009_BRGSRC_TXCEXTERN TxClkSource Description XTAL1 oscillator is used for BRG input XTAL2 oscillator is used for BRG input XTAL3 oscillator is used for BRG input External clock at RxC input used for BRG input External clock at TxC input used for BRG input This parameter specifies the frequency source used as input to the transmit engine Valid values are Value TDRV009_TXCSRC_BRG TDRV009_TXCSRC_BRGDIV16 TDRV009_TXCSRC_RXCE
15. AR control code NULL 0 NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_ACCESS_DENIED This function is not supported by the specific channel All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 62 of 63 TEWS amp TECHNOLOGIES 4 1 3 25 IOCTL_TDRV009_DSR_GET This TDRV009 control function returns the current state of the DSR signal line of the specific channel This function is only available for local module channel 3 The parameter oOutBuffer passes a pointer to the user buffer unsigned long to the device driver Depending on the state of DSR either 0 inactive or 1 active is returned The p ntBuffer parameter is not used for this function Example include tdrv009 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumBytes unsigned long DsrState success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV009_DSR_GET control code ULL r DsrState izeof unsigned long NumBytes number of bytes transferred ULL CG gp Dm eo fF gt if success printf DSR ld n DsrState else Process DeviceloControl error Error Codes ERROR_ACCESS_DENIED This function is not supported by the specific channel All other returned error codes are system error conditions TDRV009 SW 65
16. CTL_TDRV009_EVENT_REGISTER IOCTL_TDRV009_EVENT_UNREGISTER TDRV009 SW 65 Windows 2000 XP Device Driver read one data packet from internal buffer write one data packet set a channel s operation mode get a channel s current operation mode set baudrate without other changes register a ringbuffer for receive unregister the ringbuffer set operation state of the channel s receiver clear the internal receive buffer specify an externally supplied frequency directly write to an SCC register directly read from an SCC register directly write to a GLOBAL register directly read from a GLOBAL register Write value to onboard EEPROM Read value from onboard EEPROM Wait for specific channel interrupt register event which is signaled by the driver unregister formerly registered event Page 10 of 63 TEWS amp TECHNOLOGIES IOCTL_TDRV009_RTS_SET Assert RTS handshake line IOCTL_TDRV009_RTS_CLEAR De Assert RTS handshake line IOCTL_TDRV009_CTS_GET Read state of CTS IOCTL_TDRV009_DTR_SET Set DTR signal line only channel 3 IOCTL_TDRV009_DTR_CLEAR Clear DTR signal line only channel 3 IOCTL_TDRV009_DSR_GET Read state of DSR only channel 3 See behind for more detailed information on each control code lolnBuffer Pointer to a buffer that contains the data required to perform the operation ninBufferSize Specifies the size in bytes of the buffer pointed to by lpInBuffer lpOutBuffer Pointer to a buffer that receives th
17. Error Example HANDLE hDevice if CloseHandle hDevice ErrorHandler Could not close device process error See Also CreateFile Win32 documentation CloseHandle TDRV009 SW 65 Windows 2000 XP Device Driver Page 9 of 63 TEWS amp TECHNOLOGIES 4 1 3 Device I O 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 DWORD dwloControlCode LPVOID lplnBuffer DWORD nlnBufferSize LPVOID IpOutBuffer DWORD nOutBufferSize LPDWORD pBytesReturned LPOVERLAPPED pOverlapped Parameters hDevice Handle to the TDRVOO09 channel that is to perform the operation dwloControlCode Specifies the control code for the operation This value identifies the specific operation to be performed The following values are defined in tdrv009 h Value Meaning IOCTL_TDRV009_READ IOCTL_TDRV009_WRITE IOCTL_TDRV009_SET_OPERATION_MODE IOCTL_TDRV009_GET_OPERATION_MODE IOCTL_TDRV009_SET_BAUDRATE IOCTL_TDRV009_RINGBUF_REGISTER IOCTL_TDRV009_RINGBUF_UNREGISTER IOCTL_TDRV009_SET_RECEIVER_STATE IOCTL_TDRV009_CLEAR_RX_BUFFER IOCTL_TDRV009_SET_EXT_XTAL IOCTL_TDRV009_SCC_REG_WRITE IOCTL_TDRV009_SCC_REG_READ IOCTL_TDRV009_GLOB_REG_WRITE IOCTL_TDRV009_GLOB_REG_READ IOCTL_TDRV009_EEPROM_WRITE IOCTL_TDRV009_EEPROM_READ IOCTL_TDRV009_WAITFORINTERRUPT IO
18. GIES 4 1 3 5 lOCTL_TDRV009_SET_BAUDRATE This TDRV001 control function sets up the transmission rate for the specific channel This is done without all the other configuration stuff performed by IOCTL_TDRV009_SET_OPERATION_MODE No channel reset is performed either If async oversampling is enabled the desired baudrate is internally multiplied by 16 It is important that this result can be derived from the selected clocksource The parameter o nBuffer passes a pointer to an ULONG value containing the desired baudrate to the device driver The oOutBuffer parameter is not used for this function For pre defined baudrate values see file tdrv009 h Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes ULONG Baudrate Baudrate 14400 14400 bps success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRVO09_SET_BAUDRATE control code amp Baudrate input buffer sizeof ULONG NULL output buffer 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_INVALID_USER_BUFFER _ The size of the input buffer is too small ERROR_INVALID_ PARAMETER The desired baudrate is invalid All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 29 of 63 TEWS amp TECHNOLOGIES 4 1 3 6 lOCTL_TDRV009_RINGBUF_REGISTER This TDRV
19. LED CRC checking will not be used TDRV009_ ENABLED CRC checking will be used TxGeneration This parameter enables or disables the transmit CRC generation Possible values are Value Description TDRV009_ DISABLED A CRC checksum will be generated TDRV009_ ENABLED A CRC checksum will not be generated ResetValue This parameter describes the reset value for the CRC algorithm Possible values are Value Description TDRV009_CRC_RST_FFFF CRC reset value will be OxFFFF TDRV009_CRC_RST_0000 CRC reset value will be 0x0000 TDRVO009 SW 65 Windows 2000 XP Device Driver Page 27 of 63 TEWS amp TECHNOLOGIES Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_OPERATION_ MODE _STRUCT OperationMode Retrieve current channel configuration Wi success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV0O09_GET_OPERATION_MODE control code NULL parameter buffer 0 amp OperationMode sizeof TDRV009_OPERATION_MODE_STRUCT amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error else printf Baudrate d n OperationMode Baudrate Error Codes ERROR_INVALID_USER_BUFFER The size of the input or output buffer is too small All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 28 of 63 TEWS amp TECHNOLO
20. Multiplier TDRV009_CLKMULT_X1 OperationMode Baudrate 115200 OperationMode ClockInversion TDRV009_CLKINV_NONE OperationMode Encoding TDRV009_ENC_NRZ OperationMode Parity TDRV009_PAR_DISABLED OperationMode Stopbits 1 OperationMode Databits 8 OperationMode UseTermChar TDRV009_DISABLED OperationMode TermChar 0 OperationMode HwHs TDRV009_DISABLED OperationMode Crc Type TDRV009_CRC_16 OperationMode Crce RxChecking TDRV009_DISABLED OperationMode Crce TxGeneration TDRV009_DISABLED OperationMode Crc ResetValu TDRV009_CRC_RST_FFFF success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_SET_OPERATION_MODE control code amp OperationMode parameter buffer sizeof TDRV009_OPERATION_MODE_STRUCT NULL 0 amp NumBytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 21 of 63 TEWS amp TECHNOLOGIES if success Process DeviceloControl error Error Codes ERROR_INVALID_USER_BUFFER _ The size of the input buffer is too small ERROR_INVALID_PARAMETER A supplied parameter within the structure is invalid All other returned error codes are system error conditions See Also Win32 documentation DeviceloControl TDRV009 SW 65 Windows 2000 XP Device Driver Page 22 of 63 4 1 3 4 TEWS amp TECHNOLOGIES IOCTL_TDRV009_GET_OPERATION_MODE This TDRVOO9 control function reads the current channel configuration and retu
21. OR_INVALID_USER_BUFFER _ The size of the input buffer is too small ERROR_INVALID_ PARAMETER The specified frequency is invalid zero All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 39 of 63 TEWS amp TECHNOLOGIES 4 1 3 11 IOCTL_TDRV009 SCC REG WRITE This TDRVO0O9 control function writes one 32bit word to the communication controller s register space relative to the beginning of the specific channel s SCC register set The parameter p nBuffer passes a pointer to the configuration buffer TDRVO09_ADDR_STRUCT to the device driver A verification of the written data is not performed The oOutBuffer parameter is not used for this function typedef struct ULONG Offset ULONG Value TDRVO09_ADDR_STRUCT Offset This parameter specifies a byte offset into the communication controller s channel SCC register space Please refer to the hardware user manual for further information Value This 32bit word will be written to the communication controller s channel SCC register space Modifying register contents may result in communication problems system crash or other unexpected behavior Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_ADDR_STRUCT AddrBuf Write a 32bit value Termination Character Register Wi AddrBuf Offset 0x0048 AddrBuf Value 1 lt lt 15 0
22. RC_32 32bit CRC algorithm is used for checksum RxChecking This parameter enables or disables the receive CRC checking Possible values are Value Description TDRV009_ DISABLED CRC checking will not be used TDRV009_ ENABLED CRC checking will be used TxGeneration This parameter enables or disables the transmit CRC generation Possible values are Value Description TDRV009_ DISABLED A CRC checksum will be generated TDRV009_ ENABLED A CRC checksum will not be generated ResetValue This parameter describes the reset value for the CRC algorithm Possible values are Value Description TDRV009_CRC_RST_FFFF CRC reset value will be OxFFFF TDRV009_CRC_RST_0000 CRC reset value will be 0x0000 TDRVO009 SW 65 Windows 2000 XP Device Driver Page 20 of 63 TEWS amp TECHNOLOGIES Example incl ude tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_OPERATION_MODE_STRUCT OperationMode Configure channel for Async RS232 115200bps OperationMode CommType TDRV0O09_COMMTYPE_ASYNC OperationMode TransceiverMod TDRVO09_TRNSCVR _RS232 OperationMode Oversampling TDRV009_ENABLED OperationMode BrgSource TDRV009_BRGSRC_XTAL1 OperationMode TxClkSource TDRV009_TXCSRC_BRG OperationMode TxC1lkOutput 0 OperationMode RxClkSource TDRV009_RXCSRC_BRG OperationMode Clock
23. UseTermChar This parameter enables or disables the usage of a termination character for asynchronous communication Valid values are Value Description TDRVO009_ DISABLED A termination character is not used TDRVO009_ ENABLED A termination character is used TermChar This parameter specifies the termination character After receiving this termination character the communication controller will forward the received data packet immediately to the host system and use a new data packet for further received data Any 8bit value may be used for this parameter HwHs This parameter enables or disables the hardware handshaking mechanism using RTS CTS Valid values are Value Description TDRV009_ DISABLED Hardware handshaking is not used TDRV009_ ENABLED Hardware handshaking is used TDRVO009 SW 65 Windows 2000 XP Device Driver Page 26 of 63 Cre TEWS amp TECHNOLOGIES This parameter is a structure describing the CRC checking configuration typedef struct TDRV009_CRC_TYPE Type TDRV009 ENABLE DISABLE RxChecking TDRVO0O9_ ENABLE DISABLE TxGeneration TDRV009_CRC_RESET ResetValue TDRV009_CRC Type This parameter describes the CRC type to be used Possible values are Value Description TDRVO09_CRC_16 16bit CRC algorithm is used for checksum TDRVO009_CRC_32 32bit CRC algorithm is used for checksum RxChecking This parameter enables or disables the receive CRC checking Possible values are Value Description TDRV009_ DISAB
24. V009_SET OPERATION MODE This TDRV001 control function sets the desired operation mode for a channel The parameter loInBuffer passes a pointer to a TDRVO009_ OPERATION _MODE_STRUCT buffer to the device driver After setting the desired values a channel reset is performed so all received data is lost The lpOutBuffer parameter is not used for this function typedef struct TDRV009_COMM_TYPE TDRV009_TRANSCEIVER_MODE TDRV009_ENABLE_DISABLE TDRV009_ BRGSOURCE TDRV009_TXCSOURCE unsigned long TDRV009_RXCSOURCE TDRV009_CLKMULTIPLIER unsigned long unsigned char unsigned char TDRV009_ PARITY int int TDRVO0O9_ENABLE_DISABLE char TDRV009_ENABLE_DISABLE TDRVO009_CRC TDRVOO9_OPERATION_MODE_STRUCT CommType CommType TransceiverMode Oversampling BrgSource TxClkSource TxClkOutput RxClkSource ClockMultiplier Baudrate ClockInversion Encoding Parity Stopbits Databits UseTermChar TermChar HwHs Cre This parameter describes the general communication type for the specific channel Possible values are Value TDRV009_COMMTYPE_ASYNC TDRV009_COMMTYPE_HDLC_ADDRO TDRV009_COMMTYPE_HDLC_TRANSP TDRV009 SW 65 Windows 2000 XP Device Driver Description Asynchronous communication Standard HDLC communication without address recognition Used for synchronous communication Extended Transparent mode No protocol processing channel works as simple bit collector Page 16 of 63 TransceiverMode Th
25. Windows 2000 XP Device Driver Page 63 of 63
26. XTERN TDRV009_TXCSRC_TXCEXTERN TDRV009_TXCSRC_DPLL TDRV009 SW 65 Windows 2000 XP Device Driver Description Baud Rate Generator output used for Tx clock BRG output divided by 16 used for Tx clock External clock at RxC input used for Tx clock External clock at TxC input used for Tx clock DPLL output used for Tx clock Page 24 of 63 TEWS amp TECHNOLOGIES TxClkOutput This parameter specifies which output lines are used to output the transmit clock e g for synchronous communication The given values can be binary OR ed Valid values are Value Description TDRV009_ TXCOUT_TXC Transmit clock available at TxC output line TDRV009_TXCOUT_RTS Transmit clock available at RTS output line RxClkSource This parameter specifies the frequency source used as input to the receive engine Valid values are Value Description TDRV009_RXCSRC_BRG Baud Rate Generator output used for Rx clock TDRV009_ RXCSRC_RXCEXTERN External clock at RxC input used for Rx clock TDRV009_ RXCSRC_DPLL DPLL output used for Rx clock ClockMultiplier This parameter specifies the multiplier used for BRG clock input Valid values are Value Description TDRVO09_CLKMULT_X1 Clock multiplier disabled TDRV009_CLKMULT_X4 Selected input clock is multiplied by 4 Baudrate This parameter specifies the desired frequency to be generated by the BRG Baud Rate Generator which can be used as clock input signal The value is derived from the selected clocksource Please note that
27. a Dynamically enlargeable data buffer Example include tdrv009 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumBytes TDRVOO9_TX_BUFFER pTxBuf allocate some memory for up to 20 data bytes pTxBuf TDRVO09_TX_BUFFER malloc sizeof TDRVO0O9_TX_BUFFER 20 memset pTxBuf 0 sizeof TDRVOO9_TX_BUFFER 20 sprintf pTxBuf gt pData Hello World pIxBuf gt NumberOfBytes strlen pTxBuf gt pData success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV009_WRITE control code pIxBuf data buffer sizeof TP862_TX_BUFFER 20 size to be mapped pIxBuf data buffer sizeof TP862_TX_BUFFER 20 size to be mapped amp NumBytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 14 of 63 TEWS amp TECHNOLOGIES if success Process DeviceloControl error Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is invalid ERROR_INSUFFICIENT_BUFFER NumberOfBytes is larger than the specified memory area ERROR_NO_SYSTEM_RESOURCES Not enough resources available while building ScatterGather list DMA error All other returned error codes are system error conditions See Also Win32 documentation DeviceloControl TDRV009 SW 65 Windows 2000 XP Device Driver Page 15 of 63 TEWS amp TECHNOLOGIES 4 1 3 3 IOCTL_TDR
28. al Basic etc 4 1 Files and I O Functions The following section doesn t contain a full description of the Win32 functions for interaction with the TDRV009 device driver Only the required parameters are described in detail 4 1 1 Opening a Device Before you can perform any I O the TDRV0O09 channel device must be opened by invoking the CreateFile function CreateFile returns a handle that can be used to access the TDRVO09 channel device HANDLE CreateFile LPCTSTR_ pFileName DWORD dwDesiredAccess DWORD dwShareMode LPSECURITY_ATTRIBUTES pSecurityAttributes DWORD dwCreationDistribution DWORD dwFlagsAndAttributes HANDLE hTemplateFile Parameters lpFileName Points to a null terminated string which specifies the name of the TDRV009 channel to open The lpFileName string should be of the form TDRV009_x to open the device x The ending x is a one based number The first channel device found by the driver is TDRV009 1 the second TDRV009_2 and so on dwDesiredAccess Specifies the type of access to the TDRVOO9 For the TDRVO009 this parameter must be set to read write access GENERIC_READ GENERIC_WRITE dwShareMode Set of bit flags that specify how the object can be shared Set to 0 lpSecurityAttributes Pointer to a security structure Set to NULL for TDRVO009 channel devices dwCreationDistribution Specifies which action to take on files that exist and which action to take when files do not exi
29. ber of contained valid data To assist the user working with these entries some macros are supplied which are described later The ringbuffer concept is explained in detail in the following illustration NumberOfBytes Figure Ringbuffer Concept TDRV009 SW 65 Windows 2000 XP Device Driver Page 32 of 63 TEWS amp TECHNOLOGIES Assistant Macros and Functions for Bufferhandling To help the user work with this ringbuffer concept some assistant macros and functions were defined in tdrv009 h They are explained in the following CALCULATE_RINGBUFFER_SIZE BufferSize PacketSize calculates the total size necessary for allocation of the complete ringbuffer GET_BUFFER pRingBuffer index returns a pointer to the corresponding data buffer GET_VALID pRingBuffer index returns the value of the member Valid IS_VALID pRingBuffer index TRUE if the corresponding buffer contains valid data otherwise FALSE IS_FRAMEEND pRingBuffer index TRUE if the corresponding buffer contains a FrameEnd flag otherwise FALSE SET_VALID pRingBuffer index value sets the Valid flag for the specified entry to value CLEAR_BUFFER pRingBuffer index clears the corresponding data buffer GET_POS pRingBuffer returns the current get position where new data can be read OVERFLOW pRingBuffer TRUE if a buffer overflow has happened ot
30. d for performing device I O control operations The TDRV009 SW 65 device driver supports the following features Setup and configure a channel Send and receive Data Buffers Register and unregister a Receive Ringbuffer Switch on or off a channel s receiver Read and write onboard registers directly Wait for Receive Events Wait for interrupt events VVVVVVV The TDRV009 SW 65 device driver supports the modules listed below TPMC863 4 Channel Interface PMC TPMC363 4 Channel Interface PMC Conduction Cooled TCP863 4 Channel Interface CompactPCl In this document all supported modules and devices will be called TDRV009 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 TPMC863 Product Family User manual TPMC863 Product Family Engineering Manual TDRV009 SW 65 Windows 2000 XP Device Driver Page 4 of 63 TEWS amp TECHNOLOGIES 2 Installation Following files are located in directory TDRV009 SW 65 on the distribution media tdrvO09bus sys Windows 2000 XP driver binary Channel Enumerator tdrv009bus inf Windows 2000 XP installation script Channel Enumerator tdrv009 sys Windows 2000 XP driver binary Channel Driver tdrv009 inf Windows 2000 XP installation script Channel Driver tdrv009 h Header file with IOCTL code and structure definitions commCtrl h Header file with controller specific
31. d for this function Possible values are Value Description TDRV009_RCVR_ON The receiver is enabled TDRV009_ RCVR_OFF The receiver is disabled Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes ULONG ReceiverState set receiver to ON ReceiverState TDRV009_RCVR_ON success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRVO09_SET_RECEIVER_STATE control code amp ReceiverState parameter buffer sizeof ULONG NULL 0 amp NumBytes number of bytes transferred NULL if success Process DeviceloControl error Error Codes ERROR_INVALID_USER_BUFFER The size of the input buffer is too small ERROR_INVALID PARAMETER The specified receiverstate is invalid All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 37 of 63 TEWS amp TECHNOLOGIES 4 1 3 9 lOCTL_TDRV009_CLEAR_RX_BUFFER This TDRVOO9 control function clears the internal receive buffer of the corresponding channel If a ringbuffer was registered earlier the function will return with an error Otherwise the internal receive buffer is cleared The receiver is stopped for the duration of the clearing process No additional parameter is needed for this call Example include tdrv009 h HANDLE hDevice BOOLEAN success
32. definitions TDRV009 SW 65 1 0 2 pdf This document example tdrv009exa c Example application Release txt Release information ChangeLog txt Release history 2 1 Software Installation 2 1 1 Windows 2000 XP This section describes how to install the TDRVO09 Device Driver on a Windows 2000 XP operating system After installing the TDRV009 module s 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 2 In the following dialog box choose Search for a suitable driver for my device Click Next button to continue 3 In Drive A insert the TDRV009 driver disk select Disk Drive in the dialog box Click Next button to continue 4 Now the driver wizard should find a suitable device driver on the diskette Click Next button to continue 5 Complete the upgrade device driver and click Finish to take all the changes effect 6 After successful installation the TDRVO0O09 device driver will start immediately and create devices TDRV009_1 TDRVO009_2 for all recognized TDRVO009 channels a Repeat the steps above for each single channel device created by the busdriver 2 1 2 Confirming Windows 2000 XP Installation To confirm that the driver has been properly loaded in Windows 2000 XP perform the following steps 1 From Windows 2000 XP open the Contr
33. dware handshaking No additional parameter is needed for this call Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRVOO09_RTS_CLEAR control code NULL 0 NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_ACCESS_ DENIED The channel is in handshake mode so this function is not allowed All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 59 of 63 TEWS amp TECHNOLOGIES 4 1 3 22 IOCTL_TDRV009 CTS GET This TDRVO0O9 control function returns the current state of the CTS handshake signal line of the specific channel The parameter oOutBuffer passes a pointer to the user buffer unsigned long to the device driver Depending on the state of CTS either 0 inactive or 1 active is returned The p ntBuffer parameter is not used for this function Example include tdrv009 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumBytes unsigned long CtsState success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_CTS_GET control code NULL 0 amp CtsState sizeof unsigned long amp NumBytes number of bytes transferred NULL i if success printf CTS ld n
34. e operation s output data nOutBufferSize Specifies the size in bytes of the buffer pointed to by lpOutBuffer lpBytesReturned Pointer to a variable that receives the size in bytes of the data stored into the buffer pointed to by lpOutBuffer A valid pointer is required lpOverlapped Pointer to an Overlapped structure This value must be set to NULL no overlapped I O To use these TDRV009 specific control codes the header file tdrv009 h must be included 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 Please note that the TDRVOO09 device driver returns always standard Win32 error codes on failure Please refer to the Windows Platform SDK Documentation for a detailed description of returned error codes See Also Win32 documentation DeviceloControl TDRV009 SW 65 Windows 2000 XP Device Driver Page 11 of 63 TEWS amp TECHNOLOGIES 4 1 3 1 lOCTL_TDRV009 READ This TDRVOO9 control function reads a data frame from the internal receive buffer A pointer to the callers receive buffer TDRVOO9_RX_BUFFER is passed by the parameters p nBuffer and JoOutBuffer to the driver This control function returns immediately even if there is no data currently available The caller has to verify the structure member Valid to determine if the buffer contains data All structure members are declared as ULONG
35. eeeeaeaeaeaeees 38 4 1 3 10 IOCTL_TDRV009 SET EXT STALL 39 4 1 3 11 IOCTL_TDRV009 SCC REG WRITE nenna 40 4 1 3 12 lIOCTL_TDRV009 SCC REG READ nnn 42 4 1 3 13 lIOCTL_TDRV009 GLOB REG_WRITE ccc ccc ccececeesesesceeeeeeeeeeeeeeaeeeeeaeaeaeaes 44 4 1 3 14 lIOCTL_TDRV009 GLOB_REG_READ i ccccccccccesesesssesesesesssssesssessrsssssserersreees 46 4 1 3 15 IOCTL_TDRV009 EEPROM WRITE 48 4 1 3 16 IOCTL_TDRV009_EEPROM_ READ 2 00 0 cccceccscsesesesescssscsesescsssssssssersssssserssereees 50 4 1 3 17 IOCTL_TDRV009_ WATTEORINTERRURT 52 4 1 3 18 lIOCTL_TDRV009 EVENT REOGISTER 54 4 1 3 19 IOCTL_TDRVO09 EVENT UNREGISTER 2 0 0 0 cccccccescsesesesesssssssesssesssesesereseeeees 56 4 1 3 20 IOCTL_TDRV009 RTS GET 58 4 1 3 21 IOCTL_TDRV009 RTS CLEAR nenna 59 4 1 3 22 IOCTL_TDRV009 CTS GET 60 4 1 3 23 IOCTL_TDRV009 DIR GET 61 4 1 3 24 lIOCTL_TDRV009 DIR CLEAR nenene nnn 62 4 1 3 25 IOCTL_TDRV009 DSR GET 63 TDRV009 SW 65 Windows 2000 XP Device Driver Page 3 of 63 TEWS amp TECHNOLOGIES 1 Introduction The TDRV009 SW 65 Windows WDM Windows Driver Model device driver is a kernel mode driver which allows the operation of the TPMC863 product family on an Intel or Intel compatible x86 Windows 2000 Windows XP Windows XP embedded operating system The standard file and device I O functions CreateFile CloseHandle and DeviceloControl provide the basic interface for opening and closing a resource handle an
36. elative to the beginning of the register set The parameter oOutBuffer passes a pointer to the configuration buffer TDRVO09_ADDR_STRUCT to the device driver The p nBuffer parameter is not used for this function typedef struct unsigned long Offset unsigned long Value TDRVOO9_ADDR_STRUCT Offset This parameter specifies a byte offset into the communication controller s register space Please refer to the hardware user manual for further information Value This parameter returns the 32bit word from the communication controller s register space Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_ADDR_STRUCT AddrBuf Read a 32bit value Version Register Wi AddrBuf Offset 0x00F0 success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_GLOB_REG_READ control code NULL 0 AddrBuf output buffer sizeof TDRV009_ADDR_STRUCT amp NumBytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 46 of 63 TEWS amp TECHNOLOGIES if success Process DevicelIoControl error else printf Value 0x 1X n AddrBuf Value Error Codes ERROR_INVALID_USER_BUFFER The size of the input buffer is too small ERROR_INVALID_ PARAMETER The specified offset is invalid too large All other returned error codes are system error conditions TDRV009 SW 65 W
37. herwise false UCHAR GetNewBuffer TDRVO09_RINGBUFFER pRingBuffer ULONG length returns a pointer to a buffer containing new data The get position is set to the next entry the number of valid bytes is returned in ength TDRV009 SW 65 Windows 2000 XP Device Driver Page 33 of 63 TEWS amp TECHNOLOGIES Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes ULONG BufferSize PacketSize TotalSize TDRVO009_RINGBUFFER pRingBuffer OVERLAPPED Overlapped init Overlapped structure Overlapped Offset D Overlapped hEvent 0 allocate and init ringbuffer BufferSize 8000 PacketSize 120 TotalSize CALCULATE_RINGBUFFER_SIZE BufferSize PacketSize pRingBuffer TDRVO09_RINGBUFFER malloc TotalSize memset pRingBuffer 0 TotalSize pRingBuffer gt Header BufferSize BufferSize pRingBuffer gt Header PacketSize PacketSize success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRVO009_RINGBUF_REGISTER control code pRingBuffer input buffer TotalSize pRingBuffer output buffer TotalSize amp NumBytes number of bytes transferred amp Overlapped i if success Process DeviceloControl error and free allocated memory TDRV009 SW 65 Windows 2000 XP Device Driver Page 34 of 63 TEWS amp TECHNOLOGIES
38. indows 2000 XP Device Driver Page 47 of 63 TEWS amp TECHNOLOGIES 4 1 3 15 IOCTL_TDRV009_EEPROM_WRITE This TDRVO009 control function writes one 16bit word into the onboard EEPROM The first part of the EEPROM is reserved for factory usage write accesses to this area will result in an error The parameter o nBuffer passes a pointer to the user buffer TDRV009_EEPROM_BUFFER to the device driver A verification of the written data is not performed The oOutBuffer parameter is not used for this function typedef struct ULONG Offset USHORT Value TDRVO09_EEPROM_BUFFER Offset This parameter specifies a 16bit word offset into the EEPROM Following offsets are available Offset Access 00h GEN R 60h 7Fh R W Value This parameter specifies the 16bit word to be written into the EEPROM at the given offset Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_EEPROM_ BUFFER RepromBuf write a 16bit value into the EEPROM offset 0x61 EepromBuf Offset 0x61 EepromBuf Value 0x1234 success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRVO09_EEPROM WRITE control code amp EepromBuf input buffer buffer sizeof TDRVO009_EEPROM_BUFFER NULL 0 amp NumBytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 48 of 63
39. is parameter describes the transceiver transceivers Possible values are Value TDRV009_TRNSCVR_NOT_USED TDRV009_TRNSCVR_RS530A TDRV009_TRNSCVR_RS530 TDRV009_TRNSCVR_X21 TDRV009_TRNSCVR_V35 TDRVO009_TRNSCVR_RS449 TDRV009_TRNSCVR_V36 TDRV009_TRNSCVR_RS232 TDRV009_TRNSCVR_V28 TDRV009_TRNSCVR_NO_CABLE Oversampling TEWS amp TECHNOLOGIES mode of the programmable multi protocol Description Default V 11 EIA 530A V 11 V 10 EIA 530 V 11 also suitable for RS422 X 21 V 11 V 35 V 35 V 28 EIA 449 V 11 V 36 V 11 EIA 232 V 28 V 28 V 28 High impedance This parameter enables or disables 16times oversampling used for asynchronous communication For communication with standard UARTs it is recommended to enable this feature Valid values are Value Description TDRV009_ DISABLED The 16 times oversampling is not used TDRV009_ENABLED The 16 times oversampling is used BrgSource This parameter specifies the frequency source used as input to the BRG Baud Rate Generator Valid values are Value TDRV009_BRGSRC_XTAL1 TDRV009_BRGSRC_XTAL2 TDRV009_BRGSRC_XTAL3 TDRV009_BRGSRC_RXCEXTERN TDRV009_BRGSRC_TXCEXTERN TxClkSource Description XTAL1 oscillator is used for BRG input XTAL2 oscillator is used for BRG input XTAL8 oscillator is used for BRG input External clock at RxC input used for BRG input External clock at TxC input used for BRG input This parameter specifies the frequency source used
40. ntrol code NULL input buffer 0 pRxBuf output buffer BufferSize amp NumBytes number of bytes transferred NULL i if success Process data if pRxBuf gt Valid amp TDRVO09_RXBUF_DATAVALID amp amp pRxBuf gt NumberOfBytes gt 0 printf Received d valid bytes n pRxBuf gt NumberOfBytes else Process DeviceloControl error free pRxBuf Error Codes ERROR_INVALID_ USER_BUFFER The size of the output buffer is invalid ERROR_INSUFFICIENT_BUFFER The size of the supplied buffer is too small for the available amount of data ERROR_ACCESS_DENIED A ringbuffer is registered no read operation possible All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 13 of 63 TEWS amp TECHNOLOGIES 4 1 3 2 IlOCTL_TDRV009_ WRITE This TDRVOO9 control function sends a buffer of data A pointer to the callers data buffer TDRV009_TX_BUFFER must be passed by both parameters p nBuffer and pOutBuffer to the driver It is necessary to supply the pointer to the data buffer on both parameters because of the memory mapping used by Windows2000 XP The transfer of large physically scattered buffers bigger than one memory page is supported typedef struct ULONG NumberOfBytes UCHAR pData 1 _ dynamically expandable TDRV009_TX_BUFFER NumberOfBytes Number of bytes that should be written to the corresponding channel pDat
41. ocess DevicelIoControl error Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is invalid ERROR_INVALID PARAMETER The specified parameters are invalid ERROR_ACCESS_DENIED No event is registered for this event type All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 57 of 63 TEWS amp TECHNOLOGIES 4 1 3 20 IOCTL_TDRV009 RTS SET This TDRVO0O9 control function asserts the RTS handshake signal line of the specific channel This function is not available if the channel is configured for hardware handshaking No additional parameter is needed for this call Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV009_RTS_SET control code NULL 0 NULL 0 amp NumBytes number of bytes transferred NULL i if success Process DeviceloControl error Error Codes ERROR_ACCESS_ DENIED The channel is in handshake mode so this function is not allowed All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 58 of 63 TEWS amp TECHNOLOGIES 4 1 3 21 IOCTL_TDRV009 RTS_CLEAR This TDRV009 control function de asserts the RTS handshake signal line of the specific channel This function is not available if the channel is configured for har
42. ol Panel from My Computer 2 Click the System icon and choose the Hardware tab and then click the Device Manager button 3 Click the in front of Other Devices The driver TEWS TECHNOLOGIES TDRV009 lt ModuleName gt should appear TDRVO009 SW 65 Windows 2000 XP Device Driver Page 5 of 63 TEWS amp TECHNOLOGIES 3 Driver Configuration 3 1 Receive Buffer Configuration To configure the size of the internal receive buffer adjust the following registry keys according to the description in the corresponding manual section HKEY_LOCAL_MACHINE System CurrentControlSet Services tdrv009 RxBufferSize HKEY_LOCAL_MACHINE System CurrentControlSet Services tdrv009 RxPacketSize Default values are RxBufferSize RxPacketSize 20000 256 If the default values are not suitable the configuration can be changed by modifying the registry for instance with regedt32 The changes take effect after a new start of the driver TDRV009 SW 65 Windows 2000 XP Device Driver Page 6 of 63 TEWS amp TECHNOLOGIES 4 Device Driver Programming The TDRV009 SW 65 Windows WDM device driver is a kernel mode device driver using Direct I O 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 Visu
43. r for the corresponding buffer Valid This OR ed value describes whether or not the corresponding data buffer contains valid data Additionally the FrameEnd status is returned This value consists of the following OR ed values Value Description TDRV009_ RXBUF_DATAVALID The data buffer contains valid data TDRV009_ RXBUF_FRAMEEND The data buffer contains a FrameEnd mark typedef struct RINGBUFFER_HEADER Header UCHAR DataSection 40 dynamically expandable TDRVO0O9_RINGBUFFER Header Header information for actual ringbuffer see description of RINGBUFFER_HEADER above DataSection This value points to a user defined section for entries and data buffers The size is dynamically expandable and must be provided inside the header TDRV009 SW 65 Windows 2000 XP Device Driver Page 31 of 63 TEWS amp TECHNOLOGIES Ringbuffer Concept The used ringbuffer is highly configurable by the user Not only the total size but also the typical size of one packet can be specified One big problem for DMA drivers is that the hardware performing the direct memory access needs physically consistent memory The user allocates a large buffer which is virtually consistent but physically scattered The driver has to split it into physically consistent memory parts taking the desired typical packet size into mind too Each single buffer is accessible via a corresponding entry that holds specific information like offset size and the num
44. rns the value in an application supplied buffer TDRV009_OPERATION_MODE_STRUCT The parameter pOutBuffer passes a pointer to this buffer to the device driver The o nBuffer parameter is not used for this function typedef struct TDRV009_COMM_TYPE TDRV009_TRANSCEIVER_MODE TDRV009_ENABLE_DISABLE TDRV009_ BRGSOURCE TDRV009_TXCSOURCE unsigned long TDRV009_RXCSOURCE TDRV009_CLKMULTIPLIER unsigned long unsigned char unsigned char TDRV009_ PARITY int int TDRVO0O9_ENABLE_DISABLE char TDRV009_ENABLE_DISABLE TDRVO009_CRC TDRVOO9_OPERATION_MODE_STRUCT CommType CommType TransceiverMode Oversampling BrgSource TxClkSource TxClkOutput RxClkSource ClockMultiplier Baudrate ClockInversion Encoding Parity Stopbits Databits UseTermChar TermChar HwHs Cre This parameter describes the general communication type for the specific channel Possible values are Value TDRV009_COMMTYPE_ASYNC TDRV009_COMMTYPE_HDLC_ADDRO TDRV009_COMMTYPE_HDLC_TRANSP TDRV009 SW 65 Windows 2000 XP Device Driver Description Asynchronous communication Standard HDLC communication without address recognition Used for synchronous communication Extended Transparent mode No protocol processing channel works as simple bit collector Page 23 of 63 TransceiverMode This parameter describes the transceiver transceivers Possible values are Value TDRV009_TRNSCVR NOT USGEn TDRV009_TRNSCVR _RS530A TDRV00
45. s 1 INTRODUC TION BEE 4 2 INSTALLATION H 5 2 1 Software E ET O EE 5 2 1 1 Windows 2000 Nb 5 2 1 2 Confirming Windows 2000 XP Installation 0 cccececeeeeeeeeeeeeeeeeeeeeeeseeeeeeeaeeeseaeeeeeeseeeeen 5 3 DRIVER CONFIGURATION sicacesecadectecssiaateassdapttatedesicueeiseisensassaumadasadaneteeteanacestanigiees 6 3 1 Receive Buffer Configuration ccccssccccesseeceeeseeneeeeseeeseenseaeeeenneaessenenaeseensnaeseesseanseesseaeseenenaes 6 4 DEVICE DRIVER PROGRAMMING ccccsssseeecccesseeeeecenseeeeecnseeeseenseeeeaenseeeees 7 4 1 Files and V O Ode Vu EE 7 411 Opening a Deiere ed EEN 7 ECH e ECHT 9 4 1 3 Device I O Control Functions 0 0 0 cccccccccccccccecececeeceeeceeeeceeceeeseeesececeseseceseseseseseseseseeeess 10 4 1 3 1 IOCTL_TDRV0O09 READ ANAN NNA 12 4 t32 IOCTL TDRV009 WRITE cciicssecnsiastecenvaststenntensvennvanstanalsnadcstrthersnaianatcrnheietennl ieieavane 14 4 1 3 3 IOCTL_TDRV009_ SET OPERATION MODE 16 4 1 3 4 lIOCTL_TDRV009_ GET OPERATION MODE cccccccecesesesesesesesesessessesssesssereees 23 4 1 3 5 IOCTL_TDRV009 SET BAUDRATE nnn 29 4 1 3 6 lIOCTL_TDRV009_RINGBUF_ REOGISTER nansossssnnnnnnssnnerennnnnssrnrnnnnsnssnrirnnnnssnsrnne 30 4 1 3 7 IOCTL_TDRV009_RINGBUF_UNREGISTER 1 0 0 0 cccccecccecececeesesseeeeeeeeeesserseaees 36 4 1 3 8 IOCTL_TDRV009 SET RECEIWER SIATE 37 4 1 3 9 IOCTL_TDRV009 CLEAR _RX_BUFFER u cc ccc ccccececscseseesececeeeeeeeeee
46. set This parameter specifies a byte offset into the communication controller s register space Please refer to the hardware user manual for further information Value This 32bit word will be written to the communication controller s register space Modifying register contents may result in communication problems system crash or other unexpected behavior Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRVO009_ADDR_STRUCT AddrBuf Write a 32bit value FIFO Control Register 4 Wi AddrBuf Offset 0x0034 AddrBuf Value Oxffffffff success DevicelIoControl hDevice TDRVOO9 handle IOCTL_TDRV009_GLOB_REG_WRITE control code amp AddrBuf input buffer sizeof TDRVO09_ADDR_STRUCT NULL 0 amp NumBytes number of bytes transferred NULL 1 TDRV009 SW 65 Windows 2000 XP Device Driver Page 44 of 63 TEWS amp TECHNOLOGIES if success Process DeviceloControl error Error Codes ERROR_INVALID_USER_BUFFER _ The size of the input buffer is too small ERROR_INVALID_ PARAMETER The specified offset is invalid too large All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 45 of 63 TEWS amp TECHNOLOGIES 4 1 3 14 IOCTL_TDRV009 GLOB_REG READ This TDRVOO9 control function reads one 32bit word from the communication controllers register space r
47. st TDRV009 channel devices must be always opened OPEN_EXISTING TDRV009 SW 65 Windows 2000 XP Device Driver Page 7 of 63 TEWS amp TECHNOLOGIES dwFlagsAndAttributes Specifies the file attributes and flags for the file This value must be set to 0 no overlapped I O hTemplateFile This value must be NULL for TDRVO09 devices Return Value If the function succeeds the return value is an open handle to the specified TDRV009 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 TDRV009_1 GENERIC_READ GENERIC_WRITE 0 NULL no security attrs OPEN_EXISTING TDRV009 device always open existing 0 no overlapped I O NULL i if hDevice INVALID HANDLE VALUE ErrorHandler Could not open device process error See Also CloseHandle Win32 documentation CreateFile TDRV009 SW 65 Windows 2000 XP Device Driver Page 8 of 63 TEWS amp TECHNOLOGIES 4 1 2 Closing a Device The CloseHandle function closes an open TDRVO009 handle BOOL CloseHandle HANDLE hDevice Parameters hDevice Identifies an open TDRVOO9 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 GetLast
48. to be generated by the Baud Rate Generator BRG which can be used as clock input signal The value is derived from the selected clocksource Please note that only specific values depending on the selected oscillator are valid This frequency is internally multiplied by 16 if oversampling shall be used ClockInversion This parameter specifies the inversion of the transmit and or the receive clock This value can be binary OR ed Possible values are Value Description TDRVO009_CLKINV_NONE TDRVO09_CLKINV_TXC TDRVO09_CLKINV_RXC no clock inversion transmit clock is inverted receive clock is inverted Encoding This parameter specifies the data encoding used for communication Valid values are Value Description TDRV009_ ENC_NRZ NRZ data encoding TDRVO09_ENC_NRZI NRZI data encoding TDRVO009_ ENC_FMO FMO data encoding TDRV009_ENC_FM1 TDRV009_ENC_MANCHESTER FM1 data encoding Manchester data encoding TDRV009 SW 65 Windows 2000 XP Device Driver Page 18 of 63 TEWS amp TECHNOLOGIES Parity This parameter specifies the parity bit generation used for asynchronous communication Valid values are Value Description TDRV009_PAR_DISABLED No parity generation is used TDRVO009_PAR_EVEN EVEN parity bit TDRV009_PAR_ODD ODD parity bit TDRV009_PAR_SPACE SPACE parity bit always insert 0 TDRV009_PAR_MARK MARK parity bit always insert 1 Stopbits This parameter specifies the number of stop bits to use for asynchronous
49. vent must be created by a call to CreateEvent type This parameter specifies the event type The only event type possible is TDRV009_RX_EVENT refer to tdrv009 h for definition Keep in mind that signaling an event for each received packet means additional overhead which should be omitted in environments with high packet rates Example include tdrv009 h HANDLE hDevice BOOLEAN success ULONG NumBytes TDRV009_EVENT_STRUCT EventStruct init event structure EventStruct type TP862_RX_EVENT EventStruct hEvent CreateEvent NULL lpEventAttributes TRUE bManualReset FALSE bInitialState N ULL lpName L success DeviceloControl hDevice TDRVOO9 handle IOCTL_TDRV009_EVENT_REGISTER control code TDRV009 SW 65 Windows 2000 XP Device Driver Page 54 of 63 TEWS amp TECHNOLOGIES amp EventStruct input buffer buffer sizeof TDRVO09_EVENT_STRUCT NULL 0 amp N NumBytes number of bytes transferred ULL 1 if success Process DevicelIoControl error Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is invalid ERROR_INVALID PARAMETER The specified parameters are invalid ERROR_ACCESS_DENIED An event is already registered for this event type All other returned error codes are system error conditions
50. x42 success DevicelIoControl hDevice TDRV009 handle IOCTL_TDRV009_SCC_REG_WRITE control code amp AddrBuf input buffer sizeof TDRVO09_ADDR_STRUCT NULL 0 amp NumBytes number of bytes transferred NULL 1 TDRV009 SW 65 Windows 2000 XP Device Driver Page 40 of 63 TEWS amp TECHNOLOGIES if success Process DevicelIoControl error Error Codes ERROR_INVALID_USER_BUFFER _ The size of the input buffer is too small ERROR_INVALID_ PARAMETER The specified offset is invalid too large All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 41 of 63 TEWS amp TECHNOLOGIES 4 1 3 12 IOCTL_TDRV009 SCC REG READ This TDRVOO9 control function reads one 32bit word from the communication controllers register space relative to the beginning of the specific channel s SCC register set The parameter oOutBuffer passes a pointer to the configuration buffer TDRVO09_ADDR_STRUCT to the device driver The lointBuffer parameter is not used for this function typedef struct unsigned long Offset unsigned ong Value TDRVO09_ADDR_STRUCT Offset This parameter specifies a byte offset into the communication controller s channel SCC register space Please refer to the hardware user manual for further information Value This parameter returns the 32bit word from the communication controller s channel SCC register space Example
51. ytes number of bytes transferred NULL TDRV009 SW 65 Windows 2000 XP Device Driver Page 50 of 63 TEWS amp TECHNOLOGIES if success Process DevicelIoControl error else printf Value 0x X n EepromBuf Value Error Codes ERROR_INVALID_USER_BUFFER The size of the buffer is invalid ERROR_INVALID_PARAMETER The specified offset address is invalid or read only All other returned error codes are system error conditions TDRV009 SW 65 Windows 2000 XP Device Driver Page 51 of 63 TEWS amp TECHNOLOGIES 4 1 3 17 IOCTL_TDRV009_WAITFORINTERRUPT This TDRVOO9 control function waits until a specified SCC interrupt or the timeout occurs The parameters o nBuffer and pOutBuffer pass a pointer to the user buffer TDRVO09_WAIT_STRUCT to the device driver typedef struct unsigned long Interrupts int Timeout TDRVO09_WAIT_STRUCT Interrupts This parameter specifies specific interrupt bits to wait for If one interrupt occurs the value is returned in this parameter Please refer to the hardware user manual for further information on the possible interrupt bits Timeout This parameter specifies the time in seconds to wait for an interrupt If O is specified the function will block indefinitely Example include tdrv009 h HANDLE hDevice BOOLEAN SUCCESS ULONG NumBytes TDRVO09_WATIT_STRUCT WaitStruct Wait at least 5 seconds for a
Download Pdf Manuals
Related Search
Related Contents
mode d`emploi du camescope Sony HVR View User`s Manual South Shore Furniture 5350038 Instructions / Assembly DNA-AO-308-350 High Current Analog Output Layer User Manual ダウンロード FR - Hilti PUPIL PAGES Sennheiser E835 Professional Microphone - 59506-036_JTS_US-8001D-DB-US-8002D Tronçonneuse à chaine diamantée Copyright © All rights reserved.
Failed to retrieve file