Пример #1
0
//---- INT Handlers ----// 
void Timer0BIntHandler(void)
{
    //
    // Clear the timer interrupt flag.
    //
    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

    //
    // Update the periodic interrupt counter.
    //
    g_ui32Counter++;

    //
    // Once NUMBER_OF_INTS interrupts have been received, turn off the
    // TIMER0B interrupt.
    //
    if(g_ui32Counter == NUMBER_OF_INTS)
    {
        //
        // Disable the Timer0B interrupt.
        //
        ROM_IntDisable(INT_TIMER0B);

        //
        // Turn off Timer0B interrupt.
        //
        ROM_TimerIntDisable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

        //
        // Clear any pending interrupt flag.
        //
        ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
    }
    
}
Пример #2
0
void Timer0IntHandler(void){
	// Used to countdown from entered time

	// Clear the timer interrupt.
	ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

	// Check if time has been reached
	if(g_countdownTime == 0){
		ROM_IntMasterDisable();
		UARTprintf("Time's Up!\n\n");
		ROM_IntMasterEnable();
		ROM_TimerEnable(TIMER1_BASE, TIMER_A);
		ROM_TimerIntDisable(TIMER0_BASE, TIMER_A);
		return;
	}

	// Turn on LED
	ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED, LED_RED);
	ROM_TimerEnable(TIMER2_BASE, TIMER_A);

	// Update the interrupt status on the display.
	ROM_IntMasterDisable();
	UARTprintf("    %i\n",g_countdownTime);
	ROM_IntMasterEnable();

	// Decrement counter
	g_countdownTime--;
	
	// Turn off LED
	//ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED, 0);
}
Пример #3
0
void stop_Timer0B(void)
{
    ROM_IntDisable(INT_TIMER0B);

    ROM_TimerIntDisable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
}
Пример #4
0
void delay(unsigned long nTime) {
    ROM_TimerLoadSet(WTIMER5_BASE, TIMER_A, nTime * 10);

    ROM_TimerIntEnable(WTIMER5_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerEnable(WTIMER5_BASE, TIMER_A);
    ROM_SysCtlSleep();

    ROM_TimerIntDisable(WTIMER5_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerDisable(WTIMER5_BASE, TIMER_A);
}
Пример #5
0
void
ToneIntHandler(void)
{
    ROM_TimerIntClear(TIMER4_BASE, TIMER_A);

    //End of tone duration
    if(--g_duration <= 0) {
        	noTone(current_pin);
    		ROM_TimerIntDisable(TIMER4_BASE, TIMER_TIMA_TIMEOUT);
    		ROM_TimerIntClear(TIMER4_BASE, TIMER_TIMA_TIMEOUT);
    		ROM_TimerDisable(TIMER4_BASE, TIMER_A);
    }

}
Пример #6
0
void delay(uint32_t nTime)
{
    ROM_TimerLoadSet(WTIMER5_BASE, TIMER_A, nTime * 10);

    ROM_TimerIntEnable(WTIMER5_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerEnable(WTIMER5_BASE, TIMER_A);
    ROM_SysCtlSleep();

    // Make sure the timer finished, go back to sleep if it didn't
    // (Another interrupt may have woken up the system)
    while (ROM_TimerValueGet(WTIMER5_BASE, TIMER_A) != nTime * 10)
        ROM_SysCtlSleep();

    ROM_TimerIntDisable(WTIMER5_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerDisable(WTIMER5_BASE, TIMER_A);
}
Пример #7
0
/*
 * noTone() - Stop outputting the tone on a pin
 */
void noTone(uint8_t _pin)
{

	uint8_t timer = digitalPinToTimer(_pin);

    if(timer == tone_timer) {
		uint32_t timerBase = getTimerBase(timerToOffset(timer));
		uint32_t timerAB = TIMER_A << timerToAB(timer);
		ROM_TimerIntDisable(timerBase, TIMER_TIMA_TIMEOUT << timerToAB(tone_timer));
		ROM_TimerIntClear(timerBase, TIMER_TIMA_TIMEOUT << timerToAB(tone_timer));
		ROM_TimerDisable(timerBase, timerAB);
		tone_state = 0;
		g_duration = 0;
		pinMode(_pin, OUTPUT);
		digitalWrite(_pin, LOW);
    }

}
Пример #8
0
char stop()
{
    ROM_IntMasterDisable();
    ROM_IntDisable(INT_TIMER0A);
    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerIntDisable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerDisable(TIMER0_BASE, TIMER_A);
    ROM_GPIOPinIntClear(GPIO_PORTB_BASE, 0xff);
    ROM_GPIOPinIntDisable(GPIO_PORTB_BASE, 0xff);
    ROM_IntDisable(INT_GPIOB);
    ROM_IntPendClear(INT_TIMER0A);
    ROM_IntPendClear(INT_GPIOB);

    sampling = SAMPLING_OFF;
    tick = 0;

    led(0,1,0);

    return STATE_GET_COMMAND;
}
Пример #9
0
void Timer1IntHandler(void){

	// Clear the timer interrupt.
	ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);

	// Toggle flags
	HWREGBITW(&g_flags, 3) ^= 1;

	// Toggle LED
	ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_GREEN, g_flags);

	// Check if number of blinks is achieved
	if(g_flashCount >= 20){
		ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_GREEN, 0);
		ROM_TimerIntDisable(TIMER1_BASE, TIMER_A);	
	}

	// Increment counter
	g_flashCount++;
}
Пример #10
0
void delay_isr()
{
  ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
  
  if (delay_count > 50000)
  {
    delay_count -= 50000; 
    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, 50000*80000);
    ROM_TimerEnable(TIMER1_BASE, TIMER_A);
  } else if (delay_count > 0)
  {
    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, delay_count*80000);
    ROM_TimerEnable(TIMER1_BASE, TIMER_A);
    delay_count = 0;
  } else
  {
    delay_stat = DELAY_IDLE;
    ROM_TimerIntDisable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
    ROM_TimerDisable(TIMER1_BASE, TIMER_A);
  }
}
void throttleHome()
{
	uint8_t msg[3];
	int i;
	if (!LIMIT_SW_THROTTLE_DOWN_ON)
	{
		ROM_TimerIntDisable(WTIMER2_BASE, TIMER_CAPB_EVENT);//disable manual mode

		msg[0] = START_BYTE;
		msg[1] = HOME_CMD;
		msg[2] = 0;

		for (i=0;i<3;i++)
			ROM_UARTCharPut(UART_THROTTLE,msg[i]);

		ROM_TimerLoadSet(TIMER2_BASE, TIMER_A,ROM_SysCtlClockGet()*5);
		ROM_TimerEnable(TIMER2_BASE, TIMER_A);

		while ((!LIMIT_SW_THROTTLE_DOWN_ON) && (!flagTimeout));

		ROM_TimerIntEnable(WTIMER2_BASE, TIMER_CAPB_EVENT);
	}
}
Пример #12
0
// turn off the interrupts but don't turn of the timer because may
// be in use for pwm.
void OneMsTaskTimer::stop() {
  // disable interrupt
  ROM_TimerIntDisable(g_ulBase, TIMER_A);
  ROM_TimerIntClear(g_ulBase, TIMER_A);
  ROM_TimerDisable(g_ulBase, timerAB);
}
Пример #13
0
void ping0Int( void ) {
	// clear interrupts.
	ROM_TimerIntClear( TIMER_BASE_PING0, TIMER_PING0_MATCH|TIMER_PING0_EVENT|TIMER_PING0_TIMEOUT );
	switch( ping0state ) {
	case RECHARGE: // We are now done recharging:
		ping0state = INIT_PULSE; // Now we should start again
		// set IO pin as output
		ROM_GPIOPinTypeGPIOOutput( GPIO_BASE_PING0, GPIO_PIN_PING0 );
		ROM_GPIOPinConfigure( GPIO_MUX_PING0 );
		// drive IO pin high
		ROM_GPIOPinWrite( GPIO_BASE_PING0, GPIO_PIN_PING0, GPIO_PIN_PING0 );
		// stop timer
		ROM_TimerDisable( TIMER_BASE_PING0, TIMER_PING0 );
		// set timer for 2-5µs, single shot (start of with 5µs)
		ROM_TimerConfigure( TIMER_BASE_PING0, TIMER_CFG_SPLIT_PAIR | TIMER_PING0_ONE_SHOT );
		ROM_TimerLoadSet( TIMER_BASE_PING0, TIMER_PING0, INIT_PULSE_N );
		// set timer interrupt for end of count
		ROM_TimerIntDisable( TIMER_BASE_PING0, TIMER_PING0_MATCH|TIMER_PING0_EVENT );
		ROM_TimerIntEnable( TIMER_BASE_PING0, TIMER_PING0_TIMEOUT );
		// enable timer
		ROM_TimerEnable( TIMER_BASE_PING0, TIMER_PING0 );
		break;
	case INIT_PULSE: // We are now done sending the init pulse:
		ping0state = HOLDOFF; // Now we should wait some
		// drive low
		ROM_GPIOPinWrite( GPIO_BASE_PING0, GPIO_PIN_PING0, 0 );
		// set IO pin as input
		ROM_GPIOPinTypeGPIOInput( GPIO_BASE_PING0, GPIO_PIN_PING0 );
		ROM_GPIOPinConfigure( GPIO_MUX_PING0 );
		// stop timer
		ROM_TimerDisable( TIMER_BASE_PING0, TIMER_PING0 );
		// set timer for 500µs, single shot (holdoff is ~750µs)
		ROM_TimerConfigure( TIMER_BASE_PING0, TIMER_CFG_SPLIT_PAIR | TIMER_PING0_ONE_SHOT );
		ROM_TimerLoadSet( TIMER_BASE_PING0, TIMER_PING0, HOLDOFF_N );
		// set timer interrupt for end of count
		ROM_TimerIntDisable( TIMER_BASE_PING0, TIMER_PING0_MATCH|TIMER_PING0_EVENT );
		ROM_TimerIntEnable( TIMER_BASE_PING0, TIMER_PING0_TIMEOUT );
		// enable timer
		ROM_TimerEnable( TIMER_BASE_PING0, TIMER_PING0 );
		break;
	case HOLDOFF: // We are now done wating for the ping))) to start
		ping0state = WAIT_RISING; // Now we should wait for the begining of its reply
		// set IO pin as CCP
		ROM_GPIOPinTypeTimer( GPIO_BASE_PING0, GPIO_PIN_PING0 );
		ROM_GPIOPinConfigure( TIMER_MUX_PING0 );
		// stop timer
		ROM_TimerDisable( TIMER_BASE_PING0, TIMER_PING0 );
		// set timer to edge time
		ROM_TimerConfigure( TIMER_BASE_PING0, TIMER_CFG_SPLIT_PAIR | TIMER_PING0_TIME_UP );
		ROM_TimerLoadSet( TIMER_BASE_PING0, TIMER_PING0, 0xffffffff );
		// set count edge to rising
		ROM_TimerControlEvent( TIMER_BASE_PING0, TIMER_PING0, TIMER_EVENT_POS_EDGE );
		// set timer interrupt for event
		ROM_TimerIntDisable( TIMER_BASE_PING0, TIMER_PING0_TIMEOUT|TIMER_PING0_MATCH );
		ROM_TimerIntEnable( TIMER_BASE_PING0, TIMER_PING0_EVENT );
		// enable timer
		ROM_TimerEnable( TIMER_BASE_PING0, TIMER_PING0 );
		break;
	case WAIT_RISING: // We are now done wating for the ping))) to begin its relpy
		ping0state = WAIT_FALLING; // Now we should wait for the end of its reply
		ping0start = HWREG( TIMER_BASE_PING0 + TIMER_PING0_TR );
		ping0now = HWREG( TIMER_BASE_PING0 + TIMER_PING0_TV );
		// IO pin already CCP
		// stop timer
		ROM_TimerDisable( TIMER_BASE_PING0, TIMER_PING0 );
		// set count edge to falling
		ROM_TimerControlEvent( TIMER_BASE_PING0, TIMER_PING0, TIMER_EVENT_NEG_EDGE );
		// enable timer
		ROM_TimerEnable( TIMER_BASE_PING0, TIMER_PING0 );
		// Check if falling edge already occured, if it did: fall trough
		if ( ROM_GPIOPinRead( GPIO_BASE_PING0, GPIO_PIN_PING0 ) )
			break;
	case WAIT_FALLING: // We are now done wating for the ping))) to end its relpy
		ping0state = RECHARGE; // Now we should wait for the end of its reply
		ping0time = HWREG( TIMER_BASE_PING0 + TIMER_PING0_TR ) + ( ping0now - ping0start );
		ping0updated = true;


		int32_t pauseTime = PAUSE_TIME_N - ping0time;
		if ( pauseTime < PAUSE_TIME_MIN_N )
			pauseTime = PAUSE_TIME_MIN_N;

		// set IO pin as output
		ROM_GPIOPinTypeGPIOOutput( GPIO_BASE_PING0, GPIO_PIN_PING0 );
		ROM_GPIOPinConfigure( GPIO_MUX_PING0 );
		// drive IO pin low
		ROM_GPIOPinWrite( GPIO_BASE_PING0, GPIO_PIN_PING0, 0 );
		// stop timer
		ROM_TimerDisable( TIMER_BASE_PING0, TIMER_PING0 );
		// set timer for 200µs, single shot
		ROM_TimerConfigure( TIMER_BASE_PING0, TIMER_PING0_ONE_SHOT );
		ROM_TimerLoadSet( TIMER_BASE_PING0, TIMER_PING0, pauseTime );
		// set timer interrupt for end of count
		ROM_TimerIntDisable( TIMER_BASE_PING0, TIMER_PING0_MATCH|TIMER_PING0_EVENT );
		ROM_TimerIntEnable( TIMER_BASE_PING0, TIMER_PING0_TIMEOUT );
		// enable timer
		ROM_TimerEnable( TIMER_BASE_PING0, TIMER_PING0 );
		break;

	}


}