From 67bf5cea1f111dee750f1e7471611b9a688ce668 Mon Sep 17 00:00:00 2001 From: greedyhao Date: Sat, 19 Dec 2020 10:45:03 +0800 Subject: [bluetrum] add sound and romfs support --- bsp/bluetrum/libcpu/cpu/interrupt.c | 21 +++++++++++++++++---- bsp/bluetrum/libcpu/cpu/interrupt.h | 7 +++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 bsp/bluetrum/libcpu/cpu/interrupt.h (limited to 'bsp/bluetrum/libcpu') diff --git a/bsp/bluetrum/libcpu/cpu/interrupt.c b/bsp/bluetrum/libcpu/cpu/interrupt.c index 1903ec25ce..3e7dbdb553 100644 --- a/bsp/bluetrum/libcpu/cpu/interrupt.c +++ b/bsp/bluetrum/libcpu/cpu/interrupt.c @@ -13,8 +13,8 @@ #include #include "ab32vgx.h" -uint32_t irq_mask AT(.bss.irq_tbl); -void *tbl_irq_vector[IRQ_TOTAL_NUM] AT(.bss.irq_tbl); +uint32_t irq_mask; +void *tbl_irq_vector[IRQ_TOTAL_NUM]; void (*cpu_irq_comm_hook)(void); void set_cpu_irq_comm(void (*irq_hook)(void)) @@ -22,7 +22,6 @@ void set_cpu_irq_comm(void (*irq_hook)(void)) cpu_irq_comm_hook = irq_hook; } -AT(.com_text.irq) void cpu_irq_comm_do(void) { void (*pfnct)(void); @@ -37,6 +36,20 @@ void cpu_irq_comm_do(void) } } +void rt_hw_irq_enable(int vector) +{ + if (vector < IRQ_TOTAL_NUM) { + PICEN |= BIT(vector); + } +} + +void rt_hw_irq_disable(int vector) +{ + if (vector < IRQ_TOTAL_NUM) { + PICEN &= ~BIT(vector); + } +} + void rt_hw_interrupt_init(void) { } @@ -58,7 +71,7 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t old_handler = RT_NULL; if (vector < IRQ_TOTAL_NUM) { - uint32_t cpu_ie = PICCON&BIT(0); + uint32_t cpu_ie = PICCON & BIT(0); PICCON &= ~BIT(0); old_handler = tbl_irq_vector[vector]; tbl_irq_vector[vector] = handler; diff --git a/bsp/bluetrum/libcpu/cpu/interrupt.h b/bsp/bluetrum/libcpu/cpu/interrupt.h new file mode 100644 index 0000000000..d950f1f9b4 --- /dev/null +++ b/bsp/bluetrum/libcpu/cpu/interrupt.h @@ -0,0 +1,7 @@ +#ifndef INTERRUPT_H__ +#define INTERRUPT_H__ + +void rt_hw_irq_enable(int vector); +void rt_hw_irq_disable(int vector); + +#endif -- cgit v1.3.1 From 216285a2c3cb3f0b39197330fea562d94d0433e9 Mon Sep 17 00:00:00 2001 From: greedyhao Date: Fri, 25 Dec 2020 17:19:58 +0800 Subject: [bluetrum] fix context switch error --- bsp/bluetrum/ab32vg1-ab-prougen/.config | 7 +++++-- bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h | 4 ++-- bsp/bluetrum/libcpu/cpu/context_gcc.S | 8 ++++++-- bsp/bluetrum/libcpu/cpu/cpuport.c | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'bsp/bluetrum/libcpu') diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/.config b/bsp/bluetrum/ab32vg1-ab-prougen/.config index ae0ddcec8b..d6b19f6f8b 100644 --- a/bsp/bluetrum/ab32vg1-ab-prougen/.config +++ b/bsp/bluetrum/ab32vg1-ab-prougen/.config @@ -288,6 +288,7 @@ CONFIG_RT_USING_LIBC=y # CONFIG_PKG_USING_PDULIB is not set # CONFIG_PKG_USING_BTSTACK is not set # CONFIG_PKG_USING_LORAWAN_ED_STACK is not set +# CONFIG_PKG_USING_WAYZ_IOTKIT is not set # # security packages @@ -437,6 +438,8 @@ CONFIG_RT_USING_LIBC=y # CONFIG_PKG_USING_QKEY is not set # CONFIG_PKG_USING_RS485 is not set # CONFIG_PKG_USING_NES is not set +# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set +# CONFIG_PKG_USING_VDEVICE is not set # # miscellaneous packages @@ -495,13 +498,13 @@ CONFIG_RT_USING_LIBC=y # Onboard Peripheral Drivers # CONFIG_BSP_USING_USB_TO_USART=y +CONFIG_BSP_USING_AUDIO=y +CONFIG_BSP_USING_AUDIO_PLAY=y # # On-chip Peripheral Drivers # CONFIG_BSP_USING_UART0=y -CONFIG_BSP_USING_AUDIO=y -CONFIG_BSP_USING_AUDIO_PLAY=y # # Board extended module Drivers diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h index a123d38a5e..3ce6012a61 100644 --- a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h +++ b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h @@ -169,12 +169,12 @@ /* Onboard Peripheral Drivers */ #define BSP_USING_USB_TO_USART +#define BSP_USING_AUDIO +#define BSP_USING_AUDIO_PLAY /* On-chip Peripheral Drivers */ #define BSP_USING_UART0 -#define BSP_USING_AUDIO -#define BSP_USING_AUDIO_PLAY /* Board extended module Drivers */ diff --git a/bsp/bluetrum/libcpu/cpu/context_gcc.S b/bsp/bluetrum/libcpu/cpu/context_gcc.S index 9139657eaa..e9a6cc28e3 100644 --- a/bsp/bluetrum/libcpu/cpu/context_gcc.S +++ b/bsp/bluetrum/libcpu/cpu/context_gcc.S @@ -44,7 +44,7 @@ enable_int_ret: /* Macro for saving task context */ .macro save_context - addi sp, sp, -120 + addi sp, sp, -124 /* Save Context */ sw x1, 0(sp) @@ -79,6 +79,8 @@ enable_int_ret: lw a5, EPC(zero) //Saves current program counter (EPC) as task program counter sw a5, 116(sp) + lw a5, EPICCON(zero) + sw a5, 120(sp) sw sp, rt_cur_thread_sp, a4 //store sp in preempted tasks tcb .endm @@ -93,6 +95,8 @@ enable_int_ret: /* Load task program counter EPC*/ lw a5, 116(sp) sw a5, EPC(zero) + lw a5, 120(sp) + sw a5, EPICCON(zero) /* Restore registers, Skip global pointer because that does not change */ @@ -126,7 +130,7 @@ enable_int_ret: lw x30, 108(sp) lw x31, 112(sp) - addi sp, sp, 120 + addi sp, sp, 124 mret .endm diff --git a/bsp/bluetrum/libcpu/cpu/cpuport.c b/bsp/bluetrum/libcpu/cpu/cpuport.c index 576401421a..7689018a51 100644 --- a/bsp/bluetrum/libcpu/cpu/cpuport.c +++ b/bsp/bluetrum/libcpu/cpu/cpuport.c @@ -39,6 +39,8 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, stack_addr = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stack_addr, 8); stk = (rt_uint32_t *)stack_addr; + stk--; + *stk = (rt_uint32_t)0x10003; /* Start address */ stk--; *stk = (rt_uint32_t)tentry; /* Start address */ stk -= 22; -- cgit v1.3.1