X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fmsp430%2Fclock2%2FMsp430ClockP.nc;h=6b9066da42ff6e8356906a56aa03fe2ff058252d;hb=be862ab07d080085823951d18dcb27a28a310ace;hp=6649b01da64b7bd7377cc7f1eeb390e162f7e592;hpb=ea919e632db754746366a851e66c6d04c3959a93;p=tinyos-2.x.git diff --git a/tos/chips/msp430/clock2/Msp430ClockP.nc b/tos/chips/msp430/clock2/Msp430ClockP.nc index 6649b01d..6b9066da 100644 --- a/tos/chips/msp430/clock2/Msp430ClockP.nc +++ b/tos/chips/msp430/clock2/Msp430ClockP.nc @@ -10,7 +10,7 @@ * - 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 Universität Berlin nor the names + * - Neither the name of the Titanium Mirror, Inc. nor the names * of its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -26,22 +26,20 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * Clock initialization for msp430's with the newer basic clock +, sometimes * referred to as basic clock 2. Derived from the Msp430ClockP for the * original basic clock peripheral (chips/msp430/clock/Msp430ClockP.nc), with * some refinements suggested by TI in ther example code, filename * MSP430x261x_dco_flashcal.c. - * - * @author R. Steve McKown + * + * @author R. Steve McKown */ - -#include #include "Msp430Timer.h" -module Msp430ClockP @safe() +generic module Msp430ClockP(uint16_t TARGET_DCO_KHZ, uint16_t ACLK_KHZ) @safe() { provides interface Init; provides interface Msp430ClockInit; @@ -56,6 +54,13 @@ implementation MSP430REG_NORACE(TBIV); #endif + #if defined(__MSP430_HAS_BC2__) /* basic clock module+ */ + #define FIRST_STEP 0x1000 + #else /* orig basic clock module */ + #define RSEL3 0 + #define FIRST_STEP 0x800 + #endif + enum { DCOX = DCO2 + DCO1 + DCO0, @@ -76,7 +81,7 @@ implementation TACCTL2 = CM_1 + CCIS_1 + CAP; /* Capture on rising ACLK */ TACTL = TASSEL_2 + MC_2 + TACLR; /* Continuous mode, source SMCLK */ } - + command void Msp430ClockInit.defaultInitClocks() { const unsigned int divider = TARGET_DCO_KHZ / 1000; @@ -115,7 +120,7 @@ implementation { call Msp430ClockInit.defaultSetupDcoCalibrate(); } - + default event void Msp430ClockInit.initClocks() { call Msp430ClockInit.defaultInitClocks(); @@ -185,7 +190,7 @@ implementation uint16_t calib; uint16_t step; - for (calib = 0, step = 0x1000; step != 0; step >>= 1) { + for (calib = 0, step = FIRST_STEP; step != 0; step >>= 1) { // if the step is not past the target, commit it if (test_calib_busywait_delta(calib | step) <= TARGET_DCO_DELTA ) calib |= step;