diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-11-20 13:47:17 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-11-20 13:52:16 -0500 |
commit | bb08dc7ae91488a6e9e1e88de28bd43be9fa5651 (patch) | |
tree | 0f8255ecf3f5d4bd4a9b66db302795071533ba64 /src/atsam/adc.c | |
parent | 92ca1119868abbd859c8f7a3f88143cf53561eb3 (diff) | |
download | kutter-bb08dc7ae91488a6e9e1e88de28bd43be9fa5651.tar.gz kutter-bb08dc7ae91488a6e9e1e88de28bd43be9fa5651.tar.xz kutter-bb08dc7ae91488a6e9e1e88de28bd43be9fa5651.zip |
atsam: Add get_pclock_frequency() helper function
Add get_pclock_frequency() and use it to calculate peripheral clocks.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/atsam/adc.c')
-rw-r--r-- | src/atsam/adc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/atsam/adc.c b/src/atsam/adc.c index 5e5fe420..6ccaf537 100644 --- a/src/atsam/adc.c +++ b/src/atsam/adc.c @@ -47,7 +47,7 @@ gpio_adc_setup(uint8_t pin) if (!is_enabled_pclock(ID_ADC)) { // Setup ADC enable_pclock(ID_ADC); - uint32_t prescal = SystemCoreClock / (2 * ADC_FREQ_MAX) - 1; + uint32_t prescal = get_pclock_frequency(ID_ADC) / (2*ADC_FREQ_MAX) - 1; ADC->ADC_MR = (ADC_MR_PRESCAL(prescal) | ADC_MR_STARTUP_SUT768 | ADC_MR_TRANSFER(1)); |