示例#1
0
void SysTimerHandler(void)
{
    /// Clear interrupt flag
    MAP_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    /// Call disk process
    disk_timerproc();
}
//****************************************************************************
//
//! The delay function uses timer to implement the delay time in milliseconds
//!
//! \param time in millisecond
//
//!  \return void
//****************************************************************************
static void delay(int time_ms)
{
    // Initialize Timer 0B as one-shot down counter.
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_TIMERA0);
    MAP_TimerConfigure(TIMERA0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT);
    MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_B, PRESCALE);
    //Load the value in milisecond
    MAP_TimerLoadSet(TIMERA0_BASE, TIMER_B, MILLISECONDS_TO_TICKS(time_ms));
    // Enable the timer
    MAP_TimerEnable(TIMERA0_BASE, TIMER_B);
    //Stall during debug
    MAP_TimerControlStall(TIMERA0_BASE, TIMER_B, 1);
    // Enable interrupt upon Time-out
    MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
    // Clear Interrupt Flag
    MAP_TimerIntClear(TIMERA0_BASE, MAP_TimerIntStatus(TIMERA0_BASE, true));
    //Wait until timer time-out
    while (MAP_TimerIntStatus(TIMERA0_BASE, true) != TIMER_TIMB_TIMEOUT){}
    //Disable the timer
    MAP_TimerDisable(TIMERA0_BASE, TIMER_B);
    //Disable Interrupt
    MAP_TimerIntDisable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
    MAP_TimerIntUnregister(TIMERA0_BASE, TIMER_B);
}
示例#3
0
文件: main.c 项目: oter/BSPTools
//*****************************************************************************
//
//! Periodic Timer Interrupt Handler
//!
//! \param None
//!
//! \return None
//
//*****************************************************************************
void
TimerPeriodicIntHandler(void)
{
    unsigned long ulInts;
    
    //
    // Clear all pending interrupts from the timer we are
    // currently using.
    //
    ulInts = MAP_TimerIntStatus(TIMERA0_BASE, true);
    MAP_TimerIntClear(TIMERA0_BASE, ulInts);
    
    //
    // Increment our interrupt counter.
    //
    g_usTimerInts++;
    if(!(g_usTimerInts & 0x1))
    {
        //
        // Off Led
        //
        GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    }
    else
    {
        //
        // On Led
        //
        GPIO_IF_LedOn(MCU_RED_LED_GPIO);
    }
}
示例#4
0
//*****************************************************************************
//
//!    clears the timer interrupt
//!
//! \param ulBase is the base address for the timer.
//!
//! This function
//!     1. clears the interrupt with given base.
//!
//! \return none
//
//*****************************************************************************
void Timer_IF_InterruptClear(unsigned long ulBase)
{
    unsigned long ulInts;
    ulInts = MAP_TimerIntStatus(ulBase, true);
    //
    // Clear the timer interrupt.
    //
    MAP_TimerIntClear(ulBase, ulInts);
}
示例#5
0
文件: Tone.cpp 项目: Aginorty/Energia
void ToneIntHandler(void)
{
	MAP_TimerIntClear(TIMERA0_BASE, TIMER_B);

	if(--g_duration <= 0) {
		MAP_TimerIntDisable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
		MAP_TimerDisable(TIMERA0_BASE, TIMER_B);
		noTone(current_pin);
	}
}
static void TimerEmitCtrlHandler(void)
{
	//	Clear interrupt
	unsigned long ulInts;
	ulInts = MAP_TimerIntStatus(s_ulTimerEmitCtrl,true);
	MAP_TimerIntClear(s_ulTimerEmitCtrl,ulInts);
	
	s_ucLine++;
	s_nSampleIndex++;
	
	//	调节定时器
	EmitStop();
	if (s_nSampleIndex < 129) {
		EmitStart(FIX_E0DELAY);
	}
	
	//	启动采样与命令发送
	bool bEnPower = g_bRunning;
	s_bRxDone = false;
	//TRACE("0x%x\r\n",s_ucLine);
	
	//	缓冲区 乒乓操作
	unsigned char* pTmp;
	pTmp = s_pucRxRcv;	s_pucRxRcv = s_pucRxSnd;	s_pucRxSnd = pTmp;
	
	//	开始采样
	if ( 	((s_ucFrame & 0x01) == 0x00) 
		&&	(s_ucLine>127)
			)
	{
		DMATransceive((s_ucFrame & 0x01),g_ucZoom,g_ucGain,127,s_pucTx,s_pucRxRcv);
	}
	else {
		DMATransceive((s_ucFrame & 0x01),g_ucZoom,g_ucGain,s_ucLine,s_pucTx,s_pucRxRcv);
	}
	//	发送数据到无线连接
	if (s_nSampleIndex >= 3) {
		ISR_LineSend(s_ucFrame,s_nSampleIndex-3,s_pucRxSnd,512);
	}
	
	/*
	//	开始采样第下一条线
	s_ucLine++;
	Command(true,g_ucZoom,g_ucGain,s_ucLine);
	
	//	开始采样下一条线,并将读取的线送入队列
	if (s_nSampleIndex < 128)
		EmitStart(85000);
	else
		EmitStop();
	ReadSPI((unsigned char*)s_ucRxBuff,(unsigned char*)s_ucTxBuff,512);
	ISR_LineSend(s_ucFrame,s_nSampleIndex,(unsigned char*)s_ucRxBuff,512);
	s_nSampleIndex++;
	*/
}
示例#7
0
//*****************************************************************************
//
//! Timer interrupt handler
//
//*****************************************************************************
static void TimerIntHandler()
{
    //
    // Clear the interrupt
    //
    MAP_TimerIntClear(TIMERA2_BASE,TIMER_CAPA_EVENT);

    //
    // Get the samples and compute the frequency
    //
    g_ulSamples[0] = g_ulSamples[1];
    g_ulSamples[1] = MAP_TimerValueGet(TIMERA2_BASE,TIMER_A);
    g_ulFreq = (TIMER_FREQ/(g_ulSamples[0] - g_ulSamples[1]));
}
//	虚拟霍尔中断
void HallSyncHandler(void)
{
	//	Clear interrupt
	unsigned long ulInts;
	ulInts = MAP_TimerIntStatus(TIMERA2_BASE,true);
	MAP_TimerIntClear(TIMERA2_BASE,ulInts);
	
	
	//	送出控制命令
	if (ulInts & 0x01) {
		++g_nVirHallCnt;
		bool bCap = false;
		if (g_nVirHallCnt >= 10) {
			bCap = ISR_BufferCapacity();
		}

		//s_ucFrame++;	//	不论能不能缓冲均累计帧号,以此来区分丢帧
		if (bCap) {
			TRACE("VH\r\n");
			g_nVirHallCnt = 0;	// 复位计数器
			s_nSampleIndex = 0;
			s_ucFrame++;
			s_ucLine=0;
			s_pucTx = s_ucTxBuff;
	
			s_pucRxRcv = s_ucRxBuff_0;
			s_pucRxSnd = s_ucRxBuff_1;
			
			//	启动定时器
			TRACE("->\r\n");
			EmitStart(FIX_E0DELAY);
			//	启动DMA采样,同时发送命令
			s_bRxDone = false;
			
			DMATransceive( (s_ucFrame & 0x01) ,g_ucZoom,g_ucGain,s_ucLine,s_pucTx,s_pucRxRcv);
			
			/*
			EmitStart(85000);
			Command(true,g_ucZoom,g_ucGain,s_ucLine);	//	开始采样第一条线
			*/
		}
		else {
			//	注:前一次发射和采样还没有完成,无法开始新的一次采样
			if (g_nVirHallCnt == 10)
				EmitStop();
		}
	}
}
示例#9
0
//*****************************************************************************
//
//! \TimerA0IntHandler
//!
//! Handles interrupts for Timer A0, 
//!
//! \param None.
//!
//! \return None.
//
//*****************************************************************************
static void
TimerA0IntHandler(void)
{
    unsigned long ulStatus;
    unsigned long ulCountOnEntry;
    
    //
    // Clear all interrupts for Timer unit 0.
    //
    ulStatus = MAP_TimerIntStatus(TIMERA0_BASE, true);
    MAP_TimerIntClear(TIMERA0_BASE, ulStatus);
    
    //
    // Take a snapshot of the other interrupt's counter.
    //
    ulCountOnEntry = g_ulA1IntCount;
    MAP_TimerEnable(TIMERA1_BASE, TIMER_A);
    
    //
    // We wait 2mS to give the A1 interrupt a chance to fire. 
    //
    UTUtilsDelay(SLOW_TIMER_DELAY_uS);
    
    //
    // Determine whether the Timer A1 interrupt handler was processed during our
    // delay and set the global flag accordingly.
    //
    if(ulCountOnEntry == g_ulA1IntCount)
    {
        g_bA1CountChanged = false;
    }
    else
    {
        g_bA1CountChanged = true;
    }

    //
    // Increment our interrupt counter.
    //
    g_ulA0IntCount++;

    //
    // Alert to the user
    //
    UART_PRINT("Completed TimerA0 Interrupt Handler \n\r");
}
/* EFFECTS: Timer Interrupt handler, which toggles the RED led */
void TimerPeriodicIntHandler(void)
{
    unsigned long ulInts;

    // Clear all pending interrupts from the timer we are currently using.
    ulInts = MAP_TimerIntStatus(TIMERA0_BASE, true);
    MAP_TimerIntClear(TIMERA0_BASE, ulInts);

    // Increment our interrupt counter.
    if(g_usTimerInts)
    {
        GPIO_IF_LedOff(MCU_RED_LED_GPIO);
        g_usTimerInts = 0;
    }
    else
    {
        GPIO_IF_LedOn(MCU_RED_LED_GPIO);
        g_usTimerInts = 1;
    }
}
示例#11
0
//*****************************************************************************
//
//! \TimerA2IntHandler
//!
//! Handles interrupts for Timer A2.
//! This interrupt handler clears the source of the interrupt and
//! increments a counter and returns.
//!
//! \param None.
//!
//! \return None.
//
//*****************************************************************************
static void
TimerA2IntHandler(void)
{
    unsigned long ulStatus;
    
    //
    // Clear all interrupts for Timer. 
    //
    ulStatus = MAP_TimerIntStatus(TIMERA2_BASE, true);
    MAP_TimerIntClear(TIMERA2_BASE, ulStatus);

    //
    // Increment our global interrupt counter.
    //
    g_ulA2IntCount++;
    
    //
    // Alert to the User
    //
    UART_PRINT("Completed TimerA2 Interrupt Handler \n\r");
}
示例#12
0
static i32 hwt32_stop(struct hw_timer32* hwt)
{
        u32 status = 0;

        MAP_TimerDisable(hwt->base_addr, TIMER_A);
        MAP_TimerIntDisable(hwt->base_addr, hwt->irq_mask);

        status = MAP_TimerIntStatus(hwt->base_addr, true);
        MAP_TimerIntClear(hwt->base_addr, status);

        TimerValueSet(hwt->base_addr,TIMER_A,0x0);

        hwt32_set_op_mode(hwt, HW_TIMER_NOT_USED);

        hwt->irq_mask    = 0;
        hwt->n_rollovers = 0;
        hwt->sw_early_ro = false;

        hwt->mtone_expy.hi_32 = 0;
        hwt->mtone_expy.lo_32 = 0;

        return 0;
}
示例#13
0
void cc_hwt32_isr(cc_hndl hndl)
{
        u32 status;

        struct hw_timer32 *hwt = (struct hw_timer32*) hndl;

        if(NULL == hwt)
                return;

        status = MAP_TimerIntStatus(hwt->base_addr, true);

        if((false == hwt32_is_running(hwt)) ||
           (status & ~hwt->irq_mask))  
                goto hwt32_isr_exit;
        
                
        hwt32_handle_timeout(hwt, status);
        
 hwt32_isr_exit:
        MAP_TimerIntClear(hwt->base_addr, status);
        
        return;
}
示例#14
0
//*****************************************************************************
//
//! \PerformIntTest
//!
//! Performs the repeated steps in running each test scenario.
//!
//! \param ucPriorityA0 is the interrupt priority to be used for Timer A0
//! \param ucPriorityA1 is the interrupt priority to be used for Timer A1
//! \param ucPriorityA2 is the interrupt priority to be used for Timer A2
//!
//! This function performs all the steps which are common to each test scenario
//! inside function InterruptTest.
//!
//! \return None.
//
//*****************************************************************************
tBoolean
PerformIntTest(unsigned long ulPriBits, unsigned char ucPriorityA0,
       unsigned char ucPriorityA1,unsigned char ucPriorityA2)
{
    tBoolean bRetcode;
    unsigned long ulStatus;
    
    //
    // Set the appropriate interrupt priorities.
    //
    MAP_IntPriorityGroupingSet(ulPriBits);
    MAP_IntPrioritySet(INT_TIMERA0A, ucPriorityA0);
    MAP_IntPrioritySet(INT_TIMERA1A, ucPriorityA1);
    MAP_IntPrioritySet(INT_TIMERA2A, ucPriorityA2);
    
    //
    // Clear any pending timer interrupts
    //
    ulStatus = MAP_TimerIntStatus(TIMERA0_BASE, false);
    MAP_TimerIntClear(TIMERA0_BASE, ulStatus);
    ulStatus = MAP_TimerIntStatus(TIMERA1_BASE, false);
    MAP_TimerIntClear(TIMERA1_BASE, ulStatus);
    ulStatus = MAP_TimerIntStatus(TIMERA2_BASE, false);
    MAP_TimerIntClear(TIMERA2_BASE, ulStatus);
    
    //
    // Clear all the counters and flags used by the interrupt handlers.
    //
    g_ulA0IntCount = 0;
    g_ulA1IntCount = 0;
    g_ulA2IntCount=0;
    g_bA1CountChanged = false;
    
    //
    // Enable three timer interrupts
    //
    MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMA_TIMEOUT);
    MAP_TimerIntEnable(TIMERA1_BASE, TIMER_TIMA_TIMEOUT);
    MAP_TimerIntEnable(TIMERA2_BASE, TIMER_TIMA_TIMEOUT);
    
    //
    // Enable Timer A0
    //
    MAP_TimerEnable(TIMERA0_BASE, TIMER_A);
    
    //
    // Wait for Timer 0/A to fire.
    //
    bRetcode = UTUtilsWaitForCount(&g_ulA0IntCount, 1,
                                       ((SLOW_TIMER_DELAY_uS*3)/1000));
       
  
    //
    // Stop All timers and disable their interrupts
    //
    MAP_TimerDisable(TIMERA2_BASE, TIMER_A);
    MAP_TimerDisable(TIMERA1_BASE, TIMER_A);
    MAP_TimerDisable(TIMERA0_BASE, TIMER_A);
    MAP_TimerIntDisable(TIMERA2_BASE, TIMER_TIMA_TIMEOUT);
    MAP_TimerIntDisable(TIMERA1_BASE, TIMER_TIMA_TIMEOUT);
    MAP_TimerIntDisable(TIMERA0_BASE, TIMER_TIMA_TIMEOUT);

    return(bRetcode);
}
示例#15
0
// Timer interrupt service routine
void OneMsTaskTimer_int(void)
{
  // Clear the timer interrupt.
  MAP_TimerIntClear(g_ulBase, MAP_TimerIntStatus(g_ulBase, true));
  OneMsTaskTimer::_ticHandler();
}
示例#16
0
//*****************************************************************************
//
//! Application callback handler for GPT Timer A0 interrupt
//!
//! \param none
//!
//! This function
//!    1. Clears the WDT interrupt
//!
//! \return None.
//
//*****************************************************************************
void AppGPTCallBackHandler()
{
    MAP_TimerIntClear(TIMERA0_BASE,TIMER_TIMB_TIMEOUT|TIMER_TIMA_TIMEOUT);
    DBG_PRINT("GPT TimerA0 Interrupt occured\n\r");
}
示例#17
0
/*----------------------------------------------------------------------------*/
void hw_timer1a_int_handler()
{
    MAP_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
    tn_event_iset(g_timer1a_evt, g_timer1a_evt_pattern);
    tn_int_exit();
}