Contiki OS:如何从SKY-mote的GIO引脚读取

时间:2015-04-23 10:31:46

标签: c sensor contiki

我将外部传感器连接到天空mote的GIO端口。如何从天空mote的GIO引脚获取数据。

PS:我正在使用contiki os

P2DIR&= ~0x08; // set the port as input
P2SEL &= ~0x08;                  
P2REN |=  0x08;               
if( (P2IN & 0x08) == 0)
{
 SEND_STRING(&s->sout,"UP");
}
else
{
 SEND_STRING(&s->sout,"Down");
}

帮助我如何从contiki os中的天空mote的GIO引脚读取数据

提前谢谢。

1 个答案:

答案 0 :(得分:0)

此代码用于获取GIO2 OF SKY-MOTE

P2DIR&= ~0x08; // set the port as input
P2SEL &= ~0x08;                  
P2REN |=  0x08;               
if( (P2IN & 0x08) == 0)
{
 SEND_STRING(&s->sout,"UP");
}
else
{
 SEND_STRING(&s->sout,"Down");
}