My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

WInterrupts.c 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
  2. /*
  3. Part of the Wiring project - http://wiring.uniandes.edu.co
  4. Copyright (c) 2004-05 Hernando Barragan
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General
  14. Public License along with this library; if not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. Modified 24 November 2006 by David A. Mellis
  18. */
  19. #include <inttypes.h>
  20. #include <avr/io.h>
  21. #include <avr/interrupt.h>
  22. #include <avr/pgmspace.h>
  23. #include <stdio.h>
  24. #include "WConstants.h"
  25. #include "wiring_private.h"
  26. volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
  27. // volatile static voidFuncPtr twiIntFunc;
  28. void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)
  29. {
  30. if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
  31. {
  32. intFunc[interruptNum] = userFunc;
  33. //clear the config for the change settings
  34. EICRA &= ~(B00000011 << (interruptNum * 2));
  35. //set our mode.
  36. EICRA |= (mode << (interruptNum * 2));
  37. // Enable the interrupt.
  38. EIMSK |= (1 << interruptNum);
  39. }
  40. }
  41. void detachInterrupt(uint8_t interruptNum)
  42. {
  43. if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
  44. {
  45. // Disable the interrupt.
  46. EIMSK &= ~(1 << interruptNum);
  47. intFunc[interruptNum] = 0;
  48. }
  49. }
  50. ISR(INT0_vect) {
  51. if(intFunc[EXTERNAL_INT_0])
  52. intFunc[EXTERNAL_INT_0]();
  53. }
  54. ISR(INT1_vect) {
  55. if(intFunc[EXTERNAL_INT_1])
  56. intFunc[EXTERNAL_INT_1]();
  57. }
  58. ISR(INT2_vect) {
  59. if(intFunc[EXTERNAL_INT_2])
  60. intFunc[EXTERNAL_INT_2]();
  61. }
  62. /*
  63. SIGNAL(SIG_2WIRE_SERIAL) {
  64. if(twiIntFunc)
  65. twiIntFunc();
  66. }
  67. */