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. #ifdef IRQ_DEBUG
  34. rt_kprintf("irq comming..., irq nest:%d\n", rt_interrupt_nest);
  35. #endif
  36. level = rt_hw_interrupt_disable();
  37. rt_interrupt_nest ++;
  38. rt_hw_interrupt_enable(level);
  39. }
  40. /**
  41. * This function will be invoked by BSP, when leave interrupt service routine
  42. *
  43. * @note please don't invoke this routine in application
  44. *
  45. * @see rt_interrupt_enter
  46. */
  47. void rt_interrupt_leave()
  48. {
  49. rt_base_t level;
  50. #ifdef IRQ_DEBUG
  51. rt_kprintf("irq leave, irq nest:%d\n", rt_interrupt_nest);
  52. #endif
  53. level = rt_hw_interrupt_disable();
  54. rt_interrupt_nest --;
  55. rt_hw_interrupt_enable(level);
  56. }
  57. /*@}*/