sam3: Add enable_pclock() helper function

Add a helper function to enable peripheral clocks.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2018-12-28 19:00:29 -05:00
parent b4baabe408
commit 4683036f98
10 changed files with 32 additions and 22 deletions

View File

@@ -34,9 +34,9 @@ gpio_adc_setup(uint8_t pin)
break;
}
if (!(PMC->PMC_PCSR1 & (1 << (ID_ADC-32)))) {
if (!is_enabled_pclock(ID_ADC)) {
// Setup ADC
PMC->PMC_PCER1 = 1 << (ID_ADC-32);
enable_pclock(ID_ADC);
uint32_t prescal = SystemCoreClock / (2 * ADC_FREQ_MAX) - 1;
ADC->ADC_MR = (ADC_MR_PRESCAL(prescal)
| ADC_MR_STARTUP_SUT768