/*测试非唤醒源软timer申请和加入链表,在回调函数外删除软timer 超时时间较长*/ s32 st_softtimer_test_case13(void) { s32 ret= 0; my_softtimer.func = for_softtimer_test_1; my_softtimer.para = 123; my_softtimer.timeout = 100; my_softtimer.wake_type=SOFTTIMER_NOWAKE; osl_sem_init(0,&sem1); if (bsp_softtimer_create(&my_softtimer)) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error \n"); } bsp_softtimer_add(&my_softtimer); ret = bsp_softtimer_delete(&my_softtimer); if (ret ==OK) { ret = bsp_softtimer_free(&my_softtimer); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"softtimer_test_6 free error\n"); return ERROR; } } else if(NOT_ACTIVE == ret) { osl_sem_down(&sem1); osl_sema_delete(&sem1); } return ret; }
/***************************************************************************** 函 数 名 : modem_sleeptimer_overhandler 功能描述 : 300ms超时后投睡眠票 输入参数 : BSP_U32 uart_port_addr 输出参数 : 无 返 回 值 : void *****************************************************************************/ void modem_sleeptimer_int(u32 temp) { temp = temp; /* [false alarm]:误报 */ g_dm_dump_info->modem_sleeptimer_cnt++; g_dual_modem_ctrl.wakeup_3rdmodem_flag = DO_WAKEUP_3RD; bsp_softtimer_delete(&g_dual_modem_ctrl.hold_wake_timer); g_dual_modem_ctrl.stop_timer_flag = CPCP_FLASE; wake_unlock(&g_dual_modem_ctrl.wakelock); }
/***************************************************************************** 函 数 名 : uart_core_send 功能描述 : 发送数据 输入参数 : UART_CONSUMER_PORT uPortNo unsigned char * pDataBuffer unsigned int uslength 输出参数 : 无 返 回 值 : int *****************************************************************************/ int uart_core_send(UART_CONSUMER_ID uPortNo, unsigned char * pDataBuffer, unsigned int uslength) { UART_PORT* cur_port = &g_dual_modem_ctrl.uart_port; if(DUAl_MODEM_ENABLE != g_dual_modem_ctrl.init_flag) { dm_print_err("dual modem not init\n"); return ERROR; } cpcp_msg_count_record(&g_dm_dump_info->cbpa_send_cnt, "CbpaSendCnt"); if(NULL == pDataBuffer) { dm_print_err("pDataBuffer is null\n"); return ERROR; } wake_lock(&g_dual_modem_ctrl.wakelock); bsp_softtimer_delete(&g_dual_modem_ctrl.sleep_timer); if(g_dual_modem_ctrl.wakeup_3rdmodem_flag == DO_WAKEUP_3RD) { if(OK != wakeup_via_modem()) { dm_print_err("wakeup err\n"); dual_modem_restart_timer(&g_dual_modem_ctrl.sleep_timer); return ERROR; } (void)osl_sem_downtimeout(&g_dual_modem_ctrl.wait_reply_mutex ,CBP_WAKEUP_DELAY_TIME_MS); } bsp_softtimer_delete(&g_dual_modem_ctrl.hold_wake_timer); cur_port->ops->send(cur_port ,pDataBuffer ,uslength); dual_modem_restart_timer(&g_dual_modem_ctrl.sleep_timer); g_dual_modem_ctrl.wakeup_3rdmodem_flag = NOT_WAKEUP_V3; dual_modem_restart_timer(&g_dual_modem_ctrl.hold_wake_timer); return OK; }
/***************************************************************************** 函 数 名 : modem_wakeup_delay_overhandler 功能描述 : 300ms超时后投睡眠票 输入参数 : BSP_U32 uart_port_addr 输出参数 : 无 返 回 值 : void *****************************************************************************/ void dual_modem_restart_timer(struct softtimer_list * softtimer) { g_dual_modem_ctrl.stop_timer_flag = CPCP_FLASE; bsp_softtimer_delete(softtimer); bsp_softtimer_add(softtimer); }
/***************************************************************************** 函 数 名 : dual_modem_uart_recv_task 功能描述 : 调用回调函数,向上层发送数据 输入参数 : UART_PORT * uart_port_add 端口地址 输出参数 : 无 返 回 值 : void *****************************************************************************/ void dual_modem_uart_recv_task(UART_PORT *uart_port_addr) { s32 ret = 0; volatile u32 ulwrite = 0; volatile u32 this_size = 0; UART_PORT *uart_port = NULL; RECV_STR *recvStr = NULL; recvStr = &g_dual_modem_ctrl.uart_port.circ_buf; if(NULL == uart_port_addr) { dm_print_err("uart_port_addr is null\n"); return ; } uart_port = uart_port_addr; while(1) { osl_sem_down(&g_dual_modem_ctrl.recv_mutex); cpcp_msg_count_record(&g_dm_dump_info->rtask_SemTake_cnt, "RtaskSemTakecnt"); ulwrite = recvStr->ulWrite; bsp_softtimer_delete(&g_dual_modem_ctrl.sleep_timer); dual_modem_restart_timer(&g_dual_modem_ctrl.hold_wake_timer); g_dual_modem_ctrl.wakeup_3rdmodem_flag = NOT_WAKEUP_V3; if(NULL != uart_port->recv_callback) { if(recvStr->ulRead == ulwrite) { dual_modem_restart_timer(&g_dual_modem_ctrl.sleep_timer); continue; } if(recvStr->ulRead < ulwrite) { this_size = ulwrite - recvStr->ulRead; if((g_dm_dump_info->rx_cur_offset + this_size + 4) > DUAL_DUMP_RX_BUFF_SIZE) { g_dm_dump_info->rx_cur_offset = 0; } (void)memcpy_s((void *)(g_dm_dump_info->rx_dump_addr + g_dm_dump_info->rx_cur_offset), sizeof(u32), (void *)&g_dm_dump_info->recv_time_stamp, sizeof(u32)); g_dm_dump_info->rx_cur_offset += 4; (void)memcpy_s((g_dm_dump_info->rx_dump_addr + g_dm_dump_info->rx_cur_offset) ,this_size,(recvStr->ucData + recvStr->ulRead), this_size); g_dm_dump_info->rx_cur_offset += this_size; ret = uart_port->recv_callback(CBP_UART_PORT_ID,(recvStr->ucData + recvStr->ulRead),this_size); /* [false alarm]:误报 */ g_dm_dump_info->rx_cur_size = this_size; g_dm_dump_info->rx_total_size += this_size; if(g_dual_modem_ctrl.log_flag == 1) { dm_debug_print("RecvCurSize %d\n",this_size); dm_print_info((recvStr->ucData + recvStr->ulRead),this_size); } } else { this_size = UART_RECV_BUF_SIZE - recvStr->ulRead; if((g_dm_dump_info->rx_cur_offset + this_size + 4) > DUAL_DUMP_RX_BUFF_SIZE) { g_dm_dump_info->rx_cur_offset = 0; } (void)memcpy_s((void *)(g_dm_dump_info->rx_dump_addr + g_dm_dump_info->rx_cur_offset), sizeof(u32), (void *)&g_dm_dump_info->recv_time_stamp, sizeof(u32)); g_dm_dump_info->rx_cur_offset += 4; (void)memcpy_s((g_dm_dump_info->rx_dump_addr + g_dm_dump_info->rx_cur_offset) ,this_size,(recvStr->ucData + recvStr->ulRead), this_size); g_dm_dump_info->rx_cur_offset += this_size; ret = uart_port->recv_callback(CBP_UART_PORT_ID,(recvStr->ucData + recvStr->ulRead),this_size); /* [false alarm]:误报 */ g_dm_dump_info->rx_cur_size = this_size + ulwrite; g_dm_dump_info->rx_total_size += this_size; if(g_dual_modem_ctrl.log_flag == 1) { dm_debug_print("RecvCurSize %d\n",g_dm_dump_info->rx_cur_size); dm_print_info((recvStr->ucData + recvStr->ulRead),this_size); } if(ulwrite) { this_size = ulwrite; if((g_dm_dump_info->rx_cur_offset + this_size + 4) > DUAL_DUMP_RX_BUFF_SIZE) { g_dm_dump_info->rx_cur_offset = 0; } (void)memcpy_s((void *)(g_dm_dump_info->rx_dump_addr + g_dm_dump_info->rx_cur_offset), sizeof(u32), (void *)&g_dm_dump_info->recv_time_stamp, sizeof(u32)); g_dm_dump_info->rx_cur_offset += 4; (void)memcpy_s((g_dm_dump_info->rx_dump_addr + g_dm_dump_info->rx_cur_offset),this_size ,recvStr->ucData , this_size); g_dm_dump_info->rx_cur_offset += this_size; ret = uart_port->recv_callback(CBP_UART_PORT_ID,recvStr->ucData,this_size); /* [false alarm]:误报 */ g_dm_dump_info->rx_total_size += this_size; if(g_dual_modem_ctrl.log_flag == 1) { dm_print_info(recvStr->ucData,this_size); } } } recvStr->ulRead = ulwrite; if(OK != ret) { dm_print_err("recv error!!\n"); } } else { dm_print_err("callback is null\n"); g_dm_dump_info->callback_fail_cnt++; recvStr->ulRead = ulwrite; } dual_modem_restart_timer(&g_dual_modem_ctrl.sleep_timer); } }