mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/TARGET_STM/TARGET_STM32L0/analogin_device.c
- Revision:
- 189:f392fc9709a3
- Parent:
- 188:bcfe06ba3d64
--- a/targets/TARGET_STM/TARGET_STM32L0/analogin_device.c Thu Nov 08 11:46:34 2018 +0000 +++ b/targets/TARGET_STM/TARGET_STM32L0/analogin_device.c Wed Feb 20 22:31:08 2019 +0000 @@ -172,20 +172,16 @@ HAL_ADC_ConfigChannel(&obj->handle, &sConfig); - /* need to wait for some stabilization time after setting the TSEN bit in the ADC_CCR - register to wake up the temperature sensor from power down mode */ - if (sConfig.Channel == ADC_CHANNEL_TEMPSENSOR) { - wait_ms(20); - } - HAL_ADC_Start(&obj->handle); // Start conversion // Wait end of conversion and get value + uint16_t adcValue = 0; if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) { - return (uint16_t)HAL_ADC_GetValue(&obj->handle); - } else { - return 0; + adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle); } + sConfig.Rank = ADC_RANK_NONE; + HAL_ADC_ConfigChannel(&obj->handle, &sConfig); + return adcValue; } #endif