[Tinyos Core WG] Meeting: September 27
Martin Turon
mturon at xbow.com
Wed Sep 27 08:41:07 PDT 2006
Yes, I disagree here. I think most programmers are more likely to write
the following code:
switch (PIN.getState()) {
case GPIO_INPUT:
break;
case GPIO_OUTPUT:
break;
default:
break;
}
Then this:
if (PIN.isOutput()) {
} else if (PIN.isInput()) {
} else {
...
}
(More specifically, the code can be written to follow the second
pattern, but with isOut/In, the programmer is more likely to leave out
the final else.)
The reason is that most programmers will assume input and output are the
only states unless there is an
enum {
GPIO_INPPUT,
GPIO_OUTPUT,
GPIO_UNDEFINED
}
This isn't a big issue for me; either interface is fine ultimately.
JMHO,
Martin
__________________________________________________
Martin Turon | Crossbow Technology, Inc.
-----Original Message-----
From: joe.polastre at gmail.com [mailto:joe.polastre at gmail.com] On Behalf
Of Joe Polastre
Sent: Wednesday, September 27, 2006 7:15 AM
To: Martin Turon
Cc: Jonathan Hui; TinyOS Core WG; Philip Levis
Subject: Re: [Tinyos Core WG] Meeting: September 27
This requires requiring the known responses (the values of the enum)
and (imho) is prone to programmer error.
-Joe
On 9/27/06, Martin Turon <mturon at xbow.com> wrote:
>
>
>
>
> What was the reaction to my suggestion of combining these into one
command:
>
> GeneralIO.getState()
>
> returns an enum of possible states: GPIO_INPUT, GPIO_OUTPUT, ...
>
> Then all about the GPIO pin can be gleaned from one call.
>
> Martin
>
>
>
> -----Original Message-----
> From: tinyos-2.0wg-bounces at Mail.Millennium.Berkeley.EDU on
> behalf of Jonathan Hui
> Sent: Tue 9/26/2006 11:09 PM
> To: Joe Polastre
> Cc: TinyOS Core WG; Philip Levis
> Subject: Re: [Tinyos Core WG] Meeting: September 27
>
>
> Okay. Makes sense to have both. So for the TEP, it suffices to say
that
> if it's neither input or output then the pin is in some other MCU
> defined state. Whether it be a hardware limitation or it is
configured
> to function with some module, etc.
>
> --
> Jonathan Hui
> jhui at archrock.com
>
> Joe Polastre wrote:
> > Not all I/O's have the capability of being both input and output.
> > Just because the pin is not input does not mean it is output, and
vice
> > versa. If my pin is an ADC (and configured as such using something
> > like ADC.bindPort by another module in the system), such as on the
> > MSP430, and I call "isInput()" and it returns false, what does that
> > mean? The pin is NOT output!
> >
> > Furthermore, if I care about whether a pin is output, writing a
> > statement like:
> > if (!call GeneralIO.isInput()) {
> > //
> > }
> > is not a natural method or intuitive of programming.
> >
> >
> >
> > -Joe
> >
> > On 9/26/06, Jonathan Hui <jhui at archrock.com> wrote:
> >>
> >> Is this to support cases where a pin is set to neither an input or
> >> output? e.g. module-func? It's easy to add. But how do you set it
to
> >> something other than input or output? Is this microcontroller
specific?
> >>
> >> --
> >> Jonathan Hui
> >> jhui at archrock.com
> >>
> >> Joe Polastre wrote:
> >> > Please add isOutput() in addition to isInput().
> >> >
> >> > On 9/26/06, Jonathan Hui <jhui at archrock.com> wrote:
> >> >>
> >> >> Checked in to the devel branch.
> >> >>
> >> >> --
> >> >> Jonathan Hui
> >> >> jhui at archrock.com
> >> >>
> >> >> Philip Levis wrote:
> >> >> > On Sep 26, 2006, at 9:54 PM, Jonathan Hui wrote:
> >> >> >
> >> >> >>
> >> >> >> Updated TEP117.
> >> >> >>
> >> >> >> - added UART
> >> >> >> - updated interfaces to match tinyos-2.x (though SpiByte
still
> >> returns
> >> >> >> error_t in the code).
> >> >> >> - added isInput() to GeneralIO.
> >> >> >>
> >> >> >> Is there something else that we agreed to update before
looking
> >> at it
> >> >> >> again?
> >> >> >>
> >> >> >
> >> >> > I don't see it in the repository.
> >> >> >
> >> >> > Phil
> >> >> >
> >> >> _______________________________________________
> >> >> Tinyos-2.0wg mailing list
> >> >> Tinyos-2.0wg at Mail.Millennium.Berkeley.EDU
> >> >>
> >>
>
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-2.0
wg
> >>
> >> >>
> >> >>
> >> >
> >>
> >
> _______________________________________________
> Tinyos-2.0wg mailing list
> Tinyos-2.0wg at Mail.Millennium.Berkeley.EDU
>
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-2.0
wg
>
>
>
>
More information about the Tinyos-2.0wg
mailing list