irq.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * =====================================================================================
  3. *
  4. * ________ .__ __ ________ ____ ________
  5. * \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
  6. * / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
  7. * / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
  8. * \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
  9. * \__> \/ \/ \/ \/ \/
  10. *
  11. * www.optixx.org
  12. *
  13. *
  14. * Version: 1.0
  15. * Created: 07/21/2009 03:32:16 PM
  16. * Author: david@optixx.org
  17. *
  18. * =====================================================================================
  19. */
  20. #include <stdint.h>
  21. #include <stdio.h>
  22. #include <avr/interrupt.h> /* for sei() */
  23. #include <avr/wdt.h>
  24. #include "usbdrv.h"
  25. #include "oddebug.h" /* This is also an example for using debug macros */
  26. #include "debug.h"
  27. #include "info.h"
  28. #include "sram.h"
  29. #include "system.h"
  30. extern system_t my_system;
  31. void (*jump_to_app) (void) = 0x0000;
  32. void irq_init()
  33. {
  34. cli();
  35. PCMSK3 |= (1 << PCINT27);
  36. PCICR |= (1 << PCIE3);
  37. sei();
  38. my_system.reset_irq = RESET_IRQ_ON;
  39. }
  40. void irq_stop()
  41. {
  42. cli();
  43. PCMSK3 &= ~(1 << PCINT27);
  44. sei();
  45. my_system.reset_irq = RESET_IRQ_OFF;
  46. }
  47. void leave_application(void)
  48. {
  49. cli();
  50. usbDeviceDisconnect();
  51. my_system.avr_reset_count++;
  52. wdt_enable(WDTO_15MS);
  53. while (1);
  54. }
  55. ISR(PCINT3_vect)
  56. {
  57. if (snes_reset_test()) {
  58. info_P(PSTR("Catch SNES reset button\n"));
  59. info_P(PSTR("Set watchdog...\n"));
  60. leave_application();
  61. }
  62. }