Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.41 KB | None | 0 0
  1. // $Id: BlinkC.nc,v 1.5 2008/06/26 03:38:26 regehr Exp $
  2.  
  3. /*                                  tab:4
  4.  * "Copyright (c) 2000-2005 The Regents of the University  of California.  
  5.  * All rights reserved.
  6.  *
  7.  * Permission to use, copy, modify, and distribute this software and its
  8.  * documentation for any purpose, without fee, and without written agreement is
  9.  * hereby granted, provided that the above copyright notice, the following
  10.  * two paragraphs and the author appear in all copies of this software.
  11.  *
  12.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  13.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  14.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  15.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  18.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  19.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  20.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  21.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
  22.  *
  23.  * Copyright (c) 2002-2003 Intel Corporation
  24.  * All rights reserved.
  25.  *
  26.  * This file is distributed under the terms in the attached INTEL-LICENSE    
  27.  * file. If you do not find these files, copies can be found by writing to
  28.  * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
  29.  * 94704.  Attention:  Intel License Inquiry.
  30.  */
  31.  
  32. /**
  33.  * Implementation for Blink application.  Toggle the red LED when a
  34.  * Timer fires.
  35.  **/
  36.  
  37. #include "Timer.h"
  38.  
  39. module BlinkC @safe()
  40. {
  41.   uses interface Timer<TMilli> as Timer0;
  42.   uses interface Timer<TMilli> as Timer1;
  43.   uses interface Timer<TMilli> as Timer2;
  44.   uses interface Leds;
  45.   uses interface Boot;
  46. }
  47. implementation
  48. {
  49.   event void Boot.booted()
  50.   {
  51.     call Timer0.startPeriodic( 250 );
  52.     call Timer1.startPeriodic( 500 );
  53.     call Timer2.startPeriodic( 1000 );
  54.   }
  55.  
  56.   event void Timer0.fired()
  57.   {
  58.     dbg("BlinkC", "Timer 0 fired @ %s.\n", sim_time_string());
  59.     call Leds.led0Toggle();
  60.   }
  61.  
  62.   event void Timer1.fired()
  63.   {
  64.     dbg("BlinkC", "Timer 1 fired @ %s \n", sim_time_string());
  65.     call Leds.led1Toggle();
  66.   }
  67.  
  68.   event void Timer2.fired()
  69.   {
  70.     dbg("BlinkC", "Timer 2 fired @ %s.\n", sim_time_string());
  71.     call Leds.led2Toggle();
  72.   }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement