atusb.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * fw/atusb.c - ATUSB initialization and main loop
  3. *
  4. * Written 2008-2011 by Werner Almesberger
  5. * Copyright 2008-2011 Werner Almesberger
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <stdint.h>
  13. #include <avr/io.h>
  14. #include <avr/sleep.h>
  15. #include <avr/interrupt.h>
  16. #include "usb.h"
  17. #include "board.h"
  18. #include "sernum.h"
  19. #include "spi.h"
  20. #include "atusb/ep0.h"
  21. #ifdef DEBUG
  22. #include "uart.h"
  23. #endif
  24. int main(void)
  25. {
  26. board_init();
  27. board_app_init();
  28. reset_rf();
  29. user_get_descriptor = sernum_get_descr;
  30. /* now we should be at 8 MHz */
  31. #ifdef DEBUG
  32. uart_init();
  33. static FILE atben_stdout = FDEV_SETUP_STREAM(uart_write_char, NULL,
  34. _FDEV_SETUP_WRITE);
  35. stdout = &atben_stdout;
  36. #endif
  37. usb_init();
  38. ep0_init();
  39. #ifdef ATUSB
  40. timer_init();
  41. /* move interrupt vectors to 0 */
  42. MCUCR = 1 << IVCE;
  43. MCUCR = 0;
  44. #endif
  45. sei();
  46. while (1)
  47. sleep_mode();
  48. }