irqreg.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 THE COPYRIGHT HOLDERS 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 THE
  23. * COPYRIGHT OWNER 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$
  36. * Revision 1.16 2009/03/05 22:16:57 freckle
  37. * use __NUT_EMULATION instead of __APPLE__, __linux__, or __CYGWIN__
  38. *
  39. * Revision 1.15 2008/08/11 06:59:59 haraldkipp
  40. * BSD types replaced by stdint types (feature request #1282721).
  41. *
  42. * Revision 1.14 2008/07/26 09:38:02 haraldkipp
  43. * Added support for NUT_IRQMODE_NONE and NUT_IRQMODE_LEVEL.
  44. *
  45. * Revision 1.13 2006/01/05 16:53:56 haraldkipp
  46. * New function NutIrqSetMode() allows to modify the interrupt mode.
  47. *
  48. * Revision 1.12 2005/10/24 10:50:49 haraldkipp
  49. * New API functions added.
  50. * Interrupt counting requires NUT_PERFMON to be defined.
  51. *
  52. * Revision 1.11 2005/07/26 16:05:24 haraldkipp
  53. * Several files were moved from subdir dev to subdir arch.
  54. *
  55. * Revision 1.10 2005/04/07 12:31:37 freckle
  56. * most unix emulation specific stuff now in irqreg_unix.h.
  57. * corrected #warning "MCU not defined"
  58. *
  59. * Revision 1.9 2005/04/05 17:52:40 haraldkipp
  60. * Much better implementation of GBA interrupt registration.
  61. *
  62. * Revision 1.8 2005/02/10 07:06:51 hwmaier
  63. * Changes to incorporate support for AT90CAN128 CPU
  64. *
  65. * Revision 1.7 2004/08/05 12:13:56 freckle
  66. * Added unix emulation hook in NutThreadYield to safely process
  67. * NutPostEventAsync calls occuring in non Nut/OS threads.
  68. * Rewrote the unix read function again using the new unix NutThreadYield hook
  69. * to call the NutPostEventAsync function safely (fast & correct).
  70. * _write(nf, 0, 0) aka fflush is ignored on unix emulation.
  71. *
  72. * Revision 1.6 2004/04/07 12:13:57 haraldkipp
  73. * Matthias Ringwald's *nix emulation added
  74. *
  75. * Revision 1.5 2004/03/18 15:48:13 haraldkipp
  76. * ICCAVR failed to compile
  77. *
  78. * Revision 1.4 2004/03/16 16:48:28 haraldkipp
  79. * Added Jan Dubiec's H8/300 port.
  80. *
  81. * Revision 1.3 2004/01/30 17:00:46 drsung
  82. * Separate interrupt stack for avr-gcc only added.
  83. *
  84. * Revision 1.2 2003/11/23 16:42:13 drsung
  85. * NutRegisterInterrupt removed, because it's incompatible to the new interrupt handling
  86. *
  87. * Revision 1.1.1.1 2003/05/09 14:41:06 haraldkipp
  88. * Initial using 3.2.1
  89. *
  90. * Revision 1.10 2003/05/06 18:42:55 harald
  91. * Cleanup
  92. *
  93. * Revision 1.9 2003/02/04 18:00:37 harald
  94. * Version 3 released
  95. *
  96. * Revision 1.8 2002/07/03 16:45:40 harald
  97. * Using GCC 3.2
  98. *
  99. * Revision 1.7 2002/06/26 17:29:15 harald
  100. * First pre-release with 2.4 stack
  101. *
  102. */
  103. #include <cfg/arch.h>
  104. #include <stdint.h>
  105. #include <sys/device.h>
  106. #include <dev/irqstack.h>
  107. /*!
  108. * \file dev/irqreg.h
  109. * \brief Interrupt management definitions.
  110. */
  111. /*!
  112. * \addtogroup xgIrqReg
  113. */
  114. /*@{*/
  115. #define NUT_IRQCTL_INIT 0
  116. #define NUT_IRQCTL_CLEAR 1
  117. #define NUT_IRQCTL_STATUS 16
  118. #define NUT_IRQCTL_ENABLE 17
  119. #define NUT_IRQCTL_DISABLE 18
  120. #define NUT_IRQCTL_GETMODE 24
  121. #define NUT_IRQCTL_SETMODE 25
  122. #define NUT_IRQCTL_GETPRIO 32
  123. #define NUT_IRQCTL_SETPRIO 33
  124. #define NUT_IRQCTL_GETCOUNT 96
  125. #define NUT_IRQCTL_SETCOUNT 97
  126. #define NUT_IRQMODE_NONE 0
  127. #define NUT_IRQMODE_LOWLEVEL 1
  128. #define NUT_IRQMODE_HIGHLEVEL 2
  129. #define NUT_IRQMODE_FALLINGEDGE 5
  130. #define NUT_IRQMODE_RISINGEDGE 6
  131. #define NUT_IRQMODE_EDGE 7
  132. #define NUT_IRQMODE_LEVEL 8
  133. #define NUT_IRQMODE_BOTHEDGE 9
  134. /*
  135. * Registered interrupt handler information structure.
  136. */
  137. typedef struct {
  138. #ifdef NUT_PERFMON
  139. uint32_t ir_count; /* Counter for statistics and performance analysis */
  140. #endif
  141. void *ir_arg; /* Argument passed to interrupt handler function */
  142. void (*ir_handler) (void *); /* Interrupt handler function */
  143. int (*ir_ctl) (int cmd, void *param); /* Interrupt control function */
  144. } IRQ_HANDLER;
  145. #ifdef __NUT_EMULATION__
  146. #include <arch/unix/irqreg.h>
  147. #elif defined(__AVR__)
  148. #include <arch/avr/irqreg.h>
  149. #elif defined(__arm__) && !defined(__CORTEX__)
  150. #include <arch/arm/irqreg.h>
  151. #elif defined(__arm__) && defined(__CORTEX__)
  152. #include <arch/cm3/irqreg.h>
  153. #elif defined(__AVR32__)
  154. #include <arch/avr32/irqreg.h>
  155. #elif defined(__H8300H__) || defined(__H8300S__)
  156. #include <arch/h8300h/irqreg.h>
  157. #elif defined(__m68k__)
  158. #include <arch/m68k/irqreg.h>
  159. #else
  160. #warning "MCU not defined"
  161. #endif
  162. /*@}*/
  163. /* NutRegisterInterrupt is obsolete, use NutRegisterIrqHandler instead */
  164. //extern int NutRegisterInterrupt(int irq, void (*handler)(void *), void *arg) __attribute__ ((obsolete)) ;
  165. extern void CallHandler(IRQ_HANDLER * irh);
  166. #ifdef __NUT_EMULATION__
  167. extern int NutRegisterIrqHandler(uint8_t irq_nr, void (*handler) (void *), void *arg);
  168. #else
  169. extern int NutRegisterIrqHandler(IRQ_HANDLER * irh, void (*handler) (void *), void *arg);
  170. extern int NutIrqStatus(IRQ_HANDLER * irq);
  171. extern int NutIrqEnable(IRQ_HANDLER * irq);
  172. extern int NutIrqDisable(IRQ_HANDLER * irq);
  173. extern int NutIrqSetPriority(IRQ_HANDLER * irq, int level);
  174. extern int NutIrqGetPriority(IRQ_HANDLER * irq);
  175. extern int NutIrqSetMode(IRQ_HANDLER * irq, int mode);
  176. #endif
  177. #if defined(__CORTEX__)
  178. int CM3_IrqCtl(int cmd, void *param, IRQn_Type interrupt,
  179. void (*pfnHandler)(void*),
  180. IRQ_HANDLER* sig, int def_priority);
  181. #endif
  182. #endif