irq.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/io.h>
  23. #include <avr/interrupt.h> /* for sei() */
  24. #include <avr/wdt.h>
  25. #include "usbdrv.h"
  26. #include "oddebug.h" /* This is also an example for using debug
  27. * macros */
  28. #include "debug.h"
  29. #include "info.h"
  30. #include "sram.h"
  31. void (*jump_to_app) (void) = 0x0000;
  32. void irq_init(){
  33. cli();
  34. PCMSK3 |=(1<<PCINT27);
  35. PCICR |= (1<<PCIE3);
  36. sei();
  37. }
  38. void irq_stop(){
  39. cli();
  40. PCMSK3 &=~(1<<PCINT27);
  41. sei();
  42. }
  43. void leave_application(void)
  44. {
  45. cli();
  46. usbDeviceDisconnect();
  47. wdt_enable(WDTO_15MS);
  48. while (1);
  49. }
  50. ISR (SIG_PIN_CHANGE3)
  51. {
  52. if (snes_reset_test()){
  53. info_P(PSTR("Catch SNES reset button\n"));
  54. info_P(PSTR("Set watchdog...\n"));
  55. leave_application();
  56. }
  57. }