//***************************************************************************** // // This is the data acquisition module. It performs acquisition of data from // selected channels, starting and stopping data logging, storing acquired // data, and running the strip chart display. // //***************************************************************************** /* Notes: 12 shared analog input channels 12-bit precision ADC Hardware averaging of up to 64 samples As referred before the ADC has a reference of 3V. Voltage reference selected using the VREF field in the ADCCTL register (page 1217) J0062 PIN 21 - AN_IDS_PRESSENS_7 PIN 9 - GND J0252 PIN 21 - AN_IDS_PRESSENS_1 PIN 9 - GND J0042 PIN 21 - AN_IDS_PRESSENS_3 PIN 9 - GND ----------------- void ADCAcquireInit(void) // (MillisecInit) ok void ADCAcquireStart(ProcessCallback _callback, uint32_t _period)// (called by MillisecStart) //reading Trigger uint32_t ADC_TriggerCollection(void) // MillisecLoop //Data Get void ADC0SS0Handler(void) //---------------------------------------------------- uint32_t ADC_GetReading(int DataItemId)// ADC Data get for a single data read Void ADCProcessTask(UArg arg0, UArg arg1) void ADCAcquireStop(void) //MillisecStop //--------------------------------- for (adc_i = 0; adc_i < MAX_ADC_DEVICES ; adc_i++) ADC_Data[adc_i] = ADC_GetReading(adc_i); */ #include "ADC.h" #include "include.h" #include #include #include #include #include #include #include #include #include #include "Drivers/I2C_Communication/I2C.h" //***************************************************************************** // // The following defines which ADC channel control should be used for each // kind of data item. Basically it maps how the ADC channels are connected // on the board. This is a hardware pinmap configuration. // Physical ADC connected channels in the TIVA //***************************************************************************** #define CHAN_AIR_PRESSURE_1 ADC_CTL_CH0 #define CHAN_AIR_PRESSURE_2 ADC_CTL_CH1 #define CHAN_DISPENSE_PRESSURE_1 ADC_CTL_CH2 #define CHAN_DISPENSE_PRESSURE_2 ADC_CTL_CH3 #define CHAN_DISPENSE_PRESSURE_3 ADC_CTL_CH4 #define CHAN_DISPENSE_PRESSURE_4 ADC_CTL_CH5 #define CHAN_DISPENSE_PRESSURE_5 ADC_CTL_CH6 #define CHAN_DISPENSE_PRESSURE_6 ADC_CTL_CH7 #define CHAN_DISPENSE_PRESSURE_7 ADC_CTL_CH8 #define CHAN_DISPENSE_PRESSURE_8 ADC_CTL_CH9 #define CHAN_LEFT_DANCER_1 ADC_CTL_CH13 #define CHAN_LEFT_DANCER_2 ADC_CTL_CH14 #define CHAN_RIGHT_DANCER ADC_CTL_CH15 #define CHAN_DRYER_CURRENT_1 ADC_CTL_CH16 #define CHAN_DRYER_CURRENT_2 ADC_CTL_CH17 #define CHAN_DRYER_CURRENT_3 ADC_CTL_CH18 //***************************************************************************** // // The following maps the order that items are acquired and stored by the // ADC sequencers. Note that 16 samples are specified, using 2 of the // 8 sample sequencers. The current is sampled multiple times deliberately // because that value tends to bounce around. It is sampled multiple // times and will be averaged. // //***************************************************************************** uint32_t g_pui32ADCSeq[] = { CHAN_AIR_PRESSURE_1,CHAN_AIR_PRESSURE_2, CHAN_DISPENSE_PRESSURE_1, CHAN_DISPENSE_PRESSURE_2, CHAN_DISPENSE_PRESSURE_3, CHAN_DISPENSE_PRESSURE_4, CHAN_DISPENSE_PRESSURE_5, CHAN_DISPENSE_PRESSURE_6, CHAN_DISPENSE_PRESSURE_7, CHAN_DISPENSE_PRESSURE_8, CHAN_LEFT_DANCER_1, CHAN_LEFT_DANCER_2, CHAN_RIGHT_DANCER, CHAN_DRYER_CURRENT_1, CHAN_DRYER_CURRENT_2, CHAN_DRYER_CURRENT_3 }; #define NUM_ADC_CHANNELS (sizeof(g_pui32ADCSeq) / \ sizeof(g_pui32ADCSeq[0])) //#define SAMPLE_ARRAY_SIZE (NUM_ADC_CHANNELS + I2C_NUM_OF_CHANNELS) #define SAMPLE_ARRAY_SIZE NUM_ADC_CHANNELS #define DOUBLE_BUFFER 2 static bool isInitialized = false; static bool adcCollectActive = false; static int bufferFlipFlop = 0; //***************************************************************************** // // Global _storage for most recent sampaled Sensor Data // //***************************************************************************** // // A buffer to hold one set of ADC data that is acquired per sample time. // //***************************************************************************** static uint32_t g_pui32ADCData[DOUBLE_BUFFER][SAMPLE_ARRAY_SIZE]; //***************************************************************************** //configured in the cfg file and thats why should be defined as extern //***************************************************************************** extern Semaphore_Handle adcResultSem; static ProcessCallback processCallBack; //***************************************************************************** // ADCClockHandle: clock event handler - initiates trigger for the adc sampaling //***************************************************************************** // This function starts an ADC Conversion. //static void ADCClockHandle(UArg arg0) uint32_t ADC_TriggerCollection(void) // (called by MillisecLoop) { // // Kick off the next ADC acquisition. When these are done they will // cause an ADC interrupt. // if (adcCollectActive == true) { MAP_ADCProcessorTrigger(ADC1_BASE, 0); MAP_ADCProcessorTrigger(ADC0_BASE, 0); } return 0; } //***************************************************************************** // // ADC Data get for a single data read // //***************************************************************************** uint32_t ADC_GetReading(int DataItemId) // // ADC Data get for a single data read { int bufnotinuse; assert (DataItemId