]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
improvments in busy wait and timer, some cleaning
authorr-studio <r-studio>
Fri, 20 Nov 2009 06:47:34 +0000 (06:47 +0000)
committerr-studio <r-studio>
Fri, 20 Nov 2009 06:47:34 +0000 (06:47 +0000)
support/make/m16c62p/m16c62p.rules
tos/chips/m16c62p/control/M16c62pControlP.nc
tos/platforms/mulle/chips/rf230/HplRF230C.nc
tos/platforms/mulle/timers/BusyWaitMicroC.nc

index 8634edd5d93550b40fa14647e846a402f94f412e..05e6601d4161157907ff5666b3292d2e6dd69cdd 100755 (executable)
@@ -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
index bade4dab4be3707af3718bc186d28c004bace76b..dc380414316504c78ad90199279fd6614c98c801 100755 (executable)
@@ -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;
index 747f130fada701220dabf561089d75eb71d3d48e..c413b06bda1a6eabb9353218c82777353511c403 100755 (executable)
@@ -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;
index 82aae0a8dec61fc759cab58d664c54ee0f917ed7..fc24efb437f76d34716dfc6b2a65b5bfafc0ff2a 100755 (executable)
@@ -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)
-          );
-    }
-  }
+          );  
+    } 
+  } 
 }