From: r-studio Date: Fri, 20 Nov 2009 06:47:34 +0000 (+0000) Subject: improvments in busy wait and timer, some cleaning X-Git-Tag: rc_6_tinyos_2_1_1~133 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=63cd7c320b06acae51ca4aa6a40442cc4721c677 improvments in busy wait and timer, some cleaning --- diff --git a/support/make/m16c62p/m16c62p.rules b/support/make/m16c62p/m16c62p.rules index 8634edd5..05e6601d 100755 --- a/support/make/m16c62p/m16c62p.rules +++ b/support/make/m16c62p/m16c62p.rules @@ -58,6 +58,10 @@ else LDFLAGS += -nostartfiles -T$(TINYOS_MAKE_PATH)/$(THIS_FOLDER)/m16c.x $(TINYOS_MAKE_PATH)/$(THIS_FOLDER)/crt.S endif +# This is needed so that we know that the BusyWaitMicroC.BusyWait.wait() +# function always gets aligned. +CFLAGS += -falign-functions=2 + DEFAULT_PROGRAM ?= sm16cf # Use the 'if' function instead of the 'ifdef' construct because ifdef freaks diff --git a/tos/chips/m16c62p/control/M16c62pControlP.nc b/tos/chips/m16c62p/control/M16c62pControlP.nc index bade4dab..dc380414 100755 --- a/tos/chips/m16c62p/control/M16c62pControlP.nc +++ b/tos/chips/m16c62p/control/M16c62pControlP.nc @@ -290,6 +290,7 @@ implementation uint8_t cm0_tmp, cm1_tmp; __nesc_enable_interrupt(); PRCR.BYTE = 1; // Turn off protection of system clock control registers + CLR_BIT(CM2.BYTE, 0); cm0_tmp = CM0.BYTE; cm1_tmp = CM1.BYTE; CM0.BYTE = 0b00001000; @@ -300,7 +301,6 @@ implementation asm("nop"); asm("nop"); asm("nop"); - PRCR.BYTE = 0; // Turn off protection of system clock control registers asm volatile ("" : : : "memory"); __nesc_disable_interrupt(); CM0.BYTE = cm0_tmp; diff --git a/tos/platforms/mulle/chips/rf230/HplRF230C.nc b/tos/platforms/mulle/chips/rf230/HplRF230C.nc index 747f130f..c413b06b 100755 --- a/tos/platforms/mulle/chips/rf230/HplRF230C.nc +++ b/tos/platforms/mulle/chips/rf230/HplRF230C.nc @@ -86,8 +86,8 @@ implementation HplRF230P.Alarm -> AlarmRF230; Alarm = AlarmRF230; - components RealMainP; - RealMainP.PlatformInit -> HplRF230P.PlatformInit; + components PlatformP; + PlatformP.SubInit -> HplRF230P.PlatformInit; components LocalTimeMicroC; LocalTimeRadio = LocalTimeMicroC; diff --git a/tos/platforms/mulle/timers/BusyWaitMicroC.nc b/tos/platforms/mulle/timers/BusyWaitMicroC.nc index 82aae0a8..fc24efb4 100755 --- a/tos/platforms/mulle/timers/BusyWaitMicroC.nc +++ b/tos/platforms/mulle/timers/BusyWaitMicroC.nc @@ -50,21 +50,26 @@ implementation // add a signal from the control module of the mcu // to signal the change of speed and the wait function // can adjust to it. - inline async command void BusyWait.wait(uint16_t dt) - { + // The wait function can not be inlined because then the code alignment may + // go lost thus making the busy wait around 30% slower. + async command void BusyWait.wait(uint16_t dt ) __attribute__((noinline)) { atomic { + asm("nop"); // Nop needed to align function asm volatile ( - // The call and return of the Busywait takes about 1us "sub.w #1,%[t]\n\t" + "jeq 2f\n\t" + "sub.w #1,%[t]\n\t" + "jeq 2f\n\t" "1:\n\t" "nop\n\t" "add.w #1,%[t]\n\t" "sub.w #1,%[t]\n\t" "sub.w #1,%[t]\n\t" - "jgtu 1b" - : + "jgtu 1b\n\t" + "2:" + : : [t] "r" (dt) - ); - } - } + ); + } + } }