[Tinyos-2-commits] i need help for uart interface with micaz motes

moorthyd at ee.iitb.ac.in moorthyd at ee.iitb.ac.in
Tue Jun 5 04:53:55 PDT 2007


hi all,

i need help to solve uart interface with micaz motes. here i am attached
mu program.

-----------------------
configuration file
-------------------------
#include "hardware.h"
#include <Atm128Uart.h>
configuration   LeafAppc {


	}

implementation

{
	components LedsC,MainC,HplAtm128UartC,Atm128Uart0C,LeafAppcM ;


	 LeafAppcM -> MainC.Boot;
	LeafAppcM.Leds -> LedsC;



	LeafAppcM. HplUart0 ->HplAtm128UartC.HplUart0 ;

	LeafAppcM. Uart0RxControl->HplAtm128UartC.Uart0RxControl;

	LeafAppcM. Uart0TxControl ->HplAtm128UartC.Uart0TxControl;



	LeafAppcM.UartByte ->Atm128Uart0C;

	LeafAppcM.UartStream ->Atm128Uart0C;



}

-----------------------------------
module implementation file
------------------------------




module LeafAppcM

{


		provides
			{
				interface StdControl;
			}

		uses
			{   interface Boot;
				interface Leds;

				interface HplAtm128Uart as HplUart0;
				interface StdControl as Uart0RxControl;
				interface StdControl as Uart0TxControl;

				interface UartByte;
				interface UartStream;



			}



}



implementation 	{




uint8_t rxbuf[25] ;
uint16_t len_buf = 16;
uint8_t bit=55;

event void Boot.booted()

  {

	call Leds.led2On();


  }
command error_t StdControl.start()
	{

		call Leds.led2On();

		call Uart0TxControl.start();
		call Uart0RxControl.start();
		call UartStream.enableReceiveInterrupt();
		call HplUart0. enableRxIntr();
		call HplUart0. enableTxIntr();

		if (call HplUart0.isTxEmpty())
		 {
		   call HplUart0.enableTxCIE();
		   call Leds.led1On();
		   call  HplUart0.tx( bit);
		   }

	}

	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();
			}
		}


}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: LeafAppc.nc
Type: application/octet-stream
Size: 726 bytes
Desc: not available
Url : http://mail.millennium.berkeley.edu/pipermail/tinyos-2-commits/attachments/20070605/c0bc8568/LeafAppc.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LeafAppcM.nc
Type: application/octet-stream
Size: 2321 bytes
Desc: not available
Url : http://mail.millennium.berkeley.edu/pipermail/tinyos-2-commits/attachments/20070605/c0bc8568/LeafAppcM.obj


More information about the Tinyos-2-commits mailing list