普通高低电平TWS耳机控制通讯
📎 原始文档:https://www.kdocs.cn/l/ce2VnTH2Khzl 普通高低电平TWS耳机控制通讯
应用情况:
有些充电仓是高低电平来通讯的,如下那里提供了一种解决方法。
使用硬件定时器和ldoin的跳变沿中断,采集高低电平的时间,转换为可识别指令。
案例
案例1
【金山文档】 ldoin_commu
https://kdocs.cn/l/cjWA5xfoaBLW
【金山文档】 ldoin_commu
https://kdocs.cn/l/cdeGqZajO8YX
案例2
【金山文档】 ldoin_commu_demo2
https://kdocs.cn/l/crSHgQfeQZ7W
/*
* 收数处理demo
*/
void extern_send_cover_status(u8 state)
{
switch (state)
{
case 0x05:
log_info("open cid\n");
__this->power_status = 1;
__this->cover_status = 1;
__this->close_ing = 0;
if (__this->switch2bt == 0) {
chargestore_event_to_user(NULL, DEVICE_EVENT_CHARGE_STORE, CMD_POWER_LEVEL_OPEN, 0);
}
break;
case 0x06:
log_info("shut down\n");
__this->power_status = 0;
__this->cover_status = 0;
__this->close_ing = 0;
if(__this->shutdown_timer){
sys_hi_timer_del(__this->shutdown_timer);
}
__this->shutdown_timer = sys_hi_timer_add(NULL, chargestore_shutdown_do, 1000);
break;
case 0x0a:
log_info("close cid\n");
__this->power_status = 1;
__this->cover_status = 0;
chargestore_event_to_user(NULL, DEVICE_EVENT_CHARGE_STORE, CMD_CLOSE_CID, 0);
break;
default:
break;
}
}
公共修改点
修改ldoin中断滤波为不滤波

697系列要修改 ldoin_isr_user_comm_deal执行的位置
void ldoin_isr_user_comm_deal(u8 index, u8 gpio, u8 edge);
void sub_wakeup_isr(void)
{
static u8 old_edge = 0xff;
u8 edge = FALLING_EDGE;
if(LDO5V_DET_GET()){
edge = RISING_EDGE;
}
printf(" %s %d\n", __func__, !edge);
if(edge != old_edge){
ldoin_isr_user_comm_deal(0xff, IO_LDOIN_DET, edge);
old_edge = edge;
}
if (__this->ldo5v_timer == 0) {
__this->ldo5v_timer = usr_timer_add(0, ldo5v_detect, 2, 1);
}
}