platforms/nuttx/src/px4/nxp/kinetis/hrt/hrt.c
static void hrt_tim_init(void)
{

	/* Select a the clock source to the TPM */

	uint32_t regval = _REG(KINETIS_SIM_SOPT2);
	regval &= ~(SIM_SOPT2_TPMSRC_MASK);
	regval |= BOARD_TPM_CLKSRC;
	_REG(KINETIS_SIM_SOPT2) = regval;


	/* Enabled System Clock Gating Control for TPM */

	regval = _REG(KINETIS_SIM_SCGC2);
	regval |= HRT_SIM_SCGC2_TPM;
	_REG(KINETIS_SIM_SCGC2) = regval;


	/* claim our interrupt vector */

	irq_attach(HRT_TIMER_VECTOR, hrt_tim_isr, NULL);

	/* disable and configure the timer */

	rSC = TPM_SC_TOF;

	rCNT = 0;
	rMOD = HRT_COUNTER_PERIOD - 1;

	rSTATUS   = (TPM_STATUS_TOF | STATUS_HRT | STATUS_PPM);
	rCNSC_HRT = (TPM_CnSC_CHF | TPM_CnSC_CHIE | TPM_CnSC_MSA);
	rCNSC_PPM = (TPM_CnSC_CHF | CNSC_PPM);
	rCOMBINE  = 0;
	rPOL      = 0;
	rFILTER   = 0;
	rQDCTRL   = 0;
	rCONF     = TPM_CONF_DBGMODE_CONT;

	/* set an initial capture a little ways off */

	rCNV_PPM  = 0;
	rCNV_HRT  = 1000;

	/* enable the timer */

	rSC |= (TPM_SC_TOIE | TPM_SC_CMOD_LPTPM_CLK | TPM_SC_PS_DIV16);

	/* enable interrupts */
	up_enable_irq(HRT_TIMER_VECTOR);
}
/**
 * Initialize the timer we are going to use.
 */
Initialize the timer we are going to use.
Initialize the timer we are going to use .
static void hrt_tim_init(void)
{
	uint32_t regval = _REG(KINETIS_SIM_SOPT2);
	regval &= ~(SIM_SOPT2_TPMSRC_MASK);
	regval |= BOARD_TPM_CLKSRC;
	_REG(KINETIS_SIM_SOPT2) = regval;
	regval = _REG(KINETIS_SIM_SCGC2);
	regval |= HRT_SIM_SCGC2_TPM;
	_REG(KINETIS_SIM_SCGC2) = regval;
	irq_attach(HRT_TIMER_VECTOR, hrt_tim_isr, NULL);
	rSC = TPM_SC_TOF;
	rCNT = 0;
	rMOD = HRT_COUNTER_PERIOD - 1;
	rSTATUS   = (TPM_STATUS_TOF | STATUS_HRT | STATUS_PPM);
	rCNSC_HRT = (TPM_CnSC_CHF | TPM_CnSC_CHIE | TPM_CnSC_MSA);
	rCNSC_PPM = (TPM_CnSC_CHF | CNSC_PPM);
	rCOMBINE  = 0;
	rPOL      = 0;
	rFILTER   = 0;
	rQDCTRL   = 0;
	rCONF     = TPM_CONF_DBGMODE_CONT;
	rCNV_PPM  = 0;
	rCNV_HRT  = 1000;
	rSC |= (TPM_SC_TOIE | TPM_SC_CMOD_LPTPM_CLK | TPM_SC_PS_DIV16);
	up_enable_irq(HRT_TIMER_VECTOR);
}
static void hrt_tim_init ( void ) { uint32_t regval = _REG ( KINETIS_SIM_SOPT2 ) ; regval &= ~ ( SIM_SOPT2_TPMSRC_MASK ) ; regval |= BOARD_TPM_CLKSRC ; _REG ( KINETIS_SIM_SOPT2 ) = regval ; regval = _REG ( KINETIS_SIM_SCGC2 ) ; regval |= HRT_SIM_SCGC2_TPM ; _REG ( KINETIS_SIM_SCGC2 ) = regval ; irq_attach ( HRT_TIMER_VECTOR , hrt_tim_isr , NULL ) ; rSC = TPM_SC_TOF ; rCNT = 0 ; rMOD = HRT_COUNTER_PERIOD - 1 ; rSTATUS = ( TPM_STATUS_TOF | STATUS_HRT | STATUS_PPM ) ; rCNSC_HRT = ( TPM_CnSC_CHF | TPM_CnSC_CHIE | TPM_CnSC_MSA ) ; rCNSC_PPM = ( TPM_CnSC_CHF | CNSC_PPM ) ; rCOMBINE = 0 ; rPOL = 0 ; rFILTER = 0 ; rQDCTRL = 0 ; rCONF = TPM_CONF_DBGMODE_CONT ; rCNV_PPM = 0 ; rCNV_HRT = 1000 ; rSC |= ( TPM_SC_TOIE | TPM_SC_CMOD_LPTPM_CLK | TPM_SC_PS_DIV16 ) ; up_enable_irq ( HRT_TIMER_VECTOR ) ; }
Initialize the timer we are going to use.
Initialize the timer we are going to use .
/* Select a the clock source to the TPM */ /* Enabled System Clock Gating Control for TPM */ /* claim our interrupt vector */ /* disable and configure the timer */ /* set an initial capture a little ways off */ /* enable the timer */ /* enable interrupts */