com.motorola.oem.hapi
Class GpioCounterConfig

java.lang.Object
  extended by com.motorola.oem.hapi.GpioInterruptConfig
      extended by com.motorola.oem.hapi.GpioCounterConfig

public class GpioCounterConfig
extends GpioInterruptConfig

 The class encapsulates all Gpio Counter relevant configuration data. 
Gpio Counter feature that commands the device to count interrupts, and notify GpioCounterListener by reaching a predefined number of interrupts, defined in GpioCounterExpiryValue.





In order to configure GpioInput to receive counter event, this instance of GpioInput must get GpioCounterConfig object through GpioInput's GpioInput.enableCounter(com.motorola.oem.hapi.GpioCounterConfig) method. Counter type (COUNTER_TYPE_CYCLICAL or COUNTER_TYPE_ONE_SHOT) and counter expiry value configuration
is possible.
Counter type default value will be COUNTER_TYPE_CYCLICAL, unless a another is configured by accessing setGpioCounterType(int) method.
Counter expiry default value will be 50, unless another is configured through the
setGpioCounterExpiryValue(int) method.

GPIOs which can be configured as counters are:

GPIO14 - pin number 19 on 70 PIN connector
GPIO15 - pin number 17 on 70 PIN connector

Set GpioCounterListener object to handle events is mandatory.
Handle GpioCounter expiry value event in GpioCounterListener.onCounterExpired(int).

Note: For GpioCounterConfig object interrupt Debounce is disabled, any attempt to set Debounce
through API methods inherited from class GpioInterruptConfig will be discarded.



Field Summary
static int COUNTER_TYPE_CYCLICAL
          A static final variable specifying COUNTER_TYPE_CYCLICAL .
static int COUNTER_TYPE_ONE_SHOT
          A static final variable specifying COUNTER_TYPE_ONE_SHOT.
static int COUNTER_TYPE_UNDEFINED
          A static final variable specifying COUNTER_TYPE_UNDEFINED.
 
Fields inherited from class com.motorola.oem.hapi.GpioInterruptConfig
DEBOUNCE_FAST, DEBOUNCE_NORMAL, NOTIFICATION_TYPE_BOTH_EDGES, NOTIFICATION_TYPE_HIGH_TO_LOW, NOTIFICATION_TYPE_LOW_TO_HIGH
 
Constructor Summary
GpioCounterConfig(GpioCounterListener listener)
          Constructs a new GpioCounterConfig with the listener specified.
 
Method Summary
 int getGpioCounterExpiryValue()
          Gets GpioCounterExpiryValue member.
 int getGpioCounterType()
          Gets GpioCounterType member.
 void setGpioCounterExpiryValue(int counterExpiryValue)
          Sets GpioCounterExpiryValue member.
 void setGpioCounterListener(GpioCounterListener listener)
          Reconfigures an existing listener.
 void setGpioCounterType(int counterType)
          Sets GpioCounterType member.
 
Methods inherited from class com.motorola.oem.hapi.GpioInterruptConfig
enableDebounce, getDebounce, getNotificationType, isDebounceEnabled, setDebounce, setGpioInterruptListener, setNotificationType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COUNTER_TYPE_UNDEFINED

public static final int COUNTER_TYPE_UNDEFINED
A static final variable specifying COUNTER_TYPE_UNDEFINED.

See Also:
Constant Field Values

COUNTER_TYPE_CYCLICAL

public static final int COUNTER_TYPE_CYCLICAL
A static final variable specifying COUNTER_TYPE_CYCLICAL .

See Also:
Constant Field Values

COUNTER_TYPE_ONE_SHOT

public static final int COUNTER_TYPE_ONE_SHOT
A static final variable specifying COUNTER_TYPE_ONE_SHOT.

See Also:
Constant Field Values
Constructor Detail

GpioCounterConfig

public GpioCounterConfig(GpioCounterListener listener)
Constructs a new GpioCounterConfig with the listener specified. In order to use counters' events, one must implement GpioCounterListener and pass it on to the constructor.

Parameters:
listener - GpioCounterListener
Method Detail

setGpioCounterListener

public void setGpioCounterListener(GpioCounterListener listener)
Reconfigures an existing listener. Used to reconfigure a listener that exists in the object, in order to use GpioCounterConfig in a sequence of counter enabling, with the same object but different listeners.

Parameters:
listener - External object to receive counter events

setGpioCounterExpiryValue

public void setGpioCounterExpiryValue(int counterExpiryValue)
                               throws GpioException
Sets GpioCounterExpiryValue member.

Parameters:
counterExpiryValue - Counter expiry value; Legal range 1 - 2^31-1
Throws:
GpioException - Calling setGpioCounterExpiryValue with illegal parameters. Error code - OEMException.ILLEGAL_PARAM_ERROR

getGpioCounterExpiryValue

public int getGpioCounterExpiryValue()
Gets GpioCounterExpiryValue member.

Returns:
Gpio Counter Expiry Value

setGpioCounterType

public void setGpioCounterType(int counterType)
                        throws GpioException
Sets GpioCounterType member.

Parameters:
counterType - Counter types: COUNTER_TYPE_CYCLICAL,COUNTER_TYPE_ONE_SHOT
Throws:
GpioException - Calling setGpioCounterType with illegal parameters. Error code - OEMException.ILLEGAL_PARAM_ERROR

getGpioCounterType

public int getGpioCounterType()
Gets GpioCounterType member.

Returns:
Gpio Counter Type