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.13 2006/01/05 16:53:56 haraldkipp 00039 * New function NutIrqSetMode() allows to modify the interrupt mode. 00040 * 00041 * Revision 1.12 2005/10/24 10:50:49 haraldkipp 00042 * New API functions added. 00043 * Interrupt counting requires NUT_PERFMON to be defined. 00044 * 00045 * Revision 1.11 2005/07/26 16:05:24 haraldkipp 00046 * Several files were moved from subdir dev to subdir arch. 00047 * 00048 * Revision 1.10 2005/04/07 12:31:37 freckle 00049 * most unix emulation specific stuff now in irqreg_unix.h. 00050 * corrected #warning "MCU not defined" 00051 * 00052 * Revision 1.9 2005/04/05 17:52:40 haraldkipp 00053 * Much better implementation of GBA interrupt registration. 00054 * 00055 * Revision 1.8 2005/02/10 07:06:51 hwmaier 00056 * Changes to incorporate support for AT90CAN128 CPU 00057 * 00058 * Revision 1.7 2004/08/05 12:13:56 freckle 00059 * Added unix emulation hook in NutThreadYield to safely process 00060 * NutPostEventAsync calls occuring in non Nut/OS threads. 00061 * Rewrote the unix read function again using the new unix NutThreadYield hook 00062 * to call the NutPostEventAsync function safely (fast & correct). 00063 * _write(nf, 0, 0) aka fflush is ignored on unix emulation. 00064 * 00065 * Revision 1.6 2004/04/07 12:13:57 haraldkipp 00066 * Matthias Ringwald's *nix emulation added 00067 * 00068 * Revision 1.5 2004/03/18 15:48:13 haraldkipp 00069 * ICCAVR failed to compile 00070 * 00071 * Revision 1.4 2004/03/16 16:48:28 haraldkipp 00072 * Added Jan Dubiec's H8/300 port. 00073 * 00074 * Revision 1.3 2004/01/30 17:00:46 drsung 00075 * Separate interrupt stack for avr-gcc only added. 00076 * 00077 * Revision 1.2 2003/11/23 16:42:13 drsung 00078 * NutRegisterInterrupt removed, because it's incompatible to the new interrupt handling 00079 * 00080 * Revision 1.1.1.1 2003/05/09 14:41:06 haraldkipp 00081 * Initial using 3.2.1 00082 * 00083 * Revision 1.10 2003/05/06 18:42:55 harald 00084 * Cleanup 00085 * 00086 * Revision 1.9 2003/02/04 18:00:37 harald 00087 * Version 3 released 00088 * 00089 * Revision 1.8 2002/07/03 16:45:40 harald 00090 * Using GCC 3.2 00091 * 00092 * Revision 1.7 2002/06/26 17:29:15 harald 00093 * First pre-release with 2.4 stack 00094 * 00095 */ 00096 00097 #include <cfg/arch.h> 00098 #include <sys/device.h> 00099 #include <dev/irqstack.h> 00100 00110 00111 #define NUT_IRQCTL_INIT 0 00112 #define NUT_IRQCTL_CLEAR 1 00113 #define NUT_IRQCTL_STATUS 16 00114 #define NUT_IRQCTL_ENABLE 17 00115 #define NUT_IRQCTL_DISABLE 18 00116 #define NUT_IRQCTL_GETMODE 24 00117 #define NUT_IRQCTL_SETMODE 25 00118 #define NUT_IRQCTL_GETPRIO 32 00119 #define NUT_IRQCTL_SETPRIO 33 00120 #define NUT_IRQCTL_GETCOUNT 96 00121 #define NUT_IRQCTL_SETCOUNT 97 00122 00123 #define NUT_IRQMODE_LOWLEVEL 1 00124 #define NUT_IRQMODE_HIGHLEVEL 2 00125 #define NUT_IRQMODE_FALLINGEDGE 5 00126 #define NUT_IRQMODE_RISINGEDGE 6 00127 #define NUT_IRQMODE_EDGE 7 00128 00129 /* 00130 * Registered interrupt handler information structure. 00131 */ 00132 typedef struct { 00133 #ifdef NUT_PERFMON 00134 u_long ir_count; 00135 #endif 00136 void *ir_arg; 00137 void (*ir_handler) (void *); 00138 int (*ir_ctl) (int cmd, void *param); 00139 } IRQ_HANDLER; 00140 00141 #if defined(__AVR__) 00142 #include <arch/avr/irqreg.h> 00143 #elif defined(__arm__) 00144 #include <arch/arm/irqreg.h> 00145 #elif defined(__H8300H__) || defined(__H8300S__) 00146 #include <arch/h8300h/irqreg.h> 00147 #elif defined(__m68k__) 00148 #include <arch/m68k/irqreg.h> 00149 #elif defined (__linux__) || defined(__APPLE__) || defined(__CYGWIN__) 00150 #include <arch/unix/irqreg.h> 00151 #else 00152 #warning "MCU not defined" 00153 #endif 00154 00157 __BEGIN_DECLS 00158 /* NutRegisterInterrupt is obsolete, use NutRegisterIrqHandler instead */ 00159 //extern int NutRegisterInterrupt(int irq, void (*handler)(void *), void *arg) __attribute__ ((obsolete)) ; 00160 extern void CallHandler(IRQ_HANDLER * irh); 00161 00162 #if defined (__linux__) || defined (__APPLE__) || defined(__CYGWIN__) 00163 extern int NutRegisterIrqHandler(u_char irq_nr, void (*handler) (void *), void *arg); 00164 #else 00165 extern int NutRegisterIrqHandler(IRQ_HANDLER * irh, void (*handler) (void *), void *arg); 00166 extern int NutIrqEnable(IRQ_HANDLER * irq); 00167 extern int NutIrqDisable(IRQ_HANDLER * irq); 00168 extern int NutIrqSetPriority(IRQ_HANDLER * irq, int level); 00169 extern int NutIrqSetMode(IRQ_HANDLER * irq, int mode); 00170 #endif 00171 00172 __END_DECLS 00173 #endif