AnsweredAssumed Answered

shared adc component

Question asked by bataliero on Sep 17, 2012
Latest reply on Nov 12, 2015 by Elisa Mejia

Hi ,

Is it possible to create shared ADC component on Kinetis K60 ? I have to get values from 4 pins on ADC0 and ADC1 . It would be more elegant to do not have duplicated code like

 

LDD_TError Adc0_GetMeasuredValues(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr)
{
  uint8_t Sample;
  AdConv0_TResultData *pBuffer = (AdConv0_TResultData *)BufferPtr;

  /* Copy values from result registers defined in the active sample
     group to the user supplied buffer */
  for (Sample = 0U; Sample < ((AdConv0_TDeviceDataPtr)DeviceDataPtr)->SampleCount; Sample++) {
    pBuffer[Sample] = (uint16_t)(ADC_PDD_GetResultValueRaw(ADC0_BASE_PTR, Sample));
  }
  return ERR_OK;                       /* OK */
}

 

 

LDD_TError Adc1_GetMeasuredValues(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr)
{
  uint8_t Sample;
  AdConv1_TResultData *pBuffer = (AdConv1_TResultData *)BufferPtr;

  /* Copy values from result registers defined in the active sample
     group to the user supplied buffer */
  Sample = ((AdConv1_TDeviceDataPtr)DeviceDataPtr)->SampleCount;
  for (Sample = 0U; Sample < ((AdConv1_TDeviceDataPtr)DeviceDataPtr)->SampleCount; Sample++) {
    pBuffer[Sample] = (uint16_t)(ADC_PDD_GetResultValueRaw(ADC1_BASE_PTR, Sample));
  }
  return ERR_OK;                       /* OK */
}

Outcomes