SunSPOT API V6.0


com.sun.spot.peripheral
Class FiqInterruptDaemon

java.lang.Object
  extended by com.sun.spot.resources.Resource
      extended by com.sun.spot.peripheral.FiqInterruptDaemon
All Implemented Interfaces:
IDriver, IFiqInterruptDaemon, IResource, Runnable

public class FiqInterruptDaemon
extends Resource
implements Runnable, IDriver, IFiqInterruptDaemon

The FiqInterruptDaemon gives access to the handlers used for various notifications from the power controller. A handler that implements IEventHandler can be supplied to handle a specific event, replacing the existing handler (all events have a default handler). Note that the handler is called at MAX_SYS_PRIORITY. Your code should reduce the priority as appropriate.


Constructor Summary
FiqInterruptDaemon(IPowerController powerController, IAT91_AIC aic, ISpotPins spotPins)
           
 
Method Summary
 void addAlarmHandler(IEventHandler handler)
          Add a handler for power controller time alarms.
 void addButtonHandler(IEventHandler handler)
          Add a handler for reset button presses.
 void addExternalPowerHandler(IEventHandler handler)
          Add a handler for external power applied events.
 void addLowBatteryHandler(IEventHandler handler)
          Add a handler for low battery warnings.
 void addPowerOffHandler(IEventHandler handler)
          Add a handler for poweroff.
 void addSensorBoardHandler(IEventHandler handler)
          Add a handler for sensorboard events.
 String getDriverName()
          An identifying name for the driver (e.g.
 void removeAlarmHandler(IEventHandler handler)
          Remove a handler for power controller time alarms.
 void removeButtonHandler(IEventHandler handler)
          Remove a handler for reset button presses.
 void removeExternalPowerHandler(IEventHandler handler)
          Remove a handler for external power applied events.
 void removeLowBatteryHandler(IEventHandler handler)
          Remove a handler for low battery warnings.
 void removePowerOffHandler(IEventHandler handler)
          Remove a handler for power off.
 void removeSensorBoardHandler(IEventHandler handler)
          Remove a handler for sensorboard events.
 void run()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 IEventHandler setAlarmHandler(IEventHandler handler)
          Deprecated. Please use addAlarmHandler() instead.
 IEventHandler setButtonHandler(IEventHandler handler)
          Deprecated. Please use addButtonHandler() instead.
 void setExitOnButtonPress(boolean enable)
          Specify whether the VM should exit when the button is pressed.
 IEventHandler setExternalPowerHandler(IEventHandler handler)
          Deprecated. Please use addExternalPowerHandler() instead.
 IEventHandler setLowBatteryHandler(IEventHandler handler)
          Deprecated. Please use addLowBatteryHandler() instead.
 IEventHandler setPowerOffHandler(IEventHandler handler)
          Deprecated. Please use addPowerOffHandler() instead.
 IEventHandler setSensorBoardHandler(IEventHandler handler)
          Deprecated. Please use addSensorBoardHandler() instead.
 void setUp()
          Activate or reactivate the driver (after a deep sleep or when another driver refused to deep sleep).
 void shutDown()
          Notify the driver that the VM is about to exit.
 void startThreads()
           
 boolean tearDown()
          Deactivate the driver (usually in preparation for deep sleep).
 
Methods inherited from class com.sun.spot.resources.Resource
addTag, getTags, getTagValue, hasTag, removeTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.resources.IResource
addTag, getTags, getTagValue, hasTag, removeTag
 

Constructor Detail

FiqInterruptDaemon

public FiqInterruptDaemon(IPowerController powerController,
                          IAT91_AIC aic,
                          ISpotPins spotPins)
Method Detail

startThreads

public void startThreads()

run

public void run()
Description copied from interface: Runnable
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

The general contract of the method run is that it may take any action whatsoever.

Specified by:
run in interface Runnable
See Also:
Thread.run()

setExitOnButtonPress

public void setExitOnButtonPress(boolean enable)
Specify whether the VM should exit when the button is pressed.

Specified by:
setExitOnButtonPress in interface IFiqInterruptDaemon
Parameters:
enable - if true the VM will exit when the button is pressed.

addAlarmHandler

public void addAlarmHandler(IEventHandler handler)
Add a handler for power controller time alarms. It is very unlikely that you will want to create a handler for time alarms. The default handler logs a message if spot.diagnostics is set.

Specified by:
addAlarmHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use

removeAlarmHandler

public void removeAlarmHandler(IEventHandler handler)
Description copied from interface: IFiqInterruptDaemon
Remove a handler for power controller time alarms.

Specified by:
removeAlarmHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to remove

addButtonHandler

public void addButtonHandler(IEventHandler handler)
Add a handler for reset button presses. The default handler calls VM.stopVM(0).

Specified by:
addButtonHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use

removeButtonHandler

public void removeButtonHandler(IEventHandler handler)
Description copied from interface: IFiqInterruptDaemon
Remove a handler for reset button presses.

Specified by:
removeButtonHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to remove

addPowerOffHandler

public void addPowerOffHandler(IEventHandler handler)
Add a handler for poweroff. The power off event occurs when the user uses the reset button to turn off the SPOT. The handler has about 400ms to do work before the power goes away. The default handler does nothing.

Specified by:
addPowerOffHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use

removePowerOffHandler

public void removePowerOffHandler(IEventHandler handler)
Description copied from interface: IFiqInterruptDaemon
Remove a handler for power off.

Specified by:
removePowerOffHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to remove

addLowBatteryHandler

public void addLowBatteryHandler(IEventHandler handler)
Add a handler for low battery warnings. The default handler logs a message if spot.diagnostics is set.

Specified by:
addLowBatteryHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use

removeLowBatteryHandler

public void removeLowBatteryHandler(IEventHandler handler)
Description copied from interface: IFiqInterruptDaemon
Remove a handler for low battery warnings.

Specified by:
removeLowBatteryHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to remove

addExternalPowerHandler

public void addExternalPowerHandler(IEventHandler handler)
Add a handler for external power applied events. The default handler logs a message if spot.diagnostics is set.

Specified by:
addExternalPowerHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use

removeExternalPowerHandler

public void removeExternalPowerHandler(IEventHandler handler)
Description copied from interface: IFiqInterruptDaemon
Remove a handler for external power applied events.

Specified by:
removeExternalPowerHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to remove

addSensorBoardHandler

public void addSensorBoardHandler(IEventHandler handler)
Add a handler for sensorboard events. The default handler logs a message if spot.diagnostics is set.

Specified by:
addSensorBoardHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use

removeSensorBoardHandler

public void removeSensorBoardHandler(IEventHandler handler)
Description copied from interface: IFiqInterruptDaemon
Remove a handler for sensorboard events.

Specified by:
removeSensorBoardHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to remove

setAlarmHandler

public IEventHandler setAlarmHandler(IEventHandler handler)
Deprecated. Please use addAlarmHandler() instead.

Add a handler for power controller time alarms. It is very unlikely that you will want to create a handler for time alarms. The default handler logs a message if spot.diagnostics is set. The previous handler is no longer returned.

Specified by:
setAlarmHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use
Returns:
null

setButtonHandler

public IEventHandler setButtonHandler(IEventHandler handler)
Deprecated. Please use addButtonHandler() instead.

Add a handler for reset button presses. The default handler calls VM.stopVM(0). The previous handler is no longer returned.

Specified by:
setButtonHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use
Returns:
null

setPowerOffHandler

public IEventHandler setPowerOffHandler(IEventHandler handler)
Deprecated. Please use addPowerOffHandler() instead.

Add a handler for power off. The power off event occurs when the user uses the reset button to turn off the SPOT. The handler has about 400ms to do work before the power goes away. The default handler does nothing. The previous handler is no longer returned.

Specified by:
setPowerOffHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use
Returns:
null

setLowBatteryHandler

public IEventHandler setLowBatteryHandler(IEventHandler handler)
Deprecated. Please use addLowBatteryHandler() instead.

Add a handler for low battery warnings. The default handler logs a message if spot.diagnostics is set. The previous handler is no longer returned.

Specified by:
setLowBatteryHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use
Returns:
null

setExternalPowerHandler

public IEventHandler setExternalPowerHandler(IEventHandler handler)
Deprecated. Please use addExternalPowerHandler() instead.

Add a handler for external power applied events. The default handler logs a message if spot.diagnostics is set. The previous handler is no longer returned.

Specified by:
setExternalPowerHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use
Returns:
null

setSensorBoardHandler

public IEventHandler setSensorBoardHandler(IEventHandler handler)
Deprecated. Please use addSensorBoardHandler() instead.

Add a handler for sensorboard events. The default handler logs a message if spot.diagnostics is set. The previous handler is no longer returned.

Specified by:
setSensorBoardHandler in interface IFiqInterruptDaemon
Parameters:
handler - the new handler to use
Returns:
null

getDriverName

public String getDriverName()
Description copied from interface: IDriver
An identifying name for the driver (e.g. "AIC" for the AIC driver).

Specified by:
getDriverName in interface IDriver
Returns:
The driver name

setUp

public void setUp()
Description copied from interface: IDriver
Activate or reactivate the driver (after a deep sleep or when another driver refused to deep sleep). The driver should claim all the resources it needs from other drivers and reinitialize its hardware. It should also restore any state saved before tearDown.

Drivers are set up in the order that they registered, so that in general user drivers will be set up after any underlying system drivers.

Specified by:
setUp in interface IDriver

shutDown

public void shutDown()
Description copied from interface: IDriver
Notify the driver that the VM is about to exit.

Specified by:
shutDown in interface IDriver

tearDown

public boolean tearDown()
Description copied from interface: IDriver
Deactivate the driver (usually in preparation for deep sleep). The driver should store any important state and release all resources it has claimed from other drivers.

Drivers are torn down in the inverse order to that in which they registered, so that in general user drivers will be torn down before any underlying system drivers.

Specified by:
tearDown in interface IDriver
Returns:
True if the driver is able to deactivate, false if it cannot deactivate (e.g. due to being busy with a data transfer). If any driver returns false, no deep sleep occurs and all other drivers will be reactivated.

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.