diff --git a/grid_esp/components/grid_esp32_module_tek1/CMakeLists.txt b/grid_esp/components/grid_esp32_module_tek1/CMakeLists.txt index 254f9a6f6..b5315b4af 100644 --- a/grid_esp/components/grid_esp32_module_tek1/CMakeLists.txt +++ b/grid_esp/components/grid_esp32_module_tek1/CMakeLists.txt @@ -4,5 +4,5 @@ idf_component_register( INCLUDE_DIRS "." REQUIRES - "grid_esp32_adc" "grid_esp32_encoder" "grid_esp32_lcd" "grid_common" "grid_esp32_vmp" + "grid_esp32_adc" "grid_esp32_encoder" "grid_esp32_lcd" "grid_common" "grid_esp32_port" "grid_esp32_vmp" ) diff --git a/grid_esp/components/grid_esp32_module_tek1/grid_esp32_module_tek1.c b/grid_esp/components/grid_esp32_module_tek1/grid_esp32_module_tek1.c index 30c1bb75a..84c6c4789 100644 --- a/grid_esp/components/grid_esp32_module_tek1/grid_esp32_module_tek1.c +++ b/grid_esp/components/grid_esp32_module_tek1/grid_esp32_module_tek1.c @@ -23,6 +23,7 @@ #include "grid_ui_system.h" #include "grid_esp32_lcd.h" +#include "grid_esp32_port.h" #include "grid_font.h" #include "grid_gui.h" @@ -238,7 +239,9 @@ void grid_esp32_module_tek1_init(struct grid_sys_model* sys, struct grid_ui_mode grid_esp32_lcd_spi_bus_init(lcd_tx_bytes); // Wait for the coprocessor to pull the LCD reset pin high - vTaskDelay(pdMS_TO_TICKS(500)); + while (!rp2040_active) { + vTaskDelay(1); + } bool is_tek1_reva = grid_sys_get_hwcfg(&grid_sys_state) == GRID_MODULE_TEK1_RevA; diff --git a/grid_esp/components/grid_esp32_port/grid_esp32_port.c b/grid_esp/components/grid_esp32_port/grid_esp32_port.c index f11a4f456..06dc06cc0 100644 --- a/grid_esp/components/grid_esp32_port/grid_esp32_port.c +++ b/grid_esp/components/grid_esp32_port/grid_esp32_port.c @@ -364,6 +364,8 @@ void handle_connection_effect() { bool grid_esp32_broadcast_between(enum grid_port_type t1, enum grid_port_type t2) { return !(t1 == GRID_PORT_USART && t2 == GRID_PORT_USART); } +extern bool rp2040_active = false; + void grid_esp32_port_task(void* arg) { // Set up "outbound usart" spi transactions @@ -457,8 +459,11 @@ void grid_esp32_port_task(void* arg) { // When the rolling ID changes, reset watchdog if (rollid.last_recv != watchdog_rollid_last_recv) { + watchdog_rollid_last_time = grid_platform_rtc_get_micros(); watchdog_rollid_last_recv = rollid.last_recv; + + rp2040_active = true; } // Rolling ID watchdog expiration diff --git a/grid_esp/components/grid_esp32_port/grid_esp32_port.h b/grid_esp/components/grid_esp32_port/grid_esp32_port.h index d14925754..e01578a11 100644 --- a/grid_esp/components/grid_esp32_port/grid_esp32_port.h +++ b/grid_esp/components/grid_esp32_port/grid_esp32_port.h @@ -5,12 +5,15 @@ */ #pragma once +#include #include #ifdef __cplusplus extern "C" { #endif +extern bool rp2040_active; + uint8_t grid_platform_send_grid_message(uint8_t direction, char* buffer, uint16_t length); void grid_platform_sync1_pulse_send(void); void grid_esp32_port_task(void* arg); diff --git a/grid_esp/main/grid_fw.c b/grid_esp/main/grid_fw.c index f6d8eb619..e005d1c3a 100644 --- a/grid_esp/main/grid_fw.c +++ b/grid_esp/main/grid_fw.c @@ -525,6 +525,12 @@ void app_main(void) { xTaskCreatePinnedToCore(grid_esp32_nvm_task, "nvm", 1024 * 10, NULL, NVM_TASK_PRIORITY, &nvm_task_hdl, 0); + log_checkpoint("PORT TASK INIT"); + + TaskHandle_t port_task_hdl; + + xTaskCreatePinnedToCore(grid_esp32_port_task, "port", 1024 * 10, NULL, PORT_TASK_PRIORITY, &port_task_hdl, 1); + log_checkpoint("MODULE INIT"); if (grid_hwcfg_module_is_po16(&grid_sys_state)) { @@ -556,12 +562,6 @@ void app_main(void) { log_checkpoint("LCD TASK DONE"); } - TaskHandle_t port_task_hdl; - - xTaskCreatePinnedToCore(grid_esp32_port_task, "port", 1024 * 10, NULL, PORT_TASK_PRIORITY, &port_task_hdl, 1); - - log_checkpoint("PORT TASK DONE"); - // Initialize 1 kHz timer periodic_rtc_ms_init();