jAER project on SourceForge

net.sf.jaer.hardwareinterface.usb.silabs
Class SiLabsC8051F320

java.lang.Object
  extended by net.sf.jaer.hardwareinterface.usb.silabs.SiLabsC8051F320
All Implemented Interfaces:
AEMonitorInterface, BiasgenHardwareInterface, HardwareInterface, USBInterface

public class SiLabsC8051F320
extends java.lang.Object
implements AEMonitorInterface, BiasgenHardwareInterface

Acquires data from the UNI-USE simple USB AER board that uses Silicon Labs (http://www.silabs.com) C8051F320 controller and SiLabs USBXPress device and host driver firmware and software.

The DLL's USBAEMonitor.dll and SiUSBXp.dll must be accessible for windows programs. Generally, this means they must be somewhere on the PATH, for example, in WINNT\system32, or they can be in the directory the program is started. It is generally simplest to just put the folders on the PATH variable.

Events are captured as 16 bit addresses and 32 bit timestamps with 1us tick. To use this class, construct an instance of USB1AEMonitor, then open() it. Each time you want to capture available events, call acquireAvailableEventsFromDriver(), which returns the packet of events.

overrunOccurred() can be used to see if there was a driver overrun.

NOTE: only supports a single device at a time now. (JNI limitations).

Author:
tobi

Field Summary
protected  AEChip chip
           
 boolean eventAcquisitionEnabled
           
static int MAX_BYTES_PER_BIAS
           
static java.lang.String NATIVE_DLL_FILENAME
           
 java.beans.PropertyChangeEvent newEventPropertyChange
          event supplied to listeners when new events are collected.
static java.lang.String USBXPRESS_DLL_FILENAME
           
 
Fields inherited from interface net.sf.jaer.hardwareinterface.usb.USBInterface
PID_THESYCON_END, PID_THESYCON_START, VID_THESYCON
 
Constructor Summary
SiLabsC8051F320()
          Creates a new instance of USB1AEMonitor.
 
Method Summary
 AEPacketRaw acquireAvailableEventsFromDriver()
          Gets available events from driver and return them in a new AEPacketRaw.
 void addAEListener(AEListener listener)
          adds a listener for new events captured from the device
 void close()
          Closes the device and frees the internal device handle.
 void flashConfiguration(Biasgen biasgen)
          flashes the configuration in non-volatile storage so they will be reloaded on reset or powerup.
 byte[] formatConfigurationBytes(Biasgen biasgen)
          Formats and returns the bytes that should be sent to set a particular configuration.
 int getAEBufferSize()
          The buffer size is fixed at 16k events on this USBXPress device
 AEChip getChip()
          Sets the AEChip that this interface is acquiring events for
 short getDID()
          not implmented for SiLabs devices
 int getEstimatedEventRate()
          Only valid after acquireAvailableEventsFromDriver().
 AEPacketRaw getEvents()
          returns the last events acquired by AEMonitorInterface.acquireAvailableEventsFromDriver()
 int getMaxCapacity()
          the max capacity of this USB1 bus interface with SiLabs overhead is ~1 Mb/sec/4 bytes/event/2 ~ 150keps
 int getNumEventsAcquired()
          Returns the number of events acquired by the last call to acquireAvailableEventsFromDriver()
 short getPID()
          not implmented for SiLabs devices
 java.lang.String[] getStringDescriptors()
          return the string USB descriptors for the device.
 java.beans.PropertyChangeSupport getSupport()
           
 int getTimestampTickUs()
           
 java.lang.String getTypeName()
          get text name of interface, e.g.
 short getVID()
          not implmented for SiLabs devices
 int[] getVIDPID()
          not implmented for SiLabs devices
 boolean isEventAcquisitionEnabled()
          returns state of event acquisition flag.
 boolean isOpen()
           
 int nativeResetTimestamps()
           
 void open()
          Opens the device driver and starts acquiring events.
 boolean overrunOccurred()
          Is true if an overrun occured in the driver (>16k events) the last time acquireAvailableEventsFromDriver() was called.
 void removeAEListener(AEListener listener)
          remove a PropertyChangeListener for new events
 void resetTimestamps()
          resets the timestamps to zero
 void sendConfiguration(Biasgen biasgen)
          Sends the configuration values to the hardware.
 void setAEBufferSize(int AEBufferSize)
          on this USBXPress device you cannot set the buffer size, so this call generates a warning print
 void setChip(AEChip chip)
          Sets the AEChip that this interface is acquiring events for
 void setEventAcquisitionEnabled(boolean eventAcquisitionEnabled)
          Enables event acquisition, e.g.
 void setPowerDown(boolean powerDown)
          toggles the powerDown pin correctly to ensure on-chip biasgen is powered up.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

chip

protected AEChip chip

NATIVE_DLL_FILENAME

public static final java.lang.String NATIVE_DLL_FILENAME
See Also:
Constant Field Values

USBXPRESS_DLL_FILENAME

public static final java.lang.String USBXPRESS_DLL_FILENAME
See Also:
Constant Field Values

eventAcquisitionEnabled

public boolean eventAcquisitionEnabled

MAX_BYTES_PER_BIAS

public static final int MAX_BYTES_PER_BIAS
See Also:
Constant Field Values

newEventPropertyChange

public final java.beans.PropertyChangeEvent newEventPropertyChange
event supplied to listeners when new events are collected. this is final because it is just a marker for the listeners that new events are available

Constructor Detail

SiLabsC8051F320

public SiLabsC8051F320()
Creates a new instance of USB1AEMonitor. Note that it is possible but probably bad to construct several instances and use each of them to open and read from the same device. This class would probably better be a singleton until multiple devices are supported.

Method Detail

setChip

public void setChip(AEChip chip)
Description copied from interface: AEMonitorInterface
Sets the AEChip that this interface is acquiring events for

Specified by:
setChip in interface AEMonitorInterface
Parameters:
chip - the chip

getChip

public AEChip getChip()
Description copied from interface: AEMonitorInterface
Sets the AEChip that this interface is acquiring events for

Specified by:
getChip in interface AEMonitorInterface
Returns:
the chip

nativeResetTimestamps

public int nativeResetTimestamps()

open

public void open()
          throws HardwareInterfaceException
Opens the device driver and starts acquiring events.

Specified by:
open in interface HardwareInterface
Throws:
USBAEMonitorException - if there is a problem. Diagnostics are printed to stdout in the native code.
HardwareInterfaceException - if there is a problem. Diagnostics are printeds.
See Also:
close()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

acquireAvailableEventsFromDriver

public AEPacketRaw acquireAvailableEventsFromDriver()
                                             throws HardwareInterfaceException
Gets available events from driver and return them in a new AEPacketRaw. overrunOccurred() will be true if these was an overrun of the host USBXPress driver buffers (>16k events).

AEListeners are called if new events have been collected.

Specified by:
acquireAvailableEventsFromDriver in interface AEMonitorInterface
Returns:
packet of raw events
Throws:
USBAEMonitorException
HardwareInterfaceException - .
See Also:
.

getNumEventsAcquired

public int getNumEventsAcquired()
Returns the number of events acquired by the last call to acquireAvailableEventsFromDriver()

Specified by:
getNumEventsAcquired in interface AEMonitorInterface
Returns:
number of events acquired

resetTimestamps

public void resetTimestamps()
resets the timestamps to zero

Specified by:
resetTimestamps in interface AEMonitorInterface

close

public void close()
Closes the device and frees the internal device handle. Never throws an exception.

Specified by:
close in interface HardwareInterface

getAEBufferSize

public int getAEBufferSize()
The buffer size is fixed at 16k events on this USBXPress device

Specified by:
getAEBufferSize in interface AEMonitorInterface
Returns:
16k

overrunOccurred

public boolean overrunOccurred()
Is true if an overrun occured in the driver (>16k events) the last time acquireAvailableEventsFromDriver() was called. This flag is cleared by the next acquireAvailableEventsFromDriver(). If there is an overrun, the events grabbed are the most ancient; events after the overrun are discarded. The timestamps continue on but will probably be lagged behind what they should be.

Specified by:
overrunOccurred in interface AEMonitorInterface
Returns:
true if there was an overrun.

setAEBufferSize

public void setAEBufferSize(int AEBufferSize)
on this USBXPress device you cannot set the buffer size, so this call generates a warning print

Specified by:
setAEBufferSize in interface AEMonitorInterface
Parameters:
AEBufferSize - size of buffer in events

getStringDescriptors

public java.lang.String[] getStringDescriptors()
Description copied from interface: USBInterface
return the string USB descriptors for the device. By USB convention, the first string is the manufactuer, the second is product, and the last is the unique serial number. The serial number may not be implemented, in which case a null string may be the third string or the length of the returned array may only be 2.

Specified by:
getStringDescriptors in interface USBInterface
Returns:
String[] of USB descriptors

getSupport

public java.beans.PropertyChangeSupport getSupport()

addAEListener

public void addAEListener(AEListener listener)
adds a listener for new events captured from the device

Specified by:
addAEListener in interface AEMonitorInterface
Parameters:
listener - the listener. It is called with a PropertyChangeEvent when new events are received by a call to acquireAvailableEventsFromDriver().
See Also:
acquireAvailableEventsFromDriver()

removeAEListener

public void removeAEListener(AEListener listener)
Description copied from interface: AEMonitorInterface
remove a PropertyChangeListener for new events

Specified by:
removeAEListener in interface AEMonitorInterface
Parameters:
listener - to remove

getVIDPID

public int[] getVIDPID()
not implmented for SiLabs devices

Specified by:
getVIDPID in interface USBInterface
Returns:
null

isOpen

public boolean isOpen()
Specified by:
isOpen in interface HardwareInterface
Returns:
true if interface is open, false otherwise

flashConfiguration

public void flashConfiguration(Biasgen biasgen)
                        throws HardwareInterfaceException
Description copied from interface: BiasgenHardwareInterface
flashes the configuration in non-volatile storage so they will be reloaded on reset or powerup.

Specified by:
flashConfiguration in interface BiasgenHardwareInterface
Parameters:
biasgen - holds the configuration values
Throws:
HardwareInterfaceException

sendConfiguration

public void sendConfiguration(Biasgen biasgen)
                       throws HardwareInterfaceException
Description copied from interface: BiasgenHardwareInterface
Sends the configuration values to the hardware. The configuration can include bias values (both for on- and off-chip sources), configuration bits, etc.

Specified by:
sendConfiguration in interface BiasgenHardwareInterface
Parameters:
biasgen - the object that holds the configuration.
Throws:
HardwareInterfaceException

setPowerDown

public void setPowerDown(boolean powerDown)
                  throws HardwareInterfaceException
toggles the powerDown pin correctly to ensure on-chip biasgen is powered up. Chip may have been plugged in without being powered up. If powerdown is true, simply sets powerdown high. If powerdown is false, powerdown is toggled high and then low, to make sure a nagative transistion occurs. This transistion is necessary to ensure the startup circuit starts up the masterbias again.

Specified by:
setPowerDown in interface BiasgenHardwareInterface
Parameters:
powerDown - true to power OFF the biasgen, false to power on
Throws:
HardwareInterfaceException

isEventAcquisitionEnabled

public boolean isEventAcquisitionEnabled()
returns state of event acquisition flag. this may not have been sent to the device yet.

Specified by:
isEventAcquisitionEnabled in interface AEMonitorInterface
Returns:
true if event acquisition is enabled

setEventAcquisitionEnabled

public void setEventAcquisitionEnabled(boolean eventAcquisitionEnabled)
                                throws HardwareInterfaceException
Description copied from interface: AEMonitorInterface
Enables event acquisition, e.g. sends vendor commands to enable transfers, starts buffer pool threads. This method can be called, e.g. from acquireAvailableEventsFromDriver method to ensure driver is acquiring events.

Specified by:
setEventAcquisitionEnabled in interface AEMonitorInterface
Parameters:
eventAcquisitionEnabled - true to enable sending events from device
Throws:
HardwareInterfaceException

getTypeName

public java.lang.String getTypeName()
Description copied from interface: HardwareInterface
get text name of interface, e.g. "CypressFX2" or "SiLabsC8051F320"

Specified by:
getTypeName in interface HardwareInterface

getMaxCapacity

public int getMaxCapacity()
the max capacity of this USB1 bus interface with SiLabs overhead is ~1 Mb/sec/4 bytes/event/2 ~ 150keps

Specified by:
getMaxCapacity in interface AEMonitorInterface
Returns:
max capacity in events/sec

getEstimatedEventRate

public int getEstimatedEventRate()
Only valid after acquireAvailableEventsFromDriver().

Specified by:
getEstimatedEventRate in interface AEMonitorInterface
Returns:
event rate in events/sec as computed from last acquisition

getTimestampTickUs

public final int getTimestampTickUs()
Specified by:
getTimestampTickUs in interface AEMonitorInterface
Returns:
timestamp tick in us

getEvents

public AEPacketRaw getEvents()
Description copied from interface: AEMonitorInterface
returns the last events acquired by AEMonitorInterface.acquireAvailableEventsFromDriver()

Specified by:
getEvents in interface AEMonitorInterface
Returns:
the packet of raw events

getDID

public short getDID()
not implmented for SiLabs devices

Specified by:
getDID in interface USBInterface
Returns:
0

getPID

public short getPID()
not implmented for SiLabs devices

Specified by:
getPID in interface USBInterface
Returns:
0

getVID

public short getVID()
not implmented for SiLabs devices

Specified by:
getVID in interface USBInterface
Returns:
0

formatConfigurationBytes

public byte[] formatConfigurationBytes(Biasgen biasgen)
Description copied from interface: BiasgenHardwareInterface
Formats and returns the bytes that should be sent to set a particular configuration.

Specified by:
formatConfigurationBytes in interface BiasgenHardwareInterface
Parameters:
biasgen - the source of the configuration.
Returns:
the array to be sent.

jAER project on SourceForge