mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/{gd32v,stm32}/periph/adc: ensure max ADC speed is honored
This patch ensures that the ADC's max clock speed is not exceded.
This commit is contained in:
parent
4218fca673
commit
410e55d912
@ -22,6 +22,7 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "cpu.h"
|
||||
#include "macros/units.h"
|
||||
#include "mutex.h"
|
||||
@ -128,6 +129,7 @@ int adc_init(adc_t line)
|
||||
break;
|
||||
}
|
||||
}
|
||||
assume((periph_apb_clk(APB2) / clk_div) <= ADC_CLK_MAX);
|
||||
RCU->CFG0 &= ~(RCU_CFG0_ADCPSC_2_Msk);
|
||||
RCU->CFG0 |= ((clk_div / 2) - 1) << RCU_CFG0_ADCPSC_2_Pos;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "cpu.h"
|
||||
#include "mutex.h"
|
||||
#include "periph/adc.h"
|
||||
@ -99,6 +100,7 @@ int adc_init(adc_t line)
|
||||
break;
|
||||
}
|
||||
}
|
||||
assume((periph_apb_clk(APB2) / clk_div) <= ADC_CLK_MAX);
|
||||
RCC->CFGR &= ~(RCC_CFGR_ADCPRE);
|
||||
RCC->CFGR |= ((clk_div / 2) - 1) << 14;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "cpu.h"
|
||||
#include "mutex.h"
|
||||
#include "periph/adc.h"
|
||||
@ -92,6 +93,7 @@ int adc_init(adc_t line)
|
||||
break;
|
||||
}
|
||||
}
|
||||
assume((periph_apb_clk(APB2) / clk_div) <= ADC_CLK_MAX);
|
||||
ADC->CCR = ((clk_div / 2) - 1) << 16;
|
||||
|
||||
/* enable the ADC module */
|
||||
|
@ -19,6 +19,7 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "cpu.h"
|
||||
#include "irq.h"
|
||||
#include "mutex.h"
|
||||
@ -101,6 +102,7 @@ int adc_init(adc_t line)
|
||||
break;
|
||||
}
|
||||
}
|
||||
assume((periph_apb_clk(APB2) / clk_div) <= ADC_CLK_MAX);
|
||||
ADC->CCR = ((clk_div / 2) - 1) << 16;
|
||||
/* set sampling time to the maximum */
|
||||
unsigned irq_state = irq_disable();
|
||||
|
Loading…
Reference in New Issue
Block a user