Various fixes for DUE... (#10152)

- Watchdog reset during SD Card initialization.
- Move `DebugMonitor` to `DebugMonitor_Due.cpp`.
- Since the watchdog is enabled on boot do extra resets during init.
- Have `thermalManager` do watchdog reset before its ISR starts to prevent reset.
- Ensure that timers are stopped before reprogramming them to address tone issues.
- Improve SAM3XE reset when reflashed through the native port.
This commit is contained in:
Eduardo José Tagle
2018-03-21 21:04:45 -03:00
committed by Scott Lahteine
parent c3c264978f
commit 97e8a6ebd9
23 changed files with 441 additions and 60 deletions

View File

@@ -33,17 +33,10 @@
static pin_t tone_pin;
volatile static int32_t toggles;
void toneInit() {
HAL_timer_start(TONE_TIMER_NUM, 100000);
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
}
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
tone_pin = _pin;
toggles = 2 * frequency * duration / 1000;
HAL_timer_set_count(TONE_TIMER_NUM, 0); // ensure first beep is correct (make sure counter is less than the compare value)
HAL_timer_set_compare(TONE_TIMER_NUM, VARIANT_MCK / 2 / 2 / frequency); // 84MHz / 2 prescaler / 2 interrupts per cycle /Hz
HAL_timer_enable_interrupt(TONE_TIMER_NUM);
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
}
void noTone(const pin_t _pin) {
@@ -60,7 +53,6 @@ HAL_TONE_TIMER_ISR {
digitalWrite(tone_pin, (pin_state ^= 1));
}
else noTone(tone_pin); // turn off interrupt
HAL_timer_restrain_count(TONE_TIMER_NUM, 10); // make sure next ISR isn't delayed by up to 2 minutes
}
#endif // ARDUINO_ARCH_SAM