software_irq.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-09-09 WCH the first version
  9. * 2023-01-04 WangShun Remove redundant files
  10. */
  11. #include "rtconfig.h"
  12. #if defined (SOC_RISCV_SERIES_CH32V1)
  13. #include "ch32v10x.h"
  14. #elif defined (SOC_RISCV_SERIES_CH32V2)
  15. #include "ch32v20x.h"
  16. #elif defined (SOC_RISCV_SERIES_CH32V3)
  17. #include "ch32v30x.h"
  18. #else
  19. #error "CH32 architecture doesn't support!"
  20. #endif
  21. void rt_trigger_software_interrupt(void)
  22. {
  23. /*CH32V103 does not support systick software interrupt*/
  24. #if defined(SOC_RISCV_SERIES_CH32V1)
  25. NVIC_SetPendingIRQ(Software_IRQn);
  26. #else
  27. SysTick->CTLR |= (1 << 31);
  28. #endif
  29. }
  30. void rt_hw_do_after_save_above(void)
  31. {
  32. __asm volatile ("li t0,0x20" );
  33. __asm volatile ("csrs 0x804, t0");
  34. /*CH32V103 does not support systick software interrupt*/
  35. #if defined(SOC_RISCV_SERIES_CH32V1)
  36. NVIC_ClearPendingIRQ(Software_IRQn);
  37. #else
  38. SysTick->CTLR &= ~(1 << 31);
  39. #endif
  40. }