irq.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * File : irq.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-02-24 Bernard first version
  13. * 2006-05-03 Bernard add IRQ_DEBUG
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. /* #define IRQ_DEBUG */
  18. /**
  19. * @addtogroup Kernel
  20. */
  21. /*@{*/
  22. volatile rt_uint8_t rt_interrupt_nest;
  23. /**
  24. * This function will be invoked by BSP, when enter interrupt service routine
  25. *
  26. * @note please don't invoke this routine in application
  27. *
  28. * @see rt_interrupt_leave
  29. */
  30. void rt_interrupt_enter()
  31. {
  32. rt_base_t level;
  33. RT_DEBUG_REENT_IN
  34. RT_DEBUG_LOG(RT_DEBUG_IRQ,("irq comming..., irq nest:%d\n", rt_interrupt_nest));
  35. level = rt_hw_interrupt_disable();
  36. rt_interrupt_nest ++;
  37. rt_hw_interrupt_enable(level);
  38. }
  39. /**
  40. * This function will be invoked by BSP, when leave interrupt service routine
  41. *
  42. * @note please don't invoke this routine in application
  43. *
  44. * @see rt_interrupt_enter
  45. */
  46. void rt_interrupt_leave()
  47. {
  48. rt_base_t level;
  49. RT_DEBUG_LOG(RT_DEBUG_IRQ,("irq leave, irq nest:%d\n", rt_interrupt_nest));
  50. level = rt_hw_interrupt_disable();
  51. rt_interrupt_nest --;
  52. rt_hw_interrupt_enable(level);
  53. RT_DEBUG_REENT_OUT
  54. }
  55. /*@}*/