Removing some prior changes

This commit is contained in:
DavePutz 2020-09-14 10:53:30 -05:00 committed by GitHub
parent 127346f7ae
commit 6b93f97de1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 21 deletions

View File

@ -37,14 +37,7 @@ STATIC volatile background_callback_t *callback_head, *callback_tail;
#define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts())
#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts())
uint64_t last_background_tick = 0;
uint64_t get_background_ticks(void) {
return last_background_tick;
}
void background_callback_add_core(background_callback_t *cb) {
last_background_tick = port_get_raw_ticks(NULL);
CALLBACK_CRITICAL_BEGIN;
if (cb->prev || callback_head == cb) {
CALLBACK_CRITICAL_END;

View File

@ -27,6 +27,7 @@
#include "supervisor/shared/tick.h"
#include "py/mpstate.h"
#include "py/runtime.h"
#include "supervisor/linker.h"
#include "supervisor/filesystem.h"
#include "supervisor/background_callback.h"
@ -36,7 +37,7 @@
#if CIRCUITPY_BLEIO
#include "supervisor/shared/bluetooth.h"
#include "common-hal/_bleio/bonding.h"
#include "common-hal/_bleio/__init__.h"
#endif
#if CIRCUITPY_DISPLAYIO
@ -68,6 +69,8 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
static background_callback_t tick_callback;
volatile uint64_t last_finished_tick = 0;
void supervisor_background_tasks(void *unused) {
port_start_background_task();
@ -84,7 +87,7 @@ void supervisor_background_tasks(void *unused) {
#if CIRCUITPY_BLEIO
supervisor_bluetooth_background();
bonding_background();
bleio_background();
#endif
port_background_task();
@ -95,7 +98,7 @@ void supervisor_background_tasks(void *unused) {
}
bool supervisor_background_tasks_ok(void) {
return port_get_raw_ticks(NULL) - get_background_ticks() < 1024;
return port_get_raw_ticks(NULL) - last_finished_tick < 1024;
}
void supervisor_tick(void) {
@ -145,17 +148,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
while (remaining > 0) {
RUN_BACKGROUND_TASKS;
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
{
// clear exception and generate stacktrace
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
nlr_raise(&MP_STATE_VM(mp_kbd_exception));
}
if( MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
WATCHDOG_EXCEPTION_CHECK()) {
// stop sleeping immediately
break;
}
mp_handle_pending();
remaining = end_tick - port_get_raw_ticks(NULL);
// We break a bit early so we don't risk setting the alarm before the time when we call
// sleep.