/* 
* classTC.cpp
*
* Created: 03/06/2018 15:32:43
* Author: Ledo
*/


#include "classTC.h"

// default constructor
classTC::classTC()
{
} //classTC

// default destructor
classTC::~classTC()
{
} //~classTC

/****************************************************************
* TIMEBASE TIMER
* Clock: 48 MHz
* Period: 10 mS (100 Hz)
****************************************************************/
void classTC::tc0_init(void)
{
	//Configure PMC, TC0
	PMC->PMC_PCER0 = (1 << ID_TC0) ;
	
	TC0->TC_CHANNEL[0].TC_CMR = TC_CMR_CPCTRG;
	TC0->TC_CHANNEL[0].TC_RC = 480000;
	TC0->TC_CHANNEL[0].TC_IER = TC_IER_CPCS;
	
	//Configure TC0 interrupts
	NVIC_DisableIRQ(TC0_IRQn);
	NVIC_ClearPendingIRQ(TC0_IRQn);
	NVIC_SetPriority(TC0_IRQn, 1);
	NVIC_EnableIRQ(TC0_IRQn);
	
	// Start the TC0
	TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG;;
}