Ratoc Systems REX-USB61 Скачать руководство пользователя страница 57

4. API function reference 

                                               

Page.4-12 

 

VC 

RS_STATUS 
 usb61_get_hw_info( HANDLE hUsb61Device, 

 

  PRS_HARDWARE_INFO pHardwareInfo );

VB 

Function 
  Usb61GetHwInfo(ByVal hUsb61Device As Long,   

pHardwareInfo As Byte) As Long

Definition 

VB.NET 

Function 
  Usb61GetHwInfo(ByVal hUsb61Device As Integer,   

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; 

 

     // SPI/I2C mode 

            UCHAR MasterSlaveAct;   // Master/Slave operation 

            USHORT Frequency;            // frequency of interface 

        UCHAR   OutputVolt;     // Output voltage for target device 

      } RS_HARDWARE_INFO, *PRS_HARDWARE_INFO; 

_RS_HARDWARE_INFO structure is defined in usb61def.h. 

sample code for VB as the dellow: 

      Dim pHardWareBuf() As Byte 

      Dim HardWareInfo As RS_HARDWARE_INFO 

 

      ReDim pHardWareBuf(10) As Byte 

      rsStatus

 

=

 

Usb61api.Usb61GetHwInfo(m_hDeviceHandle,  

      pHardWareBuf) 

      If rsStatus <> RS_SUCCESS Then 

                  ' error process 

      Else 

            HardWareInfo.DeviceMode = pHardWareBuf(0) 

                  HardWareInfo.MasterSlaveAct = pHardWareBuf(1) 

            HardWareInfo.Frequency = 

                    pHardWareBuf(3)*256 + pHardWareBuf(2) 

            HardWareInfo.OutputVolt = pHardWareBuf(4) 

      End If 

Return 

Values 

RS_SUCCESS                                          Function call succeeded. 
Error code (refer. 4-5)                  Function call failed. 

 

 

 

 

 

 

 

Содержание REX-USB61

Страница 1: ...USB SPI I2C Protocol Emulator 2013 10 Rev 1 0 ...

Страница 2: ...p on Windows Vista x32 2 3 Setting up on Windows XP x32 XP x64 2 4 Confirmation of setting REX USB61 2 5 Uninstallation on Windows 8 x32 8 x64 7 x32 7 x64 Vista x64 2 6 Uninstallation on Windows Vista x32 XP x32 XP x64 3 SPI I2C Control Utility 3 1 Functions of the Utility 3 2 Explanation of the Utility 3 3 Example to control by using this utility 3 4 Grammar for script description 3 5 Example of ...

Страница 3: ... this product to an external device Can provide from 1 8V to 5 0V an input output level of SPI I2C slave port parallel out port as long as a power supply terminal of this product is provided by a external voltage Can change SPI I2C master slave SPI is a master only Can specify a frequency of SPI I2C bus Can output a digital of 4bit at I2C mode And this product comes with program source codes by wh...

Страница 4: ...USB61 inf Setting file for REX USB61 Windows Vista x32 XP x32 XP x64 Installer USB61_Setup exe Installer for Windows 8 x32 8 x64 7 x32 7 x64 Vista x64 Utility Usb61Uty exe Utility to control SPI I2C Script file I2C_script txt SPI_script txt Script file for I2C bus control Script file for SPI bus control Sample program VC6 0 VB6 0 VB 2005 C EEPROMRWUty I2cSlaveSample Sample program to send receive ...

Страница 5: ... 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 Access LED Access Orange Non Access Off ...

Страница 6: ...nge 1MHz SCL Clock for I2C 401KHz 1MHz bus voltage 5V only Pull up resistance 10kΩ 4 Black Yellow 1MHz SDA Data signal for I2C 401KHz 1MHz bus voltage 5V only Pull up resistance 10kΩ 5 Black Green SCL Clock for I2C 47KHz 400KHz 1 8 5V Pull up resistance 10kΩ 6 Black Blue SDA Data signal for I2C 47KHz 400KHz 1 8 5V Pull up resistance 10kΩ 7 Black Purple SCK Clock signal for SPI 12MHz 1 8 5V 8 Black...

Страница 7: ...Gray Purple GND Ground 18 White Gray Gray GND Ground 19 White Gray White N C N C 20 White Gray Black N C N C 1 4 Each mode The below explains master slave mode on SPI I2C bus Bus Operation SPI Bus Master mode This mode can select a slave send data display data received from the slave Master mode This mode can send data to a particular address display data received from the slave I2C Bus Slave mode...

Страница 8: ...quired 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 Inside of REX USB61 Level converter IC Power SDO 5Vor3 3V USB PIC 5V SDI DOx SCK 10KΩ 10KΩ 10KΩ Caution When connecting disconnecting a device never provide power to REX USB61 nor the device If you provide power to REX USB61 or the device and connect or disconne...

Страница 9: ...ity software or application which uses an API library The library is called usb61_power_control Refer to 4 4 at Chapter 4 A target device supply power Disable output of power supply of REX USB61 REX USB61 ATMEL AT25080A SI SO SCK CS ATMEL AT25080A SI SO SCK CS SDO SDI SCK DO0 DO1 DO2 DO3 Power GND Be sure to connect the power terminal Power Power ...

Страница 10: ...se utility software or application which uses an API library The library is called usb61_power_control Refer to 4 4 at Chapter 4 A target device doesn t supply power REX USB61 output power supply REX USB61 Power ATMEL AT25080A SI SO SCK CS ATMEL AT25080A SI SO SCK CS SDO SDI SCK DO0 DO1 DO2 DO3 GND Be sure to connect the power terminal Power Power ...

Страница 11: ...wer pin of the REX USB61 to a power supply of a target device even if the target device doesn t have power supply Inside of REX USB61 SDA SCL 10KΩ 10KΩ Pull up control 5Vor3 3V 10KΩ 10KΩ 5V Pull up control Level converter IC 1MHz SDA 1MHz SCL Power USB PIC Caution When connecting disconnecting a device never provide power to REX USB61 nor the device If you provide power to REX USB61 or the device ...

Страница 12: ...an API library The library is called usb61_power_control Refer to 4 4 at Chapter 4 ATMEL AT24C02B SDA SCL Power ATMEL AT24C02B SDA SCL Power Power SDA SCL GND Address 50h Address REX USB61 A target device supply power Disable output of power supply of REX USB61 Be sure to connect the power terminal 1 51h 1 The pull up resistance on REX USB61 is 10KΩ If necessary add pull up resistance ...

Страница 13: ...uses an API library The library is called usb61_power_control Refer to 4 4 at Chapter 4 ATMEL AT24C02B SDA SCL Power ATMEL AT24C02B SDA SCL SDA SCL REX USB61 output Power Be sure to connect the power terminal power supply A target device doesn t supply power 1 Address 50h GND Power REX USB61 Address 51h 1 The pull up resistance on REX USB61 is 10KΩ If necessary add pull up resistance ...

Страница 14: ... called usb61_power_control Refer to 4 4 at Chapter 4 ATMEL AT24C02B SDA SCL Power ATMEL AT24C02B SDA SCL Power Address 50h Power 1MHz SDA 1MHz SCL 5V 5V A target device supply power Disable output of power supply of REX USB61 Be sure to connect the power terminal GND REX USB61 Address 51h Only after providing power to all devices set on pull up resistance If a target device provide power don t at...

Страница 15: ...ry is called usb61_power_control Refer to 4 4 at Chapter 4 ATMEL AT24C02B SDA SCL Power ATMEL AT24C02B SDA SCL Power 1 Be sure to connect the power terminal power supply REX USB61 output 5V Power 1MHz SDA 1MHz SCL 5V A target device supply power Address 50h GND REX USB61 Address 51h Only after providing power to all devices set on pull up resistance 1 The pull up resistance on REX USB61 is 10KΩ If...

Страница 16: ...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 If user account window appear click Yes RATOC REX USB61 Installer will start Click Next Click Install ...

Страница 17: ...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 ...

Страница 18: ... 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 If user account window appear click Yes Click Don t search online as shown right ...

Страница 19: ... 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 ...

Страница 20: ...rdware wizard will start up Proceed to the below instruction Select No not this time and click Next Insert the bundled CD ROM and select Install the software automatically Recommended and click Next The installation of REX USB61 has finished Proceed to 2 4 Confirmation of setting REX USB61 to confirm the installation has finished properly ...

Страница 21: ...n 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 ...

Страница 22: ...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 ...

Страница 23: ... and INF file On Windows Vista you have to delete the driver only Delete the driver Open Device Manager On Windows XPx32 XPx64 open Control Panel and System And select the Hardware tab and click the Device manager button Right click the RATOC REX USB61 and select Uninstall On Windows Vista x32 put the check mark as shown right and click OK ...

Страница 24: ...elete 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 ...

Страница 25: ... time interval between data Save transfer log files Common items Switch operation modes for SPI and I2C Set clock polarity Set clock phase Set precedent bit Set frequency Set slave select pin Max 4 Create transfer data Edit transfer data Send step by step transfer data Send batch transfer data Repeatedly send transfer data Save transfer data file SPI bus Master Read transfer data saved in a file S...

Страница 26: ...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 ...

Страница 27: ...elected number All functions can work on master only Devices D Switch SPI I2C Switch modes between the SPI and I2C bus Options O Setting Switch pull up conditions of the I2C bus signal Set whether to supply power to devices Set a voltage of power supply 3 3V 5 0V Set a time interval for each 1 byte View list Switch scripts View list and switch scripts Help H Version information Display version of ...

Страница 28: ...ut to each Port Master Transfer List Display the content of setting transfer Num Number of transfer data Addr Device address Dir Direction of transfer Display Read or Write Line Display data line name Display MOSI or MISO Data Display data content Stop Display whether to stop condition is issued Size Data size Send Transfer selected data Send All Transfer all of setting items at the list view Cont...

Страница 29: ...y a current output at the lower left Freq Display a current sampling frequency at the lower left Pull up Display a current I2C bus pull up conditions Log Transfer Log Display a log of the content of transfer time Display time when a log is added hh mm ss msec mode Display transfer mode for SPI I2C SPI I2C dir Display transfer direction read write miso mosi m s Display master slave mode master slav...

Страница 30: ...address 10bit Put a check mark when you set 10 bit address N B Refer to Page 4 16 for how to set an slave address Transfer direction Set transfer direction Set it as Read or Write Stop condition Set whether to issue stop condition Transfer data setting Display a content of transfer data or file name in Hex number Set as a binary At the edit box input data which is directly sent Set from a file Set...

Страница 31: ...data Fig3 6 Option setting window Disable enable pull up Select whether to set pull up on the I2C bus line I2C at 5V 1MHz pin 401KHz 1000KHz only can be selected Whether to supply power or not Select whether to supply power to a target device Select from 3 3V or 5 0V N B Don t supply power while an external power supply provide power Set an interval Set a time interval for 1 byte each when sending...

Страница 32: ... Frequency section 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 Chapter 4 Set to supply power Supply power by selecting Option Setting Set an interval Set a time interval by 1 by...

Страница 33: ...ta is written 11h 22h Data to be written 8byte 3 row 03h Read command 00h 50h Address to be read 00h 00h Dummy data for Read 8byte 8byte data will be read Execution Write Read By clicking the Send All button the data inside of the Transfer List will be sent The sent received data will be displayed at the Transfer Log Example Write 11 22 33 44 55 66 77 88 at 50h and write 8bytes data from 50h Fig3 ...

Страница 34: ...and set each item slave address Set 7bit 1 For setting refer to Slave address as described above If you set data as 10bit put a check mark at the 10bit Transfer direction Select Write Read Stop condition Set an issue of stop condition Transfer data Set data in Hex number Length of data transfer When writing the length of data transfer will be displayed automatically and when reading set data size ...

Страница 35: ...ead Slave address 50h Set as 7bit Data direction Write Stop condition No Transfer data 00h Address to be read 3 row Read Slave address 50h Set as 7bit Data direction Read Stop condition Yes Length of data transfer 4 This won t display Execution Write Read By clicking the Send All button data inside of the Transfer List will be sent The sent received data will be displayed at the Transfer Log Fig3 ...

Страница 36: ... 8 switch modes into I2C Mode and set a sampling rate frequency power supply interval Master tab should be selected Set a slave address as 7bit at the Slave Address and click the Enable button When data is sent from a master Read data will be displayed at the Response Data and Transfer log Fig3 15 I2C slave mode setting Example Read data transferred to slave address 50h ...

Страница 37: ... TAB between a command and another command or a value and another value Two byte characters are a grammatical error Fig 3 2 Common command table Command Meaning The sentence after is treated as a comment Parameter None Command MODE Meaning Set mode for SPI or I2C There is not a default value for this MODE command If you don t set a mode it is a grammatical error After setting you can not change mo...

Страница 38: ...n Meaning Repeat a command written in after REPEAT command by a number set in this command If this is not written only a next command written right after this command will be repeated For how to use this command please refer to Page 3 17 Parameter nn 1 65536 Command PULLUP Meaning Set a pull up setting for SDA SCL signal line A default value is pull up ON and as long as voltage of power supply 5V ...

Страница 39: ...ILEn Add the data to the existing file if a file already exist Parameter xxH FILEn Set bytes to be read a file to be saved Bytes 1 65536 Command WRITE Meaning Write data set by this command If more than one data need to be written separate each data by comma Parameter xxH xxH Set data to be written by bytes Command WRITEF Meaning Send data from a file Data is treated by a binary data Data to be wr...

Страница 40: ...Parameter None Command SSRESET Meaning Set High for slave select signal set by SS command Parameter None Other functions For SPI there isn t any particular command for Read Write and write a described value SPI by its nature write and read at the same time so to read only isn t allowed Meaning Read data is saved as a file set in FILEn If FILEn is specified Add data if an existing file is set Param...

Страница 41: ...ceiving 10 bytes of data STOP condition is sent REPEAT 10 READ 1 STOP Repeat the following 10 times Send STOP condition by 1 byte each REPEAT 10 READ 1 STOP STOP condition is sent after receiving 10 bytes of data REPEAT 10 READ 1 STOP STOP condition is sent after receiving 10 bytes of data REPEAT 10 READ 1 STOP Repeat the following 10 times STOP condition is sent after receiving 1 byte of data ...

Страница 42: ... script description mode The function of each button is as follows Load Read a script file Save Save a script file Clear Erase a shown content Execute Execute a script Stop Stop executing script A result of execution shows at Transfer Log Fig3 16 Example of script You can make and edit a script file with a text editor because script files are text files ...

Страница 43: ...to save received data INTERVAL 20 Time interval between data transmission 20μsec FREQUENCY 100 Set sampling rate frequency at 100KHz POWER ON5 External power supply 5V PULLUP ON SCL SDA line pull up ADDRESSMODE 7 Address mode 7 bit ADDRESS 50h Slave address 50h From here access to a device Write 4 bytes data from address 0008h WRITE 08h Write address 08h WRITE 00h 01h 02h 03h Write data STOP STOP ...

Страница 44: ...cess to a device Write 4 bytes data from address 0015h SSSET Activate SS signal at the Low level 06h Operation code WREN SSRESET Activate SS signal at the High level SSSET Activate SS signal at the Low level 02h 15h 00h Operation code WRITE write address 00h 01h 02h 03h Write data SSRESET Activate SS signal at the High level Confirm data is written properly Read 4 bytes data from address 0015h SSS...

Страница 45: ...en 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 SSRESET Activate SS signal at the High level POWER OFF External power supply 0V END ...

Страница 46: ... RS_STATUS WINAPI usb61_close HANDLE hUsb61Device USB61LIB_API RS_STATUS WINAPI usb61_power_control HANDLE hUsb61Device UINT fPowerState USB61LIB_API RS_STATUS WINAPI usb61_mode_change HANDLE hUsb61Device UINT fDeviceMode USHORT i2cSlaveAddr USB61LIB_API RS_STATUS WINAPI usb61_set_interval HANDLE hUsb61Device USHORT IntervalCnt USB61LIB_API RS_STATUS WINAPI usb61_gpo_write HANDLE hUsb61Device UINT...

Страница 47: ...Device 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 USB61LIB_API RS_STATUS WINAPI usb61_i2c_write_master HANDLE hUsb61De...

Страница 48: ...lly For using the usb61api ocx on VB use the tool Regsvr32 exe that is attached to the Visual BASIC The Regsvr32 exe is 32bit console application Therfore you must run it on command prompt When register usb61api ocx enter on command prompt as the follows regsvr32 usb61api ocx On Windows 7 Vista you have to start the command which run as administrator The message of registration success 2 Unregistr...

Страница 49: ...o 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 added usb61api ActiveX ...

Страница 50: ... 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 Msg that called at when event occurs See the description of the Detail of API functions ...

Страница 51: ...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 To prevent appear on the run time set the Visible in the property of the object to false ...

Страница 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 ...

Страница 53: ...c_pullup Set pullup on I2C bus Each pin of SDA and SCL usb61_i2c_bus_reset Reset I2C bus usb61_i2c_set_freq Configures I2C bus frequency usb61_i2c_set_freq_ex Configures the I2C bus frequency in kilohertz usb61_i2c_read_master Read a stream of bytes from the I2C slave device usb61_i2c_read_master_ex Read a stream of bytes from the I2C slave device with sub address usb61_i2c_write_master Write a st...

Страница 54: ...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 Return Values Handle of an REX USB61 device Function call succeeded INVALID_HANDLE_VALUE Function call failed VC RS_STATUS usb61_close HANDLE hUsb61Device VB Function Usb61Close ByVal hUsb61Device As Long As Long Definition VB NET Function Usb61Close...

Страница 55: ...TRL_ON RS_OUTPUT_3_3V Enable supply power and the voltage is 3 3V RS_PWRCTRL_ON RS_OUTPUT_5_0V Enable supply power and the voltage is 5 0V Return Values RS_SUCCESS Function call succeeded Error code refer 4 5 Function call failed VC RS_STATUS usb61_get_fw_version HANDLE hUsb61Device UCHAR pFwMajorVer UCHAR pFwMinorVer VB Function Usb61GetFwVersion ByVal hUsb61Device As Long pFWMajorVer As Byte pFW...

Страница 56: ...NET Function Usb61GetDllVersion ByVal hUsb61Device As Integer ByRef pDllMajorVer As Byte 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 Hex decimal Return Values RS_SUCCESS Function call...

Страница 57: ..._HARDWARE_INFO UCHAR DeviceMode SPI I2C mode UCHAR MasterSlaveAct Master Slave operation USHORT Frequency frequency of interface UCHAR OutputVolt Output voltage for target device RS_HARDWARE_INFO PRS_HARDWARE_INFO _RS_HARDWARE_INFO structure is defined in usb61def h sample code for VB as the dellow Dim pHardWareBuf As Byte Dim HardWareInfo As RS_HARDWARE_INFO ReDim pHardWareBuf 10 As Byte rsStatus...

Страница 58: ..._MASTER SPI master IN i2cSlaveAddr Address of I2C target device when set I2C slave mode Return Values RS_SUCCESS Function call succeeded Error code refer 4 5 Function call failed VC RS_STATUS usb61_set_interval HANDLE hUsb61Device USHORT IntervalCnt VB Function Usb61SetInterval ByVal hUsb61Device As Long ByVal IntervalCnt As Long As Long Definition VB NET Function Usb61SetInterval ByVal hUsb61Devi...

Страница 59: ...or code refer 4 5 Function call failed GPO Only on I2C mode VC RS_STATUS usb61_gpo_write HANDLE hUsb61Device UINT fPortVal VB Function Usb61GpoWrite ByVal hUsb61Device As Long ByVal fPortVal As Long As Long Definition VB NET Function Usb61GpoWrite ByVal hUsb61Device As Integer ByVal fPortVal As Integer As Integer Description Output to the GPO pin on I2C mode Parameters IN hUsb61Device handle of an...

Страница 60: ...e IN fI2cFreq the frequency of I2C bus enumerated type of freqency by using the defined symbol as the following RS_I2C_FREQ_1M 1MHz RS_I2C_FREQ_400K 400KHz RS_I2C_FREQ_100K 100KHz Return Values RS_SUCCESS Function call succeeded Error code refer 4 5 Function call failed VC RS_STATUS usb61_i2c_set_freq_ex HANDLE hUsb61Device USHORT Frequency USHORT pActualFrequency VB Function Usb61I2cSetFreqEx ByV...

Страница 61: ...yVal fI2cOption As Integer ByVal readBytes As Short ByRef pReadBuf As Object 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 IN ReadBytes the number of bytes to read OUT pReadBuf pointer to da...

Страница 62: ...r ByVal readBytes As Short ByRef pReadBuf As Object As Integer Description Read a stream of bytes from the I2C slave device with sub address 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 fr...

Страница 63: ...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 IN fI2cOption special operation as described in Table 4 2 and below IN WriteBytes the number of bytes to write IN pWriteBuf pointer to data to write Return Values RS_SUCCESS Function call succeeded Error code refer 4 5 Function call fa...

Страница 64: ..._data function to set the data for sending to master device in advance 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 RS_NOTIFY_CALLBACK notified by callback function only VC RS_NOTIFY_US...

Страница 65: ...a wParam lParam pBuf End Sub Return Values RS_SUCCESS Function call always succeeded VC RS_STATUS usb61_i2c_set_response_data HANDLE hUsb61Device USHORT ResponseBytes UCHAR pResponseBuf VB Function Usb61I2cSetResponseData ByVal hUsb61Device As Long ByVal ResponseBytes As Integer ByVal pResponseBuf As Byte As Long Definition VB NET Function Usb61I2cSetResponseData ByVal hUsb61Device As Integer ByVa...

Страница 66: ... by the Frequency parameter If the X is greater than or equal to 1020 X 1020 Y integer of X 16 pAcutualFrequency integer of 6024 Y 16 The Y is the integer part of the value that X divided by 16 The integer part of the value which 6024 divided by 16 multiple of Y will set to the pAcutualFrequency parameter If the X is greater than or equal to 256 and smaller than 1020 256 X 1020 Y integer of X 4 pA...

Страница 67: ...vice RS_SPI_SS fSlaveSelect USHORT TransmitSize UCHAR pSendBuf UCHAR pRecvBuf VB Function Usb61SpiTransmitMaster ByVal hUsb61Device As Long ByVal fSlaveSelect As Integer ByVal TransmitSize As Integer ByVal pSendBuf As Byte pRecvBuf As Byte As Long Definition VB NET Function Usb61SpiTransmitMaster ByVal hUsb61Device As Integer ByVal fSlaveSelect As Short ByVal transmitSize As Short ByVal pSendBuf A...

Страница 68: ...Buf As Object As Integer Description Write a stream of bytes to the downstream SPI slave device and read back dummy data 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 RS_SPI_SS0 Slave select pi...

Страница 69: ...XIST 22 device already opened RS_I2C_NOT_AVAILABLE 100 I2C bus not available RS_I2C_NOT_ENABLED 101 I2C not enabled RS_I2C_READ_ERROR 102 I2C read error RS_I2C_WRITE_ERROR 103 I2C wrtie error RS_I2C_BAD_CONFIG 104 I2C bad configuration RS_I2C_TIMEOUT 105 I2C bus timeout RS_I2C_DROPPED_EXCESS_BYTES 106 I2C dropped excess bytes RS_I2C_BUS_ALREADY_FREE 107 I2C bus already free RS_I2C_WRITE_COLLISION ...

Страница 70: ... Utility Select SPI I2C Bus select mode SPI or I2C Direction Read or Write Operation Frequency Enter the frequency for setting Actual Frequency Display the frequency that calculated from the above value Interval Configure Interval of 1 byte for sending I2C Target address Enter I2C target address EEPROM Address Start position for reading or writing Transfer length Transfer length for reading or wri...

Страница 71: ...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 Display receive data from I2C master Clear Erase displayed receive data View of I2CSlaveSample See the source code for programming ...

Страница 72: ...o Device address DeviceAddr 0x00 Device address 0x00 Data 0xFF A byte FF hex decimal data DataLen 1 length of data 1 usb61_i2c_write_master hDeviceHandle DeviceAddr RS_I2C_FLAG_STOP DataLen Data Finish using the REX USB61 device usb61_close hDeviceHandle hDeviceHandle NULL HANDLE hDeviceHandle Device handle BYTE DeviceAddr Device address WORD DataLen Transfer length USHORT i2cFreq Operating freque...

Страница 73: ...nsmit_master hDeviceHandle RS_SPI_SS0 DataLen pWriteBuf pReadBuf Send the Write Enable command 0x06 HANDLE hDeviceHandle Device handle WORD DataLen Transfer length USHORTspiFreq Operating frequency WORD ActualFreq Actual frequency BYTE pWriteBuf Store data for writing BYTE pReadBuf Store data for reading UINT uiFlag bit combination of clock leading or trailing polarity Get device handle hDeviceHan...

Страница 74: ...e handle hDeviceHandle usb61_open rsStatus Supplies a power supply from I2C master REX USB61 does not supply power usb61_power_control hDeviceHandle RS_PWRCTRL_OFF I2C salve address GetDlgItemText hwnd IDE_SLAVE_ADDRESS csSlaveAddr sizeof csSlaveAddr ulSlaveAddr strtoul csSlaveAddr stopstring 16 Set I2C slave mode usb61_mode_change hDeviceHandle RS_DEVMODE_I2C RS_DEVMODE_SLAVE USHORT ulSlaveAddr E...

Страница 75: ...RATOC Systems Inc All rights reserved ...

Отзывы: