A59 -V1.1版本提交
This commit is contained in:
@ -8,6 +8,7 @@ QueueHandle_t rx_queue = NULL;
|
||||
int initialize_timeout = 0;
|
||||
bt_at_callback gCallback = NULL;
|
||||
static void* gCbContex = NULL;
|
||||
static TaskHandle_t console_task_handle = NULL;
|
||||
|
||||
/*
|
||||
example to demonstrate that:
|
||||
@ -17,11 +18,11 @@ static void* gCbContex = NULL;
|
||||
note:
|
||||
the applicaton should process data as soon as possilbe (otherwise the queue may overflow)
|
||||
*/
|
||||
static void* console_task(void* arg)
|
||||
static void console_task(void* arg)
|
||||
{
|
||||
char buf[AT_CMD_PAYLOAD_LEN];
|
||||
char buf[AT_CMD_PAYLOAD_LEN];
|
||||
|
||||
gCbContex = gCbContex;//make iar happy
|
||||
gCbContex = gCbContex;//make iar happy
|
||||
for (;;)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
@ -40,6 +41,7 @@ static void* console_task(void* arg)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
response[response_len-2] = '\0';
|
||||
response += 2;
|
||||
|
||||
@ -50,23 +52,28 @@ static void* console_task(void* arg)
|
||||
if(strlen(response) > 4 && !memcmp(response,"+VER",4))
|
||||
{
|
||||
console_send_atcmd("AT+NAME\r\n", strlen("AT+NAME\r\n"));
|
||||
// }else{
|
||||
// parseBtATCommand(response,response_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int console_init(bt_at_callback cb)
|
||||
{
|
||||
pthread_t task;
|
||||
pthread_attr_t attr;
|
||||
if (NULL == gCallback)
|
||||
gCallback = cb;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setstacksize(&attr, 4096 * 3);
|
||||
pthread_create(&task, &attr, console_task, NULL);
|
||||
pthread_t task;
|
||||
pthread_attr_t attr;
|
||||
if (NULL == gCallback)
|
||||
{
|
||||
gCallback = cb;
|
||||
}
|
||||
|
||||
if (xTaskCreate(console_task, "console", 4096, NULL,
|
||||
configMAX_PRIORITIES / 3, &console_task_handle) != pdPASS) {
|
||||
printf("create console_task task fail.\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "console.h"
|
||||
#include "board.h"
|
||||
@ -33,27 +32,19 @@ static int fsc_bt_play_state_callback(BT_PLAY_STATE_E state, unsigned short samp
|
||||
|
||||
static int fsc_bt_a2dp_pcm_data_callback(unsigned char* buffer, unsigned short length)
|
||||
{
|
||||
/* À¶ÑÀÒôÀÖ²¥·ÅÊý¾Ý ²ÉÑùÂÊΪ44100»ò48000£¬2 channel 16bit£¬Ö±½ÓÊä³öµ½I2SÉ豸 */
|
||||
//printf("a2dp length %d\r\n", length);
|
||||
/* 蓝牙音乐播放数据 采样率为44100或48000,2 channel 16bit,直接输出到I2S设备 */
|
||||
//printf("a2dp length %d 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \r\n", length, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fsc_bt_hfp_spk_pcm_data_callback(unsigned char* buffer, unsigned short length)
|
||||
{
|
||||
/* À¶ÑÀµç»°ÏÂÐÐÊý¾Ý ²ÉÑùÂÊΪ8000»ò16000£¬1 channel 16bit£¬Ö±½ÓÊä³öµ½I2SÉ豸 */
|
||||
//printf("spk length %d\r\n", length);
|
||||
/* 蓝牙电话下行数据 采样率为8000或16000,1 channel 16bit,直接输出到I2S设备 */
|
||||
//if (buffer[0] || buffer[1] || buffer[2] || buffer[3])
|
||||
//printf("spk length %d 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \r\n", length, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int fsc_bt_hfp_mic_pcm_data_callback(unsigned char* buffer, unsigned short length)
|
||||
{
|
||||
/* À¶ÑÀµç»°ÉÏÐÐÊý¾Ý ²ÉÑùÂÊΪ8000»ò16000£¬1 channel 16bit£¬°´ÕÕ²ÎÊýlength»ñÈ¡micÊý¾ÝÌî³äbuffer */
|
||||
//printf("mic length %d\r\n", length);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void bt_task(void* arg)
|
||||
{
|
||||
// bluetooth stack require none volatile storage to store configuration (e.g. device name) and paired record link key and etc.
|
||||
@ -75,6 +66,8 @@ static void bt_task(void* arg)
|
||||
|
||||
bt_hw_cfg.bt_en_pin = BT_RESET_IO;
|
||||
bt_hw_cfg.uartport = BT_UART_PORT;
|
||||
bt_hw_cfg.flashaddr = DB0_START_ADDR;
|
||||
bt_hw_cfg.flashaddr1 = DB1_START_ADDR;
|
||||
|
||||
bt_sw_cfg.rx_queue = rx_queue;
|
||||
bt_sw_cfg.tx_queue = tx_queue;
|
||||
@ -92,22 +85,17 @@ static void bt_task(void* arg)
|
||||
bt_sw_cfg.play_state_cb = g_bt_cfg.play_state_cb;
|
||||
else
|
||||
bt_sw_cfg.play_state_cb = fsc_bt_play_state_callback;
|
||||
|
||||
|
||||
if (g_bt_cfg.a2dp_cb)
|
||||
bt_sw_cfg.a2dp_cb = g_bt_cfg.a2dp_cb;
|
||||
else
|
||||
bt_sw_cfg.a2dp_cb = fsc_bt_a2dp_pcm_data_callback;
|
||||
|
||||
|
||||
if (g_bt_cfg.hfp_spk_cb)
|
||||
bt_sw_cfg.hfp_spk_cb = g_bt_cfg.hfp_spk_cb;
|
||||
else
|
||||
bt_sw_cfg.hfp_spk_cb = fsc_bt_hfp_spk_pcm_data_callback;
|
||||
#if 0
|
||||
if (g_bt_cfg.hfp_mic_cb)
|
||||
bt_sw_cfg.hfp_mic_cb = g_bt_cfg.hfp_mic_cb;
|
||||
else
|
||||
bt_sw_cfg.hfp_mic_cb = fsc_bt_hfp_mic_pcm_data_callback;
|
||||
#endif
|
||||
|
||||
fscbt_init(&bt_hw_cfg, &bt_sw_cfg);
|
||||
|
||||
while(!initialize_timeout)
|
||||
@ -125,7 +113,7 @@ int fsc_bt_main(void)
|
||||
if (fsc_bt_task_handle)
|
||||
return 0;
|
||||
/* Create a task to process uart rx data */
|
||||
if (xTaskCreate(bt_task, "bt_main", 4096 * 2, NULL,
|
||||
if (xTaskCreate(bt_task, "bt_main", 4096, NULL,
|
||||
configMAX_PRIORITIES / 3, &fsc_bt_task_handle) != pdPASS) {
|
||||
printf("create fsc_bt_thread task fail.\n");
|
||||
return -1;
|
||||
|
@ -33,6 +33,10 @@ typedef enum
|
||||
BT_UART_PORT_END
|
||||
} BT_UART_PORT_E;
|
||||
|
||||
#define DB0_START_ADDR ((unsigned int)0x00036000)
|
||||
#define DB0_END_ADDR ((unsigned int)0x00036fff)
|
||||
#define DB1_START_ADDR ((unsigned int)0x00037000) /* for backup database */
|
||||
#define DB1_END_ADDR ((unsigned int)0x00037FFF)
|
||||
|
||||
typedef int (* bt_play_state_callback)(BT_PLAY_STATE_E state, unsigned short samplerate, unsigned char channel);
|
||||
typedef int (* bt_pcm_data_callback)(unsigned char* buffer, unsigned short length);
|
||||
@ -41,6 +45,8 @@ typedef struct
|
||||
{
|
||||
unsigned int bt_en_pin;
|
||||
unsigned int uartport;
|
||||
unsigned int flashaddr; /* Start Block Flash Address for Database. Default address is 0x00036000*/
|
||||
unsigned int flashaddr1; /* Start Block Flash Address for bakeup Database. Default address is 0x00037000 */
|
||||
}bt_hw_cfg_t;
|
||||
|
||||
typedef struct
|
||||
|
Binary file not shown.
BIN
lib/bt/fsc_bt/lib/blueware_bw2231.a
Normal file
BIN
lib/bt/fsc_bt/lib/blueware_bw2231.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user