void RMBD01Init( void ) { // // Configure the ADC for Pitch and Roll // sequence 3 means a single sample // sequence 1, 2 means up to 4 samples // sequence 0 means up to 8 samples // we use sequence 1 // if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ADC0)) { SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_TIMER, 0); // 1 captures up to 4 samples // // Select the external reference for greatest accuracy. // ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V); ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ENCODER_CHANNEL_PITCH); // sample pitch ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ENCODER_CHANNEL_ROLL | ADC_CTL_IE | ADC_CTL_END); // sample roll ADCIntRegister(ADC0_BASE,1,ADCIntHandler); ADCSequenceEnable(ADC0_BASE, 1); ADCIntEnable(ADC0_BASE, 1); // // Setup timer for ADC_TRIGGER_TIMER // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Configure the second timer to generate triggers to the ADC // TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER); TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet() / 1000); // 2 ms TimerControlStall(TIMER1_BASE, TIMER_A, true); TimerControlTrigger(TIMER1_BASE, TIMER_A, true); // // Enable the timers. // TimerEnable(TIMER1_BASE, TIMER_A); new_adc = false; // } // // Clear outstanding ADC interrupt and enable // ADCIntClear(ADC0_BASE, 1); IntEnable(INT_ADC0); } // InitADC
/*---------------------------------------------------------------------------*/ void clock_init(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet()/1000); TimerControlStall(TIMER0_BASE,TIMER_A,true); TimerEnable(TIMER0_BASE, TIMER_A); ROM_IntEnable(INT_TIMER0A); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ROM_TimerEnable(TIMER0_BASE, TIMER_A); count = 0; }
void confTimer(){ //Inicializamos el TIMER2 para el ADC como Trigger a una frecuencia de 10Hz SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER2); TimerControlStall(TIMER2_BASE,TIMER_A,true); TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC); uint32_t ui32Period = SysCtlClockGet() *0.1; TimerLoadSet(TIMER2_BASE, TIMER_A, ui32Period -1); TimerControlTrigger(TIMER2_BASE,TIMER_A,true); TimerEnable(TIMER2_BASE, TIMER_A); //Inicializamos el TIMER4 para la pulsación larga con un periodo de 2 segundos SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER4); TimerConfigure(TIMER4_BASE, TIMER_CFG_ONE_SHOT); ui32Period = (SysCtlClockGet() *2) ; TimerLoadSet(TIMER4_BASE, TIMER_A, ui32Period -1); IntEnable(INT_TIMER4A); TimerIntRegister(TIMER4_BASE,TIMER_A,timerBotonHandler); IntPrioritySet(INT_TIMER4A,5<<5); TimerIntEnable(TIMER4_BASE, TIMER_TIMA_TIMEOUT); }
void RMBD01Init(void) { // // Configure the ADC for Pitch and Roll // sequence 3 means a single sample // sequence 1, 2 means up to 4 samples // sequence 0 means up to 8 samples // we use sequence 1 // if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ADC0)) { SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // // Configure the pins to be used as analog inputs. // GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3); // // Select the external reference for greatest accuracy. // //ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V); // // Only for LM4F232 Apply workaround for erratum 6.1, in order to use the // external reference. // //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //HWREG(GPIO_PORTB_BASE + GPIO_O_AMSEL) |= GPIO_PIN_6; ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); // 1 captures up to 4 samples //ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); // 1 captures up to 4 samples //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ENCODER_CHANNEL_PITCH); // sample pitch //ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ENCODER_CHANNEL_ROLL | ADC_CTL_IE | ADC_CTL_END); // sample roll ADCHardwareOversampleConfigure(ADC0_BASE, 64); //ADCSoftwareOversampleConfigure(ADC0_BASE, 0, 8); //ADCSoftwareOversampleStepConfigure(ADC0_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END)); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0); //ADCSoftwareOversampleStepConfigure(ADC0_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END)); //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0); // sample roll //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END); // sample roll //ADCIntRegister(ADC0_BASE,0,ADCIntHandler); // // Enable the sequencer and interrupt // ADCSequenceEnable(ADC0_BASE, 3); ADCIntEnable(ADC0_BASE, 3); IntEnable(INT_ADC3); // // Zero the oversample counter and the sum // g_ucOversampleCnt = 0; g_ulSum = 0; //ADCSequenceEnable(ADC0_BASE, 2); //ADCIntEnable(ADC0_BASE, 2); #if 0 // // Enable the ADC sequencers // ADCSequenceEnable(ADC0_BASE, 0); // // Flush the ADC sequencers to be sure there is no lingering data. // ADCSequenceDataGet(ADC0_BASE, 0, PitchRollAmp); // // Enable ADC interrupts // ADCIntClear(ADC0_BASE, 0); ADCIntEnable(ADC0_BASE, 0); IntEnable(INT_ADC0SS0); #else // // Setup timer for ADC_TRIGGER_TIMER // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Configure the second timer to generate triggers to the ADC // TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER); TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() / 20000); // 50 us == 20K ulTimeSysClock = ROM_SysCtlClockGet()/20000; TimerControlStall(TIMER1_BASE, TIMER_A, true); TimerControlTrigger(TIMER1_BASE, TIMER_A, true); // // Enable the timers. // TimerEnable(TIMER1_BASE, TIMER_A); #endif new_adc = false; // } // // Clear outstanding ADC interrupt and enable // //ADCIntClear(ADC0_BASE, 2); //ADCIntEnable(ADC0_BASE, 2); //IntEnable(INT_ADC2); // // Set the zero current to indicate that the initial sampling has just // begun. // g_usCurrentZero = 0xffff; } // InitADC