On Monday 07 May 2007 19:37, liangjing wrote:
> Hi Steve ,
> I have read the TEP 117 and found that it is a tinyos 2.0 version ,
> but our platform is mica2 and a tinyos 1.0 version . I am sorry that I
> don't write this in advance and I don't find Low-Level I/O
> documentation in www.tinyos.net/tinyos-1.x/doc so the code doesn't
> seem to fit with our platform, maybe I need to write our own button
> interface and module comparable with HplMsp430GeneralIOC and
> GpioInterruptC in your code, is that right ? Thank you again for your
> specific advice.
Sorry, I should have been specific in my original feedback about which tos
version I was referring. I'm woefully unprepared to give advice on TinyOS
1.1, as I've never really used it.
If memory, serves, tos1 platforms define and use TOSH macros to manipulate IO
pins. It looks like $TOSDIR/platforms/avrmote/avrhardware.h has these
definitions for all the avr-based motes. You can find examples of their use
in your specific platform directory, $TOSDIR/platforms/mica2. I can't help
you at all about managing external interrupts in tos1, but I'm sure there's
example code within the distribution.
Sorry,
Steve
>
> Best Wishes
> Jing
>
> 2007/5/7, Steve McKown <[EMAIL PROTECTED]>:
> > Hi Jing,
> >
> > On Monday 07 May 2007 02:18, liangjing wrote:
> > > 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?
> >
> > Perhaps I misunderstood what you wanted to do? I though you wanted to
> > perform
> > some action when a button on the mote was pressed. Therefore,
> > Int.fired() is
> > signalled by the button. Have you read TEP 117? It describes how TinyOS
> > handles low level IO and is available as a link from the www.tinyos.net
> > home page. If it is unclear, perhaps you should make a test program out
> > of the code snippet and do some experimentation on your own.
> >
> > Here's a summary of what the code snippet I sent is doing:
> >
> > HplMsp430GeneralIOC provides an msp430 specific interface for every
> > digital IO
> > available on the uC hardware. HplMsp430InterruptC provides an msp430
> > specific interface for every digital IO which is capable of generating an
> > interrupt on state change of its pin.
> >
> > The example assumes the button is connected to the msp430's P2.0 pin,
> > which is
> > associated with bit 0 of port 2 of the msp430 (sometimes called port20 or
> > port2.0, etc.). The physical button is configured such that the button
> > presents an active high state to the pin normally and active low when the
> > button is pressed. The hardware could be configured differently, of
> > course.
> >
> > SomeButtonC instantiates one each of GeneralIOC (Pin) and GpioInterruptC
> > (Int)
> > components that convert the respective msp430 specific interfaces into
> > platform independent ones.
> >
> > The boot process calls SomeButtonP's Init.init(), which configures the
> > iopin.
> > This function first makes the iopin an input, then sets the interrupt to
> > fire
> > on its rising edge (i.e. a low to high transition of the pin's input
> > state).
> >
> > Given the hardware assumption above, this means the interrupt actually
> > fires as the button is released.
> >
> > Code present in core TinyOS and the configuration in SomeButtonC ensure
> > that when the interrupt is fired, the SomeButtonP's Int.fired() event is
> > signalled. This code can then deal with the event as is appropriate for
> > the application.
> >
> > Steve
> >
> > > 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
>
> !DSPAM:463fd74a41049716080633!
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help