Initialize device, ports
Description:
This is a function that initializes both ports and resets the device’s internal latches.
There are two 8-bit ports on the U401⁄421⁄U451, 16 I⁄O lines. The 16 total I⁄O lines can be set to inputs or outputs on an individual per-line basis. The initial state of the ports on power up is that all of the 16 lines are set to be inputs.
Command Syntax: (USBm.dll)
USBm_InitPorts( device )
The USBm_InitPorts function syntax has these parts:
Part | Description |
device | A zero-based index to address the appropriate USB device. |
Remarks:
Calling USBm_InitPorts will reset the ports to input and will clear the internal latches.
Calling USBm_InitPortsU401 will reset the ports to input and will clear the internal latches.
Calling USBm_InitPortsU421 will reset the ports to input and will clear the internal latches.
Calling USBm_InitPortsU451 will reset port A to input, port B to output and will clear the internal latches.
There is nothing stopping you from calling the USBm_InitPortsU421 when connected to a U401, for instance. Or any of the other combinations. The different flavors of init are provided for user convenience. USBm_InitPortsU451 is currently the only different one in the group as it sets port B to all output.
USBm_InitPorts is in all versions of the DLL. The variations are present in version 65 or newer.
VB Declaration
Public Declare Function USBm_InitPorts _ Lib “USBm.dll” _ (ByVal device As Byte) _ As Integer Public Declare Function USBm_InitPortsU401 _ Lib “USBm.dll” _ (ByVal device As Byte) _ As Integer Public Declare Function USBm_InitPortsU421 _ Lib “USBm.dll” _ (ByVal device As Byte) _ As Integer Public Declare Function USBm_InitPortsU451 _ Lib “USBm.dll” _ (ByVal device As Byte) _ As Integer |
VB Example
USBm_InitPorts (3) |
This code fragment initializes the ports of device number three.
C Prototype
int USBm_InitPorts( unsigned char device ); int USBm_InitPortsU401( unsigned char device ); int USBm_InitPortsU421( unsigned char device ); int USBm_InitPortsU451( unsigned char device ); |
C Example
USBm_InitPorts( 0 ); |
This code fragment initializes the ports of device number 0 (the first U4x1 device that is found).
RobotBASIC
usbm_InitPorts(ne_DeviceNumber)
Returns true if successful, false otherwise. This function resets the A and B ports as Input Ports, which is the default state upon connecting the device to the PC.
Raw Command Format:
Byte Number | Description |
0 | 00h: InitPortsCmd |
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 | 00h: InitPortsCmd |
1 | <not used> |
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 through byte 7 are unused.
Raw Command Example Usage:
Sending the InitPortsCmd command to the device will reset the ports.