interrupts.s34 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * File : interrupt.s34
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 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. * 2010-04-20 fify the first version
  13. *
  14. * For : Renesas M16C
  15. * Toolchain : IAR's EW for M16C v3.401
  16. */
  17. PUBLIC rt_hw_timer_handler
  18. PUBLIC rt_hw_uart0_receive_handler
  19. EXTERN rt_thread_switch_interrput_flag
  20. EXTERN rt_interrupt_from_thread
  21. EXTERN rt_interrupt_to_thread
  22. EXTERN rt_interrupt_enter
  23. EXTERN rt_interrupt_leave
  24. EXTERN rt_tick_increase
  25. EXTERN u0rec_handler
  26. RSEG CSTACK
  27. RSEG ISTACK
  28. RSEG CODE:CODE:NOROOT(2)
  29. rt_hw_context_switch_interrupt_do
  30. MOV.W #0, rt_thread_switch_interrput_flag
  31. MOV.W rt_interrupt_from_thread, A0
  32. STC ISP, [A0]
  33. MOV.W rt_interrupt_to_thread, A0
  34. LDC [A0], ISP
  35. POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore all processor registers from the new task's stack
  36. REIT
  37. .EVEN
  38. rt_hw_timer_handler:
  39. PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers
  40. JSR rt_interrupt_enter
  41. JSR rt_tick_increase
  42. JSR rt_interrupt_leave
  43. CMP.W #1,rt_thread_switch_interrput_flag
  44. JEQ rt_hw_context_switch_interrupt_do
  45. POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers
  46. REIT ; Return from interrup
  47. .EVEN
  48. rt_hw_uart0_receive_handler:
  49. PUSHM R0,R1,R2,R3,A0,A1,SB,FB ; Save current task's registers
  50. JSR rt_interrupt_enter
  51. JSR u0rec_handler
  52. JSR rt_interrupt_leave
  53. CMP.W #1, rt_thread_switch_interrput_flag
  54. JEQ rt_hw_context_switch_interrupt_do
  55. POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore current task's registers
  56. REIT ; Return from interrup
  57. END