From c106a52430d8ded02ce60b7b68c73afe4570020d Mon Sep 17 00:00:00 2001 From: andreaskoepke Date: Fri, 13 Jun 2008 13:40:59 +0000 Subject: [PATCH] add a special short cut --- tos/chips/tda5250/HplTda5250ConfigP.nc | 4 +-- tos/chips/tda5250/RfPower.nc | 33 +++++++++++++++++++++++++ tos/chips/tda5250/Tda5250RadioC.nc | 7 +++++- tos/chips/tda5250/Tda5250RadioP.nc | 34 ++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 tos/chips/tda5250/RfPower.nc diff --git a/tos/chips/tda5250/HplTda5250ConfigP.nc b/tos/chips/tda5250/HplTda5250ConfigP.nc index de8f61a1..bf1ae116 100644 --- a/tos/chips/tda5250/HplTda5250ConfigP.nc +++ b/tos/chips/tda5250/HplTda5250ConfigP.nc @@ -80,9 +80,9 @@ implementation { /**************************************************************** Global Variables Declared *****************************************************************/ - norace uint16_t currentConfig; + norace uint16_t currentConfig = TDA5250_REG_DEFAULT_SETTING_CONFIG; uint8_t currentClockDiv; - norace uint8_t currentLpf; + norace uint8_t currentLpf = TDA5250_REG_DEFAULT_SETTING_LPF; /**************************************************************** diff --git a/tos/chips/tda5250/RfPower.nc b/tos/chips/tda5250/RfPower.nc new file mode 100644 index 00000000..b976d033 --- /dev/null +++ b/tos/chips/tda5250/RfPower.nc @@ -0,0 +1,33 @@ +/* -*- mode: c++ -*- + * 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. + * + */ + +interface RfPower { + async command error_t set(uint8_t setting); +} diff --git a/tos/chips/tda5250/Tda5250RadioC.nc b/tos/chips/tda5250/Tda5250RadioC.nc index 0989c774..fafba5bc 100644 --- a/tos/chips/tda5250/Tda5250RadioC.nc +++ b/tos/chips/tda5250/Tda5250RadioC.nc @@ -47,6 +47,9 @@ configuration Tda5250RadioC { interface ResourceRequested; interface RadioByteComm; interface ClkDiv; +#ifdef LNDW + interface RfPower; +#endif } } implementation { @@ -65,7 +68,9 @@ implementation { RadioByteComm = Tda5250RadioP; SplitControl = Tda5250RadioP; ClkDiv = Tda5250RadioP; - +#ifdef LNDW + RfPower = Tda5250RadioP; +#endif Tda5250RadioP.DelayTimer -> DelayTimer; Tda5250RadioP.ConfigResource -> HplTda5250ConfigC; diff --git a/tos/chips/tda5250/Tda5250RadioP.nc b/tos/chips/tda5250/Tda5250RadioP.nc index a1ea56a8..975fcaa6 100644 --- a/tos/chips/tda5250/Tda5250RadioP.nc +++ b/tos/chips/tda5250/Tda5250RadioP.nc @@ -55,6 +55,9 @@ module Tda5250RadioP { interface RadioByteComm; interface ResourceRequested; interface ClkDiv; +#ifdef LNDW + interface RfPower; +#endif } uses { interface HplTda5250Config; @@ -79,6 +82,27 @@ implementation { radioMode_t radioMode; // Current Mode of the Radio float onTime, offTime; +#ifdef LNDW + norace bool rfpowerdirty = FALSE; + norace uint8_t rfpower = INITIAL_RF_POWER; + task void setRfPower() { + uint8_t rp, rd; + atomic { + rp = rfpower; + rd = rfpowerdirty; + } + if(rd) { + if(call ConfigResource.immediateRequest() == SUCCESS) { + call HplTda5250Config.SetRFPower(rp); + atomic rfpowerdirty = FALSE; + } + else { + post setRfPower(); + } + } + } +#endif + /**************** Radio Init *****************/ command error_t Init.init() { radioMode = RADIO_MODE_OFF; @@ -156,6 +180,7 @@ implementation { call HplTda5250Config.SetSleepMode(); atomic radioMode = RADIO_MODE_SLEEP; signal Tda5250Control.SleepModeDone(); + if(rfpowerdirty) post setRfPower(); break; case RADIO_MODE_TX_TRANSITION: call HplTda5250Config.SetSlaveMode(); @@ -454,4 +479,13 @@ implementation { } default async event void ClkDiv.stopping() { } +#ifdef LNDW + async command error_t RfPower.set(uint8_t setting) { + atomic { + rfpower = setting; + rfpowerdirty = TRUE; + } + return SUCCESS; + } +#endif } -- 2.39.2