mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 21:31:02 +01:00
Initial timer setup code
This commit is contained in:
parent
5ccef35074
commit
63c9ca414d
@ -65,6 +65,25 @@ void DCCTimer::begin(INTERRUPT_CALLBACK callback) {
|
|||||||
ADC->CTRLA.bit.ENABLE = 1; // enable ADC
|
ADC->CTRLA.bit.ENABLE = 1; // enable ADC
|
||||||
while(ADC->STATUS.bit.SYNCBUSY == 1); // wait for synchronization
|
while(ADC->STATUS.bit.SYNCBUSY == 1); // wait for synchronization
|
||||||
|
|
||||||
|
// PMA - actual timer setup goo
|
||||||
|
// Setup clock sources first
|
||||||
|
REG_GCLK_GENDIV = GCLK_GENDIV_DIV(1) | // Divide 48MHz by 1
|
||||||
|
GCLK_GENDIV_ID(4); // Apply to GCLK4
|
||||||
|
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||||
|
|
||||||
|
REG_GCLK_GENCTRL = GCLK_GENCTRL_GENEN | // Enable GCLK
|
||||||
|
GCLK_GENCTRL_SRC_DFLL48M | // Set the 48MHz clock source
|
||||||
|
GCLK_GENCTRL_ID(4); // Select GCLK4
|
||||||
|
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||||
|
|
||||||
|
REG_GCLK_CLKCTRL = GCLK_CLKCTRL_CLKEN | // Enable generic clock
|
||||||
|
4 << GCLK_CLKCTRL_GEN_Pos | // Apply to GCLK4
|
||||||
|
GCLK_CLKCTRL_ID_TCC0_TCC1; // Feed GCLK to TCC0/1
|
||||||
|
while (GCLK->STATUS.bit.SYNCBUSY);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DCCTimer::isPWMPin(byte pin) {
|
bool DCCTimer::isPWMPin(byte pin) {
|
||||||
|
Loading…
Reference in New Issue
Block a user