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.3KB

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