示例#1
0
文件: io.c 项目: RevaReva/tiva-c
//*****************************************************************************
//
// Set the timer used to pace the animation.  We scale the timer timeout such
// that a speed of 100% causes the timer to tick once every 20 mS (50Hz).
//
//*****************************************************************************
static void
io_set_timer(unsigned long ulSpeedPercent)
{
    unsigned long ulTimeout;

    //
    // Turn the timer off while we are mucking with it.
    //
    ROM_TimerDisable(TIMER2_BASE, TIMER_A);

    //
    // If the speed is non-zero, we reset the timeout.  If it is zero, we
    // just leave the timer disabled.
    //
    if(ulSpeedPercent)
    {
        //
        // Set Timeout
        //
        ulTimeout = g_ui32SysClock / 50;
        ulTimeout = (ulTimeout * 100 ) / ulSpeedPercent;

        ROM_TimerLoadSet(TIMER2_BASE, TIMER_A, ulTimeout);
        ROM_TimerEnable(TIMER2_BASE, TIMER_A);
    }
}
示例#2
0
void
AcquireStop(void)
{

	tLogRecord pRecord;

	//pRecord.usItemMask = (unsigned short)15;
	//pRecord.sItems[0]=rcount;
	//pRecord.sItems[1]=rcount;
	//pRecord.sItems[2]=rcount;
	//pRecord.sItems[3]=rcount;
	//USBStickWriteRecord(&pRecord);
	//USBStickWriteRecord(&pRecord);

    // Disable ADC interrupts
    //
    ROM_IntDisable(INT_ADC0SS2);
    ROM_ADCSequenceDisable(ADC0_BASE, SEQUENCER);
    ROM_TimerDisable(TIMER0_BASE,TIMER_A);

    //ROM_IntMasterDisable();
   // ROM_IntDisable(INT_TIMER1A);
  //  ROM_TimerIntDisable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
//    ROM_TimerDisable(TIMER1_BASE, TIMER_A);


    //USBStickCloseFile();
}
示例#3
0
//*****************************************************************************
//
// The interrupt handler for the fourth timer interrupt. (light)
//
//*****************************************************************************
void
Timer3IntHandler(void)
{
    //
    // Clear the timer interrupt.
    //
    ROM_TimerIntClear(TIMER3_BASE, TIMER_TIMA_TIMEOUT);



	// Get the timer value and reset it
	ROM_TimerDisable(TIMER5_BASE, TIMER_A);
	// Get the timer value
	Timer = ROM_TimerValueGet(TIMER5_BASE, TIMER_A);
	// Reset the timer value to 65000
	ROM_TimerLoadSet(TIMER5_BASE, TIMER_A, 65000); // Timer5
	ROM_TimerEnable(TIMER5_BASE, TIMER_A);

    //
    // Toggle the flag for the light timer.
    //
    HWREGBITW(&g_ui32InterruptFlags, 2) = 1;

    //
    // Update the interrupt status.
    //

}
示例#4
0
//*****************************************************************************
//
//! Sets the blink rate of the RGB Led
//!
//! \param fRate is the blink rate in hertz.
//!
//! This function controls the blink rate of the RGB LED in auto blink mode.
//! to enable blinking pass a non-zero floating pointer number.  To disable
//! pass 0.0f as the argument. Calling this function will override the current
//! RGBDisable or RGBEnable status.
//!
//! \return None.
//
//*****************************************************************************
void
RGBBlinkRateSet(float fRate)
{
    uint64_t ui64Load;

    if(fRate == 0.0f)
    {
        //
        // Disable the timer and enable the RGB.  If blink rate is zero we
        // assume we want the RGB to be enabled. To disable call RGBDisable
        //
        ROM_TimerDisable(WTIMER5_BASE, TIMER_B);
        RGBEnable();
    }
    else
    {
        //
        // Keep the math in floating pointing until the end so that we keep as
        // much precision as we can.
        //
        ui64Load = (uint64_t) (((float)SysCtlClockGet()) / (fRate * 2.0f));
        ROM_TimerLoadSet(WTIMER5_BASE, TIMER_B, ui64Load);
        ROM_TimerEnable(WTIMER5_BASE, TIMER_B);
    }

}
//*****************************************************************************
//
// The interrupt handler for the periodic timer interrupt.  When the uDMA
// channel is used, interrupts from the periodic timer are used as DMA
// requests, and this interrupt handler is invoked only at the end of all of
// the DMA transfers.
//
//*****************************************************************************
void
Timer0IntHandler(void)
{
    unsigned long ulStatus;

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

    //
    // Read the uDMA channel status to verify it is done
    //
    ulStatus = uDMAChannelModeGet(UDMA_CHANNEL_TMR0A);
    if(ulStatus == UDMA_MODE_STOP)
    {
        //
        // Disable the periodic timer and set the done flag
        //
        ROM_TimerDisable(TIMER0_BASE, TIMER_A);
        g_bDoneFlag = 1;
    }

    //
    // Increment a counter to indicate the number of times this handler
    // was invoked
    //
    g_ulTimer0AIntCount++;
}
示例#6
0
void
MonitorStop() {
	ROM_TimerDisable(TIMER1_BASE, TIMER_A);
	//
	// Disable ADC sequencers
	//
	ROM_ADCSequenceDisable(ADC1_BASE, 3);
}
示例#7
0
//*****************************************************************************
//
//! Disable the RGB LED by configuring the GPIO's as inputs.
//!
//! This function or RGBEnable should be called during application
//! initialization to configure the GPIO pins to which the LEDs are attached.
//! This function disables the timers and configures the GPIO pins as inputs
//! for minimum current draw.
//!
//! \return None.
//
//*****************************************************************************
void
RGBDisable(void)
{
    //
    // Configure the GPIO pads as general purpose inputs.
    //
    ROM_GPIOPinTypeGPIOInput(RED_GPIO_BASE, RED_GPIO_PIN);
    ROM_GPIOPinTypeGPIOInput(GREEN_GPIO_BASE, GREEN_GPIO_PIN);
    ROM_GPIOPinTypeGPIOInput(BLUE_GPIO_BASE, BLUE_GPIO_PIN);

    //
    // Stop the timer counting.
    //
    ROM_TimerDisable(RED_TIMER_BASE, TIMER_BOTH);
    ROM_TimerDisable(GREEN_TIMER_BASE, TIMER_BOTH);
    ROM_TimerDisable(BLUE_TIMER_BASE, TIMER_BOTH);
}
示例#8
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);
}
示例#9
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);
    }

}
示例#10
0
void ping0InitPeriph( void ) {
	//
	// Disable timer and set parameters
	//
	ROM_TimerDisable( TIMER_BASE_PING0,	TIMER_PING0 );
	ROM_TimerPrescaleSet( TIMER_BASE_PING0, TIMER_PING0, 0 );
	ROM_TimerPrescaleMatchSet( TIMER_BASE_PING0, TIMER_PING0, 0 );
	ROM_TimerControlStall( TIMER_BASE_PING0, TIMER_PING0, false );

	IntPrioritySet( TIMER_INT_PING0, 0x40 ); // set to a middle priority group
	//
	// Register inerrupt
	//
	TimerIntRegister( TIMER_BASE_PING0, TIMER_PING0, &ping0Int );
}
示例#11
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);
}
//*****************************************************************************
//
// The interrupt handler for the SoftUART GPIO edge interrupt.
//
//*****************************************************************************
void
GPIOAIntHandler(void)
{
    //
    // Configure the SoftUART receive timer so that it will sample at the
    // mid-bit time of this character.
    //
    ROM_TimerDisable(TIMER0_BASE, TIMER_B);
    ROM_TimerLoadSet(TIMER0_BASE, TIMER_B, g_ulBitTime);
    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
    ROM_TimerEnable(TIMER0_BASE, TIMER_B);

    //
    // Call the SoftUART receive timer tick function.
    //
    SoftUARTRxTick(&g_sUART, true);
}
示例#13
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);
    }

}
示例#14
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;
}
示例#15
0
文件: delay.c 项目: knkp/stellarap
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);
  }
}
//*****************************************************************************
//
// The interrupt handler for the SoftUART receive timer interrupt.
//
//*****************************************************************************
void
Timer0BIntHandler(void)
{
    //
    // Clear the timer interrupt.
    //
    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

    //
    // Call the SoftUART receive timer tick function, and see if the timer
    // should be disabled.
    //
    if(SoftUARTRxTick(&g_sUART, false) == SOFTUART_RXTIMER_END)
    {
        //
        // Disable the timer interrupt since the SoftUART doesn't need it any
        // longer.
        //
        ROM_TimerDisable(TIMER0_BASE, TIMER_B);
    }
}
示例#17
0
void LEDToggleISR() {
	ROM_TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	//
	// Toggle the flag for the third timer.
	//
	HWREGBITW(&g_ui32Flags, 2) ^= 1;
//	HWREGBITW(GPIO_PORTG_BASE, 2) ^= 1;
	if (led_val == 255) {
		led_val = 0;
	} else {
		led_val = 255;
	}
	GPIOPinWrite(GPIO_PORTG_BASE,0x04, led_val);
	blink_count++;
	if (blink_count == MAX_BLINK_COUNT){
		ROM_TimerDisable(TIMER2_BASE, TIMER_A);
		// Start monitoring again
		blink_count = 0;
		MonitorStart();
	}
}
int main()
{
	ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
   	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
   	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_BLUE);

	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

    ROM_IntMasterEnable();

	ROM_TimerDisable(TIMER0_BASE, TIMER_A);
	ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
	ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet());

    ROM_IntEnable(INT_TIMER0A);
	ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntRegister(TIMER0_BASE, TIMER_A, Timer0AIntHandler);

	ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE, led_value);

	ROM_TimerEnable(TIMER0_BASE, TIMER_A);
	while(1)
   	{}
}
示例#19
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;

	}


}
示例#20
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);
}
示例#21
0
//*****************************************************************************
//
// The interrupt handler for the button interrupt.
//
//*****************************************************************************
void
ButtonIntHandler(void)
{
    //
    // Delay here on button push for simple debouncing.
    //
    SysCtlDelay(g_ui32SysClock / 10);

    //
    // Clear the timer interrupt.
    //
    ROM_GPIOIntClear(GPIO_PORTJ_AHB_BASE, GPIO_INT_PIN_0);

    //
    // Increment Mode.
    //
    g_ui32SleepMode = (g_ui32SleepMode + 1) % 3;

    switch (g_ui32SleepMode)
    {
        //
        // Enter Run Mode.
        //
        case 0:

            //
            // Disable the PWM.
            //
            ROM_PWMGenDisable(PWM0_BASE, PWM_GEN_0);

            //
            // Configure Toggle LED as a GPIO output.
            //
            ROM_GPIOPinTypeGPIOOutput(TOGGLE_GPIO_BASE, TOGGLE_GPIO_PIN);

            //
            // Enable the timer.
            //
            ROM_TimerEnable(TIMER0_BASE, TIMER_A);

            //
            // Print mode over the UART.
            //
            UARTprintf("\033[100D");
            UARTprintf("\033[K");
            UARTprintf("Run\t\tMOSC with PLL\tTimer");
            SysCtlDelay(10000);
            break;

            //
            // Enter Sleep Mode.
            //
        case 1:

            //
            // Print mode over the UART.
            // Delay to let the UART finish before going to Sleep.
            //
            UARTprintf("\033[100D");
            UARTprintf("\033[K");
            UARTprintf("Sleep\t\tPIOSC\t\tTimer");
            SysCtlDelay(10000);

            //
            // Switch clock to PIOSC and power down the MOSC before going into 
            // Sleep.
            //
            g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_OSC_INT |
                                                      SYSCTL_USE_OSC |
                                                      SYSCTL_MAIN_OSC_DIS), 
                                                      16000000);

            break;

            //
            // Enter Deep-Sleep Mode.
            //
        case 2:

            //
            // Switch back to the MOSC + PLL.
            //
            g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                                      SYSCTL_OSC_MAIN |
                                                      SYSCTL_USE_PLL |
                                                      SYSCTL_CFG_VCO_320), 
                                                      16000000);

            //
            // Disable the timer.
            //
            ROM_TimerDisable(TIMER0_BASE, TIMER_A);

            //
            // Configure the toggle pin as a PWM pin.
            //
            ROM_GPIOPinConfigure(GPIO_PF0_M0PWM0);
            ROM_GPIOPinTypePWM(TOGGLE_GPIO_BASE, TOGGLE_GPIO_PIN);

            //
            // Enable the PWM.
            //
            ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_0);

            //
            // Print mode over the UART.
            // Delay to let the UART finish before going to Sleep.
            //
            UARTprintf("\033[100D");
            UARTprintf("\033[K");
            UARTprintf("Deep-Sleep\tLFIOSC\t\tPWM");
            SysCtlDelay(10000);
            break;

        default:
            break;
    }

    //
    // Set LEDs to show what mode we are in.
    //
    PowerLEDsSet();
}
示例#22
0
//*****************************************************************************
//
// The interrupt handler for the third timer interrupt. (proximity)
//
//*****************************************************************************
void
Timer2IntHandler(void)
{
	//
	// Clear the timer interrupt.
	//
	ROM_TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);

	//Increment Timer A Count
	TimerCCount++;

	uint32_t ui32PulseStartTime; // Timer value at echo pulse rising edge
	uint32_t ui32PulseStopTime; // Timer value at echo pulse falling edge

	// // // Send a trigger pulse \\ \\ \\

	//
	// Enable the GPIO pin for the trigger pulse (M4).
	//
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE, GPIO_PIN_4);

	//
	// Turn on pulse.
	//
	MAP_GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_PIN_4);

	//
	// Delay for 5 us.
	//
	delayFiveMicroseconds(g_ui32SysClock);

	//
	// Turn off pulse.
	//
	MAP_GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_4, 0);


	// // // Measure pulse length \\ \\ \\

	//
	// Clear Timer A capture flag
	//
	TIMER4_ICR_R |= (1 << 2);

	//
	// Enable GPIO pin for timer event capture (M4).
	//
	ROM_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_4);

	//
	// Configure PM4 as Timer 4 CCP0
	//
	ROM_GPIOPinConfigure(GPIO_PM4_T4CCP0);

	//
	// Start Timer4 A
	//
	ROM_TimerEnable(TIMER4_BASE, TIMER_A);

	//
	// Wait for first capture event
	//
	while((TIMER4_RIS_R & (0x1 << 2)) == 0){};

	//
	// After first event, save timer A's captured value.
	//
	ui32PulseStartTime = TIMER4_TAR_R;

	//
	// Clear Timer A capture flag
	//
	TIMER4_ICR_R |= (1 << 2);

	//
	// Wait for second capture event
	//
	while((TIMER4_RIS_R & (0x1 << 2)) == 0){};

	//
	// After second event, save timer A's captured value.
	//
	ui32PulseStopTime = TIMER4_TAR_R;

	//
	// Calculate length of the pulse by subtracting the two timer values.
	// Note that even if stop time is less than start time, due to the
	// timer overflowing and starting over at 0, the 24 LSBs of our result are
	// still valid
	//
	g_ui32PulseLengthTicks = (ui32PulseStopTime - ui32PulseStartTime) & 0x0FFFFFF;

	//
	// Print the start time, stop time, and pulse length
	//
	//	UARTprintf("Pulse length: %d - %d = %d\n", ui32PulseStopTime,
	//		ui32PulseStartTime, ui32PulseLengthTicks);

	//
	// Print the distance
	//
	//UARTprintf("Distance: %d\n", ui32DistanceCM);

	//
	// Stop Timer4 A.
	//
	ROM_TimerDisable(TIMER4_BASE, TIMER_A);


	/*//
    // Use the flags to Toggle the LED for this timer
    //
    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, g_ui32Flags);*/

	//
	// Toggle the flag for the proximity timer.
	//
	HWREGBITW(&g_ui32InterruptFlags, 1) = 1;
}