// #define DEBUG #define BAUD_RATE 115200 #include "common.h" #include "fpga.h" #include "wifi.h" #include "config.h" #include "led.h" #include #include // On board v1, IO7 is N/C. // On board v2, IO7 is USB_PWR_EN and has a 36k pulldown. static int get_board_version() { return 2; // For now } static void dump_config() { printf("--- Configuration:\n"); write_config(stdout); printf("--- End configuration\n"); } static void init_hw() { // Configure USB power control pinMode(7, OUTPUT); // USB_PWR_EN digitalWrite(7, 1); // Disable power sourcing pinMode(8, OUTPUT); // USB_PWR_SINK digitalWrite(8, 0); // This is a power sink // Configure LEDs led_init(); led_set(LED_BLUE, LED_FLASH); // ESP32 software initializing // Enable external PSRAM for heap heap_caps_malloc_extmem_enable(2048); // >= 2K allocations in PSRAM } void setup() { printf("[START] MAX80 firmware compiled on " __DATE__ " " __TIME__ "\n"); init_hw(); init_config(); SetupWiFi(); //fpga_services_start(); printf("[RDY]\n"); dump_config(); led_set(LED_BLUE, LED_ON); // Software ready printf("Total heap: %d\n" "Free heap: %d\n" "Total PSRAM: %d\n" "Free PSRAM: %d\n", ESP.getHeapSize(), ESP.getFreeHeap(), ESP.getPsramSize(), ESP.getFreePsram()); } static inline char task_state(eTaskState state) { switch (state) { case eInvalid: return 'X'; case eReady: case eRunning: return 'R'; case eBlocked: return 'D'; case eSuspended: return 'S'; case eDeleted: return 'Z'; default: return '?'; } } static void dump_tasks(void) { TaskHandle_t task = NULL; while (1) { task = pxTaskGetNext(task); if (!task) break; printf("%-16s %c %2u\n", pcTaskGetName(task), task_state(eTaskGetState(task)), uxTaskPriorityGet(task)); } } void loop() { printf("loop task: %s\n", pcTaskGetName(xTaskGetCurrentTaskHandle())); printf("idle task: %s\n", pcTaskGetName(xTaskGetIdleTaskHandle())); dump_tasks(); putchar('\n'); vTaskDelay(120 * configTICK_RATE_HZ); }