diff options
author | px4dev <px4@purgatory.org> | 2012-12-31 18:31:37 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-12-31 18:31:37 -0800 |
commit | b167912b1b3137c494a5033fe0dea6bb373624d2 (patch) | |
tree | 1ca2fbbd263c0f85a94ce67580a19cdb1755d912 /apps/drivers/stm32/adc/adc.cpp | |
parent | bc432b1feb906e5c2895d35bf1430fa6bf004061 (diff) | |
download | px4-firmware-b167912b1b3137c494a5033fe0dea6bb373624d2.tar.gz px4-firmware-b167912b1b3137c494a5033fe0dea6bb373624d2.tar.bz2 px4-firmware-b167912b1b3137c494a5033fe0dea6bb373624d2.zip |
Enable the temperature sensor channel for F2/F4 devices.
Diffstat (limited to 'apps/drivers/stm32/adc/adc.cpp')
-rw-r--r-- | apps/drivers/stm32/adc/adc.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/drivers/stm32/adc/adc.cpp b/apps/drivers/stm32/adc/adc.cpp index ed40b478a..87dac1ef9 100644 --- a/apps/drivers/stm32/adc/adc.cpp +++ b/apps/drivers/stm32/adc/adc.cpp @@ -91,6 +91,10 @@ #define rJDR4 REG(STM32_ADC_JDR4_OFFSET) #define rDR REG(STM32_ADC_DR_OFFSET) +#ifdef STM32_ADC_CCR +# define rCCR REG(STM32_ADC_CCR_OFFSET) +#endif + class ADC : public device::CDev { public: @@ -140,6 +144,9 @@ ADC::ADC(uint32_t channels) : { _debug_enabled = true; + /* always enable the temperature sensor */ + channels |= 1 << 16; + /* allocate the sample array */ for (unsigned i = 0; i < 32; i++) { if (channels & (1 << i)) { @@ -188,10 +195,16 @@ ADC::init() /* enable the temperature sensor / Vrefint channel if supported*/ rCR2 = #ifdef ADC_CR2_TSVREFE + /* enable the temperature sensor in CR2 */ ADC_CR2_TSVREFE | #endif 0; +#ifdef ADC_CCR_TSVREFE + /* enable temperature sensor in CCR */ + rCCR = ADC_CCR_TSVREFE; +#endif + /* configure for a single-channel sequence */ rSQR1 = 0; rSQR2 = 0; |