//*****************************************************************************
//
// This function is called to stop an acquisition running.  It disables the
// ADC sequencers and the RTC match interrupt.
//
//*****************************************************************************
void
AcquireStop(void)
{
    //
    // Disable RTC interrupts
    //
    MAP_IntDisable(INT_HIBERNATE);

    //
    // Disable ADC interrupts
    //
    MAP_IntDisable(INT_ADC0SS0);
    MAP_IntDisable(INT_ADC1SS0);

    //
    // Disable ADC sequencers
    //
    MAP_ADCSequenceDisable(ADC0_BASE, 0);
    MAP_ADCSequenceDisable(ADC1_BASE, 0);

    //
    // If USB stick is being used, then close the file so it will flush
    // the buffers to the USB stick.
    //
    if(g_psConfigState->ui8Storage == CONFIG_STORAGE_USB)
    {
        USBStickCloseFile();
    }

    //
    // Disable the configuration pointer, which acts as a flag to indicate
    // if we are properly configured for data acquisition.
    //
    g_psConfigState = 0;
}
Esempio n. 2
0
/*
 * @brief Initializes gyro.
 *
 * Sets sampling speed, configures and enables the gyro.
 * @returns void
 */
void gyro_init(void) {
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);

	//Set sampling speed
	MAP_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS);

	//Disable sample sequences for configuration
	MAP_ADCSequenceDisable(ADC_BASE, GYRO_ADC_CHANNEL);

	//Timer Trigger, priorities are same as number
	MAP_ADCSequenceConfigure(ADC_BASE, GYRO_ADC_CHANNEL, ADC_TRIGGER_PROCESSOR, GYRO_ADC_CHANNEL);

	MAP_ADCSequenceStepConfigure(ADC_BASE, GYRO_ADC_CHANNEL, 0, ADC_CTL_CH3 | ADC_CTL_END);

	//Config sequence steps
	MAP_ADCSequenceEnable(ADC_BASE, GYRO_ADC_CHANNEL);

}
void configureADC()
{
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

	MAP_SysCtlDelay(2);

	// Disable sequencer 0
	MAP_ADCSequenceDisable(ADC0_BASE, 3);

	//
	// Configure GPIO Pin
	//
	MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_7);

	//  **************************
	// Configure timer
	//  **************************
	MAP_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);

	// Load timer for periodic sampling of ADC
	MAP_TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock/SAMPLING_RATE);

	// Enable ADC triggering
	MAP_TimerControlTrigger(TIMER1_BASE, TIMER_A, true);

	// Trigger ADC on timer A timeout
	MAP_TimerADCEventSet(TIMER1_BASE, TIMER_ADC_TIMEOUT_A);

	// **************************
	// Configure ADC
	// **************************
	// Clear the interrupt raw status bit (should be done early
	// on, because it can take several cycles to clear.)
	MAP_ADCIntClear(ADC0_BASE, 3);

	// ADC0, Seq 0, Timer triggered, Priority 0
	MAP_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
	//	MAP_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

	/*// Set all 8 sequencer steps to sample from analog channel 5 (PD7)
	int i;
	for(i = 0; i < 1; i++)
	{
	  MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, i, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);
	}

	// Configure step 7 to trigger interrupt, and be the end of sequence
//	MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);
	 */
	MAP_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);

	MAP_ADCSequenceEnable(ADC0_BASE, 3);

	// Enable interrupts when sample conversion complete
	MAP_ADCIntEnable(ADC0_BASE, 3);

	// Enable NVIC interrupt for ADC0 SS0
	MAP_IntEnable(INT_ADC0SS3);

	MAP_IntMasterEnable();

	MAP_TimerEnable(TIMER1_BASE, TIMER_A);
}