public final class SerialComMCHPSimpleIO extends SerialComVendorLib
Microchip Technology Inc provides a shared library known as 'SimpleIO' for communicating with their USB-UART devices. More information can be found here : http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en546923
Developers are requested to check with vendor library documentation if a particular function is supported for desired platform or not and also how does a particular API will behave. Also consider paying attention to valid values and range when passing arguments to a method.
| Modifier and Type | Field and Description |
|---|---|
static int |
BLINKFAST
Constant representing fast rate of blinking LED.
|
static int |
BLINKSLOW
Constant representing slow rate of blinking LED.
|
static int |
OFF
Constant representing off state.
|
static int |
ON
Constant representing on state.
|
static int |
TOGGLE
Constant representing toggling in operational state.
|
VLIB_FTDI_D2XX, VLIB_MCHP_SIMPLEIO, VLIB_SLABS_CP210XMANUFACTURING, VLIB_SLABS_CP210XRUNTIME, VLIB_SLABS_USBXPRESS| Constructor and Description |
|---|
SerialComMCHPSimpleIO(File libDirectory,
String vlibName,
int cpuArch,
int osType,
com.serialpundit.core.SerialComSystemProperty serialComSystemProperty)
Allocates a new SerialComMCHPSimpleIO object and extract and load shared libraries as required.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
clearPin(int pinNumber)
Executes ClearPin function of 'SimpleIO-xxxx' library.
|
boolean |
configureIO(short ioMap)
Executes ConfigureIO function of 'SimpleIO-xxxx' library.
|
boolean |
configureIoDefaultOutput(short ioMap,
short ucDefValue)
Executes ConfigureIoDefaultOutput function of 'SimpleIO-xxxx' library.
|
boolean |
configureMCP2200(byte ioMap,
long baudRateParam,
int rxLEDMode,
int txLEDMode,
boolean flow,
boolean uload,
boolean sspnd,
boolean invert)
Executes ConfigureMCP2200 function of 'SimpleIO-xxxx' library.
|
boolean |
fnInvertUartPol(int onOff)
Executes fnInvertUartPol function of 'SimpleIO-xxxx' library.
|
boolean |
fnRxLED(int mode)
Executes fnRxLED function of 'SimpleIO-xxxx' library.
|
boolean |
fnSetBaudRate(long baudRateParam)
Executes fnSetBaudRate function of 'SimpleIO-xxxx' library.
|
boolean |
fnSuspend(int onOff)
Executes fnSuspend function of 'SimpleIO-xxxx' library.
|
boolean |
fnTxLED(int mode)
Executes fnTxLED function of 'SimpleIO-xxxx' library.
|
boolean |
fnULoad(int onOff)
Executes fnULoad function of 'SimpleIO-xxxx' library.
|
String |
getDeviceInfo(int uiDeviceNumber)
Executes GetDeviceInfo function of 'SimpleIO-xxxx' library.
|
int |
getNumOfDevices()
Executes GetNoOfDevices function of 'SimpleIO-xxxx' library.
|
int |
getSelectedDevice()
Executes GetSelectedDevice function of 'SimpleIO-xxxx' library.
|
String |
getSelectedDeviceInfo()
Executes GetSelectedDeviceInfo function of 'SimpleIO-xxxx' library.
|
boolean |
hardwareFlowControl(int onOff)
Executes fnHardwareFlowControl function of 'SimpleIO-xxxx' library.
|
boolean |
initMCP2200(int vendorID,
int productID)
Executes InitMCP2200 function of 'SimpleIO-xxxx' library.
|
boolean |
isConnected()
Executes IsConnected function of 'SimpleIO-xxxx' library.
|
int |
readEEPROM(int uiEEPAddress)
Executes ReadEEPROM function of 'SimpleIO-xxxx' library.
|
int |
readPin(int pinNumber)
Executes ReadPin function of 'SimpleIO-xxxx' library.
|
int |
readPinValue(int pinNumber)
Executes ReadPinValue function of 'SimpleIO-xxxx' library.
|
int |
readPort()
Executes ReadPort function of 'SimpleIO-xxxx' library.
|
int |
readPortValue()
Executes ReadPortValue function of 'SimpleIO-xxxx' library.
|
boolean |
selectDevice(int uiDeviceNumber)
Executes SelectDevice function of 'SimpleIO-xxxx' library.
|
boolean |
setPin(int pinNumber)
Executes SetPin function of 'SimpleIO-xxxx' library.
|
boolean |
writeEEPROM(int uiEEPAddress,
short ucValue)
Executes WriteEEPROM function of 'SimpleIO-xxxx' library.
|
boolean |
writePort(int portValue)
Executes WritePort function of 'SimpleIO-xxxx' library.
|
getVendorLibInstancepublic static final int OFF
Constant representing off state.
public static final int ON
Constant representing on state.
public static final int TOGGLE
Constant representing toggling in operational state.
public static final int BLINKSLOW
Constant representing slow rate of blinking LED.
public static final int BLINKFAST
Constant representing fast rate of blinking LED.
public SerialComMCHPSimpleIO(File libDirectory, String vlibName, int cpuArch, int osType, com.serialpundit.core.SerialComSystemProperty serialComSystemProperty) throws com.serialpundit.core.SerialComException
Allocates a new SerialComMCHPSimpleIO object and extract and load shared libraries as required.
libDirectory - directory in which native library will be extracted and vendor library will be found.vlibName - name of vendor library to load and link.cpuArch - architecture of CPU this library is running on.osType - operating system this library is running on.serialComSystemProperty - instance of SerialComSystemProperty to get required java properties.SerialComUnexpectedException - if a critical java system property is null in system.SecurityException - if any java system property can not be accessed.FileNotFoundException - if the vendor library file is not found.SerialComLoadException - if any file system related issue occurs.UnsatisfiedLinkError - if loading/linking shared library fails.com.serialpundit.core.SerialComException - if initializing native library fails.public boolean initMCP2200(int vendorID,
int productID)
throws com.serialpundit.core.SerialComException
Executes InitMCP2200 function of 'SimpleIO-xxxx' library.
Configures the Simple IO class for a specific Vendor and product ID.
vendorID - USB vendor ID as Assigned by USB IF (www.usb.org).productID - USB product ID of this device belongs to.com.serialpundit.core.SerialComException - if an I/O error occurs.IllegalArgumentException - if vendorID or productID is negative or invalid number.public boolean isConnected()
throws com.serialpundit.core.SerialComException
Executes IsConnected function of 'SimpleIO-xxxx' library.
Checks with the OS to see if the current VID/PID device is connected.
com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean configureMCP2200(byte ioMap,
long baudRateParam,
int rxLEDMode,
int txLEDMode,
boolean flow,
boolean uload,
boolean sspnd,
boolean invert)
throws com.serialpundit.core.SerialComException
Executes ConfigureMCP2200 function of 'SimpleIO-xxxx' library.
Configures the device. Sets the default GPIO designation, baud rate, TX/RX Led modes, flow control.
The argument rxLEDMode and txLEDMode can be one of these constants OFF, ON, TOGGLE, BLINKSLOW, BLINKFAST defined in SerialComMCHPSimpleIO class.
ioMap - A byte which represents the input/output state of the pins (each bit may be either a 1 for
input, and 0 for output).baudRateParam - the default communication baud rate.rxLEDMode - defines the behavior of the RX Led.txLEDMode - defines the behavior of the TX Led.flow - establishes the default flow control method (false - no HW flow control, true - RTS/CTS flow
control).uload - enables/disables the GP1 pin as a USB configuration status indicator.sspnd - enables/disables the GP0 pin as a USB suspend status pin.invert - enables/disables the UART lines states: (1) Normal – Tx/Rx idle high; CTS/RTS active low,
(2) Inverted – Tx/Rx idle low; CTS/RTS active high.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean setPin(int pinNumber)
throws com.serialpundit.core.SerialComException
Executes SetPin function of 'SimpleIO-xxxx' library.
Sets the specified pin to logic '1'.
pinNumber - number of the pin which need to be set to logic 1.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean clearPin(int pinNumber)
throws com.serialpundit.core.SerialComException
Executes ClearPin function of 'SimpleIO-xxxx' library.
Sets the specified pin to logic '0'.
pinNumber - number of the pin which need to be set to logic 0.com.serialpundit.core.SerialComException - if an I/O error occurs.public int readPinValue(int pinNumber)
throws com.serialpundit.core.SerialComException
Executes ReadPinValue function of 'SimpleIO-xxxx' library.
Reads the specified pin's value/state.
pinNumber - number of the pin whose value is to be read.com.serialpundit.core.SerialComException - if an I/O error occurs.public int readPin(int pinNumber)
throws com.serialpundit.core.SerialComException
Executes ReadPin function of 'SimpleIO-xxxx' library.
Reads the specified pin's value/state.
pinNumber - number of the pin whose value is to be read.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean writePort(int portValue)
throws com.serialpundit.core.SerialComException
Executes WritePort function of 'SimpleIO-xxxx' library.
Writes the given value to the GPIO port.
portValue - byte value to set on the port.com.serialpundit.core.SerialComException - if an I/O error occurs.public int readPort()
throws com.serialpundit.core.SerialComException
Executes ReadPort function of 'SimpleIO-xxxx' library.
Reads the GPIO port as digital input.
com.serialpundit.core.SerialComException - if an I/O error occurs.public int readPortValue()
throws com.serialpundit.core.SerialComException
Executes ReadPortValue function of 'SimpleIO-xxxx' library.
Reads the GPIO port as digital input.
com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean selectDevice(int uiDeviceNumber)
throws com.serialpundit.core.SerialComException
Executes SelectDevice function of 'SimpleIO-xxxx' library.
Selects one of the active devices in the system.
uiDeviceNumber - the ID of the device to select (can have a value between 0 to (number
of devices - 1).com.serialpundit.core.SerialComException - if an I/O error occurs.public int getSelectedDevice()
throws com.serialpundit.core.SerialComException
Executes GetSelectedDevice function of 'SimpleIO-xxxx' library.
Gets the currently selected device from one of the active devices in the system.
com.serialpundit.core.SerialComException - if an I/O error occurs.public int getNumOfDevices()
throws com.serialpundit.core.SerialComException
Executes GetNoOfDevices function of 'SimpleIO-xxxx' library.
Find the number of available devices present in the system.
com.serialpundit.core.SerialComException - if an I/O error occurs.public String getDeviceInfo(int uiDeviceNumber) throws com.serialpundit.core.SerialComException
Executes GetDeviceInfo function of 'SimpleIO-xxxx' library.
Find the pathname for one of the connected devices.
uiDeviceNumber - device number about whom information is to be fetched.com.serialpundit.core.SerialComException - if an I/O error occurs.public String getSelectedDeviceInfo() throws com.serialpundit.core.SerialComException
Executes GetSelectedDeviceInfo function of 'SimpleIO-xxxx' library.
Find the pathname for currently selected device.
com.serialpundit.core.SerialComException - if an I/O error occurs.public int readEEPROM(int uiEEPAddress)
throws com.serialpundit.core.SerialComException
Executes ReadEEPROM function of 'SimpleIO-xxxx' library.
Reads a byte from the EEPROM at the given address.
uiEEPAddress - EEPROM address from where to read value.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean writeEEPROM(int uiEEPAddress,
short ucValue)
throws com.serialpundit.core.SerialComException
Executes WriteEEPROM function of 'SimpleIO-xxxx' library.
Reads a byte value to the given EEPROM address.
uiEEPAddress - EEPROM address to write at.ucValue - value to write at given address.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean fnRxLED(int mode)
throws com.serialpundit.core.SerialComException
Executes fnRxLED function of 'SimpleIO-xxxx' library.
Configures the Rx LED mode. Rx LED configuration will be stored in NVRAM.
The argument mode can be one of these constants OFF, ON, TOGGLE, BLINKSLOW, BLINKFAST defined in SerialComMCHPSimpleIO class.
mode - mode as described above.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean fnTxLED(int mode)
throws com.serialpundit.core.SerialComException
Executes fnTxLED function of 'SimpleIO-xxxx' library.
Configures the Tx LED mode. Tx LED configuration will be stored in NVRAM.
The argument mode can be one of these constants OFF, ON, TOGGLE, BLINKSLOW, BLINKFAST defined in SerialComMCHPSimpleIO class.
mode - mode as described above.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean hardwareFlowControl(int onOff)
throws com.serialpundit.core.SerialComException
Executes fnHardwareFlowControl function of 'SimpleIO-xxxx' library.
Sets the flow control to HW flow control (RTS/CTS) or No flow control.
onOff - if 1 hardware flow control will be set. if 0 no flow control will be set.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean fnULoad(int onOff)
throws com.serialpundit.core.SerialComException
Executes fnULoad function of 'SimpleIO-xxxx' library.
Configures the GP1 pin of the MCP2200 to show the status of the USB configuration.
onOff - if 1 GP1 will reflect the USB configuration status, if 0 GP1 will not reflect the USB configuration status (can be used as GPIO).com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean fnSuspend(int onOff)
throws com.serialpundit.core.SerialComException
Executes fnSuspend function of 'SimpleIO-xxxx' library.
Configures the MCP2200 to invert the UART polarity or not.
onOff - if 1 GP0 will reflect the USB Suspend/Resume states, if 0 GP0 will not reflect
the USB Suspend/Resume states (can be used as GPIO).com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean fnInvertUartPol(int onOff)
throws com.serialpundit.core.SerialComException
Executes fnInvertUartPol function of 'SimpleIO-xxxx' library.
Configures the MCP2200 to invert the UART polarity or not.
onOff - if 1 invert the UART polarity, if 0 leave the polarity as default.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean fnSetBaudRate(long baudRateParam)
throws com.serialpundit.core.SerialComException
Executes fnSetBaudRate function of 'SimpleIO-xxxx' library.
Sets the desired baudrate and it will store it into device's NVRAM.
baudRateParam - baud rate value to set.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean configureIO(short ioMap)
throws com.serialpundit.core.SerialComException
Executes ConfigureIO function of 'SimpleIO-xxxx' library.
Configures the GPIO pins for Digital Input, Digital Output.
ioMap - a byte which represents a bitmap of the GPIO configuration. A bit set to '1'
will be a digital input, a bit set to '0' will be a digital output.com.serialpundit.core.SerialComException - if an I/O error occurs.public boolean configureIoDefaultOutput(short ioMap,
short ucDefValue)
throws com.serialpundit.core.SerialComException
Executes ConfigureIoDefaultOutput function of 'SimpleIO-xxxx' library.
Configures the IO pins for Digital Input, Digital Output and also the default output latch value.
ioMap - a byte which represents a bitmap of the GPIO configuration. A bit set to '1'
will be a digital input, a bit set to '0' will be a digital output.ucDefValue - the default value that will be loaded to the output latch (effect only on the pins
configured as outputs).com.serialpundit.core.SerialComException - if an I/O error occurs.Copyright © 2017. All rights reserved.