Esempio n. 1
0
void vInitialiseTimerForIntQueueTest( void )
{
const uint32_t ulTimer0Count = configCPU_CLOCK_HZ / tmrTIMER_0_FREQUENCY;
const uint32_t ulTimer1Count = configCPU_CLOCK_HZ / tmrTIMER_1_FREQUENCY;
const uint32_t ulTimer2Count = configCPU_CLOCK_HZ / tmrTIMER_2_FREQUENCY;

	tmrGIRQ23_ENABLE_SET = tmrGIRQ23_TIMER_BITS;

	/* Initialise the three timers as described at the top of this file, and
	enable their interrupts in the NVIC. */
	btimer_init( tmrTIMER_CHANNEL_0, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer0Count, ulTimer0Count );
	btimer_interrupt_status_get_clr( tmrTIMER_CHANNEL_0 );
	NVIC_SetPriority( TIMER0_IRQn, tmrLOWER_PRIORITY ); //0xc0 into 0xe000e431
	NVIC_ClearPendingIRQ( TIMER0_IRQn );
	NVIC_EnableIRQ( TIMER0_IRQn );
	btimer_start( tmrTIMER_CHANNEL_0 );

	btimer_init( tmrTIMER_CHANNEL_1, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer1Count, ulTimer1Count );
	btimer_interrupt_status_get_clr( tmrTIMER_CHANNEL_1 );
	NVIC_SetPriority( TIMER1_IRQn, tmrMEDIUM_PRIORITY ); //0xa0 into 0xe000e432
	NVIC_ClearPendingIRQ( TIMER1_IRQn );
	NVIC_EnableIRQ( TIMER1_IRQn );
	btimer_start( tmrTIMER_CHANNEL_1 );

	btimer_init( tmrTIMER_CHANNEL_2, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer2Count, ulTimer2Count );
	btimer_interrupt_status_get_clr( tmrTIMER_CHANNEL_2 );
	NVIC_SetPriority( TIMER2_IRQn, tmrHIGHER_PRIORITY );
	NVIC_ClearPendingIRQ( TIMER2_IRQn );
	NVIC_EnableIRQ( TIMER2_IRQn );
	btimer_start( tmrTIMER_CHANNEL_2 );
}
	static void prvSetupBasicTimer( void )
	{
	const uint8_t ucTimerChannel = 0;
	const uint32_t ulTimer0Count = configCPU_CLOCK_HZ / 10;

		/* Enable btimer 0 interrupt in the aggregated GIRQ23 block. */
		lpEC_GIRQ23_SOURCE = lpGIRQ23_BIT_TIMER0;
		lpEC_GIRQ23_ENABLE_CLEAR = lpGIRQ23_BIT_TIMER0;
		lpBLOCK_ENABLE_SET = lpBTIMER_GIRQ_BLOCK;
		lpGIRQ23_ENABLE_SET = lpGIRQ23_BIT_TIMER0;

		/* To fully test the low power tick processing it is necessary to sometimes
		bring the MCU out of its sleep state by a method other than the tick
		interrupt.  Interrupts generated from a basic timer are used for this
		purpose. */
		btimer_init( ucTimerChannel, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer0Count, ulTimer0Count );
		btimer_interrupt_status_get_clr( ucTimerChannel );
		NVIC_SetPriority( GIRQ23_IRQn, ucTimerChannel );
		NVIC_ClearPendingIRQ( GIRQ23_IRQn );
		NVIC_EnableIRQ( GIRQ23_IRQn );
		btimer_start( ucTimerChannel );
	}