Tews Technologies TDRV003-SW-65 Manual

Windows device driver

Advertisement

Quick Links

The Embedded I/O Company
TDRV003-SW-65
Windows Device Driver
16(8) Digital I/O
Version 2.0.x
User Manual
Issue 2.0.0
June 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

Advertisement

Table of Contents
loading

Summary of Contents for Tews Technologies TDRV003-SW-65

  • Page 1 The Embedded I/O Company TDRV003-SW-65 Windows Device Driver 16(8) Digital I/O Version 2.0.x User Manual Issue 2.0.0 June 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...
  • Page 2 TPMC671 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. 2005-2011 by TEWS TECHNOLOGIES GmbH...
  • Page 3: Table Of Contents

    IOCTL_TDRV003_READ ...................41 5.1.3.2 IOCTL_TDRV003_WRITE ..................42 5.1.3.3 IOCTL_TDRV003_OUTPUTGET................44 5.1.3.4 IOCTL_TDRV003_WRITEMASK ................46 5.1.3.5 IOCTL_TDRV003_OUTPUTSETBITS ...............48 5.1.3.6 IOCTL_TDRV003_OUTPUTCLEARBITS ..............50 5.1.3.7 IOCTL_TDRV003_WAIT_EVENT ................52 5.1.3.8 IOCTL_TDRV003_DEBENABLE ................54 5.1.3.9 IOCTL_TDRV003_DEBDISABLE ................56 5.1.3.10 IOCTL_TDRV003_WDENABLE................57 5.1.3.11 IOCTL_TDRV003_WDDISABLE................58 5.1.3.12 IOCTL_TDRV003_WDRESET .................59 TDRV003-SW-65 – Windows Device Driver Page 3 of 59...
  • Page 4: Introduction

    1 Introduction The TDRV003-SW-65 Windows device driver is a kernel mode driver which allows the operation of supported hardware modules 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)
  • Page 5: Installation

    2 Installation Following files are located in directory TDRV003-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...
  • Page 6: Windows 7

    2.1.2 Windows 7 This section describes how to install the TDRV003-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 32bit or 64bit systems. This will install all required driver files using an installation wizard.
  • Page 7: Driver Configuration

    If the default values are not suitable the configuration can be changed by modifying the registry, for instance with regedt32. To change the number of queue entries the following value must be modified. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\tdrv003\Parameters\NumReqEntries Valid values are in range between 1 and 100. TDRV003-SW-65 – Windows Device Driver Page 7 of 59...
  • Page 8: Api Documentation

    This parameter points to a null-terminated string that specifies the name of the device. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; ** open file descriptor to device hdl = tdrv003Open(“\\\\.\\TDRV003_1” ); if (hdl == NULL) /* handle open error */ TDRV003-SW-65 – Windows Device Driver Page 8 of 59...
  • Page 9 RETURNS A device handle, or NULL if the function fails. To get extended error information, call GetLastError. ERROR CODES All error codes are standard error codes set by the I/O system. TDRV003-SW-65 – Windows Device Driver Page 9 of 59...
  • Page 10: Tdrv003Close

    This value specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; ** close file descriptor to device result = tdrv003Close( hdl ); if (result != TDRV003_OK) /* handle close error */ TDRV003-SW-65 – Windows Device Driver Page 10 of 59...
  • Page 11 RETURNS On success TDRV003_OK, or an appropriate error code. ERROR CODES All error codes are standard error codes set by the I/O system. TDRV003-SW-65 – Windows Device Driver Page 11 of 59...
  • Page 12: Device Access Functions

    This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pInputBuf This argument points to a buffer where the value will be returned. TDRV003-SW-65 – Windows Device Driver Page 12 of 59...
  • Page 13 /* handle error */ RETURNS On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003-SW-65 – Windows Device Driver Page 13 of 59...
  • Page 14: Tdrv003Outputwrite

    2 and so on. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // set OUTPUT1 and OUTPUT16 and clear all other result = tdrv003OutputWrite(hdl, 0x8001); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 14 of 59...
  • Page 15 On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003_ERR_IO The output register is locked by a watchdog failure. Execute the function tdrv003WatchdogReset to reset the watchdog error. TDRV003-SW-65 – Windows Device Driver Page 15 of 59...
  • Page 16: Tdrv003Outputread

    This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pOutputBuf This argument points to a buffer where the value will be returned. TDRV003-SW-65 – Windows Device Driver Page 16 of 59...
  • Page 17 On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003_ERR_IO The output register is locked by a watchdog failure. Execute the function tdrv003WatchdogReset to reset the watchdog error. TDRV003-SW-65 – Windows Device Driver Page 17 of 59...
  • Page 18: Tdrv003Outputwritemask

    Only those bits in OutputValue for which the corresponding bit position in this mask is set to 1 will be changed in the output port. TDRV003-SW-65 – Windows Device Driver Page 18 of 59...
  • Page 19 On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003_ERR_IO The output register is locked by a watchdog failure. Execute the function tdrv003WatchdogReset to reset the watchdog error. TDRV003-SW-65 – Windows Device Driver Page 19 of 59...
  • Page 20: Tdrv003Outputsetbits

    EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // set OUTPUT1 and OUTPUT16 to active state result = tdrv003OutputSetBits(hdl, (1<<15) | (1<<0)); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 20 of 59...
  • Page 21 On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003_ERR_IO The output register is locked by a watchdog failure. Execute the function tdrv003WatchdogReset to reset the watchdog error. TDRV003-SW-65 – Windows Device Driver Page 21 of 59...
  • Page 22: Tdrv003Outputclearbits

    EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // clear OUTPUT1 and OUTPUT16 result = tdrv003OutputSetBits(hdl, (1<<15) | (1<<0)); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 22 of 59...
  • Page 23 On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003_ERR_IO The output register is locked by a watchdog failure. Execute the function tdrv003WatchdogReset to reset the watchdog error. TDRV003-SW-65 – Windows Device Driver Page 23 of 59...
  • Page 24: Tdrv003Eventwait

    Specifies the amount of time (in seconds) the caller is willing to wait for the specified event to occur. A value of 0 means wait indefinitely. TDRV003-SW-65 – Windows Device Driver Page 24 of 59...
  • Page 25 No more free entries in the drivers queue to handle concurrent event-controlled read requests. Increase the queue size (see also 3.1). TDRV003_ERR_TIMEOUT The requested event does not occur within the specified time (timeout). TDRV003-SW-65 – Windows Device Driver Page 25 of 59...
  • Page 26: Tdrv003Debouncerenable

    EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // Enable the debouncer with a debounce time of 1ms result = tdrv003DebouncerEnable(hdl, 147); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 26 of 59...
  • Page 27 RETURNS On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003-SW-65 – Windows Device Driver Page 27 of 59...
  • Page 28: Tdrv003Debouncerdisable

    This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // Disable the debouncer circuit result = tdrv003DebouncerDisable(hdl); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 28 of 59...
  • Page 29 RETURNS On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003-SW-65 – Windows Device Driver Page 29 of 59...
  • Page 30: Tdrv003Watchdogenable

    This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // Enable output watchdog result = tdrv003WatchdogEnable(hdl); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 30 of 59...
  • Page 31 RETURNS On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003-SW-65 – Windows Device Driver Page 31 of 59...
  • Page 32: Tdrv003Watchdogdisable

    This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // Disable output watchdog result = tdrv003WatchdogDisable(hdl); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 32 of 59...
  • Page 33 RETURNS On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003-SW-65 – Windows Device Driver Page 33 of 59...
  • Page 34: Tdrv003Watchdogreset

    This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv003api.h” TDRV003_HANDLE hdl; TDRV003_STATUS result; // Reset watchdog error result = tdrv003WatchdogReset (hdl); if (result != TDRV003_OK) /* handle error */ TDRV003-SW-65 – Windows Device Driver Page 34 of 59...
  • Page 35 RETURNS On success, TDRV003_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES TDRV003_ERR_INVALID_HANDLE The specified TDRV003_HANDLE is invalid. TDRV003-SW-65 – Windows Device Driver Page 35 of 59...
  • Page 36: Device Driver Programming

    5 Device Driver Programming The TDRV003-SW-65 Windows device driver is a kernel mode device driver. The standard file and device (I/O) functions (CreateFile, CloseHandle, and DeviceIoControl) provide the basic interface for opening and closing a resource handle and for performing device I/O control operations.
  • Page 37 NULL, // no security attrs OPEN_EXISTING, // TDRV003 device always open existing NULL if (hDevice == INVALID_HANDLE_VALUE) ErrorHandler("Could not open device" ); // process error SEE ALSO CloseHandle(), Win32 documentation CreateFile() TDRV003-SW-65 – Windows Device Driver Page 37 of 59...
  • Page 38: Closing A Tdrv003 Device

    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 () TDRV003-SW-65 – Windows Device Driver Page 38 of 59...
  • Page 39: Tdrv003 Device I/O Control Functions

    IOCTL_TDRV003_WDRESET Reset output watchdog See below for more detailed information on each control code. To use these TDRV003 specific control codes the header file tdrv003.h must be included in the application TDRV003-SW-65 – Windows Device Driver Page 39 of 59...
  • Page 40 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 DeviceIoControl() TDRV003-SW-65 – Windows Device Driver Page 40 of 59...
  • Page 41: Ioctl_Tdrv003_Read

    ErrorHandler ("Device I/O control error” ); // process error ERROR CODES ERROR_INVALID_PARAMETER This error is returned if the size of the read buffer is too small. All other returned error codes are system error conditions. TDRV003-SW-65 – Windows Device Driver Page 41 of 59...
  • Page 42: Ioctl_Tdrv003_Write

    PortData = 0x1234; success = DeviceIoControl ( hDevice, IOCTL_TDRV003_WRITE, &PortData, sizeof(PortData), NULL, &NumBytes, NULL if( success ) printf("\nOutput port successful written\n"); else ErrorHandler ( "Device I/O control error” ); // process error TDRV003-SW-65 – Windows Device Driver Page 42 of 59...
  • Page 43 The output register is locked by a watchdog failure. Execute the control function IOCTL_TDRV003_WDRESET to reset the watchdog error. All other returned error codes are system error conditions. SEE ALSO Win32 documentation DeviceIoControl(), TDRV003 Hardware User Manual TDRV003-SW-65 – Windows Device Driver Page 43 of 59...
  • Page 44: Ioctl_Tdrv003_Outputget

    = DeviceIoControl ( hDevice, IOCTL_TDRV003_OUTPUTGET, NULL, &PortData, sizeof(PortData), &NumBytes, NULL if( success ) printf ("Read output port successful (0x%x)\n", PortData); else ErrorHandler ("Device I/O control error” ); // process error TDRV003-SW-65 – Windows Device Driver Page 44 of 59...
  • Page 45 This error is returned if the size of the read buffer is too small. ERROR_IO_DEVICE The output register is locked by a watchdog failure. Execute the control function IOCTL_TDRV003_WDRESET to reset the watchdog error. All other returned error codes are system error conditions. TDRV003-SW-65 – Windows Device Driver Page 45 of 59...
  • Page 46: Ioctl_Tdrv003_Writemask

    ULONG NumBytes; TDRV003_WRITEBUF WriteBuf; // set OUTPUT1 to 0 and OUTPUT16 to 1 WriteBuf.mask = 0x8001; WriteBuf.value = 0x8000; success = DeviceIoControl ( hDevice, IOCTL_TDRV003_WRITEMASK, &WriteBuf, sizeof(WriteBuf), NULL, &NumBytes, NULL TDRV003-SW-65 – Windows Device Driver Page 46 of 59...
  • Page 47 The output register is locked by a watchdog failure. Execute the control function IOCTL_TDRV003_WDRESET to reset the watchdog error. All other returned error codes are system error conditions. SEE ALSO Win32 documentation DeviceIoControl(), TDRV003 Hardware User Manual TDRV003-SW-65 – Windows Device Driver Page 47 of 59...
  • Page 48: Ioctl_Tdrv003_Outputsetbits

    OutputBits = (1<<15) | (1<<1) | (1<<0); success = DeviceIoControl ( hDevice, IOCTL_TDRV003_OUTPUTSETBITS, &OutputBits, sizeof(OutputBits), NULL, &NumBytes, NULL if( success ) printf("\nOutput port successful written\n"); else ErrorHandler ( "Device I/O control error” ); // process error TDRV003-SW-65 – Windows Device Driver Page 48 of 59...
  • Page 49 The output register is locked by a watchdog failure. Execute the control function IOCTL_TDRV003_WDRESET to reset the watchdog error. All other returned error codes are system error conditions. SEE ALSO Win32 documentation DeviceIoControl(), TDRV003 Hardware User Manual TDRV003-SW-65 – Windows Device Driver Page 49 of 59...
  • Page 50: Ioctl_Tdrv003_Outputclearbits

    OutputBits = (1<<15) | (1<<1) | (1<<0); success = DeviceIoControl ( hDevice, IOCTL_TDRV003_OUTPUTCLEARBITS, &OutputBits, sizeof(OutputBits), NULL, &NumBytes, NULL if( success ) printf("\nOutput port successful written\n"); else ErrorHandler ( "Device I/O control error” ); // process error TDRV003-SW-65 – Windows Device Driver Page 50 of 59...
  • Page 51 The output register is locked by a watchdog failure. Execute the control function IOCTL_TDRV003_WDRESET to reset the watchdog error. All other returned error codes are system error conditions. SEE ALSO Win32 documentation DeviceIoControl(), TDRV003 Hardware User Manual TDRV003-SW-65 – Windows Device Driver Page 51 of 59...
  • Page 52: Ioctl_Tdrv003_Wait_Event

    BOOLEAN success; ULONG NumBytes; TDRV003_WAIT_BUFFER WaitBuf; Wait for a high-transition at bit 7 (INPUT 8) WaitBuf.mode = TDRV003_HIGH_TR; WaitBuf.mask = 1<<7; // high-transition at bit 7 WaitBuf.timeout = 10; // seconds TDRV003-SW-65 – Windows Device Driver Page 52 of 59...
  • Page 53 Increase the queue size (see also 3.1). ERROR_SEM_TIMEOUT The requested event does not occur within the specified time (timeout). All other returned error codes are system error conditions. TDRV003-SW-65 – Windows Device Driver Page 53 of 59...
  • Page 54: Ioctl_Tdrv003_Debenable

    DebounceTime = 147; success = DeviceIoControl ( hDevice, IOCTL_TDRV003_DEBENABLE, &DebounceTime, sizeof(DebounceTime), NULL, &NumBytes, NULL if( success ) printf("Enable output watchdog successful\n"); } else ErrorHandler ("Device I/O control error”); // process error TDRV003-SW-65 – Windows Device Driver Page 54 of 59...
  • Page 55 ERROR CODES ERROR_INVALID_PARAMETER This error is returned if the size of the timer value buffer is too small All other returned error codes are system error conditions. TDRV003-SW-65 – Windows Device Driver Page 55 of 59...
  • Page 56: Ioctl_Tdrv003_Debdisable

    = DeviceIoControl ( hDevice, IOCTL_TDRV003_DEBDISABLE, NULL, NULL, &NumBytes, NULL if( success ) printf("Disable debouncer successful\n"); else ErrorHandler ("Device I/O control error”); // process error ERROR CODES No driver specific error codes TDRV003-SW-65 – Windows Device Driver Page 56 of 59...
  • Page 57: Ioctl_Tdrv003_Wdenable

    = DeviceIoControl ( hDevice, IOCTL_TDRV003_WDENABLE, NULL, NULL, &NumBytes, NULL if( success ) printf("Enable output watchdog successful\n"); else ErrorHandler ("Device I/O control error”); // process error ERROR CODES No driver specific error codes TDRV003-SW-65 – Windows Device Driver Page 57 of 59...
  • Page 58: Ioctl_Tdrv003_Wddisable

    = DeviceIoControl ( hDevice, IOCTL_TDRV003_WDDISABLE, NULL, NULL, &NumBytes, NULL if( success ) printf("Disable output watchdog successful\n"); else ErrorHandler ("Device I/O control error”); // process error ERROR CODES No driver specific error codes TDRV003-SW-65 – Windows Device Driver Page 58 of 59...
  • Page 59: Ioctl_Tdrv003_Wdreset

    = DeviceIoControl ( hDevice, IOCTL_TDRV003_WDRESET, NULL, NULL, &NumBytes, NULL if( success ) printf("Reset output watchdog successful\n"); else ErrorHandler ("Device I/O control error”); // process error ERROR CODES No driver specific error codes TDRV003-SW-65 – Windows Device Driver Page 59 of 59...

Table of Contents