Ratoc Systems REX-USB61 User Manual

Usb-spi/i2c protocol emulator

Advertisement

Quick Links

USB-SPI/I2C Protocol Emulator
2013.10
Rev. 1.0

Advertisement

Table of Contents
loading

Summary of Contents for Ratoc Systems REX-USB61

  • Page 1 USB-SPI/I2C Protocol Emulator 2013.10 Rev. 1.0...
  • Page 2: Table Of Contents

    (2-2) Setting up on Windows Vista x32 2- 3 (2-3) Setting up on Windows XP x32/XP x64 2- 5 (2-4) Confirmation of setting REX-USB61 2- 6 (2-5) Uninstallation on Windows 8 x32/8 x64/7 x32/7 x64/Vista x64 2- 7 (2-6) Uninstallation on Windows Vista x32/XP x32/XP x64 2- 8 3.
  • Page 3: Introduction ---------------------------------------------

    1.Introduction Page.1-1 (1-1) Specifications of the product REX-USB61 enables you to easily control from a PC a variety of devices with SPI/I2C bus. [This product comes with SPI/I2C control utility] This bundled utility can control SPI/I2C, GPO(General Purpose Output) and save a setting file or log file.
  • Page 4 Code file for Visual Basic ActiveX control usb61api.ocx ActiveX control for REX-USB61 Utility to delete INF file Uninstall utility USB61_uninst.exe (Windows XP x32/XP x64) * REX-USB61 can only use 1 device. On the other hand, REX-USB61M can use multiple devices.
  • Page 5: Package Contents

    1.Introduction Page.1-3 (1-2) Package contents REX-USB61 package includes: ☑ REX-USB61 ☑ CD-ROM ☑ USB A – mini B cable ☑ SPI/I2C cable ☑ Warranty Card SPI/I2C cable (For specifications, please see a next page) USB mini B(Female) connector Power LED (Power On : Green Power Off : Off)
  • Page 6: Cable Specifications

    1.Introduction Page.1-4 (1-3) Cable Specifications The below explains the specifications of the cable bundled with REX-USB61. Housing Cable Signal Usage number color color Input/Output of power supply for a target device Black Brown Power (Output 5V or 3.3V @100mA) (Input 1.8V - 5V )
  • Page 7: Each Mode

    I2C Bus This mode can display data received to self Slave mode -address, send data to master. You can select master mode or slave mode of REX-USB61 by the bundled utility software or API library.
  • Page 8: Connection Of A Spi Device

    In order to provide power supply to a level converter IC on the REX-USB61, it is required to connect the power pin of the REX-USB61 to a power supply of a target device, even if the target device doesn’t have power supply.
  • Page 9 API library. ( The library is called usb61_power_control(). Refer to (4-4) at Chapter 4.) Disable output of power Be sure to connect the target device supply of REX-USB61. power terminal. supply power. Power Power ●...
  • Page 10 Page.1-8 SPI Connection( If a target device doesn’t have power supply) If REX-USB61 supply power(3.3V/5.0V) to a target device, please use utility software or application which uses an API library. ( The library is called usb61_power_control(). Refer to (4-4) at Chapter 4.)
  • Page 11: Connection Of A I2C Device

    In order to provide power supply to a level converter IC on the REX-USB61, it is required to connect the power pin of the REX-USB61 to a power supply of a target device, even if the target device doesn’t have power supply.
  • Page 12 ● ● ● ● ● ● ● ● ● ● Address ● ATMEL: ● ● ● ● AT24C02B ● ● Power REX-USB61 ● Address ATMEL: AT24C02B ● *1 The pull-up resistance on REX-USB61 is 10KΩ. If necessary, add pull-up resistance.
  • Page 13 Page.1-11 I2C connection( If a target device doesn’t power supply) If REX-USB61 supply power(3.3V/5.0V) to a target device, please use utility software or application which uses an API library. ( The library is called usb61_power_control(). Refer to (4-4) at Chapter 4.)
  • Page 14 API library. ( The library is called usb61_power_control(). Refer to (4-4) at Chapter 4.) Disable output of power Be sure to connect the target device supply of REX-USB61. power terminal. supply power. ● ● Power Power ●...
  • Page 15 I2C connection [1MHz-SCL / 1MHz-SDA] ( If a target device doesn’t have power supply) If REX-USB61 supply power(5.0V) to a target device, please use utility software or application which uses an API library. ( The library is called usb61_power_control(). Refer to (4-4) at Chapter 4.)
  • Page 16 2.Setting up on Windows Page.2-1 (2-1) Set up on Windows 8 x32/8 x64/7 x32/7 x64/Vista x64 Turn on the PC and proceed to the below installation before connecting REX-USB61 to the USB port. Start Win8_7_VistaX64¥USB61_ Setup.exe at the bundled CD-ROM.
  • Page 17 Page.2-2 Click [Install] on the Windows Security window. The set up has finished. If REX-USB61 is connected to the PC, the installation will automatically finish. Proceed to (2-4) Confirmation of setting REX- USB61 to confirm the installation has finished properly.
  • Page 18 2.Setting up on Windows Page.2-3 (2-2) Setting up on Windows Vista x32 Turn on the PC and connect REX-USB61 to the USB port. The below hardware wizard will start up. Proceed to the below instruction. Select [Locate and install driver software (recommended)].
  • Page 19 2.Setting up on Windows Page.2-4 Insert the bundled CD-ROM and click [Next]. Select [Install this driver software anyway]. The installation of REX-USB61 has finished. Proceed to (2-4) Confirmation of setting REX- USB61 to confirm the installation has finished properly.
  • Page 20 2.Setting up on Windows Page.2-5 (2-3) Setting up on Windows XP x32/XP x64 Turn on the PC and connect REX-USB61 to the USB port. The below hardware wizard will start up. Proceed to the below instruction. Select [No, not this time] and click [Next].
  • Page 21 (2-4) Confirmation of setting REX- USB61 Open [Device Manager]. (※ On Windows XP x32/XP x64, open [Control Panel] and [System]. And select the [Hardware] tab and click the [Device manager] button.) Confirm there is a string of [RATOC REX-USB61] properly under the [SPI/I2C Converter Device].
  • Page 22 2.Setting up on Windows Page.2-7 (2-5) Uninstallation on Windows 8 x32/8 x64/7 x32/7 x64/Vista x64 Start [Programs and Functions]. Select [RATOC REX-USB61 Installer] and click [Uninstall]. Click [Yes]. The uninstallation of REX-USB61 has finished.
  • Page 23 2.Setting up on Windows Page.2-8 (2-6) Uninstallation on Windows Vista x32/XP x32/XP x64 To uninstall REX-USB61, you have to delete the driver and INF file. (On Windows Vista, you have to delete the driver only.) ・Delete the driver Open [Device Manager].
  • Page 24 2.Setting up on Windows Page.2-9 ・Delete INF file (Windows XPx32/XPx64) Start [USB61_uninst.exe] at the bundled CD-ROM. ([CD-ROM]:¥USB61_uninst .exe) When the dialog shown right appear, click [OK]. When the dialog shown right appear, click [OK]. The uninstallation of REX-USB61 has finished.
  • Page 25: Spi/I2C Control Utility ---------------------------------------

    3.SPI/I2C Control Utility Page.3-1 (3-1) Functions of the utility The bundled Usb61Uty.exe can control a target device with SPI or I2C interface and has the following functions: Switch operation modes for SPI and I2C Control SPI device(Master operation) Control I2C device(Master/Slave operation) Control PORT pin Read/Write setting values Save setting files(BIN file format)
  • Page 26: Explanation Of The Utility

    3.SPI/I2C Control Utility Page.3-2 (3-2) Explanation of the utility The below explains screens of the utility and each function. Fig 3-2. I2C master mode Fig 3-1. SPI master mode Fig 3-3. I2C slave mode...
  • Page 27 3.SPI/I2C Control Utility Page.3-3 Menu bar File(F) ・ Create : Create a new setting file ・ Open : Open a setting file ・ Overwrite : Overwrite a current setting ・ Save a file : Save a current setting as a new name ・...
  • Page 28 3.SPI/I2C Control Utility Page.3-5 Controls SPI Option ・ SPI Option :Set SPI mode ・ Slave Select :Select slave select pin ・ Sampling Timing :Set when to sample by which part of a clock ・ Polarity :Select positive polarity or negative polarity ・...
  • Page 29 3.SPI/I2C Control Utility Page.3-5 Master/Slave common ・ Sampling rate : Set/display a sampling rate(frequency). You can set a sampling rate(frequency) by 1KHz each. For SPI, a sampling rate(frequency) will be set at an approximate value which can be really set. (I2C:47KHz - 1MHz / SPI: Up to 12MHz) * For how to calculate an approximate value, please refer to a usb61_spi_set_freq() function at...
  • Page 30 3.SPI/I2C Control Utility Page.3-6 Edit window for transfer data If you double-click a row at the transfer list, the below edit window will be shown. Fig3-4. SPI mode Fig3-5. I2C mode ・ I2C setting : Set transfer setting for the I2C bus ①...
  • Page 31 3.SPI/I2C Control Utility Page.3-7 Option setting You can set the following by selecting [Option(O)] →[Setting]. ・ Set pull-up setting on the I2C bus ・ Set to supply power to a target device ・ Set an interval between data Fig3-6. Option setting window ・Disable/enable pull-up : Select whether to set pull-up on the I2C bus line.
  • Page 32: Example To Control By Using This Utility

    3.SPI/I2C Control Utility Page.3-8 (3-3) Example to control by using this utility * The below explanation is an example used ATMEL:AT24C02B、AT25080A ・ SPI master mode [Switch SPI/I2C] By switching SPI/I2C, SPI Mode can be selected. [Set a sampling rate(frequency)] Set a sampling rate(frequency) at the Frequency section.
  • Page 33 3.SPI/I2C Control Utility Page.3-9 Example : Write 11 22 33 44 55 66 77 88 at 50h, and write 8bytes data from 50h. [Data input(Write / Read)] Double-click an inside of [Transfer List] and input a Hex number. Please see the below example. (1 row) 06h --- Set Write Enable bit (2 row)
  • Page 34 3.SPI/I2C Control Utility Page.3-10 ・ I2C master mode [Switch SPI/I2C] [Set a sampling rate(frequency)] [Set to supply power] [Set an interval] Like the procedure described at Page.3-8,switch modes into I2C Mode and set a sampling rate(frequency) / power supply / interval. (Master tab should be selected) *1 Slave address (R/W bit is not included)
  • Page 35 3.SPI/I2C Control Utility Page.3-11 Please see the below sample. (1 row) <Write> ・ Slave address --- 50h(Set as 7bit) ・ Data direction --- Write ・ Stop condition ---Yes ・ Transfer data 00h --- Address to be written 11h 22h.. --- Data to be written (2 row) <Write for Read>...
  • Page 36 3.SPI/I2C Control Utility Page.3-12 ・ I2C slave mode Example : Read data transferred to slave address 50h [Switch SPI/I2C] [Set a sampling rate(frequency)] [Set to supply power] [Set an interval] Like the procedure described at Page.3-8,switch modes into I2C Mode and set a sampling rate(frequency) / power supply/interval.
  • Page 37: Grammar For Script Description

    3.SPI/I2C Control Utility Page.3-13 (3-4) Grammar for script description This utility can treat a script file where a description of a device access is written. You can describe a comment at the script file. By using the script file, you can access a device.
  • Page 38 3.SPI/I2C Control Utility Page.3-14 Command INTERVAL= Meaning Set an interval of waiting time which is inserted into bytes of data to be sent.(Unit: micro second) If you don’t set this value, a default value is 0. Parameter Set a value ranging from 0 to 65535.(0 – 65535 micro seconds) * An actual interval time include process time, so it will be longer than the interval set here.
  • Page 39 3.SPI/I2C Control Utility Page.3-15 Command for I2C only Fig.3-3 I2C command table Command ADDRESSMODE= Meaning Set I2C address to 7 bit mode or 10 bit mode. (Default value is 7 bit mode) Parameter 7 or 10 Command ADDRESS= Meaning Set I2C address You can change address any time, but if [READ] or [WRITE] command is written before setting an address, it is a grammatical error.
  • Page 40 3.SPI/I2C Control Utility Page.3-16 Command for SPI only Fig.3-4 SPI command table Command SS=n Meaning S et slave select pin. Default value is 0. Parameter Parameter n=0 - 3 Command SAMPLING=n Meaning S et bus sampling method. Default value is 0. Parameter Sampling edge Figure...
  • Page 41 3.SPI/I2C Control Utility Page.3-17 How to use REPEAT command This section explains REPEAT script and inside process of{ }and STOP. Script code Explanation of function REPEAT=10 After receiving 10 bytes of data, STOP condition is sent. READ STOP REPEAT=10 Repeat the following 10 times: [Send STOP condition by 1 byte each] READ 1 STOP...
  • Page 42: Example Of Script

    3.SPI/I2C Control Utility Page.3-18 (3-5) Example of script The below is an explanation of how to use a script file. From [Option]-> [List View/Script Change], show script description mode. The function of each button is as follows: [Load] --- Read a script file. [Save] --- Save a script file.
  • Page 43 3.SPI/I2C Control Utility Page.3-19 The below describes script samples(Write/Read) to control an I2C and SPI device. (The script files are included at the bundled CD-ROM. I2C_script.txt/ SPI_script.txt) ・Sample of I2C script: (Write 4bytes data(00h 01h 02h 03h) from the address of 08h of the device at slave address 50h, and read the data to confirm the data is written properly.
  • Page 44 3.SPI/I2C Control Utility Page.3-20 ・Sample of SPI script: (Write 4bytes data(00h 01h 02h 03h) from the address of 15h, and read the data to confirm the data is written properly. And also, write data on the file, and read the data to a file to confirm the data is written.
  • Page 45 3.SPI/I2C Control Utility Page.3-21 # (Continue from the previous page) # Confirm data is written properly # Copy data read from address 0015h onto FILE2 SSSET # Activate SS signal at the Low level 03h,15h,00h # Operation code READ+ read address FILE1 FILE2 # Write dummy data from FILE1 # Save date read to FILE2...
  • Page 46: Api Function Reference ---------------------------------------

    Page.4-1 (4-1) Using on VC This API functions is a library software to support software development using REX-USB61. By using the API functions, it will be possible to incorporate the application program own control SPI/I2C target device. The header file (usb61def.h) and the library file (usb61api.lib, usb61spi.dll) are provided to use the library functions on VC++.
  • Page 47 4. API function reference Page.4-2 USB61LIB_API RS_STATUS WINAPI usb61_i2c_set_freq( HANDLE hUsb61Device, RS_I2C_FREQ fI2cFreq ); USB61LIB_API RS_STATUS WINAPI usb61_i2c_set_freq_ex( HANDLE hUsb61Device, USHORT Frequency, USHORT *pActualFrequency ); USB61LIB_API RS_STATUS WINAPI usb61_i2c_read_master( HANDLE hUsb61Device, USHORT SlaveAddress, UINT fI2cOption,USHORT ReadBytes, UCHAR *pReadBuf ); USB61MLIB_API RS_STATUS WINAPI usb61_i2c_read_master_ex(HANDLE hUsb61Device, USHORT SlaveAddress, UINT fI2cOption, USHORT ReadBytes, UCHAR *pReadBuf );...
  • Page 48: Using On Vb / Visual C#

    4. API function reference Page.4-3 (4-2) Using on VB / Visual C# To use an ActiveX component that is attached to a product from application of Visual C# and Visual BASIC, you need to register your ActiveX by following method. (1) Registration of ActiveX Install the driver in Chapter 2 Windows Setup.
  • Page 49 4. API function reference Page.4-4 (3)How to reference ActiveX on VB6 Create new project. Select the component with the Project menu. Check-in the "usb61spi ActiveX Control Module" in the list of controls. Click "OK" button. Then the usb61api Active X component is added.
  • Page 50 4. API function reference Page.4-5 Select the usb61api Active X component that was added, and then paste the project to the form. To prevent appear on the run-time, set the "Visible" in the property of the object to false. Double-click the object, then appear the subroutine "Sub Usb61api1_OnEvnet...
  • Page 51 4. API function reference Page.4-6 (4)How to reference ActiveX on VB.NET / Visual C# Create new project. Select the [Tool] - [Choose Toolbox Items…] - [COM Components] in the menu. Check the [Usb61apiControl]. Then click the "OK" button. Confirm the component is registered, then paste to the form.
  • Page 52 4. API function reference Page.4-7 Double-click the object, then appear the subroutine "Sub Usb61api1_OnEvnet Msg(...)" that called at when event occurs. See the description of the "Detail of API functions".
  • Page 53: List Of Api Functions

    (4-3) List of API functions The list of API functions is as the below: Table 4-1. API Function Names and Descriptions Function name Description usb61_open() Open the REX-USB61 device usb61_close() Close the REX-USB61 device. usb61_power_control() Control the supply power to the device usb61_get_fw_version()
  • Page 54: Detail Of Api Functions

    HANDLE usb61_open( RS_STATUS *pStatus ); Function Usb61Open (pStatus As Long) As Long Function Usb61Open (ByRef pStatus As Integer) As Integer VB.NET Description Open the REX-USB61 device. Start for using the REX-USB61 device. Parameters [OUT] pStatus : RS_SUCCESS Function call succeeded. Error code (refer. 4-5) Function call failed.
  • Page 55: Usb61_Power_Control

    Usb61PowerControl (ByVal hUsb61Device As Integer, ByVal fPowerState As Integer) As Integer Description Control the supply power to the device Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] fPowerState : Enabled / Disabled supply power and the voltage of power...
  • Page 56: Usb61_Get_Dll_Version

    ByRef pDllMinorVer As Byte) As Integer Description Get the version number of DLL. Parameters [IN] hUsb61Device : handle of an REX-USB61 device [OUT] *pDllMajorVer : Pointer to majar version number of DLL (Hex-decimal) [OUT] *pDllMinorVer : Pointer to minor version number of DLL...
  • Page 57: Usb61_Get_Hw_Info

    ByRef pHardwareInfo As Object) As Integer Description Retrieve the hardware information for the SPI/I2C bus operation Parameters [IN] hUsb61Device : handle of an REX-USB61 device [OUT] pHardwareInfo : pointer to _RS_HARDWARE_INFO structure The _RS_HARDWARE_INFO structure is described bellow: typedef struct _RS_HARDWARE_INFO { UCHAR DeviceMode;...
  • Page 58: Usb61_Mode_Change

    (If do not call this function, then actual interval is 0 micro-second) * Need to call usb61_mode_change(), before calling this function. Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] IntervalCnt : Interval for send data (micro-second: 0 - 65535)
  • Page 59: Usb61_Gpo_Write

    ByVal fI2cPullup As Short) As Integer Description Set pullup on I2C bus. (Each pin of SDA and SCL) Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] fI2cPullup : pullup setting Set the value by using the defined symbol as the following: RS_I2C_PULLUP_DISABLE Not set pull-up the pin SCL and SDA.
  • Page 60: Usb61_I2C_Bus_Reset()

    VB.NET Usb61I2cBusReset(ByVal hUsb61Device As Integer) As Integer Description Reset I2C bus. Set the Stop condition to the I2C bus Parameters [IN] hUsb61Device : handle of an REX-USB61 device Return RS_SUCCESS Function call succeeded. Values Error code (refer. 4-5) Function call failed.
  • Page 61: Usb61_I2C_Read_Master

    As Integer Description Read a stream of bytes from the I2C slave device. Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] SlaveAddress : the slave from which to read. See the below [IN] fI2cOption : special operation as described in "Table 4-2" and below...
  • Page 62 It is different from the "usb61_i2c_read_master" function that write data before for reading with the specifying the calling position (specifying sub-address) on inside function. Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] SlaveAddress : the slave from which to read. See *Slave address in Page4-16.
  • Page 63 ByVal pWriteBuf As Object) As Integer Description Write a stream of bytes to the I2C slave device Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] SlaveAddress : the slave from which to read. See *Slave address in Page4-16.
  • Page 64 On Visual Basic, by using ActiveX control, as user-defined-message "WM_USB61_MSG" is notified. Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] nType : notification method enumerated type of notification method by using the defined symbol as the following:...
  • Page 65 Set the data for sending to master device on I2C slave mode When receive data from master device, send the data pre-set for master Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] ResponseBytes :the number of bytes for sending to master device...
  • Page 66 4. API function reference Page.4-21 SPI bus operation on SPI bus master mode RS_STATUS Definition usb61_spi_set_freq( HANDLE hUsb61Device, UINT fDataMode, USHORT Frequency, USHORT *pActualFrequency ); Function Usb61SpiSetFreq(ByVal hUsb61Device As Long, ByVal fDataMode As Long, ByVal Frequency As Long, pActualFrequency As Long) As Long Function VB.NET Usb61SpiSetFreq(ByVal hUsb61Device As Integer,...
  • Page 67 4. API function reference Page.4-22 Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] fDataMode : a bit mask specifying which operation mode for sending on SPI bus. The clock polarity and the clock edge determine the value of bit mask.
  • Page 68 After write, not set SS line status to High. For setting SS line to High, call usb61_gpo_write function. Parameters [IN] hUsb61Device : handle of an REX-USB61 device [IN] fSlaveSelect : Pin number for slave select enumerated values specifying pin number the bellow:...
  • Page 69: Error Codes

    Function call succeeded RS_OK RS_DEVICE_FOUND device is found RS_DEVICE_CONNECT device is connected RS_UNABLE_TO_LOAD_LIBRARY unable to load library RS_UNABLE_TO_LOAD_DRIVER unable load REX-USB61 driver RS_UNABLE_TO_LOAD_FUNCTION unable to call function RS_INCOMPATIBLE_LIBRARY incompatible library version RS_INCOMPATIBLE_DEVICE incompatible device RS_COMMUNICATION_ERROR communication error RS_UNABLE_TO_OPEN unable to open device...
  • Page 70: Sample Applications

    4. API function reference Page.4-25 (4-6) Sample Applications REX-USB61 includes a sample application of reference of the application development. The "EEPROM R / W Utility" sample application that can read and write for the EEPROM (ATMEL AT24C02B, AT25080A) with I2C interface or SPI.
  • Page 71 4. API function reference Page.4-26 [Description of I2CSlaveSample] I2C Slave address ..Set I2C slave address Operation Frequency of I2C Master ..Select frequency of I2C master device Response data ..Set response data for I2C master Execute ..Start for I2C slave Receive data ..
  • Page 72: How To Develop Application Using This Api Functions

    Page.4-27 (4-7) How to develop application using this API functions This section describes how to create a control application using the REX-USB61 API functions. It is an example in C++. If you want to know in other programming language or detail, refer to the source code of the sample programs.
  • Page 73 // bit combination of clock leading or trailing, polarity // Get device handle hDeviceHandle = usb61_open(&rsStatus); // Supply 5.0V power to target device. // Using the source power from target device without from REX-USB61, // Set RS_PWRCTRL_OFF usb61_power_control(hDeviceHandle, RS_PWRCTRL_ON | RS_OUTPUT_5_0V); // Set SPI master mode usb61_mode_change(hDeviceHandle, RS_DEVMODE_SPI | RS_DEVMODE_MASTER, NULL );...
  • Page 74 4. API function reference Page.4-29 Example – I2cSlaveSample [I2C] : This program operates as a slave device for REX-USB61. When reading from the I2C master device, send the response data which prepared in advance to the I2C master device. The transmission of data from the I2C master device is notified by the event of receipt or the callback function.
  • Page 75 RATOC Systems, Inc. All rights reserved.

Table of Contents