2018-07-10 11:49:51 -04:00
|
|
|
/*
|
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2018-07-05 00:30:12 -04:00
|
|
|
|
2019-01-17 21:19:07 -05:00
|
|
|
#include "py/runtime.h"
|
2019-03-20 12:21:36 -04:00
|
|
|
#include "supervisor/filesystem.h"
|
2018-10-19 21:46:22 -04:00
|
|
|
#include "supervisor/usb.h"
|
2018-12-07 19:11:21 -05:00
|
|
|
#include "supervisor/shared/stack.h"
|
|
|
|
|
2019-06-06 17:49:32 -04:00
|
|
|
#if CIRCUITPY_DISPLAYIO
|
2019-01-17 21:19:07 -05:00
|
|
|
#include "shared-module/displayio/__init__.h"
|
|
|
|
#endif
|
|
|
|
|
2019-09-08 14:08:15 -04:00
|
|
|
#if CIRCUITPY_AUDIOBUSIO
|
|
|
|
#include "common-hal/audiobusio/I2SOut.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-15 20:56:21 -04:00
|
|
|
#if CIRCUITPY_AUDIOPWMIO
|
2019-07-29 18:39:00 -04:00
|
|
|
#include "common-hal/audiopwmio/PWMAudioOut.h"
|
2019-07-15 20:56:21 -04:00
|
|
|
#endif
|
|
|
|
|
2019-09-14 15:40:24 -04:00
|
|
|
#if CIRCUITPY_BLEIO
|
|
|
|
#include "supervisor/shared/bluetooth.h"
|
2020-01-05 23:33:42 -05:00
|
|
|
#include "common-hal/_bleio/bonding.h"
|
2019-09-14 15:40:24 -04:00
|
|
|
#endif
|
|
|
|
|
2019-04-09 20:23:01 -04:00
|
|
|
static bool running_background_tasks = false;
|
|
|
|
|
|
|
|
void background_tasks_reset(void) {
|
|
|
|
running_background_tasks = false;
|
|
|
|
}
|
|
|
|
|
2018-07-05 00:30:12 -04:00
|
|
|
void run_background_tasks(void) {
|
2019-04-09 20:23:01 -04:00
|
|
|
// Don't call ourselves recursively.
|
|
|
|
if (running_background_tasks) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
running_background_tasks = true;
|
2019-03-20 12:21:36 -04:00
|
|
|
filesystem_background();
|
2019-07-15 20:56:21 -04:00
|
|
|
#if CIRCUITPY_AUDIOPWMIO
|
|
|
|
audiopwmout_background();
|
|
|
|
#endif
|
2019-09-08 14:08:15 -04:00
|
|
|
#if CIRCUITPY_AUDIOBUSIO
|
|
|
|
i2s_background();
|
|
|
|
#endif
|
|
|
|
|
2019-09-14 15:40:24 -04:00
|
|
|
#if CIRCUITPY_BLEIO
|
|
|
|
supervisor_bluetooth_background();
|
2020-01-05 23:33:42 -05:00
|
|
|
bonding_background();
|
2019-09-14 15:40:24 -04:00
|
|
|
#endif
|
2019-01-17 21:19:07 -05:00
|
|
|
|
2019-06-06 17:49:32 -04:00
|
|
|
#if CIRCUITPY_DISPLAYIO
|
2019-08-14 17:17:35 -04:00
|
|
|
displayio_background();
|
2018-10-19 21:46:22 -04:00
|
|
|
#endif
|
2019-04-09 20:23:01 -04:00
|
|
|
running_background_tasks = false;
|
2019-01-17 21:19:07 -05:00
|
|
|
|
2018-12-07 19:11:21 -05:00
|
|
|
assert_heap_ok();
|
2018-07-05 00:30:12 -04:00
|
|
|
}
|