00001 #ifndef _DEV_IRQREG_H_ 00002 #define _DEV_IRQREG_H_ 00003 00004 /* 00005 * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. Neither the name of the copyright holders nor the names of 00017 * contributors may be used to endorse or promote products derived 00018 * from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00023 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE 00024 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00025 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00027 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00028 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00029 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00030 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * For additional information see http://www.ethernut.de/ 00034 */ 00035 00036 /* 00037 * $Log: irqreg.h,v $ 00038 * Revision 1.14 2008/07/26 09:38:02 haraldkipp 00039 * Added support for NUT_IRQMODE_NONE and NUT_IRQMODE_LEVEL. 00040 * 00041 * Revision 1.13 2006/01/05 16:53:56 haraldkipp 00042 * New function NutIrqSetMode() allows to modify the interrupt mode. 00043 * 00044 * Revision 1.12 2005/10/24 10:50:49 haraldkipp 00045 * New API functions added. 00046 * Interrupt counting requires NUT_PERFMON to be defined. 00047 * 00048 * Revision 1.11 2005/07/26 16:05:24 haraldkipp 00049 * Several files were moved from subdir dev to subdir arch. 00050 * 00051 * Revision 1.10 2005/04/07 12:31:37 freckle 00052 * most unix emulation specific stuff now in irqreg_unix.h. 00053 * corrected #warning "MCU not defined" 00054 * 00055 * Revision 1.9 2005/04/05 17:52:40 haraldkipp 00056 * Much better implementation of GBA interrupt registration. 00057 * 00058 * Revision 1.8 2005/02/10 07:06:51 hwmaier 00059 * Changes to incorporate support for AT90CAN128 CPU 00060 * 00061 * Revision 1.7 2004/08/05 12:13:56 freckle 00062 * Added unix emulation hook in NutThreadYield to safely process 00063 * NutPostEventAsync calls occuring in non Nut/OS threads. 00064 * Rewrote the unix read function again using the new unix NutThreadYield hook 00065 * to call the NutPostEventAsync function safely (fast & correct). 00066 * _write(nf, 0, 0) aka fflush is ignored on unix emulation. 00067 * 00068 * Revision 1.6 2004/04/07 12:13:57 haraldkipp 00069 * Matthias Ringwald's *nix emulation added 00070 * 00071 * Revision 1.5 2004/03/18 15:48:13 haraldkipp 00072 * ICCAVR failed to compile 00073 * 00074 * Revision 1.4 2004/03/16 16:48:28 haraldkipp 00075 * Added Jan Dubiec's H8/300 port. 00076 * 00077 * Revision 1.3 2004/01/30 17:00:46 drsung 00078 * Separate interrupt stack for avr-gcc only added. 00079 * 00080 * Revision 1.2 2003/11/23 16:42:13 drsung 00081 * NutRegisterInterrupt removed, because it's incompatible to the new interrupt handling 00082 * 00083 * Revision 1.1.1.1 2003/05/09 14:41:06 haraldkipp 00084 * Initial using 3.2.1 00085 * 00086 * Revision 1.10 2003/05/06 18:42:55 harald 00087 * Cleanup 00088 * 00089 * Revision 1.9 2003/02/04 18:00:37 harald 00090 * Version 3 released 00091 * 00092 * Revision 1.8 2002/07/03 16:45:40 harald 00093 * Using GCC 3.2 00094 * 00095 * Revision 1.7 2002/06/26 17:29:15 harald 00096 * First pre-release with 2.4 stack 00097 * 00098 */ 00099 00100 #include <cfg/arch.h> 00101 #include <sys/device.h> 00102 #include <dev/irqstack.h> 00103 00113 00114 #define NUT_IRQCTL_INIT 0 00115 #define NUT_IRQCTL_CLEAR 1 00116 #define NUT_IRQCTL_STATUS 16 00117 #define NUT_IRQCTL_ENABLE 17 00118 #define NUT_IRQCTL_DISABLE 18 00119 #define NUT_IRQCTL_GETMODE 24 00120 #define NUT_IRQCTL_SETMODE 25 00121 #define NUT_IRQCTL_GETPRIO 32 00122 #define NUT_IRQCTL_SETPRIO 33 00123 #define NUT_IRQCTL_GETCOUNT 96 00124 #define NUT_IRQCTL_SETCOUNT 97 00125 00126 #define NUT_IRQMODE_NONE 0 00127 #define NUT_IRQMODE_LOWLEVEL 1 00128 #define NUT_IRQMODE_HIGHLEVEL 2 00129 #define NUT_IRQMODE_FALLINGEDGE 5 00130 #define NUT_IRQMODE_RISINGEDGE 6 00131 #define NUT_IRQMODE_EDGE 7 00132 #define NUT_IRQMODE_LEVEL 8 00133 00134 /* 00135 * Registered interrupt handler information structure. 00136 */ 00137 typedef struct { 00138 #ifdef NUT_PERFMON 00139 u_long ir_count; 00140 #endif 00141 void *ir_arg; 00142 void (*ir_handler) (void *); 00143 int (*ir_ctl) (int cmd, void *param); 00144 } IRQ_HANDLER; 00145 00146 #if defined(__AVR__) 00147 #include <arch/avr/irqreg.h> 00148 #elif defined(__arm__) 00149 #include <arch/arm/irqreg.h> 00150 #elif defined(__H8300H__) || defined(__H8300S__) 00151 #include <arch/h8300h/irqreg.h> 00152 #elif defined(__m68k__) 00153 #include <arch/m68k/irqreg.h> 00154 #elif defined (__linux__) || defined(__APPLE__) || defined(__CYGWIN__) 00155 #include <arch/unix/irqreg.h> 00156 #else 00157 #warning "MCU not defined" 00158 #endif 00159 00162 __BEGIN_DECLS 00163 /* NutRegisterInterrupt is obsolete, use NutRegisterIrqHandler instead */ 00164 //extern int NutRegisterInterrupt(int irq, void (*handler)(void *), void *arg) __attribute__ ((obsolete)) ; 00165 extern void CallHandler(IRQ_HANDLER * irh); 00166 00167 #if defined (__linux__) || defined (__APPLE__) || defined(__CYGWIN__) 00168 extern int NutRegisterIrqHandler(u_char irq_nr, void (*handler) (void *), void *arg); 00169 #else 00170 extern int NutRegisterIrqHandler(IRQ_HANDLER * irh, void (*handler) (void *), void *arg); 00171 extern int NutIrqEnable(IRQ_HANDLER * irq); 00172 extern int NutIrqDisable(IRQ_HANDLER * irq); 00173 extern int NutIrqSetPriority(IRQ_HANDLER * irq, int level); 00174 extern int NutIrqSetMode(IRQ_HANDLER * irq, int mode); 00175 #endif 00176 00177 __END_DECLS 00178 #endif