irqreg.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #ifndef _DEV_IRQREG_H_
  2. #define _DEV_IRQREG_H_
  3. /*
  4. * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log: irqreg.h,v $
  36. * Revision 1.13 2006/01/05 16:53:56 haraldkipp
  37. * New function NutIrqSetMode() allows to modify the interrupt mode.
  38. *
  39. * Revision 1.12 2005/10/24 10:50:49 haraldkipp
  40. * New API functions added.
  41. * Interrupt counting requires NUT_PERFMON to be defined.
  42. *
  43. * Revision 1.11 2005/07/26 16:05:24 haraldkipp
  44. * Several files were moved from subdir dev to subdir arch.
  45. *
  46. * Revision 1.10 2005/04/07 12:31:37 freckle
  47. * most unix emulation specific stuff now in irqreg_unix.h.
  48. * corrected #warning "MCU not defined"
  49. *
  50. * Revision 1.9 2005/04/05 17:52:40 haraldkipp
  51. * Much better implementation of GBA interrupt registration.
  52. *
  53. * Revision 1.8 2005/02/10 07:06:51 hwmaier
  54. * Changes to incorporate support for AT90CAN128 CPU
  55. *
  56. * Revision 1.7 2004/08/05 12:13:56 freckle
  57. * Added unix emulation hook in NutThreadYield to safely process
  58. * NutPostEventAsync calls occuring in non Nut/OS threads.
  59. * Rewrote the unix read function again using the new unix NutThreadYield hook
  60. * to call the NutPostEventAsync function safely (fast & correct).
  61. * _write(nf, 0, 0) aka fflush is ignored on unix emulation.
  62. *
  63. * Revision 1.6 2004/04/07 12:13:57 haraldkipp
  64. * Matthias Ringwald's *nix emulation added
  65. *
  66. * Revision 1.5 2004/03/18 15:48:13 haraldkipp
  67. * ICCAVR failed to compile
  68. *
  69. * Revision 1.4 2004/03/16 16:48:28 haraldkipp
  70. * Added Jan Dubiec's H8/300 port.
  71. *
  72. * Revision 1.3 2004/01/30 17:00:46 drsung
  73. * Separate interrupt stack for avr-gcc only added.
  74. *
  75. * Revision 1.2 2003/11/23 16:42:13 drsung
  76. * NutRegisterInterrupt removed, because it's incompatible to the new interrupt handling
  77. *
  78. * Revision 1.1.1.1 2003/05/09 14:41:06 haraldkipp
  79. * Initial using 3.2.1
  80. *
  81. * Revision 1.10 2003/05/06 18:42:55 harald
  82. * Cleanup
  83. *
  84. * Revision 1.9 2003/02/04 18:00:37 harald
  85. * Version 3 released
  86. *
  87. * Revision 1.8 2002/07/03 16:45:40 harald
  88. * Using GCC 3.2
  89. *
  90. * Revision 1.7 2002/06/26 17:29:15 harald
  91. * First pre-release with 2.4 stack
  92. *
  93. */
  94. #include <cfg/arch.h>
  95. #include <sys/device.h>
  96. #include <dev/irqstack.h>
  97. /*!
  98. * \file dev/irqreg.h
  99. * \brief Interrupt management definitions.
  100. */
  101. /*!
  102. * \addtogroup xgIrqReg
  103. */
  104. /*@{*/
  105. #define NUT_IRQCTL_INIT 0
  106. #define NUT_IRQCTL_CLEAR 1
  107. #define NUT_IRQCTL_STATUS 16
  108. #define NUT_IRQCTL_ENABLE 17
  109. #define NUT_IRQCTL_DISABLE 18
  110. #define NUT_IRQCTL_GETMODE 24
  111. #define NUT_IRQCTL_SETMODE 25
  112. #define NUT_IRQCTL_GETPRIO 32
  113. #define NUT_IRQCTL_SETPRIO 33
  114. #define NUT_IRQCTL_GETCOUNT 96
  115. #define NUT_IRQCTL_SETCOUNT 97
  116. #define NUT_IRQMODE_LOWLEVEL 1
  117. #define NUT_IRQMODE_HIGHLEVEL 2
  118. #define NUT_IRQMODE_FALLINGEDGE 5
  119. #define NUT_IRQMODE_RISINGEDGE 6
  120. #define NUT_IRQMODE_EDGE 7
  121. /*
  122. * Registered interrupt handler information structure.
  123. */
  124. typedef struct {
  125. #ifdef NUT_PERFMON
  126. u_long ir_count;
  127. #endif
  128. void *ir_arg;
  129. void (*ir_handler) (void *);
  130. int (*ir_ctl) (int cmd, void *param);
  131. } IRQ_HANDLER;
  132. #if defined(__AVR__)
  133. #include <arch/avr/irqreg.h>
  134. #elif defined(__arm__)
  135. #include <arch/arm/irqreg.h>
  136. #elif defined(__H8300H__) || defined(__H8300S__)
  137. #include <arch/h8300h/irqreg.h>
  138. #elif defined(__m68k__)
  139. #include <arch/m68k/irqreg.h>
  140. #elif defined (__linux__) || defined(__APPLE__) || defined(__CYGWIN__)
  141. #include <arch/unix/irqreg.h>
  142. #else
  143. #warning "MCU not defined"
  144. #endif
  145. /*@}*/
  146. __BEGIN_DECLS
  147. /* NutRegisterInterrupt is obsolete, use NutRegisterIrqHandler instead */
  148. //extern int NutRegisterInterrupt(int irq, void (*handler)(void *), void *arg) __attribute__ ((obsolete)) ;
  149. extern void CallHandler(IRQ_HANDLER * irh);
  150. #if defined (__linux__) || defined (__APPLE__) || defined(__CYGWIN__)
  151. extern int NutRegisterIrqHandler(u_char irq_nr, void (*handler) (void *), void *arg);
  152. #else
  153. extern int NutRegisterIrqHandler(IRQ_HANDLER * irh, void (*handler) (void *), void *arg);
  154. extern int NutIrqEnable(IRQ_HANDLER * irq);
  155. extern int NutIrqDisable(IRQ_HANDLER * irq);
  156. extern int NutIrqSetPriority(IRQ_HANDLER * irq, int level);
  157. extern int NutIrqSetMode(IRQ_HANDLER * irq, int mode);
  158. #endif
  159. __END_DECLS
  160. #endif