Hi Andres,

On Sun, Dec 2, 2012 at 3:19 PM, Andres Mabini <andres.mabi...@gmail.com>wrote:

> Hi everyone,
>
> I am trying to understand how TinyOS works at the low level, and I hope
> you guys could help me out with some "dumb questions"
>

These are beginner questions, but really good questions.


>
> I've been studying app.c and I noticed that for turning the LEDs on in
> Telosb, the only main difference between LED0 and LED1 is in the
> HplMsp430GeneralIOP__37__IO__clr/HplMsp430GeneralIOP__36__IO__clr
> functions. In HplMsp430GeneralIOP__37__IO__clr, it is
>

If you want to check the app.c, you might want to use the debug extra (make
telosb debug instead of make telosb). That will disable the preprocessor,
and you would see nice const names instead of values.


>
> * (volatile uint8_t * )49U &= ~(0x01 << 5);
>
> while in HplMsp430GeneralIOP__36__IO__clr it is
>
> * (volatile uint8_t * )49U &= ~(0x01 << 4);
>
> Here are my questions
>
> 1. Where is the source code that dictates this(the "4" for led0 and "5"
> for led1)? I can't seem to find it anywhere - even after following the
> files specified in app.c.
>

/tos/system/LedsC connects 3 GeneralIO interface from PlatformLedsC to
LedsP. LedsP does the actual on/off/toggle, and PlatformLedsC defines where
these leds are connected to. You can find this PlatformLedsC at
/tos/platforms/telosa (telosb reuses a lot of code from telosa).
I'm not really familiar with msp430 gpio (I always used avr), but it seems
to use a gpio, you need two component: Msp430GpioC, which converts the
HplMsp430GeneralIO interface to the platform independent GeneralIO, and
HplMsp430GeneralIOC, which provides the low-level gpio. HplMsp430GeneralIOC
uses HplMsp430GeneralIOP, which uses the registers of the msp430 mcu (with
some macros and pointers, for shorter code). All of these files are at
/tos/chips/msp430/pins.
I hope it's understandable, but check the source codes, it's self
explanatory.


> 2. Is it possible to to modify the code at the lowest level so that the
> red LED would light up even though it is led1.turnOn that was called(e.g.
> is it possible to switch the wiring of the LEDs)? I know that there is a
> more elegant "higher level" way of doing this, but for the sake of
> experimentation, I would like to try it by modifying low level stuff.
>

Sure. You can change this in LedsC, LedsP, PlatformLedsC,
HplMsp430GeneralIOC and HplMsp430GeneralIOP. But LedsC  and LedsP are in
/tos/system, so if you change this, it will affect every platform.
HplMsp430GeneralIOC and HplMsp430GeneralIOP are in /tos/chips/msp430, so it
will affect any msp 430 based mote. PlatformLedsC is in
/tos/platform/telosa, it will only affect telosa and telosb. If you only
want to change telosb, copy PlatformLedsC to /tos/platforms/telosb, and
modify it there.


>
> 3. In the lines specified above, what does 49U stand for? Does it stand
> for the state of the MSP430 pins?
>

It should be an msp430 register address. If you use the debug extra, it
should be readable, because it's defined in the msp430-libc.


>
> 4. Is it possible to "halt" the compilation process midway so that app.c
> is produced but not yet the binary? Idea is, I would like to edit app,c by
> hand, and then compile it to become the binary.
>

Probably. You should dig deep in the makefiles to do this...
And don't make this a habit, it's really hard to reproduce or commit to a
version control system like svn or git.

Andras Biro
Software Engineer
Unicomp Ltd.
http://ucmote.com




>
> Thanks in advance!
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to