whoa....I just sent this to someone else...
Why all the sudden interest in m'dot I/O?
anyway:
I haven't used or even looked at the dots but I think they use the
same controller and basic layout as the mica2/z, so the attached
code is a _very_ basic full port access mechanism for the mica2.
Hopefully it will be a good starting point.
MS
vipul surve wrote:
Dear all,
I recently started using motes and TinyOS. As a small
project I need some suggestions from you. I would be more than happy
if you could give me some.
My project involves using mica2dot motes working at
916Mhz . I need to send and receive a logic 1(3 V) single using the
i/o channels of the mote.
I would be making use of two mica2dot motes, first to send the logic 1
and another to receive it using a radio link.
I need to use 4 pins as input and 4 as output on each mote.(that is 8
pins on each port to be used)
I would like to know if this is possible to achieve at if so could you
suggest me some templates which I could use to begin with.
I read the hardware.h file for mica2dot and thought of making a few
changes there as setting ports as input or output. But then I had a
doubt as when I make changes there it reflects to all mica2dot? dosent
it.
How can I achieve this.
I would be very pleased if you could give me some suggestions.
Thanking you,
Vipul Surve
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
/** HPLPortCM.nc -- Implement HPLPort interface on ATMEGA port C.
**/
module HPLPortCM
{
provides interface HPLPort;
}
implementation
{
/**
* Initialize the module and port.
* @param direction -- 0 == input, !0 == output
* @return Always returns SUCCESS.
*/
command result_t HPLPort.init( uint8_t direction )
{
// Set pin directions...
if( direction == 0 )
{
// DDRC==0 is input and turn on internal pullups
outp( 0x00, DDRC );
outp( 0xff, PORTC );
}
else
{
// DDRC==1 is output and turn off outputs
outp( 0x00, PORTC );
outp( 0xff, DDRC );
}
return SUCCESS;
}
/**
* read the value of an input port
* @return 8 bit unsigned value.
*/
command uint8_t HPLPort.read()
{
return inp( PINC );
}
/**
* write the given 8 bit value to the port.
* @param value -- data to write
* @return Always returns SUCCESS.
*/
command result_t HPLPort.write( uint8_t value )
{
outp( value, PORTC );
return SUCCESS;
}
}
/** HPLPort.nc -- Interface for reading/writing a raw I/O port.
**/
interface HPLPort
{
/**
* Initialize the module and port.
* @param direction -- 0 == input, !0 == output
* @return Always returns SUCCESS.
*/
command result_t init( uint8_t direction );
/**
* read the value of an input port
* @return 8 bit unsigned value.
*/
command uint8_t read();
/**
* write the given 8 bit value to the port.
* @param value -- data to write
* @return Always returns SUCCESS.
*/
command result_t write( uint8_t value );
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help