mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 10:43:30 +08:00
[bluetrum] add fmrx support
This commit is contained in:
parent
74f6a0ba7d
commit
3e65ce5d03
@ -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
|
||||
@ -197,6 +198,11 @@ CONFIG_RT_USING_LIBC=y
|
||||
# CONFIG_RT_USING_ULOG is not set
|
||||
# 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
|
||||
|
@ -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 | 暂不支持 | |
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user