firmware.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * firmware.c
  3. *
  4. * Copyright (C) 2019 Sylvain Munaut
  5. * All rights reserved.
  6. *
  7. * LGPL v3+, see LICENSE.lgpl3
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 3 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. */
  23. #include <stdint.h>
  24. #include <stdbool.h>
  25. #include <string.h>
  26. #include "console.h"
  27. #include "usb.h"
  28. void main()
  29. {
  30. bool usb_active = false;
  31. int cmd = 0;
  32. /* Init console IO */
  33. console_init();
  34. puts("Booting..\n");
  35. /* Main loop */
  36. while (1)
  37. {
  38. /* Prompt ? */
  39. if (cmd >= 0)
  40. puts("\nCommand> ");
  41. /* Poll for command */
  42. cmd = getchar_nowait();
  43. if (cmd >= 0) {
  44. if (cmd > 32 && cmd < 127)
  45. putchar(cmd);
  46. switch (cmd)
  47. {
  48. case 'd':
  49. usb_debug_print();
  50. break;
  51. case 'u':
  52. usb_active = true;
  53. usb_init();
  54. break;
  55. default:
  56. break;
  57. }
  58. }
  59. /* USB poll */
  60. if (usb_active)
  61. usb_poll();
  62. }
  63. }