1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- // #define DEBUG
- #define BAUD_RATE 115200
- #include "common.h"
- #include <freertos/task_snapshot.h>
- #include "fpga.h"
- #include "wifi.h"
- #include "config.h"
- #include "led.h"
- // 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
- }
- 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
- }
- 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);
- }
|