Exemplo n.º 1
0
void stellaris_timer_early_init(void)
{
	uint32_t clock_rate = SysCtlClockGet();
	tick_rate_mhz = clock_rate / 1000000;

#if 0
	SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);

	/* configure the timer as a 64bit up counting tick at syslock rate */
	TimerConfigure(WTIMER0_BASE, TIMER_CFG_PERIODIC_UP);
	TimerLoadSet64(WTIMER0_BASE, ULONG_MAX);
	TimerEnable(WTIMER0_BASE, TIMER_BOTH);
#endif
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: Teider/QuIES
//*****************************************************************************
//
// This example application demonstrates the use of the timers to generate
// periodic interrupts.
//
//*****************************************************************************
int
main(void)
{
    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
		FPUEnable();
		FPULazyStackingEnable();

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
	
		//
    // Enable processor interrupts.
    //
    IntMasterEnable();

    //
    // Initialize the UART and write status.
    //
    ConfigureUART();
		ConfigureXBeeUART();
		ConfigureUARTSensores();
		ButtonsInit();
		inicializa_motores();

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

    //
    // Configure the two 32-bit periodic timers.
    //
    TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
    TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet()/200000);
		
		
    //
    // Setup the interrupts for the timer timeouts.
    //
    IntEnable(INT_TIMER1A);
   
    TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);

    //
    // Enable the timers.
    //
		
    TimerEnable(TIMER1_BASE, TIMER_A);


		// Configure a wide timer for timing purposes
		
		SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
		TimerConfigure(WTIMER0_BASE, TIMER_CFG_PERIODIC_UP);
		TimerLoadSet64(WTIMER0_BASE, (((long long)1) << 60));
		TimerEnable(WTIMER0_BASE, TIMER_A);
	
	int counter_verify_no_ar = 0;
	
	while(1) {
		SysCtlDelay(SysCtlClockGet() / 1000);
		checkButtons();
		
		readPackage();
		
		counter_verify_no_ar++;
		
		if (counter_verify_no_ar == 1000) {
			counter_verify_no_ar = 0;
			if (no_ar) {
				enviaNoAr();
				no_ar = false;
			}
			if (no_chao) {
				enviaNoChao();
				no_chao = false;
			}
		}
	}
}
Exemplo n.º 3
0
void joystick_init(void) {

	// Register Joystick button isr
	GPIOPinTypeGPIOInput(JOY_PORT, JOY_MASK);
	GPIOPadConfigSet(JOY_PORT, JOY_MASK, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
	GPIOIntTypeSet(JOY_PORT, JOY_MASK, GPIO_BOTH_EDGES);
	GPIOPortIntRegister(JOY_PORT, button_handler);
	GPIOPinIntEnable(JOY_PORT, JOY_MASK);

    //
    // The ADC0 peripheral must be enabled for use.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

    //
    // Select the analog ADC function for these pins.
    //
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0);
    GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3);

    // Use sequences 0 and 1 for x and y.
    ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);

    // Single ended sample on CH3 (X) and CH4 (Y).
    ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);
    ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);

    // Enable the sequences.
    ADCSequenceEnable(ADC0_BASE, 0);
    ADCSequenceEnable(ADC0_BASE, 1);

    // Register ISRs.
    ADCIntRegister(ADC0_BASE, 0, x_handler);
    ADCIntRegister(ADC0_BASE, 1, y_handler);
    ADCIntEnable(ADC0_BASE, 0);
    ADCIntEnable(ADC0_BASE, 1);

    // Trigger the first conversion (auto-center)
	ADCProcessorTrigger(ADC0_BASE, 0);
	ADCProcessorTrigger(ADC0_BASE, 1);

	// Configure timer
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
	TimerConfigure(JOY_TIMER, TIMER_CFG_PERIODIC);


//	//Register Jog Z buttons
//	GPIOPinTypeGPIOInput(JOG_Z_PORT, JOG_Z_MASK);
//	GPIOIntTypeSet(JOG_Z_PORT, JOG_Z_MASK, GPIO_BOTH_EDGES);
//	GPIOPortIntRegister(JOG_Z_PORT, jog_z_handler);
//	GPIOPinIntEnable(JOG_Z_PORT, JOG_Z_MASK);
//	GPIOPadConfigSet(JOG_Z_PORT,JOG_Z_MASK,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD);

	// Create a 10ms timer callback
	TimerLoadSet64(JOY_TIMER, SysCtlClockGet() / 500);
	TimerIntRegister(JOY_TIMER, TIMER_A, joystick_isr);
	TimerIntEnable(JOY_TIMER, TIMER_TIMA_TIMEOUT);
	IntPrioritySet(INT_TIMER3A, CONFIG_JOY_PRIORITY);
	TimerEnable(JOY_TIMER, TIMER_A);
}