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