Reconfigurable fpga with 16 x 16 bit analog input, 8 x 16 bit analog output and 32 digital i/o (95 pages)
Summary of Contents for Tews Technologies TDRV004-SW-82
Page 1
The Embedded I/O Company TDRV004-SW-82 Linux Device Driver Reconfigurable FPGA Version 2.0.x User Manual Issue 2.0.0 November 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
TCP630 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...
1 Introduction The TDRV004-SW-82 Linux device driver allows the operation of the TDRV004 compatible devices conforming to the Linux I/O system specification. This includes a device-independent basic I/O interface with open(), close(),and ioctl() functions. The TDRV004-SW-82 device driver supports the following features: ...
Example application example/Makefile Example application makefile In order to perform an installation, extract all files of the archive TDRV004-SW-82-SRC.tar.gz to the desired target directory. The command ‘tar -xzvf TDRV004-SW-82-SRC.tar.gz’ will extract the files into the local directory. Login as root and change to the target directory ...
Be sure that the driver isn’t opened by any application program. If opened you will get the response “tdrv004drv: Device or resource busy” and the driver will still remain in the system until you close all opened files and execute modprobe –r again. TDRV004-SW-82 - Linux Device Driver Page 6 of 62...
Valid numbers are in range between 0 and 255. A value of 0 means dynamic number allocation. Example: #define TDRV004_MAJOR Be sure that the desired major number isn’t used by other drivers. Please check /proc/devices to see which numbers are free. TDRV004-SW-82 - Linux Device Driver Page 7 of 62...
This parameter points to a null-terminated string that specifies the name of the device. EXAMPLE #include “tdrv004api.h” TDRV004_HANDLE hdl; ** open file descriptor to device hdl = tdrv004open( “/dev/tdrv004_0” ); if (hdl == NULL) /* handle open error */ TDRV004-SW-82 - Linux Device Driver Page 8 of 62...
Page 9
A device handle, or NULL if the function fails. An error code will be stored in errno. ERROR CODES The error codes are stored in errno. The error code is a standard error code set by the I/O system. TDRV004-SW-82 - Linux Device Driver Page 9 of 62...
This value specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv004api.h” TDRV004_HANDLE hdl; TDRV004_STATUS result; ** close file descriptor to device result = tdrv004Close( hdl ); if (result != TDRV004_OK) /* handle close error */ TDRV004-SW-82 - Linux Device Driver Page 10 of 62...
Page 11
RETURNS On success TDRV004_OK, or an appropriate error code. ERROR CODES TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. Other returned error codes are system error conditions. TDRV004-SW-82 - Linux Device Driver Page 11 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pXsvfContent This argument points to an unsigned char array containing the XSVF data. TDRV004-SW-82 - Linux Device Driver Page 12 of 62...
Page 13
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY The device is already busy with XSVF TDRV004_ERR_INVAL An error occurred during XSVF operation TDRV004-SW-82 - Linux Device Driver Page 13 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pXsvfPos This parameter specifies a pointer to an unsigned int value which receives the current processed XSVF byte. TDRV004-SW-82 - Linux Device Driver Page 14 of 62...
Page 15
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004-SW-82 - Linux Device Driver Page 15 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pXsvfLastCmd This parameter specifies a pointer to an unsigned int value which receives the last executed XSVF command (line number of ASCII SVF file). TDRV004-SW-82 - Linux Device Driver Page 16 of 62...
Page 17
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004-SW-82 - Linux Device Driver Page 17 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. EXAMPLE #include “tdrv004api.h” TDRV004_HANDLE hdl; TDRV004_STATUS result; ** Reconfigure FPGA result = tdrv004Reconfigure( hdl ); if (result != TDRV004_OK) /* handle error */ TDRV004-SW-82 - Linux Device Driver Page 18 of 62...
Page 19
The DONE signal of the FPGA refused to change state, the reconfiguration might be invalid. An error occurred during reconfiguration. This may be caused by an invalid FPGA content located inside the XSVF file. TDRV004-SW-82 - Linux Device Driver Page 19 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. WaitStates This parameter specifies the number of waitstates to be used for XSVF programming. Valid values are 1 to 1000. TDRV004-SW-82 - Linux Device Driver Page 20 of 62...
Page 21
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004-SW-82 - Linux Device Driver Page 21 of 62...
} TDRV004_CLOCK_PARAM; TDRV004-SW-82 - Linux Device Driver Page 22 of 62...
Page 23
Please refer to the Cypress CY27EE16 user manual for detailed explanation of the above register values. Use Cypress’ CyberClocks Version R3.10.00 to determine the correct values. This program is also part of the TPMC630 or TCP630 Engineering Documentation. TDRV004-SW-82 - Linux Device Driver Page 23 of 62...
Page 24
&ClockParam ); if (result != TDRV004_OK) /* handle error */ RETURNS On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. TDRV004-SW-82 - Linux Device Driver Page 24 of 62...
Page 25
The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY The device is already busy with XSVF, Reconfig or SPI action. TDRV004_ERR_INVAL It was tried to disable CLK1. This is not allowed. TDRV004_ERR_NOT_READY A device error occurred during programming. TDRV004-SW-82 - Linux Device Driver Page 25 of 62...
This parameter specifies a pointer to a TDRV004_SPI_BUF structure: typedef struct unsigned char SpiAddr; unsigned char SubAddr; unsigned long len; unsigned char pData[1]; /* dynamically expandable */ } TDRV004_SPI_BUF; TDRV004-SW-82 - Linux Device Driver Page 26 of 62...
Page 27
** allocate enough memory to hold the data structure + write data BufferSize = ( sizeof(TDRV004_SPI_BUF) + 5*sizeof(unsigned char) ); pSpiBuf = (TDRV004_SPI_BUF*)malloc( BufferSize ); pSpiBuf->SpiAddr = TDRV004_CLKADDR_EEBLOCK1; pSpiBuf->SubAddr = 0x00; pSpiBuf->len = 5; TDRV004-SW-82 - Linux Device Driver Page 27 of 62...
Page 28
The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY The device is already busy with XSVF, Reconfig or SPI action. TDRV004_ERR_NOT_READY A device error occurred during programming. TDRV004_ERR_INVAL The specified SubAddr+len exceeds 256, or len is invalid. TDRV004-SW-82 - Linux Device Driver Page 28 of 62...
This parameter specifies a pointer to a TDRV004_SPI_BUF structure: typedef struct unsigned char SpiAddr; unsigned char SubAddr; unsigned long len; unsigned char pData[1]; /* dynamically expandable */ } TDRV004_SPI_BUF; TDRV004-SW-82 - Linux Device Driver Page 29 of 62...
Page 30
** allocate enough memory to hold the data structure + read data BufferSize = ( sizeof(TDRV004_SPI_BUF) + 5*sizeof(unsigned char) ); pSpiBuf = (TDRV004_SPI_BUF*)malloc( BufferSize ); pSpiBuf->SpiAddr = TDRV004_CLKADDR_EEBLOCK1; pSpiBuf->SubAddr = 0x00; pSpiBuf->len = 5; … TDRV004-SW-82 - Linux Device Driver Page 30 of 62...
Page 31
The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY The device is already busy with XSVF, Reconfig or SPI action. TDRV004_ERR_NOT_READY A device error occurred during programming. TDRV004_ERR_INVAL The specified SubAddr+len exceeds 256, or len is invalid. TDRV004-SW-82 - Linux Device Driver Page 31 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pPlxBuf This parameter specifies a pointer to a TDRV004_PLX_BUF structure: typedef struct unsigned int Offset; unsigned short Value; } TDRV004_PLX_BUF; TDRV004-SW-82 - Linux Device Driver Page 32 of 62...
Page 33
This value specifies a 16bit word that should be written to the specified offset. EXAMPLE #include “tdrv004api.h” TDRV004_HANDLE hdl; TDRV004_STATUS result; TDRV004_PLX_BUF PlxBuf; ** Change the Subsystem Vendor ID to TEWS TECHNOLOGIES (0x1498) PlxBuf.Offset = 0x0E; PlxBuf.Value = 0x1498; result = tdrv004PlxWrite( hdl, &PlxBuf ); if (result != TDRV004_OK)
Page 34
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY The device is already busy with XSVF, Reconfig or SPI action. TDRV004_ERR_INVAL The specified offset is invalid, or read-only. TDRV004-SW-82 - Linux Device Driver Page 34 of 62...
This argument specifies the device handle to the hardware module retrieved by a call to the corresponding open-function. pPlxBuf This parameter specifies a pointer to a TDRV004_PLX_BUF structure: typedef struct unsigned int Offset; unsigned short Value; } TDRV004_PLX_BUF; TDRV004-SW-82 - Linux Device Driver Page 35 of 62...
Page 36
TDRV004_PLX_BUF PlxBuf; ** Read Subsystem ID PlxBuf.Offset = 0x0C; result = tdrv004PlxRead( hdl, &PlxBuf ); if (result == TDRV004_OK) printf( “SubsystemID = 0x%04X\n”, PlxBuf.Value ); } else { /* handle error */ TDRV004-SW-82 - Linux Device Driver Page 36 of 62...
Page 37
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY The device is already busy with XSVF, Reconfig or SPI action. TDRV004_ERR_INVAL The specified offset is invalid. TDRV004-SW-82 - Linux Device Driver Page 37 of 62...
The Base Address Register (BAR) usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM. Therefore the following table is just an example how the PCI Base Address Registers could be used. TDRV004-SW-82 - Linux Device Driver Page 38 of 62...
Page 39
** allocate enough memory to hold the data structure + read data BufferSize = ( sizeof(TDRV004_MEMIO_BUF) + 50*sizeof(unsigned char) ); pMemIoBuf = (TDRV004_MEMIO_BUF*)malloc( BufferSize ); pMemIoBuf->Size = 50; pMemIoBuf->Resource = TDRV004_RES_MEM_2; pMemIoBuf->Offset = 0; … TDRV004-SW-82 - Linux Device Driver Page 39 of 62...
Page 40
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_ACCESS The specified Resource is not available for access. TDRV004_ERR_INVAL The specified Offset+Size exceeds the available memory or I/O space. TDRV004-SW-82 - Linux Device Driver Page 40 of 62...
The Base Address Register (BAR) usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM. Therefore the following table is just an example how the PCI Base Address Registers could be used. TDRV004-SW-82 - Linux Device Driver Page 41 of 62...
Page 42
** allocate enough memory to hold the data structure + read data BufferSize = ( sizeof(TDRV004_MEMIO_BUF) + 50*sizeof(unsigned short) ); pMemIoBuf = (TDRV004_MEMIO_BUF*)malloc( BufferSize ); pMemIoBuf->Size = 50; pMemIoBuf->Resource = TDRV004_RES_MEM_2; pMemIoBuf->Offset = 0; … TDRV004-SW-82 - Linux Device Driver Page 42 of 62...
Page 43
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_ACCESS The specified Resource is not available for access. TDRV004_ERR_INVAL The specified Offset+Size exceeds the available memory or I/O space. TDRV004-SW-82 - Linux Device Driver Page 43 of 62...
The Base Address Register (BAR) usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM. Therefore the following table is just an example how the PCI Base Address Registers could be used. TDRV004-SW-82 - Linux Device Driver Page 44 of 62...
Page 45
** allocate enough memory to hold the data structure + read data BufferSize = ( sizeof(TDRV004_MEMIO_BUF) + 50*sizeof(unsigned int) ); pMemIoBuf = (TDRV004_MEMIO_BUF*)malloc( BufferSize ); pMemIoBuf->Size = 50; pMemIoBuf->Resource = TDRV004_RES_MEM_2; pMemIoBuf->Offset = 0; … TDRV004-SW-82 - Linux Device Driver Page 45 of 62...
Page 46
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_ACCESS The specified Resource is not available for access. TDRV004_ERR_INVAL The specified Offset+Size exceeds the available memory or I/O space. TDRV004-SW-82 - Linux Device Driver Page 46 of 62...
The Base Address Register (BAR) usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM. Therefore the following table is just an example how the PCI Base Address Registers could be used. TDRV004-SW-82 - Linux Device Driver Page 47 of 62...
Page 49
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_ACCESS The specified Resource is not available for access. TDRV004_ERR_INVAL The specified Offset+Size exceeds the available memory or I/O space. TDRV004-SW-82 - Linux Device Driver Page 49 of 62...
The Base Address Register (BAR) usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM. Therefore the following table is just an example how the PCI Base Address Registers could be used. TDRV004-SW-82 - Linux Device Driver Page 50 of 62...
Page 52
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_ACCESS The specified Resource is not available for access. TDRV004_ERR_INVAL The specified Offset+Size exceeds the available memory or I/O space. TDRV004-SW-82 - Linux Device Driver Page 52 of 62...
The Base Address Register (BAR) usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM. Therefore the following table is just an example how the PCI Base Address Registers could be used. TDRV004-SW-82 - Linux Device Driver Page 53 of 62...
Page 55
ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_ACCESS The specified Resource is not available for access. TDRV004_ERR_INVAL The specified Offset+Size exceeds the available memory or I/O space. TDRV004-SW-82 - Linux Device Driver Page 55 of 62...
Value Description TDRV004_LINT1_POLHIGH Local Interrupt Source 1 HIGH active TDRV004_LINT1_POLLOW Local Interrupt Source 1 LOW active TDRV004_LINT2_POLHIGH Local Interrupt Source 2 HIGH active TDRV004_LINT2_POLLOW Local Interrupt Source 2 LOW active TDRV004-SW-82 - Linux Device Driver Page 56 of 62...
Page 57
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_INVAL Invalid interrupt configuration specified. TDRV004-SW-82 - Linux Device Driver Page 57 of 62...
This value specifies the amount of time to wait for the incoming interrupt event. The timeout value is specified in milliseconds. However, the timeout granularity depends on the system ticks. To wait indefinitely, specify -1. TDRV004-SW-82 - Linux Device Driver Page 58 of 62...
Page 59
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY There is already a job waiting for this interrupt. TDRV004_ERR_TIMEOUT The specified timeout has passed TDRV004-SW-82 - Linux Device Driver Page 59 of 62...
This value specifies the amount of time to wait for the incoming interrupt event. The timeout value is specified in milliseconds. However, the timeout granularity depends on the system ticks. To wait indefinitely, specify -1. TDRV004-SW-82 - Linux Device Driver Page 60 of 62...
Page 61
On success, TDRV004_OK is returned. In the case of an error, the appropriate error code is returned by the function. ERROR CODES Error Code Description TDRV004_ERR_INVALID_HANDLE The specified TDRV004_HANDLE is invalid. TDRV004_ERR_BUSY There is already a job waiting for this interrupt. TDRV004_ERR_TIMEOUT The specified timeout has passed TDRV004-SW-82 - Linux Device Driver Page 61 of 62...
Need help?
Do you have a question about the TDRV004-SW-82 and is the answer not in the manual?
Questions and answers