Example #1
0
/*
** ===================================================================
**     Method      :  AD2_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 AdcLdd2_OnMeasurementComplete(LDD_TUserData *UserDataPtr)
{
  (void)UserDataPtr;                   /* Parameter is not used, suppress unused argument warning */
  if (ModeFlg == CALIBRATING) {        /* If the driver is in CALIBRATING mode */
    (void)AdcLdd2_GetCalibrationResultStatus(AdcLdd2_DeviceDataPtr);
    ModeFlg = STOP;                    /* Set the device to the stop mode */
    AD2_OnCalibrationEnd();            /* If yes then invoke user event */
    return;                            /* Return from interrupt */
  }
  AdcLdd2_GetMeasuredValues(AdcLdd2_DeviceDataPtr, (LDD_TData *)&AD2_OutV);
  OutFlg = TRUE;                       /* Measured value is available */
  AD2_OnEnd();                         /* If yes then invoke user event */
  ModeFlg = STOP;                      /* Set the device to the stop mode */
}
/*
** ===================================================================
**     Method      :  M1_ANALOG_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 AdcLdd2_OnMeasurementComplete(LDD_TUserData *UserDataPtr)
{
  word 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)AdcLdd2_GetCalibrationResultStatus(AdcLdd2_DeviceDataPtr);
    ModeFlg = STOP;                    /* Set the device to the stop mode */
    M1_ANALOG_OnCalibrationEnd();      /* If yes then invoke user event */
    return;                            /* Return from interrupt */
  }
  AdcLdd2_GetMeasuredValues(AdcLdd2_DeviceDataPtr, (LDD_TData *)&ResultData);
  M1_ANALOG_SumV[SumChan] += ResultData;
  SumChan++;                           /* Increase counter of measured channels*/
  if (SumChan == 2U) {                 /* 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 == 8U) {                /* Is number of conversions on each channel equal to the number of conversions defined in the component? */
      OutFlg = TRUE;                   /* Measured values are available */
      M1_ANALOG_OutV[0] = (word)M1_ANALOG_SumV[0]; /* Save measured value to the output buffer */
      M1_ANALOG_OutV[1] = (word)M1_ANALOG_SumV[1]; /* Save measured value to the output buffer */
      if (ModeFlg != MEASURE) {        /* Is the device in other then measure state? */
        M1_ANALOG_SumV[0] = 0U;        /* Set mesured values to 0 */
        M1_ANALOG_SumV[1] = 0U;        /* Set mesured values to 0 */
        SumCnt = 0U;                   /* Set counter of conversions to 0 */
      }
      M1_ANALOG_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 = SumChan; /* Start measurement of next channel */
  (void)AdcLdd2_CreateSampleGroup(AdcLdd2_DeviceDataPtr, (LDD_ADC_TSample *)SampleGroup, 1U); /* Configure sample group */
  (void)AdcLdd2_StartSingleMeasurement(AdcLdd2_DeviceDataPtr);
}