/* ** =================================================================== ** Method : AD1_OnMeasurementComplete (component ADC) ** ** Description : ** The method services the conversion complete interrupt of the ** selected peripheral(s) and eventually invokes the beans ** event(s). ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void AdcLdd1_OnMeasurementComplete(LDD_TUserData *UserDataPtr) { (void)UserDataPtr; /* Parameter is not used, suppress unused argument warning */ if (ModeFlg == STOP) { /* If the driver is in STOP mode */ return; /* Return from interrupt */ } if (ModeFlg == CALIBRATING) { /* If the driver is in CALIBRATING mode */ (void)AdcLdd1_GetCalibrationResultStatus(AdcLdd1_DeviceDataPtr); ModeFlg = STOP; /* Set the device to the stop mode */ AD1_OnCalibrationEnd(); /* If yes then invoke user event */ return; /* Return from interrupt */ } if (ModeFlg != SINGLE) { AdcLdd1_GetMeasuredValues(AdcLdd1_DeviceDataPtr, (LDD_TData *)&AD1_OutV); OutFlg = TRUE; /* Measured value is available */ AD1_OnEnd(); /* If yes then invoke user event */ if (ModeFlg == MEASURE) { /* Is the device in the measure state? */ ModeFlg = STOP; /* Set the device to the stop mode */ return; /* Return from interrupt */ } SampleGroup[0].ChannelIdx = 0U; /* Restart measurement */ (void)AdcLdd1_CreateSampleGroup(AdcLdd1_DeviceDataPtr, (LDD_ADC_TSample *)SampleGroup, 1U); /* Configure sample group */ (void)AdcLdd1_StartSingleMeasurement(AdcLdd1_DeviceDataPtr); } else { AdcLdd1_GetMeasuredValues(AdcLdd1_DeviceDataPtr, (LDD_TData *)&AD1_OutV); OutFlg = TRUE; /* Measured value is available */ AD1_OnEnd(); /* If yes then invoke user event */ ModeFlg = STOP; /* Set the device to the stop mode */ } }
/* ** =================================================================== ** Method : AD1_OnMeasurementComplete (component ADC) ** ** Description : ** The method services the conversion complete interrupt of the ** selected peripheral(s) and eventually invokes the beans ** event(s). ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void AdcLdd1_OnMeasurementComplete(LDD_TUserData *UserDataPtr) { AdcLdd1_TResultData ResultData; /* Temporary result data */ (void)UserDataPtr; /* Parameter is not used, suppress unused argument warning */ if (ModeFlg == CALIBRATING) { /* If the driver is in CALIBRATING mode */ (void)AdcLdd1_GetCalibrationResultStatus(AdcLdd1_DeviceDataPtr); ModeFlg = STOP; /* Set the device to the stop mode */ AD1_OnCalibrationEnd(); /* If yes then invoke user event */ return; /* Return from interrupt */ } AdcLdd1_GetMeasuredValues(AdcLdd1_DeviceDataPtr, (LDD_TData *)&ResultData); AD1_OutV[SumChan] += ResultData; SumChan++; /* Increase counter of measured channels*/ if (SumChan == 4U) { /* Is number of measured channels equal to the number of channels used in the component? */ SumChan = 0U; /* If yes then set the counter of measured channels to 0 */ SumCnt++; /* Increase counter of conversions*/ if (SumCnt == 128U) { /* Is number of conversions on each channel equal to the number of conversions defined in the component? */ OutFlg = TRUE; /* Measured values are available */ AD1_OnEnd(); /* If yes then invoke user event */ ModeFlg = STOP; /* Set the device to the stop mode */ return; /* Return from interrupt */ } } SampleGroup[0].ChannelIdx = SumChan; /* Start measurement of next channel */ (void)AdcLdd1_CreateSampleGroup(AdcLdd1_DeviceDataPtr, (LDD_ADC_TSample *)SampleGroup, 1U); /* Configure sample group */ (void)AdcLdd1_StartSingleMeasurement(AdcLdd1_DeviceDataPtr); }
/* ** =================================================================== ** Method : AD1_HWEnDi (component ADC) ** ** Description : ** Enables or disables the peripheral(s) associated with the ** component. The method is called automatically as a part of the ** Enable and Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void AD1_HWEnDi(void) { if (ModeFlg) { /* Start or stop measurement? */ OutFlg = FALSE; /* Output value isn't available */ SampleGroup[0].ChannelIdx = 0U; (void)AdcLdd1_CreateSampleGroup(AdcLdd1_DeviceDataPtr, (LDD_ADC_TSample *)SampleGroup, 1U); /* Configure sample group */ (void)AdcLdd1_StartSingleMeasurement(AdcLdd1_DeviceDataPtr); } }
/* ** =================================================================== ** Method : AD1_HWEnDi (component ADC) ** ** Description : ** Enables or disables the peripheral(s) associated with the ** component. The method is called automatically as a part of the ** Enable and Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void AD1_HWEnDi(void) { if (ModeFlg) { /* Start or stop measurement? */ OutFlg = FALSE; /* Output values aren't available */ SumChan = 0U; /* Set the counter of measured channels to 0 */ ClrSumV(); /* Clear measured values */ SampleGroup[0].ChannelIdx = 0U; (void)AdcLdd1_CreateSampleGroup(AdcLdd1_DeviceDataPtr, (LDD_ADC_TSample *)SampleGroup, 1U); /* Configure sample group */ (void)AdcLdd1_StartSingleMeasurement(AdcLdd1_DeviceDataPtr); } }
/* ** =================================================================== ** Method : MainMeasure (component ADC) ** ** Description : ** The method performs the conversion of the input channels in ** the polling mode. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void AD1_MainMeasure(void) { AdcLdd1_TResultData ResultData; byte SumCnt; /* Counter of conversions */ byte SumChan; /* Counter of measured channels */ for (SumCnt=0U; SumCnt<16U; SumCnt++) { for (SumChan=0U; SumChan<8U; SumChan++) { SampleGroup[0].ChannelIdx = SumChan; (void)AdcLdd1_CreateSampleGroup(AdcLdd1_DeviceDataPtr, (LDD_ADC_TSample *)SampleGroup, 1U); /* Configure sample group */ (void)AdcLdd1_StartSingleMeasurement(AdcLdd1_DeviceDataPtr); while (AdcLdd1_GetMeasurementCompleteStatus(AdcLdd1_DeviceDataPtr) == FALSE) {} /* Wait for AD conversion complete */ AdcLdd1_GetMeasuredValues(AdcLdd1_DeviceDataPtr, (LDD_TData *)&ResultData); AD1_OutV[SumChan] += ResultData; } } OutFlg = TRUE; /* Measured values are available */ ModeFlg = STOP; /* Set the device to the stop mode */ }