irqreg.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef _DEV_IRQREG_CM3_H_
  2. #define _DEV_IRQREG_CM3_H_
  3. /*
  4. * Copyright (C) 2001-2007 by egnite Software GmbH. All rights reserved.
  5. * Copyright (C) 2013 Uwe Bonnes(bon@elektron.ikp.physik.tu-darmstadt.de).
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the name of the copyright holders nor the names of
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  27. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  28. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  30. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. *
  33. * For additional information see http://www.ethernut.de/
  34. */
  35. /*
  36. * $Log$
  37. *
  38. * Revision 1.00 2010/08/10 16:48:28 ulrichprinz
  39. * Initial version
  40. *
  41. *
  42. */
  43. #if defined(__CORTEX__)
  44. #if defined(SAM3U)
  45. #include <arch/cm3/atmel/sam3u_irqreg.h>
  46. #elif defined(MCU_STM32)
  47. #include <arch/cm3/stm/stm32_irqreg.h>
  48. #elif defined(MCU_LPC176x) || defined(MCU_LPC177x_8x) || defined(MCU_LPC407x_8x)
  49. #include <arch/cm3/nxp/lpc17xx_irqreg.h>
  50. #else
  51. #warning "Unknown CortexM3 MCU defined"
  52. #endif
  53. #else
  54. #warning "No CortexM3 MCU defined"
  55. #endif
  56. #ifdef NUT_PERFMON
  57. #define CREATE_HANDLER(IRQ_SIG, DEV, PRIORITY) \
  58. \
  59. static int IRQ_SIG## IrqCtl(int cmd, void *param); \
  60. \
  61. IRQ_HANDLER sig_ ##IRQ_SIG = { \
  62. 0, /* Interrupt counter, ir_count. */ \
  63. NULL, /* Passed argument, ir_arg. */ \
  64. NULL, /* Handler subroutine, ir_handler. */ \
  65. IRQ_SIG## IrqCtl /* Interrupt control, ir_ctl. */ \
  66. }; \
  67. static void IRQ_SIG## IrqEntry(void *arg); \
  68. void IRQ_SIG## IrqEntry(void *arg) \
  69. { \
  70. sig_ ##IRQ_SIG.ir_count++; \
  71. if (sig_ ##IRQ_SIG.ir_handler) { \
  72. (sig_ ##IRQ_SIG.ir_handler) (sig_ ##IRQ_SIG.ir_arg); \
  73. } \
  74. } \
  75. int IRQ_SIG## IrqCtl(int cmd, void* param) \
  76. { \
  77. return CM3_IrqCtl(cmd, param, DEV## _IRQn, & IRQ_SIG##IrqEntry, &sig_ ##IRQ_SIG, PRIORITY); \
  78. }
  79. #else /* NUT_PERFMON */
  80. #define CREATE_HANDLER(IRQ_SIG, DEV, PRIORITY) \
  81. \
  82. static int IRQ_SIG##IrqCtl(int cmd, void *param); \
  83. \
  84. IRQ_HANDLER sig_ ##IRQ_SIG = { \
  85. NULL, /* Passed argument, ir_arg. */ \
  86. NULL, /* Handler subroutine, ir_handler. */ \
  87. IRQ_SIG## IrqCtl /* Interrupt control, ir_ctl. */ \
  88. }; \
  89. static void IRQ_SIG## IrqEntry(void *arg); \
  90. void IRQ_SIG## IrqEntry(void *arg) \
  91. { \
  92. if (sig_ ##IRQ_SIG.ir_handler) { \
  93. (sig_ ##IRQ_SIG.ir_handler) (sig_ ##IRQ_SIG.ir_arg); \
  94. } \
  95. } \
  96. int IRQ_SIG## IrqCtl(int cmd, void* param) \
  97. { \
  98. return CM3_IrqCtl(cmd, param, DEV## _IRQn, & IRQ_SIG##IrqEntry, &sig_ ##IRQ_SIG, PRIORITY); \
  99. }
  100. #endif
  101. #endif