Compare commits

...

10 Commits

Author SHA1 Message Date
Ben V. Brown d9902acf43 Update README.md 2022-12-28 21:41:15 +11:00
Ben V. Brown fbbaf15442 Update target.mk 2022-12-28 21:39:16 +11:00
Ben V. Brown 1527ed4edd Set Audio channel from TWS side
Use the TWS side detection to figure out if your Left or Right; rather than relying on the master to be the right bud (not always true if you flash and pair left first).
2022-12-28 21:30:20 +11:00
Ben V. Brown 9a9ad05100 Use the GPIO level to set the TWS side 2022-12-28 21:29:29 +11:00
Ben V. Brown 5c119d048c Raise debugging baud rate 2022-12-28 21:22:58 +11:00
Ben V. Brown 9915b7eec0 Update side at boot 2022-12-28 21:22:31 +11:00
Ben V. Brown 54a37c230c Long press in charge case to reboot 2022-12-28 20:42:06 +11:00
Ben V. Brown 99f5683f86 Create hardware side detect function 2022-12-28 19:36:44 +11:00
Ben V. Brown d03aa0212e We have powerkey 2022-12-28 18:53:16 +11:00
Ben V. Brown 2d176516ca We have no GPIO Keys
Update tgt_hardware.c
2022-12-28 18:52:58 +11:00
7 changed files with 82 additions and 45 deletions

View File

@ -23,3 +23,12 @@ In order to program the buds from inside of the docker container; privileged mod
bestool write-image out/open_source/open_source.bin --port /dev/ttyACM0
bestool write-image out/open_source/open_source.bin --port /dev/ttyACM1
```
## Changelist from stock opeen source SDK
+ Long hold (5 ish seconds) the button on the back when buds are in the case to force a device reboot (so it can be programmed)
+ Use the resistor in the buds to pick Left/Right rather than TWS master/slave pairing
+ Pressing the button on the back while in the case no longer triggers DFU mode
+ Debugging baud rate raised to 200000 to match stock firmware

View File

@ -1396,12 +1396,17 @@ void app_key_init(void)
}
#endif
}
void app_key_reboot(APP_KEY_STATUS *status, void *param)
{
TRACE(1,"%s ",__func__);
hal_cmu_sys_reboot();
}
void app_key_init_on_charging(void)
{
uint8_t i = 0;
const APP_KEY_HANDLE key_cfg[] = {
// {{APP_KEY_CODE_PWR,APP_KEY_EVENT_REPEAT},"ota function key",app_ota_key_handler, NULL},
{{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGLONGPRESS},"long press reboot",app_key_reboot, NULL},
// {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_dfu_key_handler, NULL},
#ifdef __USB_COMM__
{{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"usb cdc key",app_usb_cdc_comm_key_handler, NULL},
@ -2228,7 +2233,7 @@ int app_init(void)
TRACE(2,"__factory_start: %p length: 0x%x", __factory_start, FACTORY_SECTION_SIZE);
TRACE(0,"app_init\n");
app_tws_set_side_from_gpio();
#ifdef __RPC_ENABLE__
extern int rpc_service_setup(void);
rpc_service_setup();

View File

@ -10,7 +10,7 @@ RTOS ?= 1
#KERNEL ?= FREERTOS
NO_PWRKEY = 0 # We have powerkey input
LIBC_ROM ?= 1
export USER_SECURE_BOOT ?= 0
@ -45,7 +45,7 @@ export CONTROLLER_DUMP_ENABLE ?= 0
export CONTROLLER_MEM_LOG_ENABLE ?= 0
export INTERSYS_DEBUG ?= 1
export INTERSYS_DEBUG ?= 0
export PROFILE_DEBUG ?= 0
@ -209,7 +209,7 @@ CUSTOM_INFORMATION_TILE_ENABLE ?= 0
INTERCONNECTION ?= 0
INTERACTION ?= 0
INTERACTION ?= 0 # Looks like Find-My-Device support?
INTERACTION_FASTPAIR ?= 0
@ -258,7 +258,7 @@ export A2DP_AVDTP_CP ?= 0
export A2DP_DECODER_VER := 2
export IBRT ?= 1
export IBRT = 1
export IBRT_SEARCH_UI ?= 1
@ -350,7 +350,7 @@ AUDIO_BUFFER_SIZE := 100*1024
endif
export TRACE_BUF_SIZE := 16*1024
export TRACE_BAUD_RATE := 921600
export TRACE_BAUD_RATE := 2000000
init-y :=
core-y := platform/ services/ apps/ utils/cqueue/ utils/list/ services/multimedia/ utils/intersyshci/

View File

@ -82,7 +82,7 @@ const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = {
#endif
#endif
*/
{HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
// {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
};
//bt config
@ -104,6 +104,23 @@ uint8_t bt_addr[6] = {
#endif
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = {
HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
bool tgt_tws_get_channel_is_right(void)
{
#ifdef __FIXED_TWS_EAR_SIDE__
return TWS_EAR_SIDE_ROLE;
#else
hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_hw_tws_channel_cfg,1);
// Pinebuds pull down to 0 for right ear, but float to 1 for left ear
return (hal_gpio_pin_get_val(
(enum HAL_GPIO_PIN_T)cfg_hw_tws_channel_cfg.pin) == 0);
#endif
}
//audio config
//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]}
//gain range -12~+12
@ -181,13 +198,13 @@ const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT ={
};
*/
const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={
HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
// const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={
// HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
// };
const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={
HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
// const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={
// HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
// };
@ -319,10 +336,6 @@ Filter4_A=[ 134217728, -264794659, 130668486];
},
*/
.dac_gain_offset=0,
.adc_gain_offset=(0)*4,
},

View File

@ -76,7 +76,7 @@ extern const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER];
#elif BES_AUDIO_DEV_Main_Board_9v0
#define CFG_HW_GPIOKEY_NUM (6)
#else
#define CFG_HW_GPIOKEY_NUM (1)
#define CFG_HW_GPIOKEY_NUM (0)
#endif
#endif

View File

@ -15,6 +15,7 @@
****************************************************************************/
#include <string.h>
#include "app_tws_ibrt_trace.h"
#include "app_tws_if.h"
#include "bluetooth.h"
#include "btapp.h"
#include "app_ibrt_ui.h"
@ -210,22 +211,27 @@ void app_bt_manager_ibrt_role_process(const btif_event_t *Event)
{
memcpy(p_ibrt_ctrl->local_addr.address,p_remote_dev_addr->address,6);
}
#if 0
p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE;
#else
if(IBRT_MASTER == p_ibrt_ctrl->nv_role)
{
TRACE(0,"#right");
if (app_tws_is_left_side()){
p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL;
}else {
p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL;
}
else if(IBRT_SLAVE == p_ibrt_ctrl->nv_role)
{
TRACE(0,"#left");
p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL;
}
#endif
// #if 0
// p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE;
// #else
// if(IBRT_MASTER == p_ibrt_ctrl->nv_role)
// {
// TRACE(0,"#right");
// p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL;
// }
// else if(IBRT_SLAVE == p_ibrt_ctrl->nv_role)
// {
// TRACE(0,"#left");
// p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL;
// }
// #endif
}
}

View File

@ -663,6 +663,7 @@ static APP_TWS_SIDE_T app_tws_side = EAR_SIDE_UNKNOWN;
void app_tws_set_side(APP_TWS_SIDE_T side)
{
ASSERT((EAR_SIDE_LEFT == side) || (EAR_SIDE_RIGHT == side), "Error: setting invalid side");
TRACE(1,"Set TWS side to %d",side);
app_tws_side = side;
}
@ -681,22 +682,25 @@ bool app_tws_is_unknown_side(void)
return (app_tws_side == EAR_SIDE_UNKNOWN);
}
void app_tws_set_side_from_addr(uint8_t *addr)
{
ASSERT(addr, "Error: address invalid");
if (addr[0] & 0x1) {
app_tws_set_side(EAR_SIDE_RIGHT);
TRACE(0, "Right earbud");
} else {
app_tws_set_side(EAR_SIDE_LEFT);
TRACE(0, "Left earbud");
}
}
// void app_tws_set_side_from_addr(uint8_t *addr)
// {
// ASSERT(addr, "Error: address invalid");
// if (addr[0] & 0x1) {
// app_tws_set_side(EAR_SIDE_RIGHT);
// TRACE(0, "Right earbud");
// } else {
// app_tws_set_side(EAR_SIDE_LEFT);
// TRACE(0, "Left earbud");
// }
// }
void app_tws_set_side_from_gpio(void)
{
if (tgt_tws_get_channel_is_right()){
app_tws_set_side(EAR_SIDE_RIGHT);
}else {
app_tws_set_side(EAR_SIDE_LEFT);
}
}
#endif