From 4032fd4f0aca0fbcf920c01e553bb8e7cca163fa Mon Sep 17 00:00:00 2001 From: smckown Date: Tue, 9 Sep 2008 14:17:06 +0000 Subject: [PATCH] Make Msp430ClockC a generic so that the target DCO clock and the ACLK can be passed in as instantiation variables. This provides a more TinyOS savvy mechanism to set desired clocks as opposed to the prior method which involved overriding macros defined in Msp430DcoSpec.h. This and other enhancements to the clock initialization has also slightly reduced executable sizes. Below is the Blink application from TinyOS 2.1.0, compiled with the plain vanilla 2.1.0 and with the clock init modifications for all msp430 platforms in the standard distribution: Compiled ROM sizes in bytes || Platform || 2.1.0 || updated || || || || || || eyesIFX || 2570 || 2510 || || shimmer || 2522 || 2462 || || telosa || 2538 || 2478 || || telosb || 2634 || 2574 || || tinynode || 2896 || 2838 || --- tos/chips/msp430/clock/Msp430ClockC.nc | 4 +-- tos/chips/msp430/clock/Msp430ClockP.nc | 4 +-- tos/chips/msp430/clock/Msp430DcoSpec.h | 49 -------------------------- tos/platforms/eyesIFX/.family | 1 + tos/platforms/eyesIFX/PlatformC.nc | 2 +- tos/platforms/shimmer/MoteClockC.nc | 2 +- tos/platforms/telosa/MoteClockC.nc | 2 +- tos/platforms/telosb/MoteClockC.nc | 2 +- tos/platforms/tinynode/PlatformC.nc | 2 +- tos/platforms/tmicore/MoteClockC.nc | 2 +- tos/platforms/tmicore/MoteClockP.nc | 6 ---- 11 files changed, 10 insertions(+), 66 deletions(-) delete mode 100644 tos/chips/msp430/clock/Msp430DcoSpec.h diff --git a/tos/chips/msp430/clock/Msp430ClockC.nc b/tos/chips/msp430/clock/Msp430ClockC.nc index 5249fbe0..ec37861a 100644 --- a/tos/chips/msp430/clock/Msp430ClockC.nc +++ b/tos/chips/msp430/clock/Msp430ClockC.nc @@ -23,14 +23,14 @@ * @author Cory Sharp */ -configuration Msp430ClockC +generic configuration Msp430ClockC(uint16_t TARGET_DCO_KHZ, uint16_t ACLK_KHZ) { provides interface Init; provides interface Msp430ClockInit; } implementation { - components Msp430ClockP, Msp430TimerC; + components new Msp430ClockP(TARGET_DCO_KHZ, ACLK_KHZ); Init = Msp430ClockP; Msp430ClockInit = Msp430ClockP; diff --git a/tos/chips/msp430/clock/Msp430ClockP.nc b/tos/chips/msp430/clock/Msp430ClockP.nc index e700dd52..43043453 100644 --- a/tos/chips/msp430/clock/Msp430ClockP.nc +++ b/tos/chips/msp430/clock/Msp430ClockP.nc @@ -25,11 +25,9 @@ * @author Vlado Handziski */ -#include - #include "Msp430Timer.h" -module Msp430ClockP @safe() +generic module Msp430ClockP(uint16_t TARGET_DCO_KHZ, uint16_t ACLK_KHZ) @safe() { provides interface Init; provides interface Msp430ClockInit; diff --git a/tos/chips/msp430/clock/Msp430DcoSpec.h b/tos/chips/msp430/clock/Msp430DcoSpec.h deleted file mode 100644 index 84ce060a..00000000 --- a/tos/chips/msp430/clock/Msp430DcoSpec.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- mode:c++; indent-tabs-mode: nil -*- - * Copyright (c) 2007, Technische Universitaet Berlin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - Neither the name of the Technische Universitaet Berlin nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES {} LOSS OF USE, DATA, - * OR PROFITS {} OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Specify the target cpu clock speed of your platform by overriding this file. - * - * Be aware that tinyos relies on binary 4MHz, that is 4096 binary kHz. Some - * platforms have an external high frequency oscilator to generate the SMCLK - * (e.g. eyesIFX, and possibly future ZigBee compliant nodes). These - * oscillators provide metric frequencies, but may not run in power down - * modes. Here, we need to switch the SMCLK source, which is easier if - * the external and thd DCO source frequency are the same. - * - * @author: Andreas Koepke (koepke@tkn.tu-berlin.de) - */ - - -#ifndef MS430DCOSPEC_H -#define MS430DCOSPEC_H - -#define TARGET_DCO_KHZ 4096 // the target DCO clock rate in binary kHz -#define ACLK_KHZ 32 // the ACLK rate in binary kHz -#endif diff --git a/tos/platforms/eyesIFX/.family b/tos/platforms/eyesIFX/.family index fa237c92..f40d14fe 100644 --- a/tos/platforms/eyesIFX/.family +++ b/tos/platforms/eyesIFX/.family @@ -17,6 +17,7 @@ push( @includes, qw( %T/chips/ad5200 %T/chips/msp430 %T/chips/msp430/adc12 + %T/chips/msp430/clock %T/chips/msp430/dma %T/chips/msp430/pins %T/chips/msp430/sensors diff --git a/tos/platforms/eyesIFX/PlatformC.nc b/tos/platforms/eyesIFX/PlatformC.nc index 4beccbf4..e8192c07 100644 --- a/tos/platforms/eyesIFX/PlatformC.nc +++ b/tos/platforms/eyesIFX/PlatformC.nc @@ -32,7 +32,7 @@ configuration PlatformC implementation { components PlatformP - , Msp430ClockC + , new Msp430ClockC(4096, 32) ; Init = PlatformP; diff --git a/tos/platforms/shimmer/MoteClockC.nc b/tos/platforms/shimmer/MoteClockC.nc index 12df90bd..ef2ade67 100644 --- a/tos/platforms/shimmer/MoteClockC.nc +++ b/tos/platforms/shimmer/MoteClockC.nc @@ -41,7 +41,7 @@ configuration MoteClockC implementation { - components Msp430ClockC; + components new Msp430ClockC(4096, 32); MoteClockInit = Msp430ClockC.Init; } diff --git a/tos/platforms/telosa/MoteClockC.nc b/tos/platforms/telosa/MoteClockC.nc index 12df90bd..ef2ade67 100644 --- a/tos/platforms/telosa/MoteClockC.nc +++ b/tos/platforms/telosa/MoteClockC.nc @@ -41,7 +41,7 @@ configuration MoteClockC implementation { - components Msp430ClockC; + components new Msp430ClockC(4096, 32); MoteClockInit = Msp430ClockC.Init; } diff --git a/tos/platforms/telosb/MoteClockC.nc b/tos/platforms/telosb/MoteClockC.nc index 4fe33910..f8576218 100644 --- a/tos/platforms/telosb/MoteClockC.nc +++ b/tos/platforms/telosb/MoteClockC.nc @@ -41,7 +41,7 @@ configuration MoteClockC implementation { - components Msp430ClockC, MoteClockP; + components new Msp430ClockC(4096, 32), MoteClockP; MoteClockInit = Msp430ClockC.Init; //MoteClockP.Msp430ClockInit -> Msp430ClockC; diff --git a/tos/platforms/tinynode/PlatformC.nc b/tos/platforms/tinynode/PlatformC.nc index 73b1e248..2435334a 100644 --- a/tos/platforms/tinynode/PlatformC.nc +++ b/tos/platforms/tinynode/PlatformC.nc @@ -32,7 +32,7 @@ configuration PlatformC implementation { components PlatformP - , Msp430ClockC + , new Msp430ClockC(4096, 32) ; Init = PlatformP; diff --git a/tos/platforms/tmicore/MoteClockC.nc b/tos/platforms/tmicore/MoteClockC.nc index e838b5e5..dca07742 100644 --- a/tos/platforms/tmicore/MoteClockC.nc +++ b/tos/platforms/tmicore/MoteClockC.nc @@ -42,7 +42,7 @@ implementation { components MoteClockP; MoteClockInit = MoteClockP.Init; - components Msp430ClockC; + components new Msp430ClockC(8192, 32); MoteClockP.SubInit -> Msp430ClockC.Init; MoteClockP.Msp430ClockInit -> Msp430ClockC; } diff --git a/tos/platforms/tmicore/MoteClockP.nc b/tos/platforms/tmicore/MoteClockP.nc index 3502a0a4..84acca22 100644 --- a/tos/platforms/tmicore/MoteClockP.nc +++ b/tos/platforms/tmicore/MoteClockP.nc @@ -31,14 +31,8 @@ * @author R. Steve McKown */ -//#include "msp430hardware.h" #include "Msp430Timer.h" -#define MS430DCOSPEC_H -#define TARGET_DCO_KHZ 8192 // the target DCO clock rate in binary kHz -//#define TARGET_DCO_KHZ 4096 // the target DCO clock rate in binary kHz -#define ACLK_KHZ 32 // the ACLK rate in binary kHz - module MoteClockP { provides interface Init; uses { -- 2.39.2