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