while(1)
{
if(index == 0)
{
printf("temp=%0.3f\r\n",g_temperature);
Delay_ms(500);
sendData.head = 0x54;
sendData.cmd = 0x58;
sendData.data_len = sizeof(UsbSendData);
sendData.temperature = g_temperature;
sendData.** = g_fTemp;
sendData.exp_freq = g_para_cfg.current_freq;
sendData.exp_time = g_para_cfg.current_pulse;
sendData.current_pulse = g_para_cfg.mh7139_current_value;
sendData.vol_pulse = 0;
sendData.vcsel_state = g_para_cfg.enable;
memcpy(Temp_Buffer, &sendData, sizeof(sendData));
}
if (PrevXferComplete)
{
if(index < sizeof(UsbSendData))
{
Send_Buffer[0] = 0x05;
Send_Buffer[1] = Temp_Buffer[index];
UserToPMABufferCopy(Send_Buffer, ENDP1_TXADDR, 2);
SetEPTxCount(ENDP1, 2);
SetEPTxValid(ENDP1);
index++;
if(index == sizeof(UsbSendData))
{
index = 0;
}
printf(&quot;index = %d\n&quot;,index);
PrevXferComplete = 0;
}
}
}请问下为什么在INDEX==0这里我把延迟加到Delay_ms(500);USB传输就正常,如果更改为Delay_ms(50);或者在 if(index == sizeof(UsbSendData))
{
index = 0;
}
printf(&quot;index = %d\n&quot;,index);增加打印语句USB传输就不正常。 还有HID USB方式是不是不支持应答方式传输数据?
void EP1_IN_Callback(void)
{
PrevXferComplete = 1;} EP1_IN_Callback 什么时候才会被调用? |