X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fatm1281%2Ftimer%2FHplAtm1281Timer2AsyncP.nc;h=fa7d8b2070f22a42f0cd4f3a3467c6b6088300ff;hb=406725454a6e1d497656961c78230c7fadb5d889;hp=b4b3623b207b7173cbe30fe05573c5642c18ba98;hpb=5dc512be69b8398c34c9675c533e478d01260df9;p=tinyos-2.x.git diff --git a/tos/chips/atm1281/timer/HplAtm1281Timer2AsyncP.nc b/tos/chips/atm1281/timer/HplAtm1281Timer2AsyncP.nc index b4b3623b..fa7d8b20 100644 --- a/tos/chips/atm1281/timer/HplAtm1281Timer2AsyncP.nc +++ b/tos/chips/atm1281/timer/HplAtm1281Timer2AsyncP.nc @@ -5,18 +5,18 @@ * 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 CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO - * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL + * + * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS 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 CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. + * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. * * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. */ @@ -28,12 +28,12 @@ * 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 VANDERBILT UNIVERSITY 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 VANDERBILT * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * THE VANDERBILT UNIVERSITY 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 @@ -55,7 +55,7 @@ #include -module HplAtm1281Timer2AsyncP +module HplAtm1281Timer2AsyncP @safe() { provides { // 8-bit Timers @@ -92,52 +92,52 @@ implementation async command void Timer.off() { call Timer.setScale(AVR_CLOCK_OFF); } //=== Write a new timer scale. ======================================== - async command void Timer.setScale(uint8_t s) { + async command void Timer.setScale(uint8_t s) { Atm128_TCCR2B_t x = (Atm128_TCCR2B_t) call TimerCtrl.getControlB(); x.bits.cs = s; - call TimerCtrl.setControlB(x.flat); + call TimerCtrl.setControlB(x.flat); } //=== Read the control registers. ===================================== - async command uint8_t TimerCtrl.getControlA() { - return TCCR2A; + async command uint8_t TimerCtrl.getControlA() { + return TCCR2A; } - async command uint8_t TimerCtrl.getControlB() { - return TCCR2B; + async command uint8_t TimerCtrl.getControlB() { + return TCCR2B; } //=== Write the control registers. ==================================== - async command void TimerCtrl.setControlA( uint8_t x ) { + async command void TimerCtrl.setControlA( uint8_t x ) { while (ASSR & 1 << TCR2AUB) ; - TCCR2A = ((Atm128_TCCR2A_t)x).flat; + TCCR2A = ((Atm128_TCCR2A_t)x).flat; } - async command void TimerCtrl.setControlB( uint8_t x ) { + async command void TimerCtrl.setControlB( uint8_t x ) { while (ASSR & 1 << TCR2BUB) ; - TCCR2B = ((Atm128_TCCR2B_t)x).flat; + TCCR2B = ((Atm128_TCCR2B_t)x).flat; } //=== Read the interrupt mask. ===================================== - async command uint8_t TimerCtrl.getInterruptMask() { - return TIMSK2; + async command uint8_t TimerCtrl.getInterruptMask() { + return TIMSK2; } //=== Write the interrupt mask. ==================================== - async command void TimerCtrl.setInterruptMask( uint8_t x ) { - TIMSK2 = x; + async command void TimerCtrl.setInterruptMask( uint8_t x ) { + TIMSK2 = x; } //=== Read the interrupt flags. ===================================== - async command uint8_t TimerCtrl.getInterruptFlag() { - return TIFR2; + async command uint8_t TimerCtrl.getInterruptFlag() { + return TIFR2; } //=== Write the interrupt flags. ==================================== - async command void TimerCtrl.setInterruptFlag( uint8_t x ) { - TIFR2 = x; + async command void TimerCtrl.setInterruptFlag( uint8_t x ) { + TIFR2 = x; } //=== Timer 8-bit implementation. ==================================== @@ -146,37 +146,37 @@ implementation async command void Timer.stop() { CLR_BIT(TIMSK2, TOIE2); } bool overflowed() { - return ((Atm128_TIFR2_t)call TimerCtrl.getInterruptFlag()).bits.tov; + return ((Atm128_TIFR2_t)call TimerCtrl.getInterruptFlag()).bits.tov; } - async command bool Timer.test() { + async command bool Timer.test() { return overflowed(); } - - async command bool Timer.isOn() { - return ((Atm128_TIMSK2_t)call TimerCtrl.getInterruptMask()).bits.toie; + + async command bool Timer.isOn() { + return ((Atm128_TIMSK2_t)call TimerCtrl.getInterruptMask()).bits.toie; } - + async command void Compare.reset() { TIFR2 = 1 << OCF2A; } async command void Compare.start() { SET_BIT(TIMSK2,OCIE2A); } async command void Compare.stop() { CLR_BIT(TIMSK2,OCIE2A); } - async command bool Compare.test() { - return ((Atm128_TIFR2_t)call TimerCtrl.getInterruptFlag()).bits.ocfa; + async command bool Compare.test() { + return ((Atm128_TIFR2_t)call TimerCtrl.getInterruptFlag()).bits.ocfa; } - async command bool Compare.isOn() { - return ((Atm128_TIMSK2_t)call TimerCtrl.getInterruptMask()).bits.ociea; + async command bool Compare.isOn() { + return ((Atm128_TIMSK2_t)call TimerCtrl.getInterruptMask()).bits.ociea; } //=== Read the compare registers. ===================================== async command uint8_t Compare.get(){ return OCR2A; } //=== Write the compare registers. ==================================== - async command void Compare.set(uint8_t t) { + async command void Compare.set(uint8_t t) { atomic { while (ASSR & 1 << OCR2AUB) ; - OCR2A = t; + OCR2A = t; } } @@ -195,11 +195,11 @@ implementation * is needed. If the timer is not running it returns POWER_DOWN. * Please refer to TEP 112 and the atm128 datasheet for details. */ - + async command mcu_power_t McuPowerOverride.lowestState() { uint8_t diff; // We need to make sure that the sleep wakeup latency will not - // cause us to miss a timer. POWER_SAVE + // cause us to miss a timer. POWER_SAVE if (TIMSK2 & (1 << OCIE2A | 1 << TOIE2)) { // need to wait for timer 2 updates propagate before sleeping // (we don't need to worry about reentering sleep mode too early, @@ -209,7 +209,7 @@ implementation ; diff = OCR2A - TCNT2; if (diff < EXT_STANDBY_T0_THRESHOLD || - TCNT2 > 256 - EXT_STANDBY_T0_THRESHOLD) + TCNT2 > 256 - EXT_STANDBY_T0_THRESHOLD) return ATM128_POWER_EXT_STANDBY; return ATM128_POWER_SAVE; } @@ -222,7 +222,7 @@ implementation AVR_ATOMIC_HANDLER(SIG_OUTPUT_COMPARE2A) { stabiliseTimer2(); // __nesc_enable_interrupt(); - + signal Compare.fired(); }