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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/io.h>
  12. #include <avr/wdt.h>
  13. #include <avr/interrupt.h> /* for sei() */
  14. #include <avr/pgmspace.h> /* required by usbdrv.h */
  15. #include <util/delay.h> /* for _delay_ms() */
  16. #include "usbdrv.h"
  17. #include "usart_print.h" /* This is also an example for using debug macros */
  18. #include "usb_keycodes.h"
  19. #include "matrix_skel.h"
  20. #include "keymap_skel.h"
  21. #include "mousekey.h"
  22. #include "layer.h"
  23. #include "print.h"
  24. #include "debug.h"
  25. #include "sendchar.h"
  26. #include "host.h"
  27. #include "host_vusb.h"
  28. #include "timer.h"
  29. #include "led.h"
  30. #include "keyboard.h"
  31. #define DEBUGP_INIT() do { DDRC = 0xFF; } while (0)
  32. #define DEBUGP(x) do { PORTC = x; } while (0)
  33. //static uint8_t last_led = 0;
  34. int main(void)
  35. {
  36. DEBUGP_INIT();
  37. wdt_enable(WDTO_1S);
  38. /* Even if you don't use the watchdog, turn it off here. On newer devices,
  39. * the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
  40. */
  41. /* RESET status: all port bits are inputs without pull-up.
  42. * That's the way we need D+ and D-. Therefore we don't need any
  43. * additional hardware initialization.
  44. */
  45. odDebugInit();
  46. usbInit();
  47. print_enable = true;
  48. debug_enable = true;
  49. keyboard_init();
  50. /* enforce re-enumeration, do this while interrupts are disabled! */
  51. usbDeviceDisconnect();
  52. uint8_t i = 0;
  53. while(--i){ /* fake USB disconnect for > 250 ms */
  54. wdt_reset();
  55. _delay_ms(1);
  56. }
  57. usbDeviceConnect();
  58. sei();
  59. //uint8_t fn_bits = 0;
  60. while (1) { /* main event loop */
  61. wdt_reset();
  62. usbPoll();
  63. keyboard_proc();
  64. host_vusb_keyboard_send();
  65. }
  66. }