* - 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.
*
* (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 <smckown@gmail.com>
+ *
+ * @author R. Steve McKown <rsmckown@gmail.com>
*/
-
-#include <Msp430DcoSpec.h>
#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;
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,
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;
{
call Msp430ClockInit.defaultSetupDcoCalibrate();
}
-
+
default event void Msp430ClockInit.initClocks()
{
call Msp430ClockInit.defaultInitClocks();
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;