コード例 #1
0
ファイル: rits.c プロジェクト: patriciobos/TpFinal
/* Set timer interval value */
void Chip_RIT_SetTimerInterval_(LPC_RITIMER_T *pRITimer, uint32_t time_interval)
{
	uint32_t cmp_value;

	/* Determine aapproximate compare value based on clock rate and passed interval */
	cmp_value = ((Chip_Clock_GetRate(CLK_MX_RITIMER) / 1000) * time_interval )/ 1000;

	/* Set timer compare value */
	Chip_RIT_SetCOMPVAL(pRITimer, cmp_value);

	/* Set timer enable clear bit to clear timer to 0 whenever
	   counter value equals the contents of RICOMPVAL */
	Chip_RIT_EnableCTRL(pRITimer, RIT_CTRL_ENCLR);
}
コード例 #2
0
ファイル: timers.c プロジェクト: LeoSf/postgraduate_course
/** \brief Set timer interval value in microseconds */
void Chip_RIT_SetTimerIntervaluS(LPC_RITIMER_T *pRITimer, uint32_t time_interval_us)
{
	/** \details
	 * This method is a copy of Chip_RIT_SetTimerInterval provided by vendor, in which
	 * I made a minimal change to obtain a function that uses as parameter a number
	 * in microseconds to interrupt with the RIT timer
	 *
	 * \param LPC_RITIMER_T *pRITimer: pointer to the RIT timer.
	 * \param uint32_t time_interval_us: time interval in microseconds.
	 *
	 * \return nothing
	 * */
	uint32_t cmp_value;

	/* Determine approximate compare value based on clock rate and passed interval */
	cmp_value = (Chip_Clock_GetRate(CLK_MX_RITIMER)/1000000) * time_interval_us;

	/* Set timer compare value */
	Chip_RIT_SetCOMPVAL(pRITimer, cmp_value);

	/* Set timer enable clear bit to clear timer to 0 whenever
	   counter value equals the contents of RICOMPVAL */
	Chip_RIT_EnableCTRL(pRITimer, RIT_CTRL_ENCLR);
}