renamed app core

This commit is contained in:
Martijn Scheepers
2022-04-25 15:45:34 +02:00
parent 34e0c4f680
commit 8b43ffe81a
7 changed files with 35 additions and 32 deletions

View File

@@ -14,6 +14,8 @@
"idf.toolsPathWin": "C:\\Users\\ms\\.espressif",
"idf.flashType": "UART",
"files.associations": {
"esp_log.h": "c"
"esp_log.h": "c",
"h2201_app.h": "c",
"h2201_a2dp.h": "c"
}
}

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "H2201_avrcp.c" "H2201_a2dp.c" "H2201_i2s.c"
"bt_app_core.c"
idf_component_register(SRCS "h2201_app.c" "H2201_avrcp.c" "H2201_a2dp.c" "H2201_i2s.c"
"main.c"
INCLUDE_DIRS ".")

View File

@@ -16,7 +16,7 @@
#include "sys/lock.h"
#include "bt_app_core.h"
#include "H2201_app.h"
#include "H2201_i2s.h"
#include "H2201_a2dp.h"
@@ -37,7 +37,7 @@ void h2201_a2dp_callback(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
case ESP_A2D_AUDIO_CFG_EVT:
case ESP_A2D_PROF_STATE_EVT:
{
bt_app_work_dispatch(h2201_a2dp_eventhandler, event, param, sizeof(esp_a2d_cb_param_t), NULL);
h2201_app_work_dispatch(h2201_a2dp_eventhandler, event, param, sizeof(esp_a2d_cb_param_t), NULL);
break;
}
default:

View File

@@ -16,7 +16,7 @@
#include "sys/lock.h"
#include "bt_app_core.h"
#include "H2201_app.h"
#include "H2201_avrcp.h"
#include "H2201_i2s.h"
@@ -58,7 +58,7 @@ void h2201_avrcp_controller_callback(esp_avrc_ct_cb_event_t event, esp_avrc_ct_c
case ESP_AVRC_CT_REMOTE_FEATURES_EVT:
case ESP_AVRC_CT_GET_RN_CAPABILITIES_RSP_EVT:
{
bt_app_work_dispatch(h2201_avrcp_controller_eventhandler, event, param, sizeof(esp_avrc_ct_cb_param_t), NULL);
h2201_app_work_dispatch(h2201_avrcp_controller_eventhandler, event, param, sizeof(esp_avrc_ct_cb_param_t), NULL);
break;
}
default:
@@ -77,7 +77,7 @@ void h2201_avrcp_target_callback(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_pa
case ESP_AVRC_TG_SET_ABSOLUTE_VOLUME_CMD_EVT:
case ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT:
case ESP_AVRC_TG_SET_PLAYER_APP_VALUE_EVT:
bt_app_work_dispatch(h2201_avrcp_target_eventhandler, event, param, sizeof(esp_avrc_tg_cb_param_t), NULL);
h2201_app_work_dispatch(h2201_avrcp_target_eventhandler, event, param, sizeof(esp_avrc_tg_cb_param_t), NULL);
break;
default:
ESP_LOGE(H2201_AVRCP_TG_TAG, "Invalid AVRC event: %d", event);

View File

@@ -7,18 +7,19 @@
#include "freertos/queue.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "bt_app_core.h"
#include "driver/i2s.h"
#include "freertos/ringbuf.h"
//#include "driver/i2s.h"
//#include "freertos/ringbuf.h"
static void bt_app_task_handler(void *arg);
static bool bt_app_send_msg(bt_app_msg_t *msg);
static void bt_app_work_dispatched(bt_app_msg_t *msg);
#include "H2201_app.h"
static void h2201_app_task(void *arg);
static bool h2201_app_send_msg(bt_app_msg_t *msg);
static void h2201_app_work_dispatched(bt_app_msg_t *msg);
static xQueueHandle s_bt_app_task_queue = NULL;
static xTaskHandle s_bt_app_task_handle = NULL;
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
bool h2201_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
{
ESP_LOGD(BT_APP_CORE_TAG, "%s event 0x%x, param len %d", __func__, event, param_len);
@@ -31,7 +32,7 @@ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, i
if (param_len == 0)
{
return bt_app_send_msg(&msg);
return h2201_app_send_msg(&msg);
}
else if (p_params && param_len > 0)
{
@@ -43,14 +44,14 @@ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, i
{
p_copy_cback(&msg, msg.param, p_params);
}
return bt_app_send_msg(&msg);
return h2201_app_send_msg(&msg);
}
}
return false;
}
static bool bt_app_send_msg(bt_app_msg_t *msg)
static bool h2201_app_send_msg(bt_app_msg_t *msg)
{
if (msg == NULL)
{
@@ -65,7 +66,7 @@ static bool bt_app_send_msg(bt_app_msg_t *msg)
return true;
}
static void bt_app_work_dispatched(bt_app_msg_t *msg)
static void h2201_app_work_dispatched(bt_app_msg_t *msg)
{
if (msg->cb)
{
@@ -73,7 +74,7 @@ static void bt_app_work_dispatched(bt_app_msg_t *msg)
}
}
static void bt_app_task_handler(void *arg)
static void h2201_app_task(void *arg)
{
bt_app_msg_t msg;
for (;;)
@@ -84,7 +85,7 @@ static void bt_app_task_handler(void *arg)
switch (msg.sig)
{
case BT_APP_SIG_WORK_DISPATCH:
bt_app_work_dispatched(&msg);
h2201_app_work_dispatched(&msg);
break;
default:
ESP_LOGW(BT_APP_CORE_TAG, "%s, unhandled sig: %d", __func__, msg.sig);
@@ -99,14 +100,14 @@ static void bt_app_task_handler(void *arg)
}
}
void bt_app_task_start_up(void)
void h2201_app_task_startup(void)
{
s_bt_app_task_queue = xQueueCreate(10, sizeof(bt_app_msg_t));
xTaskCreate(bt_app_task_handler, "BtAppT", 3072, NULL, configMAX_PRIORITIES - 3, &s_bt_app_task_handle);
xTaskCreate(h2201_app_task, "BtAppT", 3072, NULL, configMAX_PRIORITIES - 3, &s_bt_app_task_handle);
return;
}
void bt_app_task_shut_down(void)
void h2201_app_task_shutdown(void)
{
if (s_bt_app_task_handle)
{

View File

@@ -31,10 +31,10 @@ typedef void (*bt_app_copy_cb_t)(bt_app_msg_t *msg, void *p_dest, void *p_src);
/**
* @brief work dispatcher for the application task
*/
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback);
bool h2201_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback);
void bt_app_task_start_up(void);
void h2201_app_task_startup(void);
void bt_app_task_shut_down(void);
void h2201_app_task_shutdown(void);
#endif /* __BT_APP_CORE_H__ */

View File

@@ -31,7 +31,7 @@
#include "esp_avrc_api.h"
#include "driver/i2s.h"
#include "bt_app_core.h"
#include "H2201_app.h"
#include "H2201_avrcp.h"
#include "H2201_a2dp.h"
@@ -110,10 +110,10 @@ void app_main(void)
}
/* create application task */
bt_app_task_start_up();
h2201_app_task_startup();
/* Bluetooth device name, connection mode and profile set up */
bt_app_work_dispatch(bt_av_hdl_stack_evt, BT_APP_EVT_STACK_UP, NULL, 0, NULL);
h2201_app_work_dispatch(bt_av_hdl_stack_evt, BT_APP_EVT_STACK_UP, NULL, 0, NULL);
//#if (CONFIG_BT_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
@@ -135,7 +135,7 @@ void app_main(void)
// esp_bt_gap_set_pin(pin_type, 4, pin_code);
}
void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
void h2201_gap_register_callback(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
{
switch (event)
{
@@ -190,7 +190,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
char *dev_name = "ESP_SPEAKER";
esp_bt_dev_set_device_name(dev_name);
esp_bt_gap_register_callback(bt_app_gap_cb);
esp_bt_gap_register_callback(h2201_gap_register_callback);
/* initialize AVRCP controller */
esp_avrc_ct_init();