看一下发送CMD的过程
./driver/storage/sim/src/icc_switchControl_mtk_0.c
-
L1sim_Cmd_Layer_MTK
-
{
-
//调用L1Sim_Cmd发送select命令,返回值 status=(0x61,0x19)
-
status = L1sim_Cmd(tx, (kal_uint16)*txSize, rxData, (kal_uint16*)rxSize, &error, hw_cb);
-
if((sw1 == gp)) //若sw1==0x61则说明需要getResponse
-
{
-
//合成getResponse命令并发送
-
tx = sim_get_resp_sim;{0x00, 0xc0, 0x00, 0x00, 0x00 }
-
*rxSize = sw2; //要接收的size就是刚才返回值的sw2
-
//接收到的数据放在rxData中
-
status = L1sim_Cmd(tx, LEN_OF_CMD, rxData, (kal_uint16*)rxSize, &error, hw_cb);
-
}
-
}
L1sim_Cmd_Layer_MTK
-->L1sim_Cmd()
-
L1sim_Cmd()
-
{
-
//这个函数只是重新封装了一下SIM_CMD:
-
//为了防止出错,最大重复发送三次SIM_CMD
-
//当Eroro==KAL_TRUE时会重复发送SIM_CMD
-
SW = SIM_CMD((kal_uint8 *)pNoncachedTx,txSize,(kal_uint8 *)pNoncachedRx,rcvSize,Error, hw_cb);
-
//其中返回值SW就是过程状态字段SW1与SW2
-
}
L1sim_Cmd_Layer_MTK
-->L1sim_Cmd()
-->SIM_CMD
-
SIM_CMD(kal_uint8 *txData,kal_uint16 txSize,kal_uint8 *result,kal_uint16 *rcvSize, kal_uint8 *Error, sim_HW_cb *hw_cb)
-
{
-
//txData-->要发送的数据,txSize-->要发送的数据长度
-
//
-
//返回值是SW过程状态字段
-
-
//以select[ 00 a4 08 04 02 2f 05 ]为例说明TE向SIM卡发数据的过程
-
//第1步先发5个字节:00 a4 08 04 02
-
for(index=0;index<5;index++)
-
{
-
SIM_WriteReg(SIM0_BASE_ADDR_MTK + SIM_DATA_MTK,*(txData+index));
-
}
-
sim_addMsg(SIM_CMD_TX_LOG, *(txData + 1), *(txData + 4), SIM_Reg(SIM0_BASE_ADDR_MTK + SIM_COUNT_MTK));
-
//第2步关闭DMA并设当前状态为IDLE
-
DMA_Stop(SimCard->sim_dmaport);
-
SIM_SetRXTIDE(1, hw_cb);
-
-
//第3步根据参数expSize来判断需不需要接收数据来设置DMA的状态
-
if (expSize == 0) //若为0,说明不需要接收数据
-
{
-
SIM_SetTXTIDE(0, hw_cb);
-
SimCard->sim_menu.addr = (kal_uint32)(txaddr+5);
-
SimCard->sim_input.type = DMA_HWTX;
-
SimCard->sim_input.count = txSize-5; //只需要把剩余的字符2f 05发送即可
-
if(SimCard->sim_input.count > SIM_TX_DELAY_LEN && SimCard->Speed > Speed372)
-
txDelay = KAL_TRUE;
-
SimCard->sim_input.callback = NULL;
-
INS |= SIM_INS_INSD;
-
}
-
else //若不为0,说明需要接收数据
-
{ //需要接收数据的命令长度为5,在第1次己经发送完成,
-
//只需接收即可,如(GetResponse:00 c0 00 00 19)
-
SIM_SetTXTIDE(0xffff, hw_cb);
-
SimCard->sim_menu.addr = (kal_uint32)(rxaddr); /*1*/
-
SimCard->sim_input.type = DMA_HWRX; /*2*/
-
SimCard->sim_input.count = expSize; /*3*/
-
SimCard->sim_input.callback = NULL; /*4*/
-
}
-
//设置DMA的状态
-
DMA_Config(SimCard->sim_dmaport, &SimCard->sim_input, KAL_FALSE);
-
-
-
//第4步,设置好状态后执行Run来发送数据
-
DMA_Run(SimCard->sim_dmaport);
-
//第5步,DMA发送完成后执行DMA_STOP
-
DMA_Stop(SimCard->sim_dmaport);
-
-
//第6步,若需要接收数据接收到的数据都放在SimCard->sim_menu.addr中
-
//即值参数result中
-
rxaddr = (kal_uint32)result; //几次指针的赋值,这几个addr都是一个东东
-
SimCard->sim_menu.addr = (kal_uint32)(rxaddr);
-
//第7步,获取SW并返回
-
SIM_ObtainSW(SW);
-
}
阅读(1646) | 评论(0) | 转发(0) |