commit
92d83f740d
35
ports/esp32s2/supervisor/esp_port.h
Normal file
35
ports/esp32s2/supervisor/esp_port.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Lucian Copeland 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MICROPY_INCLUDED_ESP32S2_SUPERVISOR_PORT_H
|
||||||
|
#define MICROPY_INCLUDED_ESP32S2_SUPERVISOR_PORT_H
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
|
extern TaskHandle_t sleeping_circuitpython_task;
|
||||||
|
|
||||||
|
#endif // MICROPY_INCLUDED_ESP32S2_SUPERVISOR_PORT_H
|
@ -30,6 +30,8 @@
|
|||||||
#include "supervisor/port.h"
|
#include "supervisor/port.h"
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
#include "modules/module.h"
|
#include "modules/module.h"
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "supervisor/esp_port.h"
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
@ -148,7 +150,18 @@ uint32_t *port_stack_get_limit(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *port_stack_get_top(void) {
|
uint32_t *port_stack_get_top(void) {
|
||||||
return port_stack_get_limit() + CONFIG_ESP_MAIN_TASK_STACK_SIZE / (sizeof(uint32_t) / sizeof(StackType_t));
|
// The sizeof-arithmetic is so that the pointer arithmetic is done on units
|
||||||
|
// of uint32_t instead of units of StackType_t. StackType_t is an alias
|
||||||
|
// for a byte sized type.
|
||||||
|
//
|
||||||
|
// The main stack is bigger than CONFIG_ESP_MAIN_TASK_STACK_SIZE -- an
|
||||||
|
// "extra" size is added to it (TASK_EXTRA_STACK_SIZE). This total size is
|
||||||
|
// available as ESP_TASK_MAIN_STACK. Presumably TASK_EXTRA_STACK_SIZE is
|
||||||
|
// additional stack that can be used by the esp-idf runtime. But what's
|
||||||
|
// important for us is that some very outermost stack frames, such as
|
||||||
|
// pyexec_friendly_repl, could lie inside the "extra" area and be invisible
|
||||||
|
// to the garbage collector.
|
||||||
|
return port_stack_get_limit() + ESP_TASK_MAIN_STACK / (sizeof(uint32_t) / sizeof(StackType_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
supervisor_allocation _fixed_stack;
|
supervisor_allocation _fixed_stack;
|
||||||
@ -188,25 +201,28 @@ void port_disable_tick(void) {
|
|||||||
esp_timer_stop(_tick_timer);
|
esp_timer_stop(_tick_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
TickType_t sleep_time_set;
|
|
||||||
TickType_t sleep_time_duration;
|
TickType_t sleep_time_duration;
|
||||||
|
|
||||||
void port_interrupt_after_ticks(uint32_t ticks) {
|
void port_interrupt_after_ticks(uint32_t ticks) {
|
||||||
sleep_time_set = xTaskGetTickCount();
|
sleep_time_duration = (ticks * 100)/1024;
|
||||||
sleep_time_duration = ticks / portTICK_PERIOD_MS;
|
sleeping_circuitpython_task = xTaskGetCurrentTaskHandle();
|
||||||
// esp_sleep_enable_timer_wakeup(uint64_t time_in_us)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void port_sleep_until_interrupt(void) {
|
void port_sleep_until_interrupt(void) {
|
||||||
// FreeRTOS delay here maybe.
|
|
||||||
// Light sleep shuts down BLE and wifi.
|
uint32_t NotifyValue = 0;
|
||||||
// esp_light_sleep_start()
|
|
||||||
if (sleep_time_duration == 0) {
|
if (sleep_time_duration == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vTaskDelayUntil(&sleep_time_set, sleep_time_duration);
|
xTaskNotifyWait(0x01,0x01,&NotifyValue,
|
||||||
|
sleep_time_duration );
|
||||||
|
if (NotifyValue == 1) {
|
||||||
|
sleeping_circuitpython_task = NULL;
|
||||||
|
mp_handle_pending();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Wrap main in app_main that the IDF expects.
|
// Wrap main in app_main that the IDF expects.
|
||||||
extern void main(void);
|
extern void main(void);
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
|
@ -52,6 +52,8 @@
|
|||||||
StackType_t usb_device_stack[USBD_STACK_SIZE];
|
StackType_t usb_device_stack[USBD_STACK_SIZE];
|
||||||
StaticTask_t usb_device_taskdef;
|
StaticTask_t usb_device_taskdef;
|
||||||
|
|
||||||
|
TaskHandle_t sleeping_circuitpython_task = NULL;
|
||||||
|
|
||||||
// USB Device Driver task
|
// USB Device Driver task
|
||||||
// This top level thread process all usb events and invoke callbacks
|
// This top level thread process all usb events and invoke callbacks
|
||||||
void usb_device_task(void* param)
|
void usb_device_task(void* param)
|
||||||
@ -114,3 +116,23 @@ void init_usb_hardware(void) {
|
|||||||
usb_device_stack,
|
usb_device_stack,
|
||||||
&usb_device_taskdef);
|
&usb_device_taskdef);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Callback invoked when received an "wanted" char.
|
||||||
|
* @param itf Interface index (for multiple cdc interfaces)
|
||||||
|
* @param wanted_char The wanted char (set previously)
|
||||||
|
*/
|
||||||
|
void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
|
||||||
|
{
|
||||||
|
(void) itf; // not used
|
||||||
|
// Workaround for using lib/utils/interrupt_char.c
|
||||||
|
// Compare mp_interrupt_char with wanted_char and ignore if not matched
|
||||||
|
if (mp_interrupt_char == wanted_char) {
|
||||||
|
tud_cdc_read_flush(); // flush read fifo
|
||||||
|
mp_keyboard_interrupt();
|
||||||
|
// CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB.
|
||||||
|
// So, we must notify the other task when a CTRL-C is received.
|
||||||
|
if (sleeping_circuitpython_task != NULL) {
|
||||||
|
xTaskNotifyGive(sleeping_circuitpython_task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -83,10 +83,16 @@ bool common_hal_displayio_tilegrid_get_hidden(displayio_tilegrid_t* self) {
|
|||||||
|
|
||||||
void common_hal_displayio_tilegrid_set_hidden(displayio_tilegrid_t* self, bool hidden) {
|
void common_hal_displayio_tilegrid_set_hidden(displayio_tilegrid_t* self, bool hidden) {
|
||||||
self->hidden = hidden;
|
self->hidden = hidden;
|
||||||
|
if(!hidden){
|
||||||
|
self->full_change = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayio_tilegrid_set_hidden_by_parent(displayio_tilegrid_t *self, bool hidden) {
|
void displayio_tilegrid_set_hidden_by_parent(displayio_tilegrid_t *self, bool hidden) {
|
||||||
self->hidden_by_parent = hidden;
|
self->hidden_by_parent = hidden;
|
||||||
|
if(!hidden){
|
||||||
|
self->full_change = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_area_t* area) {
|
bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_area_t* area) {
|
||||||
|
Loading…
Reference in New Issue
Block a user