Skip to content
Snippets Groups Projects
Commit 5e5076bb authored by mikas34's avatar mikas34
Browse files

Updated lab1 structure

parent 61075a0e
Branches
No related tags found
No related merge requests found
// $Id: BlinkTaskAppC.nc,v 1.4 2006/12/12 18:22:52 vlahan Exp $
/* tab:4
* "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
*
* @author tinyos-help@millennium.berkeley.edu
**/
configuration BlinkTaskAppC
{
}
implementation
{
components MainC, BlinkTaskC, LedsC, SerialStartC;
components new TimerMilliC() as Timer0;
BlinkTaskC -> MainC.Boot;
BlinkTaskC.Timer0 -> Timer0;
BlinkTaskC.Leds -> LedsC;
}
// $Id: BlinkTaskC.nc,v 1.4 2006/12/12 18:22:52 vlahan Exp $
/* tab:4
* "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*
*/
/**
* BlinkTask demo application: simple example of posting a task in TinyOS.
*
* @author Kristin Wright
*
*/
/**
* Blink Led0 every second. For expository purposes, use a task to
* toggle the LED.
**/
#include "Timer.h"
module BlinkTaskC
{
uses interface Timer<TMilli> as Timer0;
uses interface Leds;
uses interface Boot;
}
implementation
{
task void toggle()
{
call Leds.led0Toggle();
}
event void Boot.booted()
{
call Timer0.startPeriodic( 1000 );
}
event void Timer0.fired()
{
post toggle();
}
}
COMPONENT=BlinkTaskAppC
TINYOS_ROOT_DIR?=/courses/TDDI07/tinyos-main
include $(TINYOS_ROOT_DIR)/Makefile.include
$Id: README.txt,v 1.4 2006/12/12 18:22:52 vlahan Exp $
README for BlinkTask
Author/Contact:
tinyos-help@millennium.berkeley.edu
Description:
The BlinkTask application: a simple example of how to post a task
in TinyOS. A periodic timer is set to fire every
second. The Timer.fired() event posts a task to toggle the LEDs
rather than toggling the LEDs directly.
Tools:
None
Known bugs/limitations:
None.
\ No newline at end of file
COMPONENT=PhotoMeterAppC
TINYOS_ROOT_DIR?=/courses/TDDI07/tinyos-main
CFLAGS += -I$(TINYOS_ROOT_DIR)/tos/lib/printf
include $(TINYOS_ROOT_DIR)/Makefile.include
configuration PhotoMeterAppC {
}
implementation
{
components MainC, PhotoMeterC, LedsC, PrintfC, SerialStartC;
components new TimerMilliC();
components new HamamatsuS10871TsrC() as PhotoC;
/* Wire the different components */
PhotoMeterC.Boot -> MainC;
/* Connecting components like we do above is called wiring.
* You need to add any missing wiring at suitable places
* to complete the PhotoMeter application. Sensor, Leds and Timer.
*/
}
#include "printf.h"
module PhotoMeterC {
uses {
interface Boot;
interface Timer<TMilli>;
interface Leds;
/* You have to add the Read interface */
}
}
implementation {
/* This is how you create constants in TinyOS.
* The two provided here is an example, *NOT FOR YOU TO USE*.
* Remove or replace them.
*/
#define SAMPLING_FREQUENCY 500
enum { SIZE = 8, RANGE = 1024 };
/* You may want to use a circular buffer in order to store the
* data to be processed afterwards. Define the variables here.
*/
/* Module global variables are usually added at the top of the
* module implementation, i.e. here.
*/
uint16_t PhotoData=0;
/* This is where the application schedule how to start.
*/
/* All initialization of variables and components are done here.
*/
event void Boot.booted(){
}
/* Use the display function to display the data in the leds.
* The printf will help you to debug the data readings from
* the sensor. Scale the data to display it in the leds.
*/
void display(uint16_t data){
printf("%u\n",data);
}
/**
* Module task. Process sensor reading and
* display it. Hint: remember the use of atomic.
**/
task void processData()
{
bool ready=FALSE;
if(ready) display(PhotoData);
}
/** Read event handlers.
* When the reading is successful, store the data and
* start its processing. Hint: remember the use of atomic.
**/
}
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment