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

Description:

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:

Part Description
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.

Remarks:

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.

Signal types

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.


VB Declaration

Public Declare Function USBm_Wire2Control _
    Lib "USBm.dll" _
        (ByVal device As Byte, _
               ByRef dataarray As Byte) _
    As Integer

VB Example

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.


C Prototype

int USBm_Wire2Control( unsigned char device, unsigned char *data );

C Example

 


RobotBASIC

-TBD-


Raw Command  Format:

Byte Number Description
0 18h: Wire2Control
1 Signal
2 <not used>
3 <not used>
4 <not used>
5 <not used>
6 <not used>
7 <not used>

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:

Byte Number Description
0 18h: Wire2Control
1 Data read from line
2 <not used>
3 <not used>
4 <not used>
5 <not used>
6 <not used>
7 <not used>

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:

-TBD-


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

Previous  |  Next ]     [ Up  |  First  |  Last ]     (Article 78 of 126)

This page is created with TreePad