[Tinyos-help] [Fwd: Re: [Tinyos-2-commits] i need help to interface external device with micaz motes using UART interface]

moorthyd at ee.iitb.ac.in moorthyd at ee.iitb.ac.in
Tue Jun 12 22:08:52 PDT 2007


---------------------------- Original Message ----------------------------
Subject: Re: [Tinyos-2-commits] i need help to interface external device
with micaz motes using UART interface From:    "Philip Levis"
<pal at cs.stanford.edu>
Date:    Wed, June 13, 2007 7:06 am
To:      moorthyd at ee.iitb.ac.in
--------------------------------------------------------------------------

Please send questions to tinyos-help.

Phil

On Jun 10, 2007, at 10:23 PM, moorthyd at ee.iitb.ac.in wrote:

> Dear all,
>
>
> i need help to interface external device with micaz motes using UART
interface
>
>
> here ia my configuration file:
> ---------------------------------
>
> #include "hardware.h"
> #include <Atm128Uart.h>
> configuration   LeafAppc {
>
>
> /*provides
> 			{
> 				interface HplAtm128Uart  ;
> 			}*/
> 	}
>
> implementation
>
> {
> 	components LedsC,HplAtm128UartC,Atm128Uart0C,LeafAppcM ;
> 	//new TimerMilliC() as Timer0;
>
> 	 //LeafAppcM -> MainC.Boot;
> 	LeafAppcM.Leds -> LedsC;
>
> 	//LeafAppcM. Uart0Init->HplAtm128UartP.Uart0Init;
>
> 	LeafAppcM. HplUart0 ->HplAtm128UartC.HplUart0 ;
>
> 	LeafAppcM. Uart0RxControl->HplAtm128UartC.Uart0RxControl;
>
> 	LeafAppcM. Uart0TxControl ->HplAtm128UartC.Uart0TxControl;
>
> 	//LeafAppcM.StdControl->Atm128Uart0C;
>
> 	LeafAppcM.UartByte ->Atm128Uart0C;
>
> 	LeafAppcM.UartStream ->Atm128Uart0C;
>
> 	//LeafAppcM.Timer0 -> Timer0;
>
>
> }
>
> here is my module file:
> ------------------------
>
>
> module LeafAppcM
>
> {
>
>
> 		provides
> 			{
> 				interface StdControl;
> 			}
>
> 		uses
> 			{   //interface Boot;
> 				interface Leds;
> 				//interface Init as Uart0Init;
> 				interface HplAtm128Uart as HplUart0;
> 				interface StdControl as Uart0RxControl;
> 				interface StdControl as Uart0TxControl;
> 				//interface StdControl  ;
> 				interface UartByte;
> 				interface UartStream;
>
> 				//interface Timer<TMilli> as Timer0;
>
> 			}
>
>
>
> }
>
>
>
> implementation 	{
>
> //task void Data_send();
> //bool isTxEmpty;
> uint8_t uartbuf[25] = {55,00,55,00,00,00,55,55,0xff};
> uint8_t rxbuf[25] ;
> uint16_t len_buf = 16;
> //uint8_t size=55,size1=5,i=10;
>
>  //event void Boot.booted()
>   command error_t StdControl.start()
>   {
>
> 		bool isTxEmpty,TRUE_leaf = 1,FALSE_leaf =0;
> 		call Uart0TxControl.start();
> 		call Uart0RxControl.start();
> 		call UartStream.enableReceiveInterrupt();
> 		call HplUart0. enableRxIntr();
> 		call HplUart0. enableTxIntr();
> 		call Leds.led0On();
> 		//call Timer0.startPeriodic(500);
>
> 		if (!isTxEmpty)
> 		{
> 			isTxEmpty =TRUE_leaf ;
>
> 			atomic {
> 			call HplUart0.enableTxCIE();
> 			call Leds.led1On();
> 			//for (i=0; i < size1 ; i++)
> 			if (call UartStream.send(uartbuf, len_buf))
> 			return SUCCESS;
> 			isTxEmpty = FALSE_leaf;
> 				   }
> 		  return FAIL;
> 		}
>
>   }
>
>
>
>
> 	command error_t StdControl.stop()
> 	{
> 		call Uart0TxControl.stop();
> 		call Uart0RxControl.stop();
> 		call HplUart0. disableRxIntr();
> 		call HplUart0. disableTxIntr();
> 		call HplUart0.disableTxCIE();
> 		call UartStream.disableReceiveInterrupt();
> 		call Leds.led1On();
> 		return SUCCESS;
> 	}
>
> 	async event void HplUart0.rxDone(uint8_t data)
> 	{
> 	}
> 	async event void HplUart0.txDone()
> 	{
> 	call Leds.led2On();
> 	}
> 	async event void UartStream.receivedByte(uint8_t byte)
> 	{
> 	}
>
> 	async event void UartStream. receiveDone(uint8_t *buf, uint16_t len,
> error_t error)
> 	{
> 		if (error== SUCCESS)
> 			{
> 			call Leds.led1Toggle();
> 			}
> 	}
>
> 	async event void UartStream.sendDone(uint8_t *buf, uint16_t len,
> error_t
> error)
> 		{
> 		if (error== SUCCESS)
> 			{
> 			call Leds.led2Toggle();
> 			}
> 		}
>
>
> }
>
>
> thank you very much.
>
> bye,
> moorthy.T
>
>
> _______________________________________________
> Tinyos-2-commits mailing list
> Tinyos-2-commits at mail.millennium.berkeley.edu
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/
> tinyos-2-commits





More information about the Tinyos-help mailing list