summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bsp/bluetrum/ab32vg1-ab-prougen/.config17
-rw-r--r--bsp/bluetrum/ab32vg1-ab-prougen/README.md2
-rw-r--r--bsp/bluetrum/ab32vg1-ab-prougen/board/board.c26
-rw-r--r--bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c38
-rw-r--r--bsp/bluetrum/ab32vg1-ab-prougen/link.lds20
-rw-r--r--bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h6
-rw-r--r--bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/api_fmrx.h43
-rw-r--r--bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/libhal.abin0 -> 33546 bytes
-rw-r--r--bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S34
9 files changed, 134 insertions, 52 deletions
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/.config b/bsp/bluetrum/ab32vg1-ab-prougen/.config
index 9c2fe998a6..097f9df54c 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/.config
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/.config
@@ -74,7 +74,7 @@ CONFIG_RT_USING_DEVICE_OPS=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
-CONFIG_RT_VER_NUM=0x40003
+CONFIG_RT_VER_NUM=0x40004
# CONFIG_RT_USING_CPU_FFS is not set
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
@@ -160,6 +160,7 @@ CONFIG_RT_USING_PIN=y
CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set
# CONFIG_RT_USING_MODULE is not set
+CONFIG_RT_LIBC_FIXED_TIMEZONE=8
#
# Network
@@ -198,6 +199,11 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_UTEST is not set
#
+# RT-Thread Utestcases
+#
+# CONFIG_RT_USING_UTESTCASES is not set
+
+#
# RT-Thread online packages
#
@@ -309,9 +315,11 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_STEMWIN is not set
# CONFIG_PKG_USING_WAVPLAYER is not set
# CONFIG_PKG_USING_TJPGD is not set
+# CONFIG_PKG_USING_PDFGEN is not set
# CONFIG_PKG_USING_HELIX is not set
# CONFIG_PKG_USING_AZUREGUIX is not set
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
+# CONFIG_PKG_USING_NUEMWIN is not set
#
# tools packages
@@ -349,6 +357,10 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_ANV_TESTSUIT is not set
# CONFIG_PKG_USING_ANV_BENCH is not set
# CONFIG_PKG_USING_DEVMEM is not set
+# CONFIG_PKG_USING_REGEX is not set
+# CONFIG_PKG_USING_MEM_SANDBOX is not set
+# CONFIG_PKG_USING_SOLAR_TERMS is not set
+# CONFIG_PKG_USING_GAN_ZHI is not set
#
# system packages
@@ -396,6 +408,7 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_QFPLIB_M3 is not set
# CONFIG_PKG_USING_LPM is not set
# CONFIG_PKG_USING_TLSF is not set
+# CONFIG_PKG_USING_EVENT_RECORDER is not set
#
# peripheral libraries and drivers
@@ -463,6 +476,7 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_LIBNFC is not set
# CONFIG_PKG_USING_MFOC is not set
# CONFIG_PKG_USING_TMC51XX is not set
+# CONFIG_PKG_USING_TCA9534 is not set
#
# AI packages
@@ -490,6 +504,7 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
+# CONFIG_PKG_USING_MINIZIP is not set
# CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set
# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/README.md b/bsp/bluetrum/ab32vg1-ab-prougen/README.md
index 8950f880aa..5eb229a223 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/README.md
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/README.md
@@ -48,7 +48,7 @@ ab32vg1-prougen 是 中科蓝讯(Bluetrum) 推出的一款基于 RISC-V 内核�
| FLASH | 即将支持 | 对接 FAL |
| TIMER | 支持 | |
| PWM | 支持 | LPWM 的 G1 G2 G3 之间是互斥的,只能三选一 |
-| FM receive | 即将支持 | |
+| FM receive | 支持 | |
| USB Device | 暂不支持 | |
| USB Host | 暂不支持 | |
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c
index f10ea4a6c8..4fc392d008 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c
@@ -19,14 +19,13 @@ void rt_soft_isr(int vector, void *param);
void cpu_irq_comm(void);
void set_cpu_irq_comm(void (*irq_hook)(void));
void load_cache();
+void os_cache_init(void);
void sys_error_hook(uint8_t err_no);
-typedef void (*os_cache_setfunc_func)(void *load_cache_func, void *io_read);
typedef void (*spiflash_init_func)(uint8_t sf_read, uint8_t dummy);
-#define os_cache_setfunc ((os_cache_setfunc_func) 0x84024)
-
static struct rt_mutex mutex_spiflash = {0};
+static struct rt_mutex mutex_cache = {0};
extern volatile rt_uint8_t rt_interrupt_nest;
extern uint32_t __heap_start, __heap_end;
@@ -148,8 +147,9 @@ void rt_hw_us_delay(rt_uint32_t us)
RT_SECTION(".irq.cache")
void cache_init(void)
{
- os_cache_setfunc(load_cache, NULL);
+ os_cache_init();
rt_mutex_init(&mutex_spiflash, "flash_mutex", RT_IPC_FLAG_FIFO);
+ rt_mutex_init(&mutex_cache, "cache_mutex", RT_IPC_FLAG_FIFO);
}
RT_SECTION(".irq.cache")
@@ -170,6 +170,24 @@ void os_spiflash_unlock(void)
}
}
+RT_SECTION(".irq.cache")
+void os_cache_lock(void)
+{
+ // if (rt_thread_self()->stat == RT_THREAD_RUNNING) {
+ if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
+ rt_mutex_take(&mutex_cache, RT_WAITING_FOREVER);
+ }
+}
+
+RT_SECTION(".irq.cache")
+void os_cache_unlock(void)
+{
+ // if (rt_thread_self()->stat == RT_THREAD_RUNNING) {
+ if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
+ rt_mutex_release(&mutex_cache);
+ }
+}
+
RT_SECTION(".irq.err.str")
static const char stack_info[] = "thread sp=0x%x name=%s";
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c
index d250a3fc94..e2ba236512 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c
@@ -13,8 +13,9 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
-#define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100u)
#define SAI_AUDIO_FREQUENCY_48K ((uint32_t)48000u)
+#define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100u)
+#define SAI_AUDIO_FREQUENCY_38K ((uint32_t)38000u)
#define TX_FIFO_SIZE (1024)
struct sound_device
@@ -22,10 +23,11 @@ struct sound_device
struct rt_audio_device audio;
struct rt_audio_configure replay_config;
rt_sem_t semaphore;
- rt_thread_t thread;
+ rt_thread_t thread;
rt_uint8_t *tx_fifo;
rt_uint8_t *rx_fifo;
rt_uint8_t volume;
+ rt_uint8_t dma_to_aubuf;
};
static struct sound_device snd_dev = {0};
@@ -120,16 +122,15 @@ void audio_sem_pend(void)
void saia_frequency_set(uint32_t frequency)
{
+ DACDIGCON0 &= ~(0xf << 2);
if (frequency == SAI_AUDIO_FREQUENCY_48K) {
- DACDIGCON0 |= BIT(1);
- DACDIGCON0 &= ~(0xf << 2);
- DACDIGCON0 |= BIT(6);
+ DACDIGCON0 |= (0 << 2);
} else if (frequency == SAI_AUDIO_FREQUENCY_44K) {
- DACDIGCON0 &= ~BIT(1);
- DACDIGCON0 &= ~(0xf << 2);
- DACDIGCON0 |= BIT(1);
- DACDIGCON0 |= BIT(6);
+ DACDIGCON0 |= (1 << 2);
+ } else if (frequency == SAI_AUDIO_FREQUENCY_38K) {
+ DACDIGCON0 |= (2 << 2);
}
+ DACDIGCON0 |= BIT(6);
}
void saia_channels_set(uint8_t channels)
@@ -271,6 +272,10 @@ static rt_err_t sound_configure(struct rt_audio_device *audio, struct rt_audio_c
break;
}
+ case AUDIO_MIXER_EXTEND:
+ snd_dev->dma_to_aubuf = caps->udata.value;
+ break;
+
default:
result = -RT_ERROR;
break;
@@ -349,6 +354,7 @@ static rt_err_t sound_init(struct rt_audio_device *audio)
/* set default params */
saia_frequency_set(snd_dev->replay_config.samplerate);
saia_channels_set(snd_dev->replay_config.channels);
+ saia_volume_set(snd_dev->volume);
return RT_EOK;
}
@@ -368,9 +374,7 @@ static rt_err_t sound_start(struct rt_audio_device *audio, int stream)
AUBUFSIZE |= (TX_FIFO_SIZE / 8) << 16;
AUBUFSTARTADDR = DMA_ADR(snd_dev->rx_fifo);
- DACDIGCON0 = BIT(0) | BIT(10); // (0x01<<2)
- DACVOLCON = 0x7fff; // -60DB
- DACVOLCON |= BIT(20);
+ DACDIGCON0 |= BIT(0) | BIT(10); // (0x01<<2)
AUBUFCON |= BIT(1);
}
@@ -380,13 +384,11 @@ static rt_err_t sound_start(struct rt_audio_device *audio, int stream)
static rt_err_t sound_stop(struct rt_audio_device *audio, int stream)
{
- struct sound_device *snd_dev = RT_NULL;
-
RT_ASSERT(audio != RT_NULL);
- snd_dev = (struct sound_device *)audio->parent.user_data;
if (stream == AUDIO_STREAM_REPLAY)
{
+ DACDIGCON0 = 0;
AUBUFCON &= ~BIT(4);
LOG_D("close sound device");
}
@@ -463,7 +465,7 @@ static void audio_thread_entry(void *parameter)
{
while (1)
{
- if (snd_dev.audio.replay->activated == RT_TRUE) {
+ if ((snd_dev.dma_to_aubuf == RT_FALSE) && (snd_dev.audio.replay->activated == RT_TRUE)) {
rt_audio_tx_complete(&snd_dev.audio);
} else {
rt_thread_mdelay(50);
@@ -506,7 +508,7 @@ static int rt_hw_sound_init(void)
RT_NULL,
1024,
20, // must equal or lower than tshell priority
- 5
+ 1
);
if (snd_dev.thread != RT_NULL)
@@ -516,7 +518,7 @@ static int rt_hw_sound_init(void)
/* init default configuration */
{
- snd_dev.replay_config.samplerate = 48000;
+ snd_dev.replay_config.samplerate = SAI_AUDIO_FREQUENCY_48K;
snd_dev.replay_config.channels = 2;
snd_dev.replay_config.samplebits = 16;
snd_dev.volume = 55;
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/link.lds b/bsp/bluetrum/ab32vg1-ab-prougen/link.lds
index d785c3d92c..82e8906080 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/link.lds
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/link.lds
@@ -43,7 +43,7 @@ SECTIONS
. = ALIGN(4);
PROVIDE(__ctors_start__ = .);
KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
+ KEEP (*(.init_array*))
PROVIDE(__ctors_end__ = .);
. = ALIGN(4);
@@ -73,21 +73,17 @@ SECTIONS
.comm __comm_vma : {
. = ALIGN(4);
KEEP(*(.vector))
+ *(.irq.cache)
*(.irq*)
- /*applications**.o (.text .rodata)*/
- *hal_libraries*ab32vg1_hal**.o (.text .rodata)
- *(.text.unlikely)
- *(.text.startup)
- *hal_drivers**.o (.rodata)
- *audio*drv_sound.o (.rodata)
- *system_ab32vgx.o (.rodata)
- EXCLUDE_FILE(*lib_a**.o *cp-demangle.o *cp-demangle.o
- *src*mem.o *src*memheap.o *dfs**.o *components.o *drivers*sdio**.o *cmd.o *msh_file.o
- *drv_sdio.o *drv_wdt.o) *(.rodata.str1.4)
- EXCLUDE_FILE(*lib_a**.o *unwind*.o) *(.srodata)
+ *components*src**.o (.text* .rodata*)
+ *ab32vg1_hal**.o (.text* .rodata*)
+ *drv_gpio.o (.text* .rodata*)
+ *drv_usart.o (.rodata*)
+ EXCLUDE_FILE(*lib_a**.o *unwind*.o) *(.srodata*)
*(.rela*)
*(.data*)
*(.sdata*)
+ *(.com_text*)
} > comm AT > flash
.bss (NOLOAD):
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h
index 6defaad7dc..7451b8f1c0 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h
@@ -46,7 +46,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart0"
-#define RT_VER_NUM 0x40003
+#define RT_VER_NUM 0x40004
/* RT-Thread Components */
@@ -90,6 +90,7 @@
/* POSIX layer and C standard library */
#define RT_USING_LIBC
+#define RT_LIBC_FIXED_TIMEZONE 8
/* Network */
@@ -111,6 +112,9 @@
/* Utilities */
+/* RT-Thread Utestcases */
+
+
/* RT-Thread online packages */
/* IoT - internet of things */
diff --git a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/api_fmrx.h b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/api_fmrx.h
new file mode 100644
index 0000000000..2638060591
--- /dev/null
+++ b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/api_fmrx.h
@@ -0,0 +1,43 @@
+#ifndef FMRX_H__
+#define FMRX_H__
+
+/**
+ * @brief Synchronize between FMRX and DAC
+ *
+ * @param buf_size Size of audio buffer.
+ */
+void fmrx_dac_sync(uint32_t buf_size);
+
+/**
+ * @brief FMRX power on.
+ *
+ * @param val Make it zero now.
+ */
+void fmrx_power_on(uint32_t val);
+
+/**
+ * @brief FMRX power off.
+ *
+ */
+void fmrx_power_off(void);
+
+/**
+ * @brief FMRX digital start.
+ *
+ */
+void fmrx_digital_start(void);
+
+/**
+ * @brief FMRX digital stop.
+ *
+ */
+void fmrx_digital_stop(void);
+
+/**
+ * @brief FMRX dma to aubuf enable.
+ *
+ * @param enable RT_TRUE or RT_FALSE.
+ */
+void fmrx_dma_to_aubuf(uint8_t enable);
+
+#endif
diff --git a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/libhal.a b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/libhal.a
new file mode 100644
index 0000000000..97474b1370
--- /dev/null
+++ b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/libhal.a
Binary files differ
diff --git a/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S b/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S
index 3245135038..8ea645316e 100644
--- a/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S
+++ b/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S
@@ -6,26 +6,29 @@
#include "ab32vg1.h"
+.set _memcpy, 0x84044
.global _start
.section .reset, "ax"
_start:
+ la tp, _tp
+ la gp, _gp
//load comm
la a0, __comm_vma
la a1, __comm_lma
la a2, __comm_size
- call 0x84044
+ call _memcpy
//load ram1
la a0, __ram1_vma
la a1, __ram1_lma
la a2, __ram1_size
- call 0x84044
+ call _memcpy
la a0, __irq_stack_start //Stack清成0x23
li a1, 0x23
la a2, __irq_stack_size
- call memset
+ call rt_memset
la ra, __irq_stack
lui a5, 0x1
sw zero, -1920(a5)
@@ -35,7 +38,7 @@ _start:
la a0, __bss_start
li a1, 0
la a2, __bss_size
- call memset
+ call rt_memset
call cache_init
@@ -56,32 +59,33 @@ __exception:
.org 0x40
jal x0, low_prio_irq
- mret
.org 0x80
#define METHOD 1
#if METHOD == 1
addi sp, sp, -6*4
- lw a0, PICEN(zero)
+ # lw a0, PICEN(zero)
lw a1, EPC(zero)
lw a2, EPICCON(zero)
- sw a0, 3*4(sp)
+ # sw a0, 3*4(sp)
sw a1, 4*4(sp)
sw a2, 5*4(sp)
- andi a0, a0, 1
- sw a0, PICEN(zero)
+ # andi a0, a0, 1
+ # sw a0, PICEN(zero)
+ li a2, 0
+ sw a2, EPICCON(zero)
la a0, 0f
sw a0, EPC(zero)
- j 0x84020
+ j isr_cache
0:
sw a0, 0(sp)
sw a1, 4(sp)
sw a2, 8(sp)
- lw a0, 3*4(sp)
+ # lw a0, 3*4(sp)
lw a1, 4*4(sp)
lw a2, 5*4(sp)
- sw a0, PICEN(zero)
+ # sw a0, PICEN(zero)
sw a1, EPC(zero)
sw a2, EPICCON(zero)
@@ -90,9 +94,6 @@ __exception:
lw a2, 8(sp)
addi sp, sp, 6*4
mret
- .align 4
-1: .word 0, 0
- j 0x84020
#endif
.global cpu_irq_comm
@@ -102,3 +103,6 @@ cpu_irq_comm:
j cpu_irq_comm_do
ret
+
+ .global _tp
+ .set _tp, 0x84800