/*************************************************************************
 * DISCLAIMER                                                            *
 * Services performed by FREESCALE in this matter are performed          *
 * AS IS and without any warranty. CUSTOMER retains the final decision   *
 * relative to the total design and functionality of the end product.    *
 * FREESCALE neither guarantees nor will be held liable by CUSTOMER      *
 * for the success of this project. FREESCALE disclaims all warranties,  *
 * express, implied or statutory including, but not limited to,          *
 * implied warranty of merchantability or fitness for a particular       *
 * purpose on any hardware, software ore advise supplied to the project  *
 * by FREESCALE, and or any product resulting from FREESCALE services.   *
 * In no event shall FREESCALE be liable for incidental or consequential *
 * damages arising out of this agreement. CUSTOMER agrees to hold        *
 * FREESCALE harmless against any and all claims demands or actions      *
 * by anyone on account of any damage, or injury, whether commercial,    *
 * contractual, or tortuous, rising directly or indirectly as a result   *
 * of the advise or assistance supplied CUSTOMER in connection with      *
 * product, services or goods supplied under this Agreement.             *
 *************************************************************************/
/*******************************************************************
  Copyright (c) 2007 Freescale Semiconductor
  \file     	Main.c
  \brief    	Smart Card Reader for MC9S08JM60
  \author   	Freescale Semiconductor
  \version    0.1
  \date     	15/Aug/2011
*********************************************************************/

#include "CLK.h"


void CLK_Enable(void)
{
  // TPM1SC: TOF=0,TOIE=0,CPWMS=0,CLKSB=0,CLKSA=1,PS2=0,PS1=0,PS0=0
  TPM1SC = 0x08;
}


void CLK_Disable(void)
{
  TPM1SC = 0x00;
  TPM1CNTH = 0x00;
}


// Init the PWM to 1.5MHz
void CLK_Init(void)
{
  TPM1SC = 0x00;
  // TPM1C0SC: CH0F=0,CH0IE=0,MS0B=1,MS0A=1,ELS0B=1,ELS0A=1
  TPM1C0SC = 0x3C;
  
  TPM1MOD = 0x0F;
  TPM1C0V = 0x08;
  TPM1SC = 0x00;    //Stop counter
  TPM1CNTH = 0x00; 
}

