]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/tmicore/MoteClockP.nc
Fix up steve's e-mail address.
[tinyos-2.x.git] / tos / platforms / tmicore / MoteClockP.nc
index 543aab467e4bc3800ffc1d5a500167a5dc61aa59..6b5359af5e7e6426914cd6d8b54f38b41a50646f 100644 (file)
  */
  
  /**
- * @author R. Steve McKown <smckown@gmail.com>
+ * @author R. Steve McKown <rsmckown@gmail.com>
  */
  
-//#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 {
@@ -50,6 +44,9 @@ module MoteClockP {
 implementation {
   command error_t Init.init()
   {
+    uint16_t i;
+
+#if defined (CALDCO_8MHZ_) && !defined(__DisableCalData)
     if (CALBC1_8MHZ != 0xff || CALDCO_8MHZ != 0xff) {
       /* Use built-in constant */
       atomic {
@@ -64,17 +61,17 @@ implementation {
        BCSCTL2 = SELM_0 | DIVM_0 | DIVS_3;
        DCOCTL = CALDCO_8MHZ;
 
-       /* Turn on TimerB, aka the 32KHz clock */
-       TBCTL |= MC1;
+       /* Turn on timers A and B */
+       TACTL |= MC_2;
+       TBCTL |= MC_2;
       }
       return SUCCESS;
-    } else {
-      /* Constant not present; calibrate on the fly */
-      int i;
-
-      for (i = 0; i < 0xfffe; i++); /* ensure LFXT1 is stable */
-      return call SubInit.init();
     }
+#endif
+
+    /* Calibrate DCOCLK to ACLK when calibration data are disabled or erased */
+    for (i = 0; i < 0xfffe; i++); /* ensure LFXT1 is stable */
+    return call SubInit.init();
   }
 
   event void Msp430ClockInit.setupDcoCalibrate()
@@ -84,9 +81,7 @@ implementation {
 
   event void Msp430ClockInit.initClocks()
   {
-    /* We run at 8MHz, so SMCLK divider needs to be /8 */
     call Msp430ClockInit.defaultInitClocks();
-    BCSCTL2 |= DIVS_3;
   }
 
   event void Msp430ClockInit.initTimerA()