功能完成

This commit is contained in:
flym 2024-11-10 21:14:01 +08:00
parent 9fd47355c9
commit 50d8f1f7c1
69 changed files with 68830 additions and 74802 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"files.associations": {
"fm_api.h": "c"
}
}

Binary file not shown.

BIN
FW/KT24-1110/jl_isd.fw Normal file

Binary file not shown.

View File

@ -20,3 +20,4 @@
16. AUX PA3 AUX0L
17. AUX DET PC4
18. LED PB5
19. PA2 功放模式0-ClassD 1-ClassAB

View File

@ -17,12 +17,12 @@
#define APP_PROTOCOL_DEMO_CODE 0
#define APP_PROTOCOL_GMA_CODE 0
#define APP_PROTOCOL_AMA_CODE 0
#define APP_PROTOCOL_DMA_CODE 1
#define APP_PROTOCOL_DMA_CODE 0
#define APP_PROTOCOL_TME_CODE 0
#define APP_PROTOCOL_MMA_CODE 0
#define APP_PROTOCOL_SPEECH_EN 1 //语音助手功能,若无此功能则关掉
#define APP_PROTOCOL_READ_CFG_EN 1 //从custom.dat中读取配置信息若无此功能则关掉
#define APP_PROTOCOL_SPEECH_EN 0 //语音助手功能,若无此功能则关掉
#define APP_PROTOCOL_READ_CFG_EN 0 //从custom.dat中读取配置信息若无此功能则关掉
#define DEMO_HANDLER_ID 0x300 /*作为一个使用的例子同时也可作为客户自己添加协议的ID*/
#define GMA_HANDLER_ID 0x400 /*阿里天猫协议接口ID*/

View File

@ -60,12 +60,10 @@ STATUS_CONFIG status_config = {
.bt_disconnect = IDEX_TONE_BT_DISCONN,
.tws_connect_ok = IDEX_TONE_TWS_CONN,
.tws_disconnect = IDEX_TONE_TWS_DISCONN,
}
};
}};
#define __this (&status_config)
// *INDENT-OFF*
/************************** UART config****************************/
#if TCFG_UART0_ENABLE
@ -78,27 +76,30 @@ UART0_PLATFORM_DATA_BEGIN(uart0_data)
UART0_PLATFORM_DATA_END()
#endif // TCFG_UART0_ENABLE
/************************** SD config ****************************/
#if TCFG_SD0_ENABLE
/* int sdmmc_0_io_detect(const struct sdmmc_platform_data *data) */
/* { */
/* return 1; */
/* } */
/* void sd_set_power(u8 enable) */
/* { */
/* static u8 old_enable = 0xff; */
/* */
/* if(old_enable == enable){ */
/* return; */
/* } */
/* if(enable){ */
/* sdpg_config(1); */
/* }else{ */
/* sdpg_config(0); */
/* } */
/* old_enable = enable; */
/* } */
void sd_set_power(u8 enable)
{
static u8 old_enable = 0xff;
if (old_enable == enable)
{
return;
}
if (enable)
{
sdpg_config(1);
}
else
{
sdpg_config(0);
}
old_enable = enable;
}
SD0_PLATFORM_DATA_BEGIN(sd0_data)
.port = TCFG_SD0_PORTS, // sd0 support port 'A' and port 'B'
.data_width = TCFG_SD0_DAT_MODE,
@ -145,7 +146,7 @@ SD1_PLATFORM_DATA_BEGIN(sd1_data)
#else
.detect_func = sdmmc_cmd_detect,
.power = NULL, // cmd检测需要全程供电建议用硬件固定电源。当然可以自行写其他的SD卡电源控制函数传入0关电源。传入1开电源。
/* .power = sd_set_power, */
/* .power = sd_set_power, */`
#endif
SD1_PLATFORM_DATA_END()
#endif
@ -168,7 +169,6 @@ CHARGE_PLATFORM_DATA_BEGIN(charge_data)
CHARGE_PLATFORM_DATA_END()
#endif // TCFG_CHARGE_ENABLE
#if TCFG_IIS_ENABLE
ALINK_PARM alink_param = {
// portA: MCLK:PA2 SCLK:PA3 LRCK:PA4 CH0:PA0 CH1:PA1 CH2:PA5 CH3:PA6
@ -190,7 +190,6 @@ ALINK_PARM alink_param = {
};
#endif
/************************** DAC ****************************/
#if TCFG_AUDIO_DAC_ENABLE
struct dac_platform_data dac_data = {
@ -207,10 +206,12 @@ struct dac_platform_data dac_data = {
/************************** ADC ****************************/
#if TCFG_AUDIO_ADC_ENABLE
const struct ladc_port ladc_list[] = {
{// 0
{
// 0
.channel = TCFG_AUDIO_ADC_LINE_CHA0,
},
{// 1
{
// 1
.channel = TCFG_AUDIO_ADC_LINE_CHA1,
},
// total must < 4
@ -232,7 +233,7 @@ struct adc_platform_data adc_data = {
0:2.3v 1:2.5v 2:2.7v 3:3.0v */
.mic_ldo_vsel = 2,
/*MIC电容隔直模式使用内部mic偏置(PA2)*/
.mic_bias_inside = 1,
.mic_bias_inside = 0,
/*保持内部mic偏置输出*/
.mic_bias_keep = 0,
@ -256,7 +257,6 @@ struct adc_platform_data adc_data = {
/* .private_data = (void *) &audio_pf_d, */
/* }; */
/************************** IO KEY ****************************/
#if TCFG_IOKEY_ENABLE
const struct iokey_port iokey_list[] = {
@ -310,7 +310,8 @@ const struct adkey_platform_data adkey_data = {
.adkey_pin = TCFG_ADKEY_PORT, // AD按键对应引脚
.ad_channel = TCFG_ADKEY_AD_CHANNEL, // AD通道值
.extern_up_en = TCFG_ADKEY_EXTERN_UP_ENABLE, // 是否使用外接上拉电阻
.ad_value = { //根据电阻算出来的电压值
.ad_value = {
// 根据电阻算出来的电压值
TCFG_ADKEY_VOLTAGE0,
TCFG_ADKEY_VOLTAGE1,
TCFG_ADKEY_VOLTAGE2,
@ -322,7 +323,8 @@ const struct adkey_platform_data adkey_data = {
TCFG_ADKEY_VOLTAGE8,
TCFG_ADKEY_VOLTAGE9,
},
.key_value = { //AD按键各个按键的键值
.key_value = {
// AD按键各个按键的键值
TCFG_ADKEY_VALUE0,
TCFG_ADKEY_VALUE1,
TCFG_ADKEY_VALUE2,
@ -337,7 +339,6 @@ const struct adkey_platform_data adkey_data = {
};
#endif
/************************** IR KEY ****************************/
#if TCFG_IRKEY_ENABLE
const struct irkey_platform_data irkey_data = {
@ -346,7 +347,6 @@ const struct irkey_platform_data irkey_data = {
};
#endif
/************************** TOUCH_KEY ****************************/
#if TCFG_TOUCH_KEY_ENABLE
const struct touch_key_port touch_key_list[] = {
@ -431,7 +431,6 @@ const struct rdec_device rdeckey_list[] = {
.key_value1 = TCFG_RDEC2_KEY1_VALUE | BIT(7),
},
};
const struct rdec_platform_data rdec_key_data = {
.enable = 1, // TCFG_RDEC_KEY_ENABLE, //是否使能RDEC按键
@ -457,7 +456,6 @@ struct otg_dev_data otg_data = {
};
#endif
/************************** rtc ****************************/
#if TCFG_RTC_ENABLE
@ -478,7 +476,6 @@ LED_PLATFORM_DATA_BEGIN(pwm_led_data)
LED_PLATFORM_DATA_END()
#endif
#if TCFG_UI_LED7_ENABLE
LED7_PLATFORM_DATA_BEGIN(led7_data)
.pin_type = LED7_PIN7,
@ -515,7 +512,6 @@ const struct ui_devices_cfg ui_cfg_data = {
};
#endif /* #if TCFG_UI_LED7_ENABLE */
#if TCFG_UI_LCD_SEG3X9_ENABLE
LCD_SEG3X9_PLATFORM_DATA_BEGIN(lcd_seg3x9_data)
.vlcd = LCD_SEG3X9_VOLTAGE_3_3V,
@ -583,7 +579,6 @@ const struct hw_iic_config hw_iic_cfg[] = {
};
#endif
#if TCFG_HW_SPI1_ENABLE
const struct spi_platform_data spi1_p_data = {
.port = TCFG_HW_SPI1_PORT,
@ -645,8 +640,6 @@ NORFLASH_DEV_PLATFORM_DATA_BEGIN(norflash_norfs_rec_dev_data)
NORFLASH_DEV_PLATFORM_DATA_END()
#endif
#if TCFG_SPI_LCD_ENABLE
LCD_SPI_PLATFORM_DATA_BEGIN(lcd_spi_data)
.pin_reset = -1,
@ -670,8 +663,6 @@ const struct ui_devices_cfg ui_cfg_data = {
};
#endif
#if TCFG_GSENSOR_ENABLE
#if TCFG_DA230_EN
@ -763,14 +754,12 @@ const struct low_power_param power_param = {
.nv_timer_interval = 500, // ms,lp_timer中断间隔
};
/************************** PWR config ****************************/
struct port_wakeup port0 = {
.pullup_down_enable = ENABLE, // 配置I/O 内部上下拉是否使能
.edge = FALLING_EDGE, // 唤醒方式选择,可选:上升沿\下降沿
.attribute = BLUETOOTH_RESUME, // 保留参数
.iomap = IO_PORTA_06, //唤醒口选择
.iomap = IO_PORTB_01, // 唤醒口选择
};
const struct sub_wakeup sub_wkup = {
@ -810,15 +799,17 @@ static void key_wakeup_enable()
void debug_uart_init(const struct uart_platform_data *data)
{
#if TCFG_UART0_ENABLE
if (data) {
if (data)
{
uart_init(data);
} else {
}
else
{
uart_init(&uart0_data);
}
#endif
}
STATUS *get_led_config(void)
{
return &(__this->led);
@ -840,16 +831,20 @@ u8 get_power_on_status(void)
struct iokey_port *power_io_list = NULL;
power_io_list = iokey_data.port;
if (iokey_data.enable) {
if (gpio_read(power_io_list->key_type.one_io.port) == power_io_list->connect_way){
if (iokey_data.enable)
{
if (gpio_read(power_io_list->key_type.one_io.port) == power_io_list->connect_way)
{
return 1;
}
}
#endif
#if TCFG_ADKEY_ENABLE
if (adkey_data.enable) {
if (adc_get_value(adkey_data.ad_channel) < 10) {
if (adkey_data.enable)
{
if (adc_get_value(adkey_data.ad_channel) < 10)
{
return 1;
}
}
@ -899,13 +894,14 @@ void board_init()
charge_init(NULL, (void *)&charge_data);
#endif
if (!get_charge_online_flag()) {
if (!get_charge_online_flag())
{
check_power_on_voltage();
}
/* #if (TCFG_SD0_ENABLE || TCFG_SD1_ENABLE) */
/* sdpg_config(1); */
/* #endif */
#if (TCFG_SD0_ENABLE || TCFG_SD1_ENABLE) /**/
sdpg_config(1); /* */
#endif /**/
#if TCFG_FM_ENABLE
fm_dev_init(&fm_dev_data);
@ -926,9 +922,12 @@ void board_init()
dev_manager_init();
board_devices_init();
if(get_charge_online_flag()){
if (get_charge_online_flag())
{
power_set_mode(PWR_LDO15);
}else{
}
else
{
power_set_mode(TCFG_LOWPOWER_POWER_SEL);
}
@ -941,7 +940,8 @@ void board_init()
/* } */
#if TCFG_UART0_ENABLE
if (uart0_data.rx_pin < IO_MAX_NUM) {
if (uart0_data.rx_pin < IO_MAX_NUM)
{
gpio_set_die(uart0_data.rx_pin, 1);
}
#endif
@ -953,9 +953,6 @@ void board_init()
#if TCFG_RTC_ENABLE
alarm_init();
#endif
}
/*进软关机之前默认将IO口都设置成高阻状态需要保留原来状态的请修改该函数*/
@ -1015,12 +1012,15 @@ void sleep_exit_callback(u32 usec)
void sleep_enter_callback(u8 step)
{
/* 此函数禁止添加打印 */
if (step == 1) {
if (step == 1)
{
/* putchar('<'); */
APP_IO_DEBUG_0(A, 6);
dac_sniff_power_off();
/* dac_power_off(); */
} else {
}
else
{
key_wakeup_enable();
gpio_set_pull_up(IO_PORTA_03, 0);
gpio_set_pull_down(IO_PORTA_03, 0);
@ -1063,8 +1063,7 @@ void board_power_init(void)
.rx = IO_PORTA_02,
.tx = IO_PORTA_03,
.output_channel = CH1_UT1_TX,
.input_channel = INPUT_CH0
};
.input_channel = INPUT_CH0};
uart_update_init(&update_cfg);
}
#endif
@ -1076,13 +1075,16 @@ static void board_power_wakeup_init(void)
key_wakeup_disable();
#if TCFG_POWER_ON_NEED_KEY
extern u8 power_reset_src;
if ((power_reset_src & BIT(0)) || (power_reset_src & BIT(1))) {
if ((power_reset_src & BIT(0)) || (power_reset_src & BIT(1)))
{
#if TCFG_CHARGE_ENABLE
log_info("is ldo5v wakeup:%d\n", is_ldo5v_wakeup());
if (is_ldo5v_wakeup()) {
if (is_ldo5v_wakeup())
{
return;
}
if (get_ldo5v_online_hw()) {
if (get_ldo5v_online_hw())
{
return;
}
/*LDO5V,检测上升沿用于检测ldoin插入*/

View File

@ -30,7 +30,7 @@
#define TCFG_APP_FM_EN 1
#define TCFG_APP_PC_EN 1
#define TCFG_APP_RTC_EN 0
#define TCFG_APP_RECORD_EN 1
#define TCFG_APP_RECORD_EN 0
#define TCFG_APP_SPDIF_EN 0
//*********************************************************************************//
// PCM_DEBUG调试配置 //
@ -41,9 +41,9 @@
//*********************************************************************************//
// UART配置 //
//*********************************************************************************//
#define TCFG_UART0_ENABLE ENABLE_THIS_MOUDLE //串口打印模块使能
#define TCFG_UART0_ENABLE DISABLE_THIS_MOUDLE //串口打印模块使能
#define TCFG_UART0_RX_PORT NO_CONFIG_PORT //串口接收脚配置用于打印可以选择NO_CONFIG_PORT
#define TCFG_UART0_TX_PORT IO_PORTA_05 //串口发送脚配置
#define TCFG_UART0_TX_PORT IO_PORT_DP //串口发送脚配置
#define TCFG_UART0_BAUDRATE 1000000 //串口波特率配置
//*********************************************************************************//
@ -69,7 +69,7 @@
//*********************************************************************************//
// 硬件SPI 配置 //
//*********************************************************************************//
#define TCFG_HW_SPI1_ENABLE ENABLE_THIS_MOUDLE
#define TCFG_HW_SPI1_ENABLE DISABLE_THIS_MOUDLE
//A组IO: DI: PB2 DO: PB1 CLK: PB0
//B组IO: DI: PC3 DO: PC5 CLK: PC4
#define TCFG_HW_SPI1_PORT 'A'
@ -77,7 +77,7 @@
#define TCFG_HW_SPI1_MODE SPI_MODE_BIDIR_1BIT
#define TCFG_HW_SPI1_ROLE SPI_ROLE_MASTER
#define TCFG_HW_SPI2_ENABLE ENABLE_THIS_MOUDLE
#define TCFG_HW_SPI2_ENABLE DISABLE_THIS_MOUDLE
//A组IO: DI: PB8 DO: PB10 CLK: PB9
//B组IO: DI: PA13 DO: DM CLK: DP
#define TCFG_HW_SPI2_PORT 'A'
@ -97,11 +97,11 @@
// 充电参数配置 //
//*********************************************************************************//
//是否支持芯片内置充电
#define TCFG_CHARGE_ENABLE ENABLE_THIS_MOUDLE
#define TCFG_CHARGE_ENABLE DISABLE_THIS_MOUDLE
//是否支持开机充电
#define TCFG_CHARGE_POWERON_ENABLE ENABLE
#define TCFG_CHARGE_POWERON_ENABLE DISABLE
//是否支持拔出充电自动开机功能
#define TCFG_CHARGE_OFF_POWERON_NE ENABLE
#define TCFG_CHARGE_OFF_POWERON_NE DISABLE
#define TCFG_CHARGE_FULL_V CHARGE_FULL_V_4202
@ -122,7 +122,7 @@
//B组IO: CMD:PB6 CLK:PB7 DAT0:PB5 //E组IO: CMD:PA4 CLK:PC5 DAT0:DM
//C组IO: CMD:PA4 CLK:PA2 DAT0:PA3 //F组IO: CMD:PB6 CLK:PB7 DAT0:PB4
#define TCFG_SD0_ENABLE ENABLE_THIS_MOUDLE
#define TCFG_SD0_PORTS 'D'
#define TCFG_SD0_PORTS 'F'
#define TCFG_SD0_DAT_MODE 1//AC696x不支持4线模式
#define TCFG_SD0_DET_MODE SD_CLK_DECT
#define TCFG_SD0_DET_IO IO_PORT_DM//当SD_DET_MODE为2时有效
@ -133,7 +133,7 @@
#if TCFG_SD0_SD1_USE_THE_SAME_HW
#define TCFG_SD1_ENABLE 1
#else
#define TCFG_SD1_ENABLE 0
#define TCFG_SD1_ENABLE DISABLE_THIS_MOUDLE
#endif
#define TCFG_SD1_PORTS 'F'
#define TCFG_SD1_DAT_MODE 1//AC696x不支持4线模式
@ -238,7 +238,6 @@
#define TCFG_IOKEY_ENABLE DISABLE_THIS_MOUDLE //是否使能IO按键
#define TCFG_IOKEY_POWER_CONNECT_WAY ONE_PORT_TO_LOW //按键一端接低电平一端接IO
#define TCFG_IOKEY_POWER_ONE_PORT IO_PORTB_01 //IO按键端口
#define TCFG_IOKEY_PREV_CONNECT_WAY ONE_PORT_TO_LOW //按键一端接低电平一端接IO
@ -254,8 +253,8 @@
#define TCFG_ADKEY_LED_IO_REUSE DISABLE_THIS_MOUDLE //ADKEY 和 LED IO复用led只能设置蓝灯显示
#define TCFG_ADKEY_IR_IO_REUSE DISABLE_THIS_MOUDLE //ADKEY 和 红外IO复用
#define TCFG_ADKEY_LED_SPI_IO_REUSE DISABLE_THIS_MOUDLE //ADKEY 和 LED SPI IO复用
#define TCFG_ADKEY_PORT IO_PORTA_06 //AD按键端口(需要注意选择的IO口是否支持AD功能)
#define TCFG_ADKEY_AD_CHANNEL AD_CH_PA6
#define TCFG_ADKEY_PORT IO_PORTB_01 //AD按键端口(需要注意选择的IO口是否支持AD功能)
#define TCFG_ADKEY_AD_CHANNEL AD_CH_PB1
#define TCFG_ADKEY_EXTERN_UP_ENABLE ENABLE_THIS_MOUDLE //是否使用外部上拉
#if TCFG_ADKEY_EXTERN_UP_ENABLE
@ -266,15 +265,15 @@
//必须从小到大填电阻没有则同VDDIO,填0x3ffL
#define TCFG_ADKEY_AD0 (0) //0R
#define TCFG_ADKEY_AD1 (0x3ffL * 30 / (30 + R_UP)) //3k
#define TCFG_ADKEY_AD2 (0x3ffL * 62 / (62 + R_UP)) //6.2k
#define TCFG_ADKEY_AD3 (0x3ffL * 91 / (91 + R_UP)) //9.1k
#define TCFG_ADKEY_AD4 (0x3ffL * 150 / (150 + R_UP)) //15k
#define TCFG_ADKEY_AD5 (0x3ffL * 240 / (240 + R_UP)) //24k
#define TCFG_ADKEY_AD6 (0x3ffL * 330 / (330 + R_UP)) //33k
#define TCFG_ADKEY_AD7 (0x3ffL * 510 / (510 + R_UP)) //51k
#define TCFG_ADKEY_AD8 (0x3ffL * 1000 / (1000 + R_UP)) //100k
#define TCFG_ADKEY_AD9 (0x3ffL * 2200 / (2200 + R_UP)) //220k
#define TCFG_ADKEY_AD1 (0x3ffL * 100 / (100 + R_UP)) //3k
#define TCFG_ADKEY_AD2 (0x3ffL * 150 / (150 + R_UP)) //6.2k
#define TCFG_ADKEY_AD3 (0x3ffL * 510 / (510 + R_UP)) //9.1k
#define TCFG_ADKEY_AD4 (0x3ffL) //15k
#define TCFG_ADKEY_AD5 (0x3ffL) //24k
#define TCFG_ADKEY_AD6 (0x3ffL) //33k
#define TCFG_ADKEY_AD7 (0x3ffL) //51k
#define TCFG_ADKEY_AD8 (0x3ffL) //100k
#define TCFG_ADKEY_AD9 (0x3ffL) //220k
#define TCFG_ADKEY_VDDIO (0x3ffL)
#define TCFG_ADKEY_VOLTAGE0 ((TCFG_ADKEY_AD0 + TCFG_ADKEY_AD1) / 2)
@ -396,7 +395,7 @@ DAC硬件上的连接方式,可选的配置:
DAC_OUTPUT_LR
DAC_OUTPUT_MONO_LR_DIFF
*/
#define TCFG_AUDIO_DAC_CONNECT_MODE DAC_OUTPUT_LR
#define TCFG_AUDIO_DAC_CONNECT_MODE DAC_OUTPUT_MONO_L
@ -411,7 +410,7 @@ DAC硬件上的连接方式,可选的配置:
#define AUDIO_OUTPUT_WAY AUDIO_OUTPUT_WAY_DAC
#define LINEIN_INPUT_WAY LINEIN_INPUT_WAY_ANALOG
#define AUDIO_OUTPUT_AUTOMUTE 0//ENABLE
#define AUDIO_OUTPUT_AUTOMUTE 1//ENABLE
/*
@ -445,9 +444,9 @@ DAC硬件上的连接方式,可选的配置:
#define TCFG_CALL_USE_DIGITAL_VOLUME 0
// 使能改宏提示音音量使用music音量
#define APP_AUDIO_STATE_WTONE_BY_MUSIC (1)
#define APP_AUDIO_STATE_WTONE_BY_MUSIC (0)
// 0:提示音不使用默认音量; 1:默认提示音音量值
#define TONE_MODE_DEFAULE_VOLUME (0)
#define TONE_MODE_DEFAULE_VOLUME (18)
/*
*MIC模块
@ -456,7 +455,7 @@ DAC硬件上的连接方式,可选的配置:
*/
#define TCFG_SUPPORT_MIC_CAPLESS ENABLE_THIS_MOUDLE
//省电容MIC使能
#define TCFG_MIC_CAPLESS_ENABLE DISABLE_THIS_MOUDLE
#define TCFG_MIC_CAPLESS_ENABLE ENABLE_THIS_MOUDLE
//AudioEffects代码链接管理
#define AUDIO_EFFECTS_DRC_AT_RAM 0
#define AUDIO_EFFECTS_REVERB_AT_RAM 0
@ -505,9 +504,9 @@ DAC硬件上的连接方式,可选的配置:
//*********************************************************************************//
// UI 配置 //
//*********************************************************************************//
#define TCFG_UI_ENABLE ENABLE_THIS_MOUDLE //UI总开关
#define CONFIG_UI_STYLE STYLE_JL_LED7
#define TCFG_UI_LED7_ENABLE ENABLE_THIS_MOUDLE //UI使用LED7显示
#define TCFG_UI_ENABLE DISABLE_THIS_MOUDLE //UI总开关
//#define CONFIG_UI_STYLE STYLE_JL_LED7
#define TCFG_UI_LED7_ENABLE DISABLE_THIS_MOUDLE //UI使用LED7显示
// #define TCFG_UI_LCD_SEG3X9_ENABLE ENABLE_THIS_MOUDLE //UI使用LCD段码屏显示
// #define TCFG_LCD_ST7735S_ENABLE ENABLE_THIS_MOUDLE
// #define TCFG_LCD_ST7789VW_ENABLE ENABLE_THIS_MOUDLE
@ -557,7 +556,7 @@ DAC硬件上的连接方式,可选的配置:
//*********************************************************************************//
// EQ配置 //
//*********************************************************************************//
#define TCFG_EQ_ENABLE 1 //支持EQ功能,EQ总使能
#define TCFG_EQ_ENABLE 0 //支持EQ功能,EQ总使能
#if TCFG_EQ_ENABLE
#define TCFG_BT_MUSIC_EQ_ENABLE 1 //支持蓝牙音乐EQ
#define TCFG_PHONE_EQ_ENABLE 1 //支持通话近端EQ
@ -727,8 +726,8 @@ DAC硬件上的连接方式,可选的配置:
//*********************************************************************************//
#define TCFG_AUTO_SHUT_DOWN_TIME 0 //没有蓝牙连接自动关机时间
#define TCFG_SYS_LVD_EN 1 //电量检测使能
#define TCFG_POWER_ON_NEED_KEY 0 //是否需要按按键开机配置
#define TWFG_APP_POWERON_IGNORE_DEV 4000//上电忽略挂载设备0时不忽略非0则n毫秒忽略
#define TCFG_POWER_ON_NEED_KEY 1 //是否需要按按键开机配置
#define TWFG_APP_POWERON_IGNORE_DEV 0//上电忽略挂载设备0时不忽略非0则n毫秒忽略
#define TCFG_AUDIO_DEC_OUT_TASK 0 // 解码使用单独任务做输出
@ -764,8 +763,8 @@ DAC硬件上的连接方式,可选的配置:
#endif
#define BT_INBAND_RINGTONE 0 //是否播放手机自带来电铃声
#define BT_PHONE_NUMBER 1 //是否播放来电报号
#define BT_SYNC_PHONE_RING 1 //是否TWS同步播放来电铃声
#define BT_PHONE_NUMBER 0 //是否播放来电报号
#define BT_SYNC_PHONE_RING 0 //是否TWS同步播放来电铃声
#define BT_SUPPORT_DISPLAY_BAT 1 //是否使能电量检测
#define BT_SUPPORT_MUSIC_VOL_SYNC 1 //是否使能音量同步
@ -820,9 +819,9 @@ DAC硬件上的连接方式,可选的配置:
#if (RECORDER_MIX_EN)
#define TCFG_LINEIN_LR_CH AUDIO_LIN0L_CH//AUDIO_LIN0_LR
#else
#define TCFG_LINEIN_LR_CH AUDIO_LIN0_LR
#define TCFG_LINEIN_LR_CH AUDIO_LIN0L_CH
#endif/*RECORDER_MIX_EN*/
#define TCFG_LINEIN_CHECK_PORT IO_PORTB_01 // linein检测IO
#define TCFG_LINEIN_CHECK_PORT IO_PORTC_04 // linein检测IO
#define TCFG_LINEIN_PORT_UP_ENABLE 1 // 检测IO上拉使能
#define TCFG_LINEIN_PORT_DOWN_ENABLE 0 // 检测IO下拉使能
#define TCFG_LINEIN_AD_CHANNEL NO_CONFIG_PORT // 检测IO是否使用AD检测
@ -833,7 +832,7 @@ DAC硬件上的连接方式,可选的配置:
#if (RECORDER_MIX_EN)
#define TCFG_LINEIN_INPUT_WAY LINEIN_INPUT_WAY_ADC//LINEIN_INPUT_WAY_ANALOG
#else
#define TCFG_LINEIN_INPUT_WAY LINEIN_INPUT_WAY_ANALOG
#define TCFG_LINEIN_INPUT_WAY LINEIN_INPUT_WAY_ADC
#endif/*RECORDER_MIX_EN*/
#endif
#define TCFG_LINEIN_MULTIPLEX_WITH_FM DISABLE // linein 脚与 FM 脚复用
@ -845,8 +844,8 @@ DAC硬件上的连接方式,可选的配置:
//*********************************************************************************//
#define TCFG_DEC_G729_ENABLE ENABLE
#define TCFG_DEC_MP3_ENABLE ENABLE
#define TCFG_DEC_WMA_ENABLE ENABLE
#define TCFG_DEC_WAV_ENABLE ENABLE
#define TCFG_DEC_WMA_ENABLE 1
#define TCFG_DEC_WAV_ENABLE 0
#define TCFG_DEC_FLAC_ENABLE DISABLE
#define TCFG_DEC_APE_ENABLE DISABLE
#define TCFG_DEC_M4A_ENABLE DISABLE
@ -877,7 +876,7 @@ DAC硬件上的连接方式,可选的配置:
#define TCFG_FMIN_LADC_IDX 1 // linein使用的ladc通道对应ladc_list
#define TCFG_FMIN_LR_CH AUDIO_LIN1_LR
#define TCFG_FM_INPUT_WAY LINEIN_INPUT_WAY_ANALOG
#define TCFG_FM_INPUT_WAY LINEIN_INPUT_WAY_ADC
#if (TCFG_FM_INSIDE_ENABLE && TCFG_FM_ENABLE)
#if ((RECORDER_MIX_EN && RECORDER_MIX_BT_PHONE_EN) || (TCFG_MIC_EFFECT_ENABLE) || (TCFG_USER_TWS_ENABLE))
@ -974,9 +973,9 @@ DAC硬件上的连接方式,可选的配置:
//*********************************************************************************//
#define TCFG_ENC_CVSD_ENABLE ENABLE
#define TCFG_ENC_MSBC_ENABLE ENABLE
#define TCFG_ENC_MP3_ENABLE ENABLE
#define TCFG_ENC_ADPCM_ENABLE ENABLE
#define TCFG_ENC_SBC_ENABLE ENABLE
#define TCFG_ENC_MP3_ENABLE 0
#define TCFG_ENC_ADPCM_ENABLE 0
#define TCFG_ENC_SBC_ENABLE 0
#define TCFG_ENC_OPUS_ENABLE DISABLE
#define TCFG_ENC_SPEEX_ENABLE DISABLE

View File

@ -19,22 +19,22 @@ const u16 bt_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
#endif
},
[1] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_MUSIC_NEXT, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_NULL, KEY_NULL
},
[2] = {
KEY_MUSIC_PP, KEY_CALL_HANG_UP, KEY_NULL, KEY_NULL, KEY_CALL_LAST_NO, KEY_NULL
KEY_MUSIC_PREV, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_CALL_LAST_NO, KEY_NULL
},
[3] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_MUSIC_PP, KEY_CALL_HANG_UP, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[4] = {
KEY_MUSIC_PREV, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_ENC_START, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[5] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[6] = {
KEY_MUSIC_NEXT, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_REVERB_OPEN, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[7] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
@ -55,28 +55,28 @@ const u16 bt_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
const u16 fm_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
//单击 //长按 //hold //抬起 //双击 //三击
[0] = {
KEY_CHANGE_MODE, KEY_POWEROFF, KEY_POWEROFF_HOLD, KEY_NULL, KEY_FM_SCAN_ALL_DOWN, KEY_NULL
KEY_CHANGE_MODE, KEY_POWEROFF, KEY_POWEROFF_HOLD, KEY_NULL, KEY_NULL, KEY_NULL
},
[1] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_FM_NEXT_STATION, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_NULL, KEY_NULL
},
[2] = {
KEY_MUSIC_PP, KEY_NULL, KEY_NULL, KEY_NULL, KEY_FM_SCAN_ALL_DOWN, KEY_NULL
KEY_FM_PREV_STATION, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_NULL, KEY_NULL
},
[3] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_MUSIC_PP, KEY_FM_SCAN_ALL_DOWN, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[4] = {
KEY_FM_PREV_STATION, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_ENC_START, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[5] = {
KEY_FM_PREV_FREQ, KEY_FM_SCAN_UP, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[6] = {
KEY_FM_NEXT_STATION, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_REVERB_OPEN, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[7] = {
KEY_FM_NEXT_FREQ, KEY_FM_SCAN_DOWN, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[8] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
@ -97,22 +97,22 @@ const u16 linein_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
KEY_CHANGE_MODE, KEY_POWEROFF, KEY_POWEROFF_HOLD, KEY_NULL, KEY_NULL, KEY_NULL
},
[1] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_VOL_UP, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_NULL, KEY_NULL
},
[2] = {
KEY_MUSIC_PP, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_NULL, KEY_NULL
},
[3] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_MUSIC_PP, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[4] = {
KEY_NULL, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_ENC_START, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[5] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[6] = {
KEY_NULL, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_REVERB_OPEN, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[7] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
@ -133,28 +133,28 @@ const u16 linein_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
const u16 music_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
//单击 //长按 //hold //抬起 //双击 //三击
[0] = {
KEY_CHANGE_MODE, KEY_POWEROFF, KEY_POWEROFF_HOLD, KEY_NULL, KEY_MUSIC_PLAYE_REC_FOLDER_SWITCH, KEY_NULL
KEY_CHANGE_MODE, KEY_POWEROFF, KEY_POWEROFF_HOLD, KEY_NULL, KEY_NULL, KEY_NULL
},
[1] = {
KEY_MUSIC_CHANGE_REPEAT, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_MUSIC_NEXT, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_NULL, KEY_NULL
},
[2] = {
KEY_MUSIC_PP, KEY_MUSIC_CHANGE_DEV, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[3] = {
KEY_MUSIC_PLAYE_NEXT_FOLDER, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[4] = {
KEY_MUSIC_PREV, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_NULL, KEY_NULL
},
[3] = {
KEY_MUSIC_PP, KEY_MUSIC_CHANGE_DEV, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[4] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[5] = {
KEY_MUSIC_PLAYE_PREV_FOLDER, KEY_NULL, KEY_MUSIC_FR, KEY_NULL, KEY_NULL, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[6] = {
KEY_MUSIC_NEXT, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_REVERB_OPEN, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[7] = {
KEY_MUSIC_PLAYE_REC_FOLDER_SWITCH, KEY_NULL, KEY_MUSIC_FF, KEY_NULL, KEY_NULL, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[8] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
@ -178,19 +178,19 @@ const u16 pc_key_ad_table[KEY_AD_NUM_MAX][KEY_EVENT_MAX] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[2] = {
KEY_MUSIC_PP, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[3] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[4] = {
KEY_MUSIC_PREV, KEY_VOL_DOWN, KEY_VOL_DOWN, KEY_NULL, KEY_NULL, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[5] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[6] = {
KEY_MUSIC_NEXT, KEY_VOL_UP, KEY_VOL_UP, KEY_NULL, KEY_REVERB_OPEN, KEY_NULL
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL
},
[7] = {
KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL, KEY_NULL

View File

@ -96,6 +96,24 @@ static void app_init()
do_platform_initcall();
board_init();
{
//mute
gpio_set_pull_down(IO_PORTA_04,0);
gpio_set_pull_up(IO_PORTA_04,0);
gpio_set_direction(IO_PORTA_04,0);
gpio_set_output_value(IO_PORTA_04,1);
//led
gpio_set_pull_down(IO_PORTB_05,0);
gpio_set_pull_up(IO_PORTB_05,0);
gpio_set_direction(IO_PORTB_05,0);
gpio_set_output_value(IO_PORTB_05,0);
//pa mode
gpio_set_pull_down(IO_PORTA_02,0);
gpio_set_pull_up(IO_PORTA_02,0);
gpio_set_direction(IO_PORTA_02,0);
gpio_set_output_value(IO_PORTA_02,0);
}
do_initcall();
@ -164,6 +182,7 @@ static void app_init()
/* clock_add_set(CHARGE_BOX_CLK); */
chgbox_init_app();
#endif
gpio_set_output_value(IO_PORTB_05,1);
}
static void app_task_handler(void *p)

View File

@ -14,7 +14,7 @@
#define CONFIG_DEBUG_LIB(x) (x & LIB_DEBUG)
#define CONFIG_DEBUG_ENABLE
//#define CONFIG_DEBUG_ENABLE
#ifndef CONFIG_DEBUG_ENABLE
//#define CONFIG_DEBUG_LITE_ENABLE //轻量级打印开关, 默认关闭
@ -159,6 +159,8 @@
#include "usb_common_def.h"
#define CONFIG_TWS_COMMON_ADDR_SELECT 0xFF
#if TCFG_USER_TWS_ENABLE

View File

@ -2,6 +2,7 @@
#define _FM_SEVER__H_
u8 fm_get_play_statue(void);
void fm_volume_pp(void);//播放暂停
void fm_scan_down();//半自动收台
void fm_scan_up();//半自动收台

View File

@ -2,8 +2,8 @@
1:
.gpio_ram
.LED_code
.usr_timer_code

View File

@ -39,8 +39,6 @@
**************************************************************/
#include "system/includes.h"
#include "media/includes.h"
@ -65,7 +63,6 @@
#include "math.h"
#include "spp_user.h"
#include "app_chargestore.h"
#include "app_charge.h"
#include "app_main.h"
@ -94,7 +91,6 @@
#include "multi_demo/le_multi_common.h"
#include "app_protocol_api.h"
#define LOG_TAG_CONST BT
#define LOG_TAG "[BT]"
#define LOG_ERROR_ENABLE
@ -104,7 +100,6 @@
#define LOG_CLI_ENABLE
#include "debug.h"
#if TCFG_APP_BT_EN
struct app_bt_opr app_bt_hdl = {
@ -120,7 +115,67 @@ struct app_bt_opr app_bt_hdl = {
BT_USER_PRIV_VAR bt_user_priv_var;
//-----------------------------------------------------------------------------
static u16 tm_led;
static int t_cnt;
static u8 led_flag;
static u8 playing = 0;
static void led_cb(void *priv)
{
if (get_bt_connect_status() < BT_STATUS_CONNECTING)
{
if (led_flag == 1)
{
led_flag = 0;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
else
{
if (playing == 1)
{
t_cnt++;
if (t_cnt > 1)
{
t_cnt = 0;
if (led_flag == 1)
{
led_flag = 0;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
}
static void start_led(void)
{
if (tm_led)
{
sys_timer_del(tm_led);
}
t_cnt = 0;
led_flag = 1;
playing = 0;
tm_led = sys_timer_add(NULL, led_cb, 250);
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式变量初始化
@ -134,7 +189,6 @@ void bt_var_init()
memset((u8 *)&bt_user_priv_var, 0, sizeof(BT_USER_PRIV_VAR));
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式协议栈回调函数
@param
@ -225,7 +279,6 @@ static const target_uuid_t jl_search_uuid_table[] = {
};
static void ble_report_data_deal(att_data_report_t *report_data, target_uuid_t *search_uuid)
{
log_info("conn_handle:%04x,report_data:%02x,%02x,%d,len(%d)", report_data->conn_handle, report_data->packet_type,
@ -238,7 +291,8 @@ static void ble_report_data_deal(att_data_report_t *report_data, target_uuid_t *
/* return; */
/* } */
switch (report_data->packet_type) {
switch (report_data->packet_type)
{
case GATT_EVENT_NOTIFICATION: // notify
break;
@ -280,10 +334,12 @@ static void client_test_write(void)
u16 tmp_handle;
count++;
for (i = 0; i < SUPPORT_MAX_CLIENT; i++) {
for (i = 0; i < SUPPORT_MAX_CLIENT; i++)
{
tmp_handle = mul_dev_get_conn_handle(i, MULTI_ROLE_CLIENT);
if (tmp_handle) {
if (tmp_handle)
{
ret = ble_client_api->opt_comm_send_ext(tmp_handle, ble_client_write_handle, &count, 16, ATT_OP_WRITE_WITHOUT_RESPOND);
log_info("test_write:%04x,%d", tmp_handle, ret);
}
@ -293,19 +349,22 @@ static void client_test_write(void)
/* log_info("test_write:%x", ret); */
}
static void client_event_callback(le_client_event_e event, u8 *packet, int size)
{
switch (event) {
case CLI_EVENT_MATCH_DEV: {
switch (event)
{
case CLI_EVENT_MATCH_DEV:
{
client_match_cfg_t *match_dev = packet;
log_info("match_name:%s\n", match_dev->compare_data);
}
break;
case CLI_EVENT_MATCH_UUID: {
case CLI_EVENT_MATCH_UUID:
{
opt_handle_t *opt_hdl = packet;
if (opt_hdl->search_uuid == &jl_search_uuid_table[0]) {
if (opt_hdl->search_uuid == &jl_search_uuid_table[0])
{
ble_client_write_handle = opt_hdl->value_handle;
log_info("match_uuid22\n");
}
@ -314,7 +373,8 @@ static void client_event_callback(le_client_event_e event, u8 *packet, int size)
case CLI_EVENT_SEARCH_PROFILE_COMPLETE:
log_info("CLI_EVENT_SEARCH_PROFILE_COMPLETE\n");
if ((!ble_client_timer) && ble_client_write_handle) {
if ((!ble_client_timer) && ble_client_write_handle)
{
log_info("test timer_add\n");
ble_client_timer = sys_timer_add(0, client_test_write, 500);
}
@ -324,7 +384,8 @@ static void client_event_callback(le_client_event_e event, u8 *packet, int size)
break;
case CLI_EVENT_DISCONNECT:
if (ble_client_timer) {
if (ble_client_timer)
{
sys_timeout_del(ble_client_timer);
}
ble_client_timer = 0;
@ -336,7 +397,6 @@ static void client_event_callback(le_client_event_e event, u8 *packet, int size)
}
}
static const client_conn_cfg_t client_conn_config = {
.match_dev_cfg[0] = &match_dev01,
.match_dev_cfg[1] = NULL,
@ -359,8 +419,6 @@ static void ble_client_config_init(void)
#endif
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式协议栈功能配置
@param
@ -420,7 +478,6 @@ void bt_function_select_init()
// authentication_requirements: 0:not protect 1 :protect
__set_simple_pair_param(3, 0, 2);
#if (USER_SUPPORT_PROFILE_PBAP == 1)
////设置蓝牙设备类型
__change_hci_class_type(BD_CLASS_CAR_AUDIO);
@ -431,7 +488,6 @@ void bt_function_select_init()
lmp_set_sniff_disable();
#endif
/*
TX RX
AI800x PA13 PA12
@ -473,7 +529,6 @@ void bt_function_select_init()
#endif
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式协议栈对应状态处理函数
@param bt:
@ -486,11 +541,13 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
log_debug("-----------------------bt_connction_status_event_handler %d", bt->event);
if (bt_status_event_filter(bt) == false) {
if (bt_status_event_filter(bt) == false)
{
return false;
}
switch (bt->event) {
switch (bt->event)
{
case BT_STATUS_EXIT_OK:
log_info("BT_STATUS_EXIT_OK\n");
break;
@ -557,10 +614,12 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
break;
case BT_STATUS_A2DP_MEDIA_START:
log_info(" BT_STATUS_A2DP_MEDIA_START\n");
playing = 1;
bt_status_a2dp_media_start(bt);
break;
case BT_STATUS_A2DP_MEDIA_STOP:
log_info(" BT_STATUS_A2DP_MEDIA_STOP");
playing = 0;
bt_status_a2dp_media_stop(bt);
break;
case BT_STATUS_SCO_STATUS_CHANGE:
@ -607,12 +666,6 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
return 0;
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式协议栈事件
@param bt:
@ -625,19 +678,21 @@ static int bt_hci_event_handler(struct bt_event *bt)
// 对应原来的蓝牙连接上断开处理函数 ,bt->value=reason
log_debug("------------------------bt_hci_event_handler reason %x %x", bt->event, bt->value);
#if TCFG_VIRTUAL_FAST_CONNECT_FOR_EMITTER
extern u8 bt_fast_conn_hci_event_filter(struct bt_event * bt);
if (bt_fast_conn_hci_event_filter(bt) == 0) {
if (bt_fast_conn_hci_event_filter(bt) == 0)
{
return 0;
}
#endif
if (bt_hci_event_filter(bt) == 0) {
if (bt_hci_event_filter(bt) == 0)
{
return 0;
}
switch (bt->event) {
switch (bt->event)
{
case HCI_EVENT_INQUIRY_COMPLETE:
log_info(" HCI_EVENT_INQUIRY_COMPLETE \n");
bt_hci_event_inquiry(bt);
@ -682,7 +737,8 @@ static int bt_hci_event_handler(struct bt_event *bt)
case BTSTACK_EVENT_HCI_CONNECTIONS_DELETE:
case HCI_EVENT_CONNECTION_COMPLETE:
log_info(" HCI_EVENT_CONNECTION_COMPLETE \n");
switch (bt->value) {
switch (bt->value)
{
case ERROR_CODE_SUCCESS:
log_info("ERROR_CODE_SUCCESS \n");
bt_hci_event_connection(bt);
@ -722,8 +778,6 @@ static int bt_hci_event_handler(struct bt_event *bt)
return 0;
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙后台事件过滤处理
@param event:
@ -735,12 +789,15 @@ int bt_background_event_handler_filter(struct sys_event *event)
{
u8 ret = 0;
#if TCFG_BLUETOOTH_BACK_MODE
if ((u32)event->arg == SYS_BT_EVENT_TYPE_CON_STATUS) {
if ((u32)event->arg == SYS_BT_EVENT_TYPE_CON_STATUS)
{
log_info("bt con event: %d \n", event->u.bt.event);
switch (event->u.bt.event) {
switch (event->u.bt.event)
{
// 需要切换蓝牙的命令
case BT_STATUS_A2DP_MEDIA_START:
if (__this->sbc_packet_step != 0) {
if (__this->sbc_packet_step != 0)
{
/* log_info("sbc_packet_step : %d \n", __this->sbc_packet_step); */
break;
}
@ -748,11 +805,13 @@ int bt_background_event_handler_filter(struct sys_event *event)
case BT_STATUS_FIRST_DISCONNECT:
case BT_STATUS_SECOND_DISCONNECT:
// 关机导致的断开不可以回去蓝牙,否则后台关机会有问题
if (app_var.goto_poweroff_flag) {
if (app_var.goto_poweroff_flag)
{
break;
}
if (__this->close_bt_hw_in_background) {
if (__this->close_bt_hw_in_background)
{
// 需要后台关闭蓝牙硬件的就不返回蓝牙了
printf("close_bt_hw_in_background not go back\n");
break;
@ -765,10 +824,12 @@ int bt_background_event_handler_filter(struct sys_event *event)
#endif
#else
// 判断断开的是sink设备默认切换蓝牙
if (event->u.bt.value) {
if (event->u.bt.value)
{
ret = 1;
}
if (ret == 0) {
if (ret == 0)
{
bt_status_disconnect_background(&event->u.bt);
}
#endif
@ -826,9 +887,12 @@ int bt_background_event_handler_filter(struct sys_event *event)
bt_connction_status_event_handler(&event->u.bt);
break;
}
} else if ((u32)event->arg == SYS_BT_EVENT_TYPE_HCI_STATUS) {
}
else if ((u32)event->arg == SYS_BT_EVENT_TYPE_HCI_STATUS)
{
/* log_info("bt hci event: %d \n", event->u.bt.event); */
switch (event->u.bt.event) {
switch (event->u.bt.event)
{
case HCI_EVENT_IO_CAPABILITY_REQUEST:
clock_add_set(BT_CONN_CLK);
#if BACKGROUND_GOBACK
@ -845,9 +909,11 @@ int bt_background_event_handler_filter(struct sys_event *event)
}
}
#if TCFG_USER_TWS_ENABLE
else if (((u32)event->arg == SYS_BT_EVENT_FROM_TWS)) {
else if (((u32)event->arg == SYS_BT_EVENT_FROM_TWS))
{
/* log_info("bt tws event: %d \n", event->u.bt.event); */
switch (event->u.bt.event) {
switch (event->u.bt.event)
{
/* case TWS_EVENT_CONNECTED: */
/* ret = 1; */
/* break; */
@ -860,8 +926,10 @@ int bt_background_event_handler_filter(struct sys_event *event)
}
}
#endif
else if ((u32)event->arg == SYS_EVENT_FROM_CTRLER) {
switch (event->u.bt.event) {
else if ((u32)event->arg == SYS_EVENT_FROM_CTRLER)
{
switch (event->u.bt.event)
{
case BTCTRLER_EVENT_RESUME_REQ:
/*log_info("------- BTCTRLER_EVENT_RESUME_REQ \n"); */
ret = 2;
@ -882,12 +950,17 @@ int bt_background_event_handler_filter(struct sys_event *event)
int bt_background_event_handler(struct sys_event *event)
{
int ret = bt_background_event_handler_filter(event);
if (ret) {
if (false == app_check_curr_task(APP_BT_TASK)) {
if (ret)
{
if (false == app_check_curr_task(APP_BT_TASK))
{
__this->cmd_flag = 1;
if (ret == 2) {
if (ret == 2)
{
__this->call_flag = 1;
} else {
}
else
{
__this->call_flag = 0;
}
app_task_switch_to(APP_BT_TASK);
@ -897,7 +970,6 @@ int bt_background_event_handler(struct sys_event *event)
return 0;
}
// #if (USER_SUPPORT_PROFILE_HID==1)
////重写bt_get_hid_name
// const char * bt_get_hid_name()
@ -918,7 +990,8 @@ int bt_key_event_handler(struct sys_event *event)
int ret = true;
struct key_event *key = &event->u.key;
if (bt_key_event_filter_before() == false) {
if (bt_key_event_filter_before() == false)
{
return false;
}
@ -927,11 +1000,13 @@ int bt_key_event_handler(struct sys_event *event)
log_debug("bt key_event:%d %d %d %d\n", key_event, key->value, key->event, key->init);
if (bt_key_event_filter_after(key_event) == true) {
if (bt_key_event_filter_after(key_event) == true)
{
return true;
}
switch (key_event) {
switch (key_event)
{
case KEY_MUSIC_PP:
log_info(" KEY_MUSIC_PP \n");
@ -985,7 +1060,8 @@ int bt_key_event_handler(struct sys_event *event)
log_info(" KEY_NULL \n");
ret = false;
#if TCFG_USER_TWS_ENABLE
if ((u32)event->arg == KEY_EVENT_FROM_TWS) {
if ((u32)event->arg == KEY_EVENT_FROM_TWS)
{
break;
}
#endif
@ -1001,7 +1077,8 @@ int bt_key_event_handler(struct sys_event *event)
#endif
break;
case KEY_HID_TAKE_PICTURE:
if (__this->hid_mode) {
if (__this->hid_mode)
{
printf("KEY_HID_TAKE_PICTURE\n");
user_send_cmd_prepare(USER_CTRL_HID_BOTH, 0, NULL);
}
@ -1012,11 +1089,15 @@ int bt_key_event_handler(struct sys_event *event)
#if (TCFG_DEC2TWS_ENABLE)
ret = false;
#else
if (tws_api_get_tws_state() & TWS_STA_SIBLING_CONNECTED) {
if (tws_api_get_role() == TWS_ROLE_MASTER) {
if (tws_api_get_tws_state() & TWS_STA_SIBLING_CONNECTED)
{
if (tws_api_get_role() == TWS_ROLE_MASTER)
{
bt_tws_api_push_cmd(SYNC_CMD_MODE_CHANGE, 400);
}
} else {
}
else
{
ret = false;
break;
}
@ -1036,7 +1117,6 @@ int bt_key_event_handler(struct sys_event *event)
return ret;
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式协议栈状态事件、hci事件、对箱事件
@param event:
@ -1047,20 +1127,28 @@ int bt_key_event_handler(struct sys_event *event)
int bt_sys_event_office(struct sys_event *event)
{
u8 ret = false;
if ((u32)event->arg == SYS_BT_EVENT_TYPE_CON_STATUS) {
if ((u32)event->arg == SYS_BT_EVENT_TYPE_CON_STATUS)
{
bt_connction_status_event_handler(&event->u.bt);
} else if ((u32)event->arg == SYS_BT_EVENT_TYPE_HCI_STATUS) {
}
else if ((u32)event->arg == SYS_BT_EVENT_TYPE_HCI_STATUS)
{
bt_hci_event_handler(&event->u.bt);
} else if ((u32)event->arg == SYS_BT_EVENT_FORM_SELF) {
}
else if ((u32)event->arg == SYS_BT_EVENT_FORM_SELF)
{
bt_reverb_status_change(&event->u.bt);
}
#if TCFG_USER_TWS_ENABLE
else if (((u32)event->arg == SYS_BT_EVENT_FROM_TWS)) {
else if (((u32)event->arg == SYS_BT_EVENT_FROM_TWS))
{
ret = bt_tws_connction_status_event_handler(&event->u.bt);
}
#endif
else if (((u32)event->arg == SYS_BT_EVENT_FROM_KEY)) {
switch (event->u.key.event) {
else if (((u32)event->arg == SYS_BT_EVENT_FROM_KEY))
{
switch (event->u.key.event)
{
case KEY_CHANGE_MODE:
app_task_switch_next();
break;
@ -1069,7 +1157,6 @@ int bt_sys_event_office(struct sys_event *event)
return ret;
}
/*----------------------------------------------------------------------------*/
/**@brief 蓝牙模式事件消息处理
@param event:
@ -1080,7 +1167,8 @@ int bt_sys_event_office(struct sys_event *event)
static int bt_sys_event_handler(struct sys_event *event)
{
int ret = false;
switch (event->type) {
switch (event->type)
{
case SYS_KEY_EVENT:
ret = bt_key_event_handler(event);
break;
@ -1089,7 +1177,8 @@ static int bt_sys_event_handler(struct sys_event *event)
break;
case SYS_DEVICE_EVENT:
#if APP_ONLINE_DEBUG
if ((u32)event->arg == DEVICE_EVENT_ONLINE_DATA) {
if ((u32)event->arg == DEVICE_EVENT_ONLINE_DATA)
{
// putchar('%');
extern void app_online_event_handle(int evt_value);
app_online_event_handle(event->u.dev.value);
@ -1115,12 +1204,14 @@ static void bt_tone_play_end_callback(void *priv, int flag)
{
u32 index = (u32)priv;
if (APP_BT_TASK != app_get_curr_task()) {
if (APP_BT_TASK != app_get_curr_task())
{
log_error("tone callback task out \n");
return;
}
switch (index) {
switch (index)
{
case IDEX_TONE_BT_MODE:
/// 提示音播放结束, 启动播放器播放
bt_task_start();
@ -1143,6 +1234,14 @@ void app_bt_task()
int msg[32];
ui_update_status(STATUS_EXIT_LOWPOWER);
// PA mode set to class D
gpio_set_pull_down(IO_PORTA_02, 0);
gpio_set_pull_up(IO_PORTA_02, 0);
gpio_set_direction(IO_PORTA_02, 0);
gpio_set_output_value(IO_PORTA_02, 0);
bt_task_init(); // 初始化变量、时钟、显示(未进行协议栈初始化)
#if TCFG_TONE2TWS_ENABLE
@ -1151,33 +1250,45 @@ void app_bt_task()
#endif
extern u8 get_tws_background_connected_flag();
if (!__this->cmd_flag && (!get_tws_background_connected_flag())) { //蓝牙后台拉回蓝牙模式不播放提示音
if (!__this->cmd_flag && (!get_tws_background_connected_flag()))
{ // 蓝牙后台拉回蓝牙模式不播放提示音
tone_play_with_callback_by_name(tone_table[IDEX_TONE_BT_MODE], 1, bt_tone_play_end_callback, (void *)IDEX_TONE_BT_MODE);
// 协议栈初始化在提示音结束进行
} else {
}
else
{
// 后台返回的情况没有播放提示音需要在这里进行协议栈的resume
bt_task_start();
}
#if TCFG_DEC2TWS_ENABLE
extern void set_tws_background_connected_flag(u8 flag);
if (get_tws_background_connected_flag()) {
if (get_tws_background_connected_flag())
{
int state = tws_api_get_tws_state();
if (state & TWS_STA_SIBLING_CONNECTED) {
if (tws_api_get_role() == TWS_ROLE_MASTER) {
if (state & TWS_STA_SIBLING_CONNECTED)
{
if (tws_api_get_role() == TWS_ROLE_MASTER)
{
app_task_switch_back();
} else {
}
else
{
set_tws_background_connected_flag(0);
}
}
}
#endif
start_led();
while (1) {
while (1)
{
app_task_get_msg(msg, ARRAY_SIZE(msg), 1);
switch (msg[0]) {
switch (msg[0])
{
case APP_MSG_SYS_EVENT:
if (bt_sys_event_handler((struct sys_event *)(msg + 1)) == false) {
if (bt_sys_event_handler((struct sys_event *)(msg + 1)) == false)
{
app_default_event_deal((struct sys_event *)(&msg[1]));
}
break;
@ -1185,32 +1296,40 @@ void app_bt_task()
break;
}
#if TCFG_BLUETOOTH_BACK_MODE
if (!__this->init_ok && !app_var.goto_poweroff_flag) {
if (!__this->init_ok && !app_var.goto_poweroff_flag)
{
// 蓝牙后台方案必须要等待协议栈初始化完成
continue;
}
#else
if (__this->init_start && (!__this->init_ok)) { //协议栈已经初始化 但没有初始化完成
if (__this->init_start && (!__this->init_ok))
{ // 协议栈已经初始化 但没有初始化完成
// 需要等待初始化完成才可以走退出流程
continue;
}
#endif
if (app_task_exitting()) {
if (__this->init_start) {
if (app_task_exitting())
{
sys_timer_del(tm_led);
gpio_set_output_value(IO_PORTB_05, 1);
if (__this->init_start)
{
bt_task_close();
__this->wait_exit = 1;
} else { //蓝牙协议栈没有初始化,可以直接退出
}
else
{ // 蓝牙协议栈没有初始化,可以直接退出
bt_task_close();
return;
}
}
if (__this->wait_exit) { //开始退出
if (!__this->exiting) { ///等待蓝牙退出处理完成
if (__this->wait_exit)
{ // 开始退出
if (!__this->exiting)
{ /// 等待蓝牙退出处理完成
__this->wait_exit = 0;
return;
}
@ -1239,7 +1358,6 @@ int bt_background_event_handler_filter(struct sys_event *event)
return 0;
}
u8 get_call_status()
{
return BT_CALL_HANGUP;

View File

@ -40,8 +40,6 @@
**************************************************************/
#if TCFG_APP_FM_EN
static u8 fm_idle_flag = 1;
@ -53,6 +51,54 @@ u8 *get_vm_spi_code_run_addr()
return vm_spi_code_run_addr;
}
//-----------------------------------------------------------------------------
static u16 tm_led;
static int t_cnt;
static u8 led_flag;
static void led_cb(void *priv)
{
if (fm_get_play_statue() == 0)
{
t_cnt++;
if (t_cnt > 1)
{
t_cnt = 0;
if (led_flag == 1)
{
led_flag = 0;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
static void start_led(void)
{
if (tm_led)
{
sys_timer_del(tm_led);
}
t_cnt = 0;
led_flag = 1;
tm_led = sys_timer_add(NULL, led_cb, 250);
}
//--------------------------------------------------------------------------------
//*----------------------------------------------------------------------------*/
/**@brief fm按键消息入口
@param
@ -73,12 +119,14 @@ static int fm_key_event_opr(struct sys_event *event)
#if (TCFG_SPI_LCD_ENABLE)
extern int key_is_ui_takeover();
if (key_is_ui_takeover()) {
if (key_is_ui_takeover())
{
return false;
}
#endif
switch (key_event) {
switch (key_event)
{
case KEY_TEST_DEMO_0:
log_info("KEY_TEST_DEMO_0 = %d \n", key_value);
app_task_put_key_msg(KEY_TEST_DEMO_1, 5678); // test demo
@ -138,8 +186,6 @@ static int fm_key_event_opr(struct sys_event *event)
return ret;
}
//*----------------------------------------------------------------------------*/
/**@brief fm 模式活跃状态 所有消息入口
@param
@ -151,16 +197,21 @@ static int fm_key_event_opr(struct sys_event *event)
static int fm_event_handler(struct sys_event *event)
{
int err = 0;
switch (event->type) {
switch (event->type)
{
case SYS_KEY_EVENT:
return fm_key_event_opr(event);
break;
case SYS_DEVICE_EVENT:
if ((u32)event->arg == DEVICE_EVENT_FROM_FM) {
if (event->u.dev.event == DEVICE_EVENT_IN) {
if ((u32)event->arg == DEVICE_EVENT_FROM_FM)
{
if (event->u.dev.event == DEVICE_EVENT_IN)
{
log_info("fm online \n");
} else if (event->u.dev.event == DEVICE_EVENT_OUT) {
}
else if (event->u.dev.event == DEVICE_EVENT_OUT)
{
log_info("fm offline \n");
app_task_switch_next();
}
@ -191,14 +242,16 @@ static void fm_app_init(void)
int code_size = __movable_region2_start - __movable_region_start;
printf("code_size:%d\n", code_size);
mem_stats();
if (code_size && fm_code_run_addr == NULL) {
if (code_size && fm_code_run_addr == NULL)
{
#if TCFG_CODE_RUN_OVERLAY_FM_MODE
fm_code_run_addr = __fm_overlay_movable_saddr;
#else
fm_code_run_addr = phy_malloc(code_size);
#endif
}
if (fm_code_run_addr) {
if (fm_code_run_addr)
{
printf("fm_code_run_addr:0x%x", fm_code_run_addr);
code_movable_load(__movable_region_start, code_size, fm_code_run_addr, __app_movable_slot_start, __app_movable_slot2_start, &start_of_region_fm);
mem_stats();
@ -208,10 +261,12 @@ static void fm_app_init(void)
#if TCFG_VM_SPI_CODE_AT_RAM_DYANMIC
int code_size1 = __movable_region4_start - __movable_region3_start;
printf("code_size1:%d\n", code_size1);
if (code_size1 && vm_spi_code_run_addr == NULL) {
if (code_size1 && vm_spi_code_run_addr == NULL)
{
vm_spi_code_run_addr = phy_malloc(code_size1);
}
if (vm_spi_code_run_addr) {
if (vm_spi_code_run_addr)
{
printf("vm_spi_code_run_addr:0x%x", vm_spi_code_run_addr);
code_movable_load(__movable_region3_start, code_size1, vm_spi_code_run_addr, __app_movable_slot3_start, __app_movable_slot4_start, &start_of_region_spi);
}
@ -224,7 +279,6 @@ static void fm_app_init(void)
fm_api_init(); // 设置频率信息
}
static void fm_app_start(void)
{
fm_manage_start(); // 收音出声
@ -238,7 +292,8 @@ static void fm_app_uninit(void)
tone_play_stop_by_path(tone_table[IDEX_TONE_FM]);
fm_idle_flag = 1;
#if TCFG_CODE_RUN_RAM_FM_MODE
if (fm_code_run_addr) {
if (fm_code_run_addr)
{
mem_stats();
code_movable_unload(__movable_region_start, __app_movable_slot_start, __app_movable_slot2_start, &start_of_region_fm);
#if (!TCFG_CODE_RUN_OVERLAY_FM_MODE)
@ -250,7 +305,8 @@ static void fm_app_uninit(void)
#endif
#if TCFG_VM_SPI_CODE_AT_RAM_DYANMIC
if (vm_spi_code_run_addr) {
if (vm_spi_code_run_addr)
{
code_movable_unload(__movable_region3_start, __app_movable_slot3_start, __app_movable_slot4_start, &start_of_region_spi);
phy_free(vm_spi_code_run_addr);
vm_spi_code_run_addr = NULL;
@ -258,17 +314,18 @@ static void fm_app_uninit(void)
#endif
}
static void fm_tone_play_end_callback(void *priv, int flag)
{
u32 index = (u32)priv;
if (APP_FM_TASK != app_get_curr_task()) {
if (APP_FM_TASK != app_get_curr_task())
{
log_error("tone callback task out \n");
return;
}
switch (index) {
switch (index)
{
case IDEX_TONE_FM:
/// 提示音播放结束, 启动播放器播放
fm_app_start();
@ -290,9 +347,11 @@ int fm_close_bt()
{
int flag;
int msg[32];
// fm和蓝牙共用模拟后台时需要进入的时候关闭蓝牙
flag = bt_background_close_bt_hardward(1);
if (flag != 0) {
if (flag != 0)
{
// 搞个消息获取驱动sys timer的执行
app_task_get_msg(msg, ARRAY_SIZE(msg), 1);
}
@ -306,14 +365,21 @@ void app_fm_task()
if (fm_close_bt() != 0) {
return;
}*/
// PA mode set to class AB
gpio_set_pull_down(IO_PORTA_02, 0);
gpio_set_pull_up(IO_PORTA_02, 0);
gpio_set_direction(IO_PORTA_02, 0);
gpio_set_output_value(IO_PORTA_02, 1);
fm_app_init();
#if TCFG_DEC2TWS_ENABLE
extern void set_tws_background_connected_flag(u8 flag);
extern u8 get_tws_background_connected_flag();
if (get_tws_background_connected_flag()) { //不播放提示音
if (get_tws_background_connected_flag())
{ // 不播放提示音
fm_app_start();
set_tws_background_connected_flag(0);
} else
}
else
#endif
{
tone_play_with_callback_by_name(tone_table[IDEX_TONE_FM], 1, fm_tone_play_end_callback, (void *)IDEX_TONE_FM);
@ -323,12 +389,17 @@ void app_fm_task()
// fm_app_start();
// }
while (1) {
start_led();
while (1)
{
app_task_get_msg(msg, ARRAY_SIZE(msg), 1);
switch (msg[0]) {
switch (msg[0])
{
case APP_MSG_SYS_EVENT:
if (fm_event_handler((struct sys_event *)(&msg[1])) == false) {
if (fm_event_handler((struct sys_event *)(&msg[1])) == false)
{
app_default_event_deal((struct sys_event *)(&msg[1])); // 由common统一处理
}
break;
@ -336,7 +407,11 @@ void app_fm_task()
break;
}
if (app_task_exitting()) {
if (app_task_exitting())
{
sys_timer_del(tm_led);
gpio_set_output_value(IO_PORTB_05, 1);
fm_app_uninit();
return;
}
@ -354,13 +429,8 @@ REGISTER_LP_TARGET(fm_lp_target) = {
#else
void app_fm_task()
{
}
#endif

View File

@ -418,6 +418,11 @@ void fm_scan_all()
sys_timeout_add(NULL, __fm_scan_all, 20);
}
u8 fm_get_play_statue(void)
{
return __this->fm_dev_mute;
}
void fm_volume_pp(void)
{
log_info("KEY_MUSIC_PP\n");

View File

@ -67,7 +67,53 @@
static u8 linein_last_onoff = (u8) - 1;
static u8 linein_bt_back_flag = 0;
static u8 linein_idle_flag = 1;
//-----------------------------------------------------------------------------
static u16 tm_led;
static int t_cnt;
static u8 led_flag;
static void led_cb(void *priv)
{
if (linein_get_status() == 1)
{
t_cnt++;
if (t_cnt > 1)
{
t_cnt = 0;
if (led_flag == 1)
{
led_flag = 0;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
static void start_led(void)
{
if (tm_led)
{
sys_timer_del(tm_led);
}
t_cnt = 0;
led_flag = 1;
tm_led = sys_timer_add(NULL, led_cb, 250);
}
//--------------------------------------------------------------------------------
///*----------------------------------------------------------------------------*/
/**@brief 当前出于非linein 模式时候linein的在common消息处理
@param
@ -296,6 +342,14 @@ void app_linein_task()
int err = 0;
int msg[32];
// PA mode set to class D
gpio_set_pull_down(IO_PORTA_02, 0);
gpio_set_pull_up(IO_PORTA_02, 0);
gpio_set_direction(IO_PORTA_02, 0);
gpio_set_output_value(IO_PORTA_02,0);
#if TCFG_APP_BT_EN
linein_bt_back_flag = get_bt_back_flag();//从蓝牙后台返回标志
set_bt_back_flag(0);
@ -323,6 +377,7 @@ void app_linein_task()
// ///提示音播放失败直接推送KEY_MUSIC_PLAYER_START启动播放
// app_task_put_key_msg(KEY_LINEIN_START, 0);
// }
start_led();
while (1) {
app_task_get_msg(msg, ARRAY_SIZE(msg), 1);
@ -338,6 +393,8 @@ void app_linein_task()
}
if (app_task_exitting()) {
sys_timer_del(tm_led);
gpio_set_output_value(IO_PORTB_05, 1);
linein_task_close();
return;
}

View File

@ -277,6 +277,8 @@ void linein_stop(void)
*/
/*----------------------------------------------------------------------------*/
int linein_volume_pp(void)
{
if (__this->onoff) {

View File

@ -48,13 +48,15 @@
static u8 music_idle_flag = 1;
/// 模式参数结构体
struct __music_task_parm {
struct __music_task_parm
{
u8 type;
int val;
};
/// music模式控制结构体
struct __music {
struct __music
{
struct __music_task_parm task_parm;
u16 file_err_counter; // 错误文件统计
u8 file_play_direct; // 0:下一曲, 1上一曲
@ -69,20 +71,21 @@ struct __music music_hdl;
static struct __breakpoint *breakpoint = NULL;
static void music_player_play_start(void);
/// 设备提示音使能
#define MUSIC_DEVICE_TONE_EN 0
#define MUSIC_DEVICE_TONE_EN 1
#if (MUSIC_DEVICE_TONE_EN)
struct __dev_tone {
struct __dev_tone
{
char *logo;
char *phy_logo;
char *tone_path;
u16 index;
};
enum {
enum
{
/// 0x1000起始为了不要跟提示音的IDEX_TONE_重叠了
DEVICE_INDEX_UDISK = 0x1000,
DEVICE_INDEX_UDISK_REC,
@ -92,29 +95,80 @@ enum {
DEVICE_INDEX_SD1_REC,
};
const struct __dev_tone device_tone[] = {
{"udisk0", "udisk0", TONE_RES_ROOT_PATH"tone/udisk.*", DEVICE_INDEX_UDISK} ,
{"udisk0_rec", "udisk0", TONE_RES_ROOT_PATH"tone/udisk.*", DEVICE_INDEX_UDISK_REC} ,
{"sd0", "sd0", TONE_RES_ROOT_PATH"tone/sd.*", DEVICE_INDEX_SD0} ,
{"sd0_rec", "sd0", TONE_RES_ROOT_PATH"tone/sd.*", DEVICE_INDEX_SD0_REC} ,
{"sd1", "sd1", TONE_RES_ROOT_PATH"tone/sd.*", DEVICE_INDEX_SD1} ,
{"sd1_rec", "sd1", TONE_RES_ROOT_PATH"tone/sd.*", DEVICE_INDEX_SD1_REC} ,
{"udisk0", "udisk0", TONE_RES_ROOT_PATH "tone/usb.*", DEVICE_INDEX_UDISK},
{"udisk0_rec", "udisk0", TONE_RES_ROOT_PATH "tone/usb.*", DEVICE_INDEX_UDISK_REC},
{"sd0", "sd0", TONE_RES_ROOT_PATH "tone/tf.*", DEVICE_INDEX_SD0},
{"sd0_rec", "sd0", TONE_RES_ROOT_PATH "tone/tf.*", DEVICE_INDEX_SD0_REC},
{"sd1", "sd1", TONE_RES_ROOT_PATH "tone/tf.*", DEVICE_INDEX_SD1},
{"sd1_rec", "sd1", TONE_RES_ROOT_PATH "tone/tf.*", DEVICE_INDEX_SD1_REC},
};
//-----------------------------------------------------------------------------
static u16 tm_led;
static int t_cnt;
static u8 led_flag;
static void led_cb(void *priv)
{
if (music_player_get_play_status() == FILE_DEC_STATUS_PLAY)
{
t_cnt++;
if (t_cnt > 1)
{
t_cnt = 0;
if (led_flag == 1)
{
led_flag = 0;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
}
else
{
led_flag = 1;
gpio_set_output_value(IO_PORTB_05, led_flag);
}
}
static void start_led(void)
{
if (tm_led)
{
sys_timer_del(tm_led);
}
t_cnt = 0;
led_flag = 1;
tm_led = sys_timer_add(NULL, led_cb, 250);
}
//--------------------------------------------------------------------------------
static void music_tone_play_end_callback(void *priv, int flag);
int music_device_tone_play(char *logo)
{
if (logo == NULL) {
if (logo == NULL)
{
return false;
}
printf("__this->device_tone_dev = %s, logo =%s\n", __this->device_tone_dev, logo);
char *phy_logo = dev_manager_get_phy_logo(dev_manager_find_spec(logo, 0));
if (phy_logo && (strcmp(__this->device_tone_dev, phy_logo) == 0)) {
if (phy_logo && (strcmp(__this->device_tone_dev, phy_logo) == 0))
{
log_i("[%s, %d]the same phy dev, no need device tone!!\n", logo, __LINE__);
return false;
}
for (int i = 0; i < ARRAY_SIZE(device_tone); i++) {
if (strcmp(device_tone[i].logo, logo) == 0) {
for (int i = 0; i < ARRAY_SIZE(device_tone); i++)
{
if (strcmp(device_tone[i].logo, logo) == 0)
{
log_i("[%s, %d]device_tone play \n", logo, __LINE__);
memset(__this->device_tone_dev, 0, sizeof(__this->device_tone_dev));
memcpy(__this->device_tone_dev, device_tone[i].phy_logo, strlen(device_tone[i].phy_logo));
@ -127,8 +181,6 @@ int music_device_tone_play(char *logo)
}
#endif
#if TCFG_LFN_EN
static u8 music_file_name[128] = {0}; // 长文件名
u16 music_file_name_len = 0;
@ -139,7 +191,8 @@ u16 music_file_name_len = 0;
const char *music_file_get_cur_name(int *len, int *is_unicode)
{
if (music_file_name[0] == '\\' && music_file_name[1] == 'U') {
if (music_file_name[0] == '\\' && music_file_name[1] == 'U')
{
*is_unicode = 1;
*len = music_file_name_len - 2;
return (const char *)(music_file_name + 2);
@ -149,26 +202,28 @@ const char *music_file_get_cur_name(int *len, int *is_unicode)
return (const char *)music_file_name;
}
static void music_set_dev_sync_mode(char *logo, u8 mode)
{
if (logo) {
if (logo)
{
struct imount *mount_hdl = NULL;
u8 async_mode = mode;
if ((!memcmp(logo, "udisk0", strlen("udisk0")))
|| (!memcmp(logo, "udisk0_rec", strlen("udisk0_rec")))) {
if ((!memcmp(logo, "udisk0", strlen("udisk0"))) || (!memcmp(logo, "udisk0_rec", strlen("udisk0_rec"))))
{
struct file_dec_hdl *dec = get_file_dec_hdl();
if (dec) {
if (dec)
{
mount_hdl = dev_manager_get_mount_hdl(dev_manager_find_spec(logo, 0));
if (mount_hdl) {
if (dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_APE
|| dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_FLAC
|| dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_DTS
|| dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_WAV) {
if (mount_hdl)
{
if (dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_APE || dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_FLAC || dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_DTS || dec->file_dec.decoder.dec_ops->coding_type == AUDIO_CODING_WAV)
{
/// 指定解码格式开启该功能
dev_ioctl(mount_hdl->dev.fd, IOCTL_SET_ASYNC_MODE, (u32)async_mode);
} else {
}
else
{
/// 不指定的解码格式不开启
async_mode = 0;
dev_ioctl(mount_hdl->dev.fd, IOCTL_SET_ASYNC_MODE, (u32)async_mode);
@ -176,10 +231,13 @@ static void music_set_dev_sync_mode(char *logo, u8 mode)
printf("udisk, set usb ASYNC = %d\n", async_mode);
}
}
} else {
}
else
{
// 不是udisk, 如果udisk在线 将udisk设置成非AYSNC_MODE
mount_hdl = dev_manager_get_mount_hdl(dev_manager_find_spec("udisk0", 0));
if (mount_hdl) {
if (mount_hdl)
{
async_mode = 0;
printf("not udisk, set usb ASYNC = 0\n");
dev_ioctl(mount_hdl->dev.fd, IOCTL_SET_ASYNC_MODE, (u32)async_mode);
@ -188,7 +246,6 @@ static void music_set_dev_sync_mode(char *logo, u8 mode)
}
}
//*----------------------------------------------------------------------------*/
/**@brief music 解码成功回调
@param priv: parm:
@ -215,19 +272,21 @@ static void music_player_play_success(void *priv, int parm)
log_i("file indir = %d\n", music_player_get_fileindir_number());
music_file_name_len = fget_name(music_player_get_file_hdl(), music_file_name, sizeof(music_file_name));
int unicode = 0;
if ((music_file_name[0] == '\\') && (music_file_name[1] == 'U')) {
if ((music_file_name[0] == '\\') && (music_file_name[1] == 'U'))
{
unicode = 1;
music_file_name_len -= 2;
log_i("cur file = %s, len = %d, unicode = %d\n", music_file_name + 2, music_file_name_len, unicode);
} else {
}
else
{
log_i("cur file = %s, len = %d, unicode = %d\n", music_file_name, music_file_name_len, unicode);
}
log_i("\n");
/// save breakpoint, 只保存文件信息
if (music_player_get_playing_breakpoint(breakpoint, 0) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 0) == true)
{
breakpoint_vm_write(breakpoint, logo);
}
@ -238,7 +297,6 @@ static void music_player_play_success(void *priv, int parm)
/// smartbox info update
SMARTBOX_UPDATE(MUSIC_FUNCTION_MASK,
BIT(MUSIC_INFO_ATTR_STATUS) | BIT(MUSIC_INFO_ATTR_FILE_NAME) | BIT(MUSIC_INFO_ATTR_FILE_PLAY_MODE));
}
//*----------------------------------------------------------------------------*/
/**@brief music 解码结束回调处理
@ -283,35 +341,44 @@ static int music_player_scandisk_break(void)
char *logo = NULL;
char *evt_logo = NULL;
app_task_get_msg(msg, ARRAY_SIZE(msg), 0);
switch (msg[0]) {
switch (msg[0])
{
case APP_MSG_SYS_EVENT:
event = (struct sys_event *)(&msg[1]);
switch (event->type) {
switch (event->type)
{
case SYS_DEVICE_EVENT:
switch ((u32)event->arg) {
switch ((u32)event->arg)
{
case DRIVER_EVENT_FROM_SD0:
case DRIVER_EVENT_FROM_SD1:
case DRIVER_EVENT_FROM_SD2:
evt_logo = (char *)event->u.dev.value;
case DEVICE_EVENT_FROM_OTG:
if ((u32)event->arg == DEVICE_EVENT_FROM_OTG) {
if ((u32)event->arg == DEVICE_EVENT_FROM_OTG)
{
evt_logo = (char *)"udisk0";
}
/// 设备上下线底层推出的设备逻辑盘符是跟跟音乐设备一致的(音乐/录音设备, 详细看接口注释)
int str_len = 0;
logo = music_player_get_phy_dev(&str_len);
/// 响应设备插拔打断
if (event->u.dev.event == DEVICE_EVENT_OUT) {
if (event->u.dev.event == DEVICE_EVENT_OUT)
{
log_i("__func__ = %s logo=%s evt_logo=%s %d\n", __FUNCTION__, logo, evt_logo, str_len);
if (logo && (0 == memcmp(logo, evt_logo, str_len))) {
if (logo && (0 == memcmp(logo, evt_logo, str_len)))
{
/// 相同的设备才响应
__this->scandisk_break = 1;
}
} else {
}
else
{
/// 响应新设备上线
__this->scandisk_break = 1;
}
if (__this->scandisk_break == 0) {
if (__this->scandisk_break == 0)
{
log_i("__func__ = %s DEVICE_EVENT_OUT TODO\n", __FUNCTION__);
dev_status_event_filter(event);
log_i("__func__ = %s DEVICE_EVENT_OUT OK\n", __FUNCTION__);
@ -320,12 +387,14 @@ static int music_player_scandisk_break(void)
}
break;
case SYS_BT_EVENT:
if (bt_background_event_handler_filter(event)) {
if (bt_background_event_handler_filter(event))
{
__this->scandisk_break = 1;
}
break;
case SYS_KEY_EVENT:
switch (event->u.key.event) {
switch (event->u.key.event)
{
case KEY_CHANGE_MODE:
/// 响应切换模式事件
__this->scandisk_break = 1;
@ -333,7 +402,8 @@ static int music_player_scandisk_break(void)
// 其他按键case 在这里增加
}
/// 因为TWS转发sys_event_notify需要用原始的按键序号 未经过按键表处理, 所以这里要特殊处理
if (__this->scandisk_break) {
if (__this->scandisk_break)
{
app_task_put_key_msg(event->u.key.event, (int)event->u.key.value);
printf("key break scan!!");
return 1;
@ -342,12 +412,15 @@ static int music_player_scandisk_break(void)
}
break;
}
if (__this->scandisk_break) {
if (__this->scandisk_break)
{
/// 查询到需要打断的事件, 返回1 并且重新推送一次该事件,跑主循环处理流程
sys_event_notify(event);
printf("scandisk_break!!!!!!\n");
return 1;
} else {
}
else
{
return 0;
}
}
@ -363,11 +436,13 @@ static void scan_enter(struct __dev *dev)
{
#if SD_BAUD_RATE_CHANGE_WHEN_SCAN
struct imount *mount_hdl = dev_manager_get_mount_hdl(dev);
if (mount_hdl) {
if ((!memcmp(dev_manager_get_logo(dev), "sd0", strlen("sd0")))
|| (!memcmp(dev_manager_get_logo(dev), "sd1", strlen("sd1")))) {
if (mount_hdl)
{
if ((!memcmp(dev_manager_get_logo(dev), "sd0", strlen("sd0"))) || (!memcmp(dev_manager_get_logo(dev), "sd1", strlen("sd1"))))
{
dev_ioctl(mount_hdl->dev.fd, IOCTL_GET_SPEED, (u32)&__this->old_speed); // 获取sd速度
if (SD_BAUD_RATE_CHANGE_WHEN_SCAN > __this->old_speed) { //设定速度大于获取的才加速
if (SD_BAUD_RATE_CHANGE_WHEN_SCAN > __this->old_speed)
{ // 设定速度大于获取的才加速
dev_ioctl(mount_hdl->dev.fd, IOCTL_SET_SPEED, SD_BAUD_RATE_CHANGE_WHEN_SCAN);
}
}
@ -380,10 +455,12 @@ static void scan_exit(struct __dev *dev)
{
#ifdef SD_BAUD_RATE_CHANGE_WHEN_SCAN
struct imount *mount_hdl = dev_manager_get_mount_hdl(dev);
if (mount_hdl) {
if ((!memcmp(dev_manager_get_logo(dev), "sd0", strlen("sd0")))
|| (!memcmp(dev_manager_get_logo(dev), "sd1", strlen("sd1")))) {
if (SD_BAUD_RATE_CHANGE_WHEN_SCAN > __this->old_speed) {
if (mount_hdl)
{
if ((!memcmp(dev_manager_get_logo(dev), "sd0", strlen("sd0"))) || (!memcmp(dev_manager_get_logo(dev), "sd1", strlen("sd1"))))
{
if (SD_BAUD_RATE_CHANGE_WHEN_SCAN > __this->old_speed)
{
dev_ioctl(mount_hdl->dev.fd, IOCTL_SET_SPEED, __this->old_speed); // 恢复原速
}
}
@ -410,12 +487,14 @@ static void music_tone_play_end_callback(void *priv, int flag)
u32 index = (u32)priv;
char *logo = NULL;
if (APP_MUSIC_TASK != app_get_curr_task()) {
if (APP_MUSIC_TASK != app_get_curr_task())
{
log_error("tone callback task out \n");
return;
}
switch (index) {
switch (index)
{
case IDEX_TONE_MUSIC:
/// 提示音播放结束, 启动播放器播放
music_player_play_start();
@ -427,8 +506,10 @@ static void music_tone_play_end_callback(void *priv, int flag)
case DEVICE_INDEX_SD0_REC:
case DEVICE_INDEX_SD1:
case DEVICE_INDEX_SD1_REC:
for (int i = 0; i < ARRAY_SIZE(device_tone); i++) {
if (index == device_tone[i].index) {
for (int i = 0; i < ARRAY_SIZE(device_tone); i++)
{
if (index == device_tone[i].index)
{
logo = device_tone[i].logo;
break;
}
@ -441,7 +522,6 @@ static void music_tone_play_end_callback(void *priv, int flag)
}
}
//*----------------------------------------------------------------------------*/
/**@brief music 模式解码错误处理
@param err:MUSIC_PLAYER错误码表枚举
@ -453,15 +533,18 @@ void music_player_err_deal(int err)
{
u16 msg = KEY_NULL;
char *logo = NULL;
if (err != MUSIC_PLAYER_ERR_NULL && err != MUSIC_PLAYER_ERR_DECODE_FAIL) {
if (err != MUSIC_PLAYER_ERR_NULL && err != MUSIC_PLAYER_ERR_DECODE_FAIL)
{
__this->file_err_counter = 0; /// 清除错误文件累计
}
if (err != MUSIC_PLAYER_ERR_NULL && err != MUSIC_PLAYER_SUCC) {
if (err != MUSIC_PLAYER_ERR_NULL && err != MUSIC_PLAYER_SUCC)
{
log_e("music player err = %d\n", err);
}
switch (err) {
switch (err)
{
case MUSIC_PLAYER_SUCC:
__this->file_err_counter = 0;
break;
@ -472,35 +555,48 @@ void music_player_err_deal(int err)
msg = KEY_MUSIC_PLAYER_QUIT; // 退出音乐模式
break;
case MUSIC_PLAYER_ERR_DECODE_FAIL:
if (__this->file_err_counter >= music_player_get_file_total()) {
if (__this->file_err_counter >= music_player_get_file_total())
{
__this->file_err_counter = 0;
dev_manager_set_valid_by_logo(music_player_get_dev_cur(), 0); /// 将设备设置为无效设备
if (dev_manager_get_total(1) == 0) {//参数为1 :获取所有有效设备 参数0获取所有设备
if (dev_manager_get_total(1) == 0)
{ // 参数为1 :获取所有有效设备 参数0获取所有设备
msg = KEY_MUSIC_PLAYER_QUIT; // 没有设备了,退出音乐模式
} else {
}
else
{
msg = KEY_MUSIC_AUTO_NEXT_DEV; /// 所有文件都是错误的, 切换到下一个设备
}
} else {
}
else
{
__this->file_err_counter++;
if (__this->file_play_direct == 0) {
if (__this->file_play_direct == 0)
{
msg = KEY_MUSIC_NEXT; // 播放下一曲
} else {
}
else
{
msg = KEY_MUSIC_PREV; // 播放上一曲
}
}
break;
case MUSIC_PLAYER_ERR_DEV_NOFOUND:
log_e("MUSIC_PLAYER_ERR_DEV_NOFOUND \n");
if (dev_manager_get_total(1) == 0) {//参数为1 :获取所有有效设备 参数0获取所有设备
if (dev_manager_get_total(1) == 0)
{ // 参数为1 :获取所有有效设备 参数0获取所有设备
msg = KEY_MUSIC_PLAYER_QUIT; /// 没有设备在线, 退出音乐模式
} else {
}
else
{
msg = KEY_MUSIC_PLAYER_START; /// 没有找到指定设备, 播放之前的活动设备
}
break;
case MUSIC_PLAYER_ERR_FSCAN:
/// 需要结合music_player_scandisk_break中处理的标志位处理
if (__this->scandisk_break) {
if (__this->scandisk_break)
{
__this->scandisk_break = 0;
/// 此处不做任何处理, 打断的事件已经重发, 由重发事件执行后续处理
break;
@ -509,45 +605,59 @@ void music_player_err_deal(int err)
case MUSIC_PLAYER_ERR_DEV_OFFLINE:
log_e("MUSIC_PLAYER_ERR_DEV_OFFLINE \n");
logo = music_player_get_dev_cur();
if (dev_manager_online_check_by_logo(logo, 1)) {
if (dev_manager_online_check_by_logo(logo, 1))
{
/// 如果错误失败在线, 并且是播放过程中产生的,先记录下断点
if (music_player_get_playing_breakpoint(breakpoint, 1) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 1) == true)
{
music_player_stop(0); // 先停止防止下一步操作VM卡顿
breakpoint_vm_write(breakpoint, logo);
}
if (err == MUSIC_PLAYER_ERR_FSCAN) {
if (err == MUSIC_PLAYER_ERR_FSCAN)
{
dev_manager_set_valid_by_logo(logo, 0); /// 将设备设置为无效设备
} else {
}
else
{
// 针对读错误, 因为时间推到应用层有延时导致下一个模式判断不正常, 此处需要将设备卸载
dev_manager_unmount(logo);
}
}
if (dev_manager_get_total(1) == 0) {
if (dev_manager_get_total(1) == 0)
{
app_status_handler(APP_STATUS_MUSIC_QUIT);
msg = KEY_MUSIC_PLAYER_QUIT; /// 没有设备在线, 退出音乐模式
} else {
}
else
{
msg = KEY_MUSIC_AUTO_NEXT_DEV; /// 切换设备
}
break;
case MUSIC_PLAYER_ERR_FILE_NOFOUND:
/// 查找文件有扫盘的可能也需要结合music_player_scandisk_break中处理的标志位处理
if (__this->scandisk_break) {
if (__this->scandisk_break)
{
__this->scandisk_break = 0;
/// 此处不做任何处理, 打断的事件已经重发, 由重发事件执行后续处理
break;
}
case MUSIC_PLAYER_ERR_PARM:
logo = music_player_get_dev_cur();
if (dev_manager_online_check_by_logo(logo, 1)) {
if (music_player_get_file_total()) {
if (dev_manager_online_check_by_logo(logo, 1))
{
if (music_player_get_file_total())
{
msg = KEY_MUSIC_PLAYER_PLAY_FIRST; /// 有文件,播放第一个文件
break;
}
}
if (dev_manager_get_total(1) == 0) {
if (dev_manager_get_total(1) == 0)
{
msg = KEY_MUSIC_PLAYER_QUIT; // 没有设备了,退出音乐模式
} else {
}
else
{
msg = KEY_MUSIC_AUTO_NEXT_DEV;
}
break;
@ -555,7 +665,8 @@ void music_player_err_deal(int err)
msg = KEY_MUSIC_NEXT; // 播放下一曲
break;
}
if (msg != KEY_NULL) {
if (msg != KEY_NULL)
{
app_task_put_key_msg(msg, 0);
}
}
@ -581,15 +692,20 @@ static int music_key_event_opr(struct sys_event *event)
log_i("music task msg = %d\n", msg[0]);
switch (msg[0]) {
switch (msg[0])
{
case KEY_MUSIC_DEVICE_TONE_END:
#if (MUSIC_DEVICE_TONE_EN)
logo = (char *)msg[1];
log_i("KEY_MUSIC_DEVICE_TONE_END %s\n", logo);
if (logo) {
if (true == breakpoint_vm_read(breakpoint, logo)) {
if (logo)
{
if (true == breakpoint_vm_read(breakpoint, logo))
{
err = music_player_play_by_breakpoint(logo, breakpoint);
} else {
}
else
{
err = music_player_play_first_file(logo);
}
}
@ -600,23 +716,30 @@ static int music_key_event_opr(struct sys_event *event)
app_status_handler(APP_STATUS_MUSIC_PLAY);
/// 断点播放活动设备
logo = dev_manager_get_logo(dev_manager_find_active(1));
if (music_player_get_play_status() == FILE_DEC_STATUS_PLAY) {
if (music_player_get_dev_cur() && logo) {
if (music_player_get_play_status() == FILE_DEC_STATUS_PLAY)
{
if (music_player_get_dev_cur() && logo)
{
/// 播放的设备跟当前活动的设备是同一个设备,不处理
if (0 == strcmp(logo, music_player_get_dev_cur())) {
if (0 == strcmp(logo, music_player_get_dev_cur()))
{
log_w("the same dev!!\n");
break;
}
}
}
#if (MUSIC_DEVICE_TONE_EN)
if (music_device_tone_play(logo) == true) {
if (music_device_tone_play(logo) == true)
{
break;
}
#endif
if (true == breakpoint_vm_read(breakpoint, logo)) {
if (true == breakpoint_vm_read(breakpoint, logo))
{
err = music_player_play_by_breakpoint(logo, breakpoint);
} else {
}
else
{
err = music_player_play_first_file(logo);
}
break;
@ -638,10 +761,13 @@ static int music_key_event_opr(struct sys_event *event)
case KEY_MUSIC_PP:
log_i("KEY_MUSIC_PP\n");
err = music_player_pp();
if (music_player_get_play_status() == FILE_DEC_STATUS_PLAY) {
if (music_player_get_play_status() == FILE_DEC_STATUS_PLAY)
{
app_status_handler(APP_STATUS_MUSIC_PLAY);
ui_update_status(STATUS_MUSIC_PLAY);
} else {
}
else
{
app_status_handler(APP_STATUS_MUSIC_PP);
ui_update_status(STATUS_MUSIC_PAUSE);
}
@ -682,22 +808,28 @@ static int music_key_event_opr(struct sys_event *event)
auto_next_dev = ((msg[0] == KEY_MUSIC_AUTO_NEXT_DEV) ? 1 : 0);
logo = music_player_get_dev_next(auto_next_dev);
printf("next dev = %s\n", logo);
if (logo == NULL) { ///找不到下一个设备,不响应设备切换
if (logo == NULL)
{ /// 找不到下一个设备,不响应设备切换
break;
}
/// 切换设备前先保存一下上一个设备的断点信息,包括文件和解码信息
if (music_player_get_playing_breakpoint(breakpoint, 1) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 1) == true)
{
music_player_stop(0); // 先停止防止下一步操作VM卡顿
breakpoint_vm_write(breakpoint, music_player_get_dev_cur());
}
#if (MUSIC_DEVICE_TONE_EN)
if (music_device_tone_play(logo) == true) {
if (music_device_tone_play(logo) == true)
{
break;
}
#endif
if (true == breakpoint_vm_read(breakpoint, logo)) {
if (true == breakpoint_vm_read(breakpoint, logo))
{
err = music_player_play_by_breakpoint(logo, breakpoint);
} else {
}
else
{
err = music_player_play_first_file(logo);
}
break;
@ -705,12 +837,16 @@ static int music_key_event_opr(struct sys_event *event)
log_i("KEY_MUSIC_PLAYE_REC_FOLDER_SWITCH\n");
#if (TCFG_RECORD_FOLDER_DEV_ENABLE)
/// 尝试保存断点
if (music_player_get_playing_breakpoint(breakpoint, 1) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 1) == true)
{
breakpoint_vm_write(breakpoint, music_player_get_dev_cur());
}
if (true == breakpoint_vm_read(breakpoint, music_player_get_cur_music_dev())) {
if (true == breakpoint_vm_read(breakpoint, music_player_get_cur_music_dev()))
{
err = music_player_play_record_folder(NULL, breakpoint);
} else {
}
else
{
err = music_player_play_record_folder(NULL, NULL);
}
#endif // TCFG_RECORD_FOLDER_DEV_ENABLE
@ -730,7 +866,6 @@ static int music_key_event_opr(struct sys_event *event)
err = music_player_play_by_path((char *)"udisk0", "/sin.wav"); /// this is a demo
break;
/// 非播放执行类消息
case KEY_MUSIC_FF:
log_i("KEY_MUSIC_FF\n");
@ -745,7 +880,8 @@ static int music_key_event_opr(struct sys_event *event)
case KEY_MUSIC_CHANGE_REPEAT:
log_i("KEY_MUSIC_CHANGE_REPEAT\n");
mode = music_player_change_repeat_mode();
if (mode > 0) {
if (mode > 0)
{
UI_SHOW_MENU(MENU_MUSIC_REPEATMODE, 1000, mode, NULL);
}
break;
@ -762,7 +898,6 @@ static int music_key_event_opr(struct sys_event *event)
break;
}
/// 错误处理
music_player_err_deal(err);
/// smartbox info update
@ -772,7 +907,6 @@ static int music_key_event_opr(struct sys_event *event)
return ret;
}
//*----------------------------------------------------------------------------*/
/**@brief music 设备事件响应接口
@param
@ -785,29 +919,36 @@ static int music_sys_event_handler(struct sys_event *event)
int err = 0;
char *logo = NULL;
char *evt_logo = NULL;
switch (event->type) {
switch (event->type)
{
case SYS_KEY_EVENT:
return music_key_event_opr(event);
case SYS_DEVICE_EVENT:
switch ((u32)event->arg) {
switch ((u32)event->arg)
{
case DRIVER_EVENT_FROM_SD0:
case DRIVER_EVENT_FROM_SD1:
case DRIVER_EVENT_FROM_SD2:
evt_logo = (char *)event->u.dev.value;
case DEVICE_EVENT_FROM_OTG:
if ((u32)event->arg == DEVICE_EVENT_FROM_OTG) {
if ((u32)event->arg == DEVICE_EVENT_FROM_OTG)
{
evt_logo = (char *)"udisk0";
}
int str_len = 0;
logo = music_player_get_phy_dev(&str_len);
log_i("evt_logo =%s, logo = %s len =%d\n", evt_logo, logo, str_len);
if (event->u.dev.event == DEVICE_EVENT_OUT) {
if (logo == NULL) {
if (event->u.dev.event == DEVICE_EVENT_OUT)
{
if (logo == NULL)
{
break;
}
if (logo && (0 == memcmp(logo, evt_logo, str_len))) {
if (logo && (0 == memcmp(logo, evt_logo, str_len)))
{
/// 相同的设备才响应
if (music_player_get_playing_breakpoint(breakpoint, 1) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 1) == true)
{
breakpoint_vm_write(breakpoint, logo);
}
memset(__this->device_tone_dev, 0, sizeof(__this->device_tone_dev));
@ -817,7 +958,9 @@ static int music_sys_event_handler(struct sys_event *event)
app_task_put_key_msg(KEY_MUSIC_PLAYER_START, 0); // 卸载了设备再执行
log_i("KEY_MUSIC_PLAYER_START AFTER UMOUNT\n");
}
} else {
}
else
{
#if (MUSIC_DEV_ONLINE_START_AFTER_MOUNT_EN == 0)
music_task_dev_online_start();
#endif
@ -859,7 +1002,8 @@ void music_task_set_parm(u8 type, int val)
/*----------------------------------------------------------------------------*/
static void music_player_play_start(void)
{
switch (__this->task_parm.type) {
switch (__this->task_parm.type)
{
case MUSIC_TASK_START_BY_NORMAL:
log_i("MUSIC_TASK_START_BY_NORMAL\n");
app_task_put_key_msg(KEY_MUSIC_PLAYER_START, 0);
@ -875,7 +1019,6 @@ static void music_player_play_start(void)
/// 提示音播放失败直接推送KEY_MUSIC_PLAYER_START启动播放
}
//*----------------------------------------------------------------------------*/
/**@brief music 模式新设备上线处理
@param
@ -887,9 +1030,11 @@ void music_task_dev_online_start(void)
{
u8 save = 0;
char *logo = music_player_get_dev_cur();
if (logo && breakpoint) {
if (logo && breakpoint)
{
/// 新设备上线, 先记录当前设备断点, 然后播放活动设备
if (music_player_get_playing_breakpoint(breakpoint, 1) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 1) == true)
{
save = 1;
// 这里不要直接记忆断点, 解码停了之后再记忆
// breakpoint_vm_write(breakpoint, logo);
@ -897,7 +1042,8 @@ void music_task_dev_online_start(void)
}
/// 停止解码,播放新活动设备
music_player_stop(1);
if (save && breakpoint) {
if (save && breakpoint)
{
breakpoint_vm_write(breakpoint, logo);
}
app_task_put_key_msg(KEY_MUSIC_PLAYER_START, 0);
@ -931,7 +1077,6 @@ static void music_task_start()
/// 按键使能
sys_key_event_enable();
/// 播放器初始化
struct __player_parm parm = {0};
parm.cb = &music_player_callback;
@ -957,7 +1102,8 @@ static void music_task_close()
UI_HIDE_CURR_WINDOW();
tone_play_stop_by_path(tone_table[IDEX_TONE_MUSIC]); // 停止播放提示音
char *logo = music_player_get_dev_cur();
if (music_player_get_playing_breakpoint(breakpoint, 1) == true) {
if (music_player_get_playing_breakpoint(breakpoint, 1) == true)
{
breakpoint_vm_write(breakpoint, logo);
}
@ -981,7 +1127,8 @@ static void music_task_close()
/*----------------------------------------------------------------------------*/
int music_app_check(void)
{
if (dev_manager_get_total(1)) {
if (dev_manager_get_total(1))
{
return true;
}
return false;
@ -998,6 +1145,14 @@ void app_music_task()
{
int res;
int msg[32];
// PA mode set to class D
gpio_set_pull_down(IO_PORTA_02, 0);
gpio_set_pull_up(IO_PORTA_02, 0);
gpio_set_direction(IO_PORTA_02, 0);
gpio_set_output_value(IO_PORTA_02, 0);
music_task_start();
#if (MUSIC_DEVICE_TONE_EN)
@ -1006,29 +1161,37 @@ void app_music_task()
#if TCFG_DEC2TWS_ENABLE
extern void set_tws_background_connected_flag(u8 flag);
extern u8 get_tws_background_connected_flag();
if (get_tws_background_connected_flag()) { //不播放提示音
if (get_tws_background_connected_flag())
{ // 不播放提示音
music_player_play_start();
set_tws_background_connected_flag(0);
} else
}
else
#endif
{
tone_play_with_callback_by_name(tone_table[IDEX_TONE_MUSIC], 1, music_tone_play_end_callback, (void *)IDEX_TONE_MUSIC);
}
#endif
start_led();
while (1) {
while (1)
{
app_task_get_msg(msg, ARRAY_SIZE(msg), 1);
switch (msg[0]) {
switch (msg[0])
{
case APP_MSG_SYS_EVENT:
if (music_sys_event_handler((struct sys_event *)(&msg[1])) == false) {
if (music_sys_event_handler((struct sys_event *)(&msg[1])) == false)
{
app_default_event_deal((struct sys_event *)(&msg[1]));
}
break;
default:
break;
}
if (app_task_exitting()) {
if (app_task_exitting())
{
sys_timer_del(tm_led);
gpio_set_output_value(IO_PORTB_05, 1);
music_task_close();
return;
}
@ -1048,10 +1211,6 @@ REGISTER_LP_TARGET(music_lp_target) = {
void app_music_task()
{
}
#endif

View File

@ -132,9 +132,9 @@ void app_poweron_task()
UI_SHOW_MENU(MENU_POWER_UP, 0, 0, NULL);
int err = tone_play_with_callback_by_name(tone_table[IDEX_TONE_POWER_ON], 1, tone_play_end_callback, (void *)IDEX_TONE_POWER_ON);
//int err = tone_play_with_callback_by_name(tone_table[IDEX_TONE_POWER_ON], 1, tone_play_end_callback, (void *)IDEX_TONE_POWER_ON);
/* if (err) { //提示音没有,播放失败直接init流程 */
/* power_on_init(); */
power_on_init(); /* */
/* } */

View File

@ -80,7 +80,7 @@
*/
#if (TCFG_AUDIO_DAC_CONNECT_MODE == DAC_OUTPUT_MONO_LR_DIFF || \
TCFG_AUDIO_DAC_CONNECT_MODE == DAC_OUTPUT_DUAL_LR_DIFF)
#define MAX_ANA_VOL (21)
#define MAX_ANA_VOL (28)
#else
#define MAX_ANA_VOL (30)
#endif/*TCFG_AUDIO_DAC_CONNECT_MODE*/
@ -113,8 +113,8 @@
#endif
#define SYS_DEFAULT_VOL 0//(SYS_MAX_VOL/2)
#define SYS_DEFAULT_TONE_VOL 10//(SYS_MAX_VOL)
#define SYS_DEFAULT_VOL SYS_MAX_VOL/2 //(SYS_MAX_VOL/2)
#define SYS_DEFAULT_TONE_VOL 18//(SYS_MAX_VOL)
#define SYS_DEFAULT_SIN_VOL 17
#define APP_AUDIO_STATE_IDLE 0

View File

@ -946,7 +946,16 @@ REGISTER_LP_TARGET(audio_dec_init_lp_target) = {
void audio_mix_out_automute_mute(u8 mute)
{
printf(">>>>>>>>>>>>>>>>>>>> %s\n", mute ? ("MUTE") : ("UNMUTE"));
//printf(">>>>>>>>>>>>>>>>>>>> %s\n", mute ? ("MUTE") : ("UNMUTE"));
if (mute)
{
gpio_set_output_value(IO_PORTA_04,1);
}
else
{
gpio_set_output_value(IO_PORTA_04,0);
}
}
/* #define AUDIO_E_DET_UNMUTE (0x00) */

View File

@ -37,22 +37,8 @@ mp3_decoder
wma_decoder
g729_decoder
wav_decoder
cvsd_encoder
msbc_encoder
mp3_encoder
adpcm_encoder
sbc_encoder

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
44b10a8a9a97a7ea8795ce48fe8bb180954fc20c5763ded5954fc20c5763ded5399f4f1d

File diff suppressed because one or more lines are too long

View File

@ -7,13 +7,13 @@ copy ..\..\uboot.boot .
copy ..\..\ota.bin .
copy ..\..\eq_cfg_hw.bin .
..\..\isd_download.exe -tonorflash -dev br25 -boot 0x12000 -div8 -wait 300 -uboot uboot.boot -app app.bin -res tone.cfg cfg_tool.bin eq_cfg_hw.bin -uboot_compress
..\..\isd_download.exe -tonorflash -dev br25 -boot 0x12000 -div8 -wait 300 -uboot uboot.boot -app app.bin -res tone.cfg cfg_tool.bin eq_cfg_hw.bin -uboot_compress -key KTS_AC690x_5458.key
:: -format all
::-reboot 2500
@rem 删除临时文件-format all
@rem ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD>-format all
if exist *.mp3 del *.mp3
if exist *.PIX del *.PIX
if exist *.TAB del *.TAB
@ -26,16 +26,16 @@ copy jl_isd.ufw update.ufw
del jl_isd.ufw
@REM 生成配置文件升级文件
@REM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
::ufw_maker.exe -chip AC800X %ADD_KEY% -output config.ufw -res bt_cfg.cfg
::IF EXIST jl_696x.bin del jl_696x.bin
@rem 常用命令说明
@rem -format vm //擦除VM 区域
@rem -format cfg //擦除BT CFG 区域
@rem -format 0x3f0-2 //表示从第 0x3f0 个 sector 开始连续擦除 2 个 sector(第一个参数为16进制或10进制都可第二个参数必须是10进制)
@rem <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
@rem -format vm //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>VM <20><><EFBFBD><EFBFBD>
@rem -format cfg //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>BT CFG <20><><EFBFBD><EFBFBD>
@rem -format 0x3f0-2 //<EFBFBD><EFBFBD>ʾ<EFBFBD>ӵ<EFBFBD> 0x3f0 <20><> sector <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20><> sector(<28><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16<31><36><EFBFBD>ƻ<EFBFBD>10<31><30><EFBFBD>ƶ<EFBFBD><C6B6>ɣ<EFBFBD><C9A3>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10<31><30><EFBFBD><EFBFBD>)
ping /n 2 127.1>null
IF EXIST null del null

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

BIN
tone/bt.mp3 Normal file

Binary file not shown.

BIN
tone/bt.wtg Normal file

Binary file not shown.

BIN
tone/connect.mp3 Normal file

Binary file not shown.

BIN
tone/connect.wtg Normal file

Binary file not shown.

BIN
tone/disconnect.mp3 Normal file

Binary file not shown.

BIN
tone/disconnect.wtg Normal file

Binary file not shown.

BIN
tone/linein.mp3 Normal file

Binary file not shown.

BIN
tone/linein.wtg Normal file

Binary file not shown.

BIN
tone/low_power.mp3 Normal file

Binary file not shown.

BIN
tone/low_power.wtg Normal file

Binary file not shown.

BIN
tone/pwr_off.mp3 Normal file

Binary file not shown.

BIN
tone/pwr_off.wtg Normal file

Binary file not shown.

BIN
tone/radio.mp3 Normal file

Binary file not shown.

BIN
tone/radio.wtg Normal file

Binary file not shown.

BIN
tone/tf.mp3 Normal file

Binary file not shown.

BIN
tone/tf.wtg Normal file

Binary file not shown.

BIN
tone/usb.mp3 Normal file

Binary file not shown.

BIN
tone/usb.wtg Normal file

Binary file not shown.