SunSPOT API V5.0


com.sun.spot.peripheral
Class FiqInterruptDaemon

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

public class FiqInterruptDaemon
extends Object
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
 String getDriverName()
          An identifying name for the driver (e.g.
 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)
          Replace the existing handler for power controller time alarms with a user-supplied handler.
 IEventHandler setButtonHandler(IEventHandler handler)
          Replace the existing handler for reset button presses with a user-supplied handler.
 IEventHandler setExternalPowerHandler(IEventHandler handler)
          Replace the existing handler for external power applied events with a user-supplied handler.
 IEventHandler setLowBatteryHandler(IEventHandler handler)
          Replace the existing handler for low battery warnings with a user-supplied handler.
 IEventHandler setPowerOffHandler(IEventHandler handler)
          Replace the existing handler for poweroff with a user-supplied handler.
 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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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()

setAlarmHandler

public IEventHandler setAlarmHandler(IEventHandler handler)
Replace the existing handler for power controller time alarms with a user-supplied handler. 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 returned, so you can chain your new handler to that one.

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

setButtonHandler

public IEventHandler setButtonHandler(IEventHandler handler)
Replace the existing handler for reset button presses with a user-supplied handler. The default handler calls VM.stopVM(0). The previous handler is returned, so you can chain your new handler to that one.

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

setPowerOffHandler

public IEventHandler setPowerOffHandler(IEventHandler handler)
Replace the existing handler for poweroff with a user-supplied handler. 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 returned, so you can chain your new handler to that one.

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

setLowBatteryHandler

public IEventHandler setLowBatteryHandler(IEventHandler handler)
Replace the existing handler for low battery warnings with a user-supplied handler. The default handler logs a message if spot.diagnostics is set. The previous handler is returned, so you can chain your new handler to that one.

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

setExternalPowerHandler

public IEventHandler setExternalPowerHandler(IEventHandler handler)
Replace the existing handler for external power applied events with a user-supplied handler. The default handler logs a message if spot.diagnostics is set. The previous handler is returned, so you can chain your new handler to that one.

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

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 V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.