interrupt.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2021, Shenzhen Academy of Aerospace Technology
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-11-16 Dystopia the first version
  9. */
  10. #include "c66xx.h"
  11. #include "interrupt.h"
  12. #define MAX_HANDLERS 128
  13. extern volatile rt_uint8_t rt_interrupt_nest;
  14. struct rt_irq_desc isr_table[MAX_HANDLERS];
  15. rt_uint32_t rt_interrupt_from_thread;
  16. rt_uint32_t rt_interrupt_to_thread;
  17. rt_uint32_t rt_thread_switch_interrupt_flag;
  18. /**
  19. * This function will initialize hardware interrupt
  20. */
  21. void rt_hw_interrupt_init(void)
  22. {
  23. /* init exceptions table */
  24. rt_memset(isr_table, 0x00, sizeof(isr_table));
  25. /* init interrupt nest, and context in thread sp */
  26. rt_interrupt_nest = 0;
  27. rt_interrupt_from_thread = 0;
  28. rt_interrupt_to_thread = 0;
  29. rt_thread_switch_interrupt_flag = 0;
  30. }
  31. /**
  32. * This function will mask a interrupt.
  33. * @param vector the interrupt number
  34. */
  35. void rt_hw_interrupt_mask(int vector)
  36. {
  37. if (vector < 0 || vector >= MAX_HANDLERS)
  38. return;
  39. }
  40. /**
  41. * This function will un-mask a interrupt.
  42. * @param vector the interrupt number
  43. */
  44. void rt_hw_interrupt_umask(int vector)
  45. {
  46. if (vector < 0 || vector >= MAX_HANDLERS)
  47. return;
  48. }
  49. /**
  50. * This function will install a interrupt service routine to a interrupt.
  51. * @param vector the interrupt number
  52. * @param new_handler the interrupt service routine to be installed
  53. * @param old_handler the old interrupt service routine
  54. */
  55. rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
  56. void *param, const char *name)
  57. {
  58. rt_isr_handler_t old_handler = RT_NULL;
  59. if (vector < MAX_HANDLERS || vector >= 0)
  60. {
  61. old_handler = isr_table[vector].handler;
  62. if (handler != RT_NULL)
  63. {
  64. #ifdef RT_USING_INTERRUPT_INFO
  65. rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
  66. #endif /* RT_USING_INTERRUPT_INFO */
  67. isr_table[vector].handler = handler;
  68. isr_table[vector].param = param;
  69. }
  70. }
  71. return old_handler;
  72. }
  73. void rt_hw_interrupt_clear(int vector)
  74. {
  75. if (vector < 0 || vector >= MAX_HANDLERS)
  76. return;
  77. }