📄 platform creation and testing - tinyos documentation wiki.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0062)http://docs.tinyos.net/index.php/Platform_Creation_and_Testing -->
<HTML lang=en dir=ltr xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Platform Creation and Testing - TinyOS Documentation Wiki</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META
content="Platform Creation and Testing,TinyOS Tutorials,Writing Low-Power Applications"
name=keywords><LINK href="/favicon.ico" rel="shortcut icon"><LINK
title="TinyOS Documentation Wiki (English)" href="/opensearch_desc.php"
type=application/opensearchdescription+xml rel=search>
<STYLE type=text/css media="screen, projection">@import url( /skins/common/shared.css?97 );
@import url( /skins/monobook/main.css?97 );
</STYLE>
<LINK media=print
href="Platform Creation and Testing - TinyOS Documentation Wiki.files/commonPrint.css"
type=text/css rel=stylesheet><!--[if lt IE 5.5000]><style type="text/css">@import "/skins/monobook/IE50Fixes.css?97";</style><![endif]--><!--[if IE 5.5000]><style type="text/css">@import "/skins/monobook/IE55Fixes.css?97";</style><![endif]--><!--[if IE 6]>
<STYLE type=text/css>@import url( /skins/monobook/IE60Fixes.css?97 );
</STYLE>
<![endif]--><!--[if IE 7]><style type="text/css">@import "/skins/monobook/IE70Fixes.css?97";</style><![endif]--><!--[if lt IE 7]>
<SCRIPT
src="Platform Creation and Testing - TinyOS Documentation Wiki.files/IEFixes.js"
type=text/javascript></SCRIPT>
<META http-equiv=imagetoolbar content=no><![endif]-->
<SCRIPT type=text/javascript>/*<![CDATA[*/var skin = "monobook";var stylepath = "/skins";var wgArticlePath = "/index.php/$1";var wgScriptPath = "";var wgScript = "/index.php";var wgServer = "http://docs.tinyos.net";var wgCanonicalNamespace = "";var wgCanonicalSpecialPageName = false;var wgNamespaceNumber = 0;var wgPageName = "Platform_Creation_and_Testing";var wgTitle = "Platform Creation and Testing";var wgAction = "view";var wgRestrictionEdit = [];var wgRestrictionMove = [];var wgArticleId = "48";var wgIsArticle = true;var wgUserName = null;var wgUserGroups = null;var wgUserLanguage = "en";var wgContentLanguage = "en";var wgBreakFrames = false;var wgCurRevisionId = "386";/*]]>*/</SCRIPT>
<SCRIPT
src="Platform Creation and Testing - TinyOS Documentation Wiki.files/wikibits.js"
type=text/javascript><!-- wikibits js --></SCRIPT>
<SCRIPT
src="Platform Creation and Testing - TinyOS Documentation Wiki.files/index.php"
type=text/javascript><!-- site js --></SCRIPT>
<STYLE type=text/css>@import url( /index.php?title=MediaWiki:Common.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=MediaWiki:Monobook.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=-&action=raw&gen=css&maxage=18000 );
</STYLE>
<!-- Head Scripts -->
<SCRIPT
src="Platform Creation and Testing - TinyOS Documentation Wiki.files/ajax.js"
type=text/javascript></SCRIPT>
<META content="MSHTML 6.00.2900.3268" name=GENERATOR></HEAD>
<BODY class="mediawiki ns-0 ltr page-Platform_Creation_and_Testing">
<DIV id=globalWrapper>
<DIV id=column-content>
<DIV id=content><A id=top name=top></A>
<H1 class=firstHeading>Platform Creation and Testing</H1>
<DIV id=bodyContent>
<H3 id=siteSub>From TinyOS Documentation Wiki</H3>
<DIV id=contentSub></DIV>
<DIV id=jump-to-nav>Jump to: <A
href="http://docs.tinyos.net/index.php/Platform_Creation_and_Testing#column-one">navigation</A>,
<A
href="http://docs.tinyos.net/index.php/Platform_Creation_and_Testing#searchInput">search</A></DIV><!-- start content -->
<P>Last updated 21 December 2007 </P>
<P>A new platform wiring debug tool with only two code files. </P>
<P>We have a fairly simple goal -- to harness GPIOs so we can control them and
see what they are inputting on a MSP430 based platform. Seeing means displaying,
so we will use the three LEDs found on many MSP430 platforms to display a 3 bit
binary number corresponding to pin0 through Pin7 that we wish to test. This
module is for MSP430 testing purposes so will never exist as Hardware
Independent HIL modules. This code helps with testing whether a new printed
circuit board has traces going to the right MSP430 IO ports. </P>
<P>With a HAL, (hardware adaptation layer), configuration and code file plus a
HPL, (hardware presentation layer), configuration and code file we would have 4
files. Since we reuse the HplMsp430GeneralIO interface provided by
HplMsp430GeneralIOC.nc with new names and add no new functions, we can do
without configuration or code file, (beyond all the core tinyOS modules), for
this exercise. TestMSP430platfIOC.nc, the configuration file, maps connections
from any port names predefined in HplMsp430GeneralIOC.nc to our desired group of
eight ports named Pin0 - Pin7. This test is done on a new platform, defined by a
new directory added to the tinyos source code tree: for example
/opt/tinyos-2.x/tos/platforms/ecosens1. Some necessary parts for a new platform
variant were copied from telosb: PlatformC.nc MoteClockC.nc MoteClockP.nc
PlatformP.nc. They set up the clocks and initialize the MSP430. Also needed in
this new platform is hardware.h, which was copied from telosb and modified to
change names to leave off the humidity sensor, and rename some GeneralIO signal
names. </P><A name=Creating_a_new_platform></A>
<H1><SPAN class=mw-headline>Creating a new platform</SPAN></H1>
<P>There is plenty of ground work done for us, so the first steps of this
process are copying -- This example code can run on an unmodified telosb
hardware. Some details you will see are specific to an Ecosensory platform, but
they don't stop you from learning by making the IO tester program below on any
telosb derived platform. So copy from telosa and telosb and update .platform
file and remember support/make/*.target -- see lesson 10. To use the tutorial as
is, the name of the platform can be ecosens1p, p for prototype, but it will be
better to use your own name and get the hang of it more. When you are done
copying your new dir should look like this: </P><PRE> john@ecolab:/opt/tinyos-2.x-contrib/ecosensory/tos/platforms/ecosens1$ ls
ActiveMessageC.nc DemoSensorStreamC.nc MoteClockC.nc PlatformC.nc
PlatformSerialC.nc UserButtonP.nc chips Ecosens1SerialP.nc
MoteClockP.nc platform.h SwitchC.nc UserSwitchC.nc
CVS hardware.h MotePlatformC.nc PlatformLedsC.nc
SwitchToggleC.nc UserSwitchP.nc DemoSensorC.nc HplUserButtonC.nc
Msp430Timer32khzMapC.nc platform_message.h UserButtonC.nc VoltageC.nc
DemoSensorNowC.nc HplUserSwitchC.nc NotifyBit.nc PlatformP.nc
UserButton.h VoltageStreamC.nc
</PRE>
<P><BR>To simplify we will learn about the bottom, close to the hardware, HPL
layer of tinyOS modules first in the test program below. </P><A
name=GPIO_Tester_program></A>
<H1><SPAN class=mw-headline>GPIO Tester program</SPAN></H1>
<P>The configuration file called TestNewPlatformIOC.nc, declares standard telosb
tinyos parts MainC, userButtonC, LedsC, TimerMilliC() and then the program
module TestNewPlatformIOP.nc, and a low level Hpl component: </P><PRE> components HplMsp430GeneralIOC;
TestMSP430platfIOP.Pin0 -> HplMsp430GeneralIOC.Port60;
TestMSP430platfIOP.Pin1 -> HplMsp430GeneralIOC.Port61;
</PRE>
<P><BR>The arrows in a configuration file point in the direction of more
specific hardware, or the root of a definition, whether pointing left or right.
The above arrows connect references in the program sequence file to the hardware
presentation layer file specific definition, so this file can have differences
depending on platform. If two versions exist, they will be in different platform
or sensorboard dirs that also use the MSP430 chip. This snippet from
TestMSP430platfIOC.nc shows reusing interface HplMsp430GeneralIO with new names.
</P><PRE> module TestMSP430platfIOP {
uses {
interface Boot;
interface Get<state_t>;
interface Notify<state_t>;
interface Leds;
interface Timer<TMilli>;
interface HplMsp430GeneralIO as Pin0;
interface HplMsp430GeneralIO as Pin1;
etc....
</PRE>
<P>Next, declaring the HPL for the MSP430. </P><PRE> implementation {
components HplMsp430GeneralIOC;
TestMSP430platfIOP.Pin0 -> HplMsp430GeneralIOC.Port60;
TestMSP430platfIOP.Pin1 -> HplMsp430GeneralIOC.Port61;
etc....
</PRE>
<P><BR>The above wiring connections are made from the names to specific MSP430
port pins, that number many more than 8. We are just declaring a way to use 8
because we have a goal of displaying with three bits! We have a widespread
beginner display in the three LEDs, able to generate some excitement in a
newbie, so we use them. A future tutorial that repeats this program for another
platform would be a nice learning tool. </P>
<P><BR>Notice the names for our 8 IOs (Pin0, Pin1...) can be anything in this
file, they are local, and can't be used anywhere else. To use this program as a
hardware testing tool, you can redefine the right sides of the above list to
suit, using names from HplMsp430GeneralIOC.nc , and put them on a piece of paper
with room to the side to write notes, then load the program on the new platform
hardware and apply current limited 2.8 or 2.9volts if your batteries are at 3.0
Volts, and see changes in LED output as you select Pin0 or Pin5 or Pin7 by
pressing the user button to count through the LED displayed numbers. Telosb
hardware has some pull down resistance on the inputs of GPIOs -- I didn't need
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -