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

ReadLatches - Read internal pin-change latches


VERSION 3.35+ of the firmware, VERSION 65+ of the DLL

Description:

This is a function to return the values of the internal pin-change latches. After reading changed latches the latches are reset.

Command Syntax: (USBm.dll)

USBm_ReadLatches( device, dataarray )

The USBm_ReadLatches function syntax has these parts:

Part Description
device A zero-based index to address the appropriate USB device.
dataarray A byte array where the returned data will be stored. Minimum size of the array must be 4 bytes

Remarks:

Byte 0 and 2 of the modified array contain the latched value for a bit transition from 0xFF on port A (B) to any other value. If your port is pulled high with resistors (external or internal) and a button press pulls the pin low then these are the bytes to use. If your port is normally low and a button press sets a line high, then the latch data returned in bytes 1 and 3 are the appropriate bytes.


VB Declaration

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

VB Example

Dim dataarray(4) As Byte
    USBm_ReadLatches 3, dataarray(0)

This code fragment addresses U4x1 device #3, and reads the latches into data array "dataarray".


C Prototype

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

C Example

unsigned char dataarray[4];   
USBm_ReadLatches( 3, *dataarray );

This code fragment addresses U4x1 device #3, and reads the latches into data array "dataarray".


RobotBASIC

 


Raw Command  Format:

Byte Number Description
0 0Fh: ReadLatches
1 <not used>
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 through byte 7 are unused.

Raw Command Response Format:

Byte Number Description
0 0Fh: ReadLatches
1 Port A normally pulled high.
2 Port A normally pulled low.
3 Port B normally pulled high.
4 Port B normally pulled low.
5 <not used>
6 <not used>
7 <not used>

Raw Command Response Format Details:

Byte 0 contains the command. Byte 1 and 3 contain the latched value for a bit transition from 0xFF on port A (B) to any other value. If your port is pulled high with resistors (external or internal) and a button press pulls the pin low then these are the bytes to use. If your port is normally low and a button pres sets a line high, then the latch data returned in bytes 2 and 4 are the appropriate bytes.


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

This page is created with TreePad