File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
ports/atmel-samd/supervisor Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 131
131
static volatile bool sleep_ok = true;
132
132
133
133
#ifdef SAMD21
134
- uint8_t _tick_event_channel ;
134
+ static uint8_t _tick_event_channel = EVSYS_SYNCH_NUM ;
135
+
136
+ static bool tick_enabled (void ) {
137
+ return _tick_event_channel != EVSYS_SYNCH_NUM ;
138
+ }
135
139
136
140
// Sleeping requires a register write that can stall interrupt handling. Turning
137
141
// off sleeps allows for more accurate interrupt timing. (Python still thinks
@@ -431,8 +435,15 @@ void reset_port(void) {
431
435
pew_reset ();
432
436
#endif
433
437
434
- reset_event_system ();
435
- reset_ticks ();
438
+ #ifdef SAMD21
439
+ if (!tick_enabled ())
440
+ // SAMD21 ticks depend on the event system, so don't disturb the event system if we need ticks,
441
+ // such as for a display that lives across VM instantiations.
442
+ #endif
443
+ {
444
+ reset_event_system ();
445
+ reset_ticks ();
446
+ }
436
447
437
448
reset_all_pins ();
438
449
@@ -613,8 +624,8 @@ void port_enable_tick(void) {
613
624
RTC -> MODE0 .INTENSET .reg = RTC_MODE0_INTENSET_PER2 ;
614
625
#endif
615
626
#ifdef SAMD21
616
- // SAMD21 ticks won't survive reset_port(). This *should* be ok since it'll
617
- // be triggered by ticks and no Python will be running .
627
+ // reset_port() preserves the event system if ticks were still enabled after a VM finished,
628
+ // such as for an on-board display. Normally the event system would be reset between VM instantiations .
618
629
if (_tick_event_channel >= EVSYS_SYNCH_NUM ) {
619
630
turn_on_event_system ();
620
631
_tick_event_channel = find_sync_event_channel ();
You can’t perform that action at this time.
0 commit comments