Hi, Steve
Thank you for your reply. And I have some doubt about the interface
Int. The demo gives some code defining command Init.init() and async
event void Int.fired(),but I still don't know how to trigger the
event, and I don't find it in the configuration file either. Could you
help me explain it further?
Best Regards & Many Thanks
Jing
2007/4/30, Steve McKown <[EMAIL PROTECTED]>:
Hi Jing,
On Monday 30 April 2007 01:13, liangjing wrote:
> In the experiment we want to trigger an event or task that implement
> the related work after switching off the button ? I don't know if
> there exists an interrupt procedure in Tinyos since I don't find some
> app using the kind of interrupt.Please help me.
In tos, to handle an interrupt from a button, create and configure a
GpioInterrupt component and wire it to the io pin to which the button is
attached. Here's an example for msp430 platform where the button is
connected to port 2.0 of the uC. Other arches are probably similar.
configuration SomeButtonC {
provides interface Init;
provides interface ...
}
implementation
{
components SomeButtonP;
Init = SomeButtonP;
components HplMsp430GeneralIOC, new Msp430GpioC() as UserImpl;
UserImpl -> HplMsp430GeneralIOC.Port20;
SomeButtonP.Pin = UserImpl;
components HplMsp430InterruptC, new Msp430InterruptC() as UserInt;
UserInt.HplInterrupt -> HplMsp430InterruptC.Port20;
SomeButtonP.Int = UserInt;
}
And the module code...
module SomeButtonP {
uses interface GeneralIO as Pin;
uses interface GpioInterrupt as Int;
provides interface Init;
provides interface ...
}
implementation {
command error_t Init.init()
{
call Pin.makeInput();
call Int.enableRisingEdge();
return SUCCESS;
}
async event void Int.fired()
{
/* deal with button interrupt here, for example:
signal SomeInterface.button();
or
post buttonFired();
etc.
*/
}
}
You should think carefully about what constitutes a valid interrupt from a
user button. For simple "command type" user buttons, I usually disable the
interrupt as soon as one is received (in Int.fired or its call chain), then
have the higher level code re-enable the interrupt when it is prepared to
service another button press.
Steve
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help