[Tinyos-help] Receives Bytes of data from UART0 RX
Sikar Chan
sikar.chan at gmail.com
Tue Oct 23 09:52:07 PDT 2007
Would you tell me if the following part of logic is correct or not if Tmote
Sky wants to receive bytes of data from UART0 RX?
CmuCAM3 (send chars "ACK") -> Tmote Sky
Will usart.isRxIntrPending() set clear after a "usart.rx()" or by "
usart.clrRxIntr()"?
Thanks a lot
event void UsartResource.granted() {
uint32_t i;
uint8_t data,state;
call usart.enableUart();
call usart.setModeUart(&msp430_uart_default_config);
call usart.enableRxIntr();
call usart.enableTxIntr();
while (1){
call Leds.set(0); // clear the LEDs
call Leds.set (1); // Got UART
// wait for some seconds for CmuCAM3
// to get ready from restart
for (i=0;i<1400000;i++){}
call Leds.set(2); //ready to Send
call usart.tx('g');
while (! call usart.isTxEmpty());
call usart.tx('v');
while (! call usart.isTxEmpty());
call usart.tx('\r');
while (! call usart.isTxEmpty());
//call UsartResource.release();
for (i=0;i<1400000;i++){}
call Leds.set(4); //finished
for (i=0;i<1400000;i++){}
call Leds.set (7); // All Light up
//Read ACK from CmuCAM3 after sending a command
while (! call usart.isRxIntrPending()){ //wait for data in rx buffer
data = call usart.rx();
//Check ACK from CmuCAM3
if (data=='A'){
state=1;
call Leds.set(7);
}else if (data='C' && state==1){
state=2;
call Leds.set(6);
}else if (data='K' && state==2){
state=3;
call Leds.set(5);
}else if (data='\r' && state==3){
state=4;
call Leds.set(4);
}else if (data=':' && state==4){
state=5;
call Leds.set(3);
usart.clrRxIntr();
}
}
call Leds.set(2);
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20071024/dc7c167d/attachment.htm
More information about the Tinyos-help
mailing list