max80.ino 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // #define DEBUG
  2. #define BAUD_RATE 115200
  3. #include "common.h"
  4. #include <freertos/task_snapshot.h>
  5. #include "fpga.h"
  6. #include "wifi.h"
  7. #include "config.h"
  8. // On board v1, IO7 is N/C.
  9. // On board v2, IO7 is USB_PWR_EN and has a 36k pulldown.
  10. static int get_board_version()
  11. {
  12. return 2; // For now
  13. }
  14. static void dump_config()
  15. {
  16. printf("--- Configuration:\n");
  17. write_config(stdout);
  18. printf("--- End configuration\n");
  19. }
  20. void setup() {
  21. printf("[START] MAX80 firmware compiled on " __DATE__ " " __TIME__ "\n");
  22. init_config();
  23. SetupWiFi();
  24. //fpga_services_start();
  25. printf("[RDY]\n");
  26. dump_config();
  27. }
  28. static inline char task_state(eTaskState state)
  29. {
  30. switch (state) {
  31. case eInvalid:
  32. return 'X';
  33. case eReady:
  34. case eRunning:
  35. return 'R';
  36. case eBlocked:
  37. return 'D';
  38. case eSuspended:
  39. return 'S';
  40. case eDeleted:
  41. return 'Z';
  42. default:
  43. return '?';
  44. }
  45. }
  46. static void dump_tasks(void)
  47. {
  48. TaskHandle_t task = NULL;
  49. while (1) {
  50. task = pxTaskGetNext(task);
  51. if (!task)
  52. break;
  53. printf("%-16s %c %2u\n",
  54. pcTaskGetName(task),
  55. task_state(eTaskGetState(task)),
  56. uxTaskPriorityGet(task));
  57. }
  58. }
  59. void loop() {
  60. printf("loop task: %s\n", pcTaskGetName(xTaskGetCurrentTaskHandle()));
  61. printf("idle task: %s\n", pcTaskGetName(xTaskGetIdleTaskHandle()));
  62. dump_tasks();
  63. putchar('\n');
  64. vTaskDelay(120 * configTICK_RATE_HZ);
  65. }