客户XX项目AD6973D芯片型号自动关机问题相关修改点
📎 原始文档:https://www.kdocs.cn/l/cl0ZISyLyjGP 客户XX项目AD6973D芯片型号自动关机问题相关修改点
修改点1(宏远)
长按关机时间改为6s(宏远改为7S,但是客户要求改为6S)
注意:这一个修改点与客户UI相关,客户有一个长按3S功能和5S关机功能,时间接近,担心误触关机,因此有这一修改点。
修改点2(宏远)
SDK原本:diff < (cfg2 / 2)
现在:diff < (cfg2)
背景:部分耳机,触摸”触摸点边缘“检测到的变化量A,与触摸“触摸点中心”的触摸变化量B,差值小于(变化量B/2),有些客户不想要触摸到“触摸点边缘”也能触发触摸,因此提供了这一修改点。
注意:根据样机实际情况修改:
修改点3(佳宝)


修改点4(天师)
注意:最新的修改,不再使用void lp_touch_key_reset(void),改为使用SDK默认的触摸复位函数int lp_touch_key_reinit(void)


修改点5(嘉炜)
打开5V硬件复位,同时charge_err关机前将复位参数设为5V低电平长按2S复位。
P33_CON_SET(P3_PINR_CON, 0, 1, 0);
p33_tx_1byte(P3_PORT_SEL0, IO_PORT_RESET_PORT_LDOIN);
P33_CON_SET(P3_PINR_CON, 1, 1, 1);
P33_CON_SET(P3_PINR_CON, 2, 1, 1);
P33_CON_SET(P3_PINR_CON, 0, 1, 1);
P33_CON_SET(P3_PINR_CON, 4, 2, 4);

void charge_check_and_set_pinr(u8 level)
{
u8 pinr_io;
if (P33_CON_GET(P3_PINR_CON) & BIT(0)) {
pinr_io = P33_CON_GET(P3_PORT_SEL0);
if (pinr_io == IO_PORT_LDOIN) {
P33_CON_SET(P3_PINR_CON, 4, 2, 4);//16s复位
if (level == 0) {
P33_CON_SET(P3_PINR_CON, 2, 1, 0);
} else {
P33_CON_SET(P3_PINR_CON, 2, 1, 1);
}
}
}
}
void charge_check_and_set_pinr_2s(u8 level)
{
u8 pinr_io;
if (P33_CON_GET(P3_PINR_CON) & BIT(0)) {
pinr_io = P33_CON_GET(P3_PORT_SEL0);
if (pinr_io == IO_PORT_LDOIN) {
P33_CON_SET(P3_PINR_CON, 4, 2, 1);//2s复位
if (level == 0) {
P33_CON_SET(P3_PINR_CON, 2, 1, 0);
} else {
P33_CON_SET(P3_PINR_CON, 2, 1, 1);
}
}
}
}



修改点6(嘉炜)
该修改适用于仓开盖后,仓的pogopin输出由5v变为输出0v的方案。
- 添加出仓检测。
- 检测到出仓后复位触摸。 在earphone.c下,找地方添加以下代码块
extern int lp_touch_key_reinit(void);
// 检测PP0是否高电平的定时器句柄
volatile u16 user_check_pp0_io_status_timer = 0;
// 检测到耳机出仓的系统时间
// static u32 user_cur_check_io_is_high_time = 0;
static void user_udelay(u32 usec)
{
JL_TIMER0->CON = BIT(14);
JL_TIMER0->CNT = 0;
JL_TIMER0->PRD = clk_get("timer") / 1000000L * usec; //1us
JL_TIMER0->CON = BIT(0) | BIT(2) | BIT(6); //sys clk
while ((JL_TIMER0->CON & BIT(15)) == 0);
JL_TIMER0->CON = BIT(14);
}
// 检测到耳机出仓的处理回调
static void user_check_pp0_io_status_hdl(void)
{
printf("%s\n", __func__);
// user_cur_check_io_is_high_time = jiffies_msec();
// syscfg_write(VM_TEST_OUT_BOX, &user_cur_check_io_is_high_time, sizeof(user_cur_check_io_is_high_time));
lp_touch_key_reinit();
}
// 删除检测定时器
void user_check_pp0_io_status_timer_del(void)
{
printf("user_check_pp0_io_status_timer_del\n");
if (user_check_pp0_io_status_timer) {
sys_timer_del(user_check_pp0_io_status_timer);
user_check_pp0_io_status_timer = 0;
}
}
#define USER_CHECK_PP0_HIGH 1 //不在仓
#define USER_CHECK_PP0_LOW 0 // 在仓
// 耳机是否在仓的状态标志
static u8 user_ear_is_inbox_last = USER_CHECK_PP0_HIGH;
// 检测PP0是否高电平
static void user_check_pp0_io_status(void *p)
{
int err;
int msg[2];
int i = 0;
u8 user_check_pp0_is_high_cnt = 0;
JL_PORTP->PU |= BIT(0);
for (i = 0; i < 5; i++) {
user_udelay(20);
printf("JL_PORTP->IN = %d\n", JL_PORTP->IN & BIT(0));
if (JL_PORTP->IN & BIT(0)) {
user_check_pp0_is_high_cnt++;
}
}
JL_PORTP->PU &= ~BIT(0);
if (user_check_pp0_is_high_cnt >= 3) {
if (user_ear_is_inbox_last == USER_CHECK_PP0_LOW) {
msg[0] = (int)user_check_pp0_io_status_hdl;
msg[1] = 0;
err = os_taskq_post_type("app_core", Q_CALLBACK, 2, msg);
}
// user_check_pp0_io_status_timer_del();
user_ear_is_inbox_last = USER_CHECK_PP0_HIGH;
} else {
user_ear_is_inbox_last = USER_CHECK_PP0_LOW;
}
}
// 检测函数入口
void user_check_ear_is_inbox(void)
{
printf("user_check_ear_is_inbox\n");
// return;
JL_PORTP->PU |= BIT(0);
u8 user_check_pp0_is_high_cnt = 0;
int i = 0;
for (i = 0; i < 5; i++) {
user_udelay(20);
printf("JL_PORTP->IN = %d\n", JL_PORTP->IN & BIT(0));
if (JL_PORTP->IN & BIT(0)) {
user_check_pp0_is_high_cnt++;
}
}
JL_PORTP->PU &= ~BIT(0);
if (user_check_pp0_is_high_cnt >= 3) {
user_ear_is_inbox_last = USER_CHECK_PP0_HIGH;
// user_cur_check_io_is_high_time = jiffies_msec();
// syscfg_write(VM_TEST_OUT_BOX, &user_cur_check_io_is_high_time, sizeof(user_cur_check_io_is_high_time));
return;
} else {
user_ear_is_inbox_last = USER_CHECK_PP0_LOW;
}
if (user_check_pp0_io_status_timer) {
sys_timer_del(user_check_pp0_io_status_timer);
}
user_check_pp0_io_status_timer = sys_timer_add(NULL ,user_check_pp0_io_status, 1000);
}




