Skip to content
  • Tobias Badertscher's avatar
    stmhal/adc.c: Get ADC working on STM32L4 MCUs. · af9889f9
    Tobias Badertscher authored
    Fixing Issue #2243. Main problems were:
    
    - HAL_ADC_GetState(adcHandle) may return other bits set (not only
      HAL_ADC_STATE_EOC_REG) when called - so I AND-ed it out as proposed by
      mattbrejza in Issue #2243.
    - ADC Pin has to be configured as GPIO_MODE_ANALOG_ADC_CONTROL not only
      GPIO_MODE_ANALOG.
    - Resolved ADC resolution L4 specific (Use L4 define ADC_RESOLUTION_12B).
    - Changed setting of Init.EOCSelection toADC_EOC_SINGLE_CONV for L4.
    - Added call to ADC_MultiModeTypeDef as this is done on a STM32Cube
      generated project too.
    - Clean up: Configuration of ADC is done only in ONE function not the same
      is done in two functions.
    
    Test is done on PA5 pin of STM32L4Discovery-Kit which is connected to the
    DOWN button.
    
    Thanks to mattbrejza for discovering the bug.
    af9889f9