Online Development Notebook > Index > Programming Overview > Device Commands > Read1WireBit

Read1WireBit - Read a bit from a 1-wire bus⁄device


VERSION 1.46+ of the firmware, VERSION 58+ of the DLL

Description:

This is a function to send a 1-wire (MicroLAN) bit read on the previously selected port pin.

Command Syntax: (USBm.dll)

USBm_Reset1WireBit( device, dataarray )

The USBm_Reset1WireBit function syntax has these parts:

Part Description
device A zero-based index to address the appropriate USB device.
dataarray The function causes this variable to be changed to the value read from the bus (00h for a bit value of 0, and a value that is not 00h for a bit value of 1). Minimum array size of 8 bytes.

Remarks:

This command does not set the port direction pins or select the pin to use as the 1-wire bus - it is the Reset1Wire command that does this.


VB Declaration

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

VB Example

Dim dataarray(8) As Byte
    USBm_Read1WireBit 3, dataarray(0)

This code fragment addresses U4x1 device #3, and reads a bit from the 1-wire device. The read value is in "dataarray(0)". 00h for a bit value of 0, and a value that is not 00h for a bit value of 1


C Prototype

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

C Example

USBm_Read1WireBit ( 3, dataarray );

This code fragment addresses U4x1 device #3, and reads a bit from the 1-wire device. The read value is in "dataarray[0]". 00h for a bit value of 0, and a value that is not 00h for a bit value of 1


RobotBASIC

usbm_Read1WireBit(ne_DeviceNumber)

Returns a bit value that is read from the 1wire device.


Raw Command  Format:

Byte Number Description
0 1Fh: Read1WireCmd
1 <not used>
2 Byte⁄bit - 0 = write byte, 1 = write bit. Bit feature for VERSION 1.30+ of the firmware
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 is not used.

Byte 2 selects reading either a byte or a bit.

This command does not set the port direction pins or select the pin to use as the 1-wire bus - it is the Reset1Wire command that does this.

Raw Command Response Format:

Byte Number Description
0 1Fh: Read1WireCmd
1 Data - Byte⁄bit read.
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 is the byte⁄bit data that was read. Byte 2 through byte 7 are unused.

If a 0 bit is read, data = 0. If a 1 bit is read, data is not 0.


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 85 of 126)

This page is created with TreePad