Difference between revisions of "Boomerang UART0 Sample"

From TinyOS Wiki
Jump to: navigation, search
m (Added to the "Boomerang" Category)
 
Line 41: Line 41:
  
 
Sample code can be downloaded from here: [http://sing.stanford.edu/klueska/tos_wiki_files/Moteiv_Boomerang_Uart0_Sample.tar.gz Moteiv_Boomerang_Uart0_Sample.tar.gz]
 
Sample code can be downloaded from here: [http://sing.stanford.edu/klueska/tos_wiki_files/Moteiv_Boomerang_Uart0_Sample.tar.gz Moteiv_Boomerang_Uart0_Sample.tar.gz]
 +
 +
 +
[[Category:Boomerang]]

Latest revision as of 12:05, 6 April 2011

Usage

Tmote Sky uses the MSP430 microcontroller and exposes the I2C and UART0 lines on the 10-pin expansion connector. Using the I2C and UART0 expansion bus requires care because these lines are physically shared with the SPI data bus that connects the radio to the microcontroller. This document explains how to use the UART0 bus safely.

Boomerang includes a resource arbitration system that allows a TinyOS component to request a resource and be notified later when the resource becomes available. For the UART, the resource is called MSP430ResourceUART0C. It is a generic component and may be used as many times as necessary. To use this component, create a new resource in your configuration:

components new MSP430ResourceUART0C();

Your module may use one of four interfaces provided by MSP430ResourceUARTC. These include ResourceCmd, ResourceCmdAsync, Resource, and ResourceValidate. For this example, we use ResourceCmd.

In your configuration, wire to the Resource:

Impl.ResourceCmd -> MSP430ResourceUART0C;

In your module, use the resource interface

uses interface ResourceCmd;

When you want to use the resource, you must request it through the ResourceCmd interface. Two functions are provided: request() which may only be called from task context and deferRequest() which may be called from interrupt (async) context and will give the resource to your module in task context. To use either of these functions, call them with the null resource handle, RESOURCE_NONE

call ResourceCmd.request( RESOURCE_NONE );

When the resource is available for your use, the granted event is signalled:

event void ResourceCmd.granted() {
  // do work here
  call ResourceCmd.release();
}

When finished with the resource, you must explicitly release() the resource for others to use it.

Sample Application

An example application can be downloaded below. The application acquires the UART, sends a byte at 9600baud and releases the UART. In parallel, messages are being sent and received over the radio, which shares its physical communication channel with the UART using the MSP430's USART0 hardware module. The example code is a compressed archive. With a Boomerang system, you can try it using the following commands in a Cygwin window:

tar xvzf Moteiv_Boomerang_Uart0_Sample.tar.gz
cd TestUart0
make tmote install

You can monitor the output using a scope on pin 4 of the 10 pin expansion header on Tmote Sky.

Sample code can be downloaded from here: Moteiv_Boomerang_Uart0_Sample.tar.gz