|Online Development Notebook > Index > Programming Overview > Device Commands > Wire2Control|
Wire2Control - Send a 2-wire signal to the 2-wire port
VERSION 3.35+ of the firmware, VERSION 65+ of the DLL
This function sends a specific signal to the 2-wire port setting the data and clock lines as defined by this command. Signals are specific patterns of setting the 2-wire clock and data lines high or low. For I2C this command is good for initialization of the clock and data lines, for generating a start sequence, and for making a stop sequence.
Command Syntax: (USBm.dll)
USBm_Wire2Control( device, dataarray )
The USBm_Wire2Control function syntax has these parts:
|device||A zero-based index to address the appropriate USB device.|
|dataarray||The "signal" for the 2-wire data and clock lines. Minimum array size of 6.|
PA.3 is the 2-wire data line, while PA.2 is the 2-wire clock line. For 2-wire communication these two lines are set to be open collector⁄drain lines. Since they are only able to be set to zero by the U4x1 device, they must be pulled high (to 5V) by an external resistor in order to have a high state. This is often called "active low and passive high." For typical 2-wire communication (such as I2C) a 4700 ohm (4.7 kohm) resistor will suffice. For I2C communication the first three signal types (0, 1, 2) are useful for generating the initial I2C state, the start condition, and the stop condition. For transfer of clocked bytes of data, use Wire2Data.
0 - Set clock and data to open-drain, set data high, set clock high. (Good for I2C initialization.)
1 - Set data high, clock high, data low, clock low. (Good for I2C start signal.)
2 - Set data low, clock high, data high. (Good for I2C stop signal.)
3 - Set clock low, data low.
4 - Set data high, clock high.
5 - Set data high
6 - Set data low.
7 - Set clock high.
8 - Set clock low.
9 - Return data line.
10 - Return clock line.
|Public Declare Function USBm_Wire2Control _|
Lib "USBm.dll" _
(ByVal device As Byte, _
ByRef dataarray As Byte) _
|Dim dataarray(8) As Byte|
dataarray(0) = 0
USBm_Wire2Control 0, dataarray(0)
This code fragment sends a "0" signal (I2C init) to device 0.
|int USBm_Wire2Control( unsigned char device, unsigned char *data );|
Raw Command Format:
Raw Command Format Details:
Byte 0 contains the command. Byte 1 contains the 2-wire signal for clock and data lines. Byte 2 through byte 7 are unused.
Raw Command Response Format:
|1||Data read from line|
Raw Command Response Format Details:
Byte 0 contains the command. Byte 1 contains the current value of either the 2-wire data line or the 2-wire clock line for the signals that return data. Byte 2 through byte 7 are unused.
Raw Command Example Usage:
Hardware: U401 USB Interface U421 USB Interface U451 USB Interface
Programming: USBm DLL Programming Download Files
Application Notes: U4x1 Application Notes Misc Applications and Information FAQ
While every effort has been made to make sure that the information posted on this site is correct, the author can not be held liable for any damages whatsoever for losses as a result of the application of this information. Use this information at your own risk.
USBmicro can design your custom and semi-custom USB product. Email about USB design can be directed to " Robert " at usbmicro.com.
Copyright © USBmicro, L.L.C., 2002-2010