2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* File : irq.c
|
|
|
|
* This file is part of RT-Thread RTOS
|
2012-03-17 14:43:49 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
* found in the file LICENSE in this distribution or at
|
2009-12-25 20:18:53 +08:00
|
|
|
* http://www.rt-thread.org/license/LICENSE
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2006-02-24 Bernard first version
|
|
|
|
* 2006-05-03 Bernard add IRQ_DEBUG
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
|
|
/* #define IRQ_DEBUG */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Kernel
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*@{*/
|
|
|
|
|
2010-03-09 07:09:40 +08:00
|
|
|
volatile rt_uint8_t rt_interrupt_nest;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will be invoked by BSP, when enter interrupt service routine
|
|
|
|
*
|
|
|
|
* @note please don't invoke this routine in application
|
|
|
|
*
|
|
|
|
* @see rt_interrupt_leave
|
|
|
|
*/
|
2011-09-21 11:56:42 +08:00
|
|
|
void rt_interrupt_enter(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
|
|
|
rt_base_t level;
|
2009-12-25 20:18:53 +08:00
|
|
|
|
2012-12-20 15:25:19 +08:00
|
|
|
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq coming..., irq nest:%d\n",
|
|
|
|
rt_interrupt_nest));
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
rt_interrupt_nest ++;
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
}
|
2012-07-06 19:20:53 +08:00
|
|
|
RTM_EXPORT(rt_interrupt_enter);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will be invoked by BSP, when leave interrupt service routine
|
|
|
|
*
|
|
|
|
* @note please don't invoke this routine in application
|
|
|
|
*
|
|
|
|
* @see rt_interrupt_enter
|
|
|
|
*/
|
2011-09-21 11:56:42 +08:00
|
|
|
void rt_interrupt_leave(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
|
|
|
rt_base_t level;
|
|
|
|
|
2011-09-21 11:56:42 +08:00
|
|
|
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq leave, irq nest:%d\n", rt_interrupt_nest));
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
rt_interrupt_nest --;
|
|
|
|
rt_hw_interrupt_enable(level);
|
2011-06-15 07:59:42 +08:00
|
|
|
}
|
2012-07-06 19:20:53 +08:00
|
|
|
RTM_EXPORT(rt_interrupt_leave);
|
2011-06-12 18:01:48 +08:00
|
|
|
|
2011-06-15 07:59:42 +08:00
|
|
|
/**
|
|
|
|
* This function will return the nest of interrupt.
|
|
|
|
*
|
2012-06-18 20:21:03 +08:00
|
|
|
* User application can invoke this function to get whether current
|
2011-06-15 07:59:42 +08:00
|
|
|
* context is interrupt context.
|
|
|
|
*
|
|
|
|
* @return the number of nested interrupts.
|
|
|
|
*/
|
|
|
|
rt_uint8_t rt_interrupt_get_nest(void)
|
|
|
|
{
|
|
|
|
return rt_interrupt_nest;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2012-07-06 19:20:53 +08:00
|
|
|
RTM_EXPORT(rt_interrupt_get_nest);
|
|
|
|
|
|
|
|
RTM_EXPORT(rt_hw_interrupt_disable);
|
|
|
|
RTM_EXPORT(rt_hw_interrupt_enable);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
/*@}*/
|
2011-06-15 07:59:42 +08:00
|
|
|
|