From 95540854a669bffd29ed7bde05d4a12addd43319 Mon Sep 17 00:00:00 2001 From: Yaochenger <75192526+Yaochenger@users.noreply.github.com> Date: Thu, 2 Mar 2023 22:17:43 +0800 Subject: [PATCH] =?UTF-8?q?[libcpu/riscv]=E8=BF=81=E7=A7=BBlibcpu/riscv/ch?= =?UTF-8?q?32=E4=B8=AD=E6=96=87=E4=BB=B6=E8=87=B3bsp=20(#7004)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/wch/risc-v/ch32v103r-evt/board/SConscript | 1 + .../ch32v103r-evt/board}/software_irq.c | 0 bsp/wch/risc-v/ch32v208w-r0/board/SConscript | 1 + .../risc-v/ch32v208w-r0/board/software_irq.c | 41 +++++++++++++++++++ bsp/wch/risc-v/ch32v307v-r1/board/SConscript | 1 + .../risc-v/ch32v307v-r1/board/software_irq.c | 41 +++++++++++++++++++ libcpu/risc-v/ch32/SConscript | 12 ------ 7 files changed, 85 insertions(+), 12 deletions(-) rename {libcpu/risc-v/ch32 => bsp/wch/risc-v/ch32v103r-evt/board}/software_irq.c (100%) create mode 100644 bsp/wch/risc-v/ch32v208w-r0/board/software_irq.c create mode 100644 bsp/wch/risc-v/ch32v307v-r1/board/software_irq.c delete mode 100644 libcpu/risc-v/ch32/SConscript diff --git a/bsp/wch/risc-v/ch32v103r-evt/board/SConscript b/bsp/wch/risc-v/ch32v103r-evt/board/SConscript index d245fbe011..127d3c77f4 100644 --- a/bsp/wch/risc-v/ch32v103r-evt/board/SConscript +++ b/bsp/wch/risc-v/ch32v103r-evt/board/SConscript @@ -11,6 +11,7 @@ src = Split(''' board.c debug.c ch32v10x_it.c +software_irq.c ''') path = [cwd] diff --git a/libcpu/risc-v/ch32/software_irq.c b/bsp/wch/risc-v/ch32v103r-evt/board/software_irq.c similarity index 100% rename from libcpu/risc-v/ch32/software_irq.c rename to bsp/wch/risc-v/ch32v103r-evt/board/software_irq.c diff --git a/bsp/wch/risc-v/ch32v208w-r0/board/SConscript b/bsp/wch/risc-v/ch32v208w-r0/board/SConscript index bc8e7636f1..ea54a3a737 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/board/SConscript +++ b/bsp/wch/risc-v/ch32v208w-r0/board/SConscript @@ -9,6 +9,7 @@ cwd = GetCurrentDir() # add general drivers src = Split(''' board.c +software_irq.c ''') path = [cwd] diff --git a/bsp/wch/risc-v/ch32v208w-r0/board/software_irq.c b/bsp/wch/risc-v/ch32v208w-r0/board/software_irq.c new file mode 100644 index 0000000000..e91a588312 --- /dev/null +++ b/bsp/wch/risc-v/ch32v208w-r0/board/software_irq.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-09 WCH the first version + * 2023-01-04 WangShun Remove redundant files + */ +#include "rtconfig.h" +#if defined (SOC_RISCV_SERIES_CH32V1) +#include "ch32v10x.h" +#elif defined (SOC_RISCV_SERIES_CH32V2) +#include "ch32v20x.h" +#elif defined (SOC_RISCV_SERIES_CH32V3) +#include "ch32v30x.h" +#else +#error "CH32 architecture doesn't support!" +#endif +void rt_trigger_software_interrupt(void) +{ + /*CH32V103 does not support systick software interrupt*/ +#if defined(SOC_RISCV_SERIES_CH32V1) + NVIC_SetPendingIRQ(Software_IRQn); +#else + SysTick->CTLR |= (1 << 31); +#endif +} + +void rt_hw_do_after_save_above(void) +{ + __asm volatile ("li t0,0x20" ); + __asm volatile ("csrs 0x804, t0"); + /*CH32V103 does not support systick software interrupt*/ +#if defined(SOC_RISCV_SERIES_CH32V1) + NVIC_ClearPendingIRQ(Software_IRQn); +#else + SysTick->CTLR &= ~(1 << 31); +#endif +} \ No newline at end of file diff --git a/bsp/wch/risc-v/ch32v307v-r1/board/SConscript b/bsp/wch/risc-v/ch32v307v-r1/board/SConscript index bc8e7636f1..ea54a3a737 100644 --- a/bsp/wch/risc-v/ch32v307v-r1/board/SConscript +++ b/bsp/wch/risc-v/ch32v307v-r1/board/SConscript @@ -9,6 +9,7 @@ cwd = GetCurrentDir() # add general drivers src = Split(''' board.c +software_irq.c ''') path = [cwd] diff --git a/bsp/wch/risc-v/ch32v307v-r1/board/software_irq.c b/bsp/wch/risc-v/ch32v307v-r1/board/software_irq.c new file mode 100644 index 0000000000..e91a588312 --- /dev/null +++ b/bsp/wch/risc-v/ch32v307v-r1/board/software_irq.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-09 WCH the first version + * 2023-01-04 WangShun Remove redundant files + */ +#include "rtconfig.h" +#if defined (SOC_RISCV_SERIES_CH32V1) +#include "ch32v10x.h" +#elif defined (SOC_RISCV_SERIES_CH32V2) +#include "ch32v20x.h" +#elif defined (SOC_RISCV_SERIES_CH32V3) +#include "ch32v30x.h" +#else +#error "CH32 architecture doesn't support!" +#endif +void rt_trigger_software_interrupt(void) +{ + /*CH32V103 does not support systick software interrupt*/ +#if defined(SOC_RISCV_SERIES_CH32V1) + NVIC_SetPendingIRQ(Software_IRQn); +#else + SysTick->CTLR |= (1 << 31); +#endif +} + +void rt_hw_do_after_save_above(void) +{ + __asm volatile ("li t0,0x20" ); + __asm volatile ("csrs 0x804, t0"); + /*CH32V103 does not support systick software interrupt*/ +#if defined(SOC_RISCV_SERIES_CH32V1) + NVIC_ClearPendingIRQ(Software_IRQn); +#else + SysTick->CTLR &= ~(1 << 31); +#endif +} \ No newline at end of file diff --git a/libcpu/risc-v/ch32/SConscript b/libcpu/risc-v/ch32/SConscript deleted file mode 100644 index ccd26ae518..0000000000 --- a/libcpu/risc-v/ch32/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# RT-Thread building script for component - -from building import * - -cwd = GetCurrentDir() -src = Glob('*.c') + Glob('*.cpp') + Glob('*_gcc.S') -CPPPATH = [cwd] -ASFLAGS = ' -I ' + cwd - -group = DefineGroup('CPU', src, depend = [''], CPPPATH = CPPPATH, ASFLAGS = ASFLAGS) - -Return('group')