usbHostEnable (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, NX-400

Firmware version:

1.00.00


The usbHostEnable function enable/disable support for USB devices. When disabled the USB power is removed from the USB host port.

Please consult the technical manual for details on how many USB host ports a specific device offers.

 

The USB host is disabled as default, and must be enabled before devices can be discovered using usbHostEnumerate.

 

 

Input:

port : SINT  (1 .. 127)

The USB host port to enable/disable. (1=usb1, 2=usb2, etc.)

 

enable : BOOL (false/true)

TRUE:

Enables USB host support.

FALSE:

Disables USB host support.

 

Returns: INT

1

- Success.

0

- The function is not supported.

-1

- The USB host port is not present.

 

Declaration:

FUNCTION usbHostEnable : INT;
VAR_INPUT
  port : SINT;
  enable : BOOL;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  doEnable : BOOL; | enable/disable USB host
END_VAR;
 
VAR_OUTPUT
  isEnabled : BOOL := TRUE; | is USB host enabled
END_VAR;
 
PROGRAM test;
BEGIN
  IF doEnable XOR isEnabled THEN
    // Enable/Disable USB host
    usbHostEnable(port:=1,enable:=doEnable);
    isEnabled := doEnable;
  END_IF;
END;
END_PROGRAM;