Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main_vusb.c 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Name: main.c
  2. * Project: hid-mouse, a very simple HID example
  3. * Author: Christian Starkjohann
  4. * Creation Date: 2008-04-07
  5. * Tabsize: 4
  6. * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
  7. * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
  8. * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $
  9. */
  10. #include <stdint.h>
  11. #include <avr/wdt.h>
  12. #include <avr/interrupt.h>
  13. #include <util/delay.h>
  14. #include "usbdrv.h"
  15. #include "oddebug.h"
  16. #include "host_vusb.h"
  17. #include "keyboard.h"
  18. #if 0
  19. #define DEBUGP_INIT() do { DDRC = 0xFF; } while (0)
  20. #define DEBUGP(x) do { PORTC = x; } while (0)
  21. #else
  22. #define DEBUGP_INIT()
  23. #define DEBUGP(x)
  24. #endif
  25. int main(void)
  26. {
  27. DEBUGP_INIT();
  28. wdt_enable(WDTO_1S);
  29. odDebugInit();
  30. usbInit();
  31. /* enforce re-enumeration, do this while interrupts are disabled! */
  32. usbDeviceDisconnect();
  33. uint8_t i = 0;
  34. /* fake USB disconnect for > 250 ms */
  35. while(--i){
  36. wdt_reset();
  37. _delay_ms(1);
  38. }
  39. usbDeviceConnect();
  40. keyboard_init();
  41. sei();
  42. while (1) {
  43. DEBUGP(0x1);
  44. wdt_reset();
  45. usbPoll();
  46. DEBUGP(0x2);
  47. keyboard_proc();
  48. DEBUGP(0x3);
  49. host_vusb_keyboard_send();
  50. }
  51. }