2

I was looking at contiki how it defines port direction for telob/sky: https://github.com/contiki-os/contiki/blob/master/cpu/msp430/dev/hwconf.h and am buffled.

I mean, in plain msp430 jurgon you could do this

P1DIR = 0x01;

to set up, for example, port 1 or

P1SEL &= (~BIT0);    // Set P1.0 SEL for GPIO 

Now, the contiki master programmer has something like:

#define HWCONF_PIN(name, port, bit) \
static CC_INLINE void name##_SELECT() {P##port##SEL &= ~(1 << bit);} 

and so on..

to make programming the port easier but I can't figure out how this enternally gets executed.

For example, how is this " name##_SELECT()" called?

I know it's a newbie question but bear with me. Thanx

Nick_K
  • 123
  • 2
  • What's `telob/sky`? – m.Alin Jul 21 '14 at 13:30
  • http://www.google.gr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB8QFjAA&url=http%3A%2F%2Fwww.eecs.harvard.edu%2F~konrad%2Fprojects%2Fshimmer%2Freferences%2Ftmote-sky-datasheet.pdf&ei=ZBjNU7CXC-bE4gTHuIHoDg&usg=AFQjCNGG__gbvdrmasvUiDREWDAjXM3ihA&sig2=y41pM-lJX7MbQVMxqk2T8g&bvm=bv.71198958,d.bGE – Nick_K Jul 21 '14 at 13:41
  • 1
    This isn't an electronics question, it's a C programming question. Specifically, the `##` operator is how you concatentate the values of symbols in the C preprocessor. Once you understand that, you should be able to work out what the macro actually does. – Dave Tweed Jul 21 '14 at 13:53
  • @DaveTweed Thanx for the hint. I was stuck at figuring out how's concatenation is defined in C preprocessor. Now, I can find out how this macro works. – Nick_K Jul 22 '14 at 07:27

0 Answers0