阅读:2760回复:0
关于USB hDevice = OpenByInterface( &ClassGuid, 0, &Error);//
做了一个usb驱动,单片机是LPC2388 ARM7芯片,飞利浦的,ARM程序由Keil的移植到ADS下面,调试后枚举已经成功,用DriverStudio3.2做的驱动程序,驱动程序安装表现也是成功的,用
hDevice = OpenByInterface( &ClassGuid, 0, &Error);//和usb设备接口连接 if (hDevice == INVALID_HANDLE_VALUE) { ShowMessage(" Device not Open"); } else { WriteFile(hDevice, buf, 64, &nWritten,&ol); // doWrite(8); // ReadFile(hDevice, buf, 2, &nWritten, &ol); CloseIfOpen(); } 打开设备后成功,WriteFile(hDevice, buf, 64, &nWritten,&ol); 发数据后nWritten写入的长度返回为0,ARM调试也没有产生中断,下面是ARM的中断函数,枚举时有中断,我调试了,在WriteFile法数据时我在下面加断点,程序中指示的地方,不能产生中断,以我估计应该是计算机的程序问题,但是那都看不出毛病,希望有经验的高手指点一下 void USB_ISR (void) __irq { DWORD disr, val, n, m; disr = DEV_INT_STAT; /* Device Interrupt Status */ DEV_INT_CLR = disr; /* A known issue on LPC214x */ DeviceStatusValue = disr; /* Device Status Interrupt (Reset, Suspend/Resume, Connect change) */ if (disr & DEV_STAT_INT) { DeviceInterruptCount++; WrCmd(CMD_GET_DEV_STAT); val = RdCmdDat(DAT_GET_DEV_STAT); /* Device Status */ if ( val & DEV_RST ) DevStatusReset++; if ( val & DEV_CON_CH ) DevStatusConnectChange++; if ( val & DEV_CON ) DevStatusConnect++; if ( val & DEV_SUS_CH ) { DevStatusSuspendChange++; if ( val & DEV_SUS ) DevStatusSuspend++; else DevStatusResume++; } if (val & DEV_RST) { /* Reset */ USB_Reset(); #if USB_RESET_EVENT USB_Reset_Event(); #endif // goto isr_end; } if (val & DEV_SUS_CH) { /* Suspend/Resume */ if (val & DEV_SUS) { /* Suspend */ USB_Suspend(); #if USB_SUSPEND_EVENT USB_Suspend_Event(); #endif } else { /* Resume */ USB_Resume(); #if USB_RESUME_EVENT USB_Resume_Event(); #endif } // goto isr_end; } if (val & DEV_CON_CH ) { /* Connect change */ #if USB_POWER_EVENT USB_Power_Event(val & DEV_CON); #endif // goto isr_end; } goto isr_end; } #if USB_SOF_EVENT /* Start of Frame Interrupt */ if (disr & FRAME_INT) { USB_SOF_Event(); } #endif #if USB_ERROR_EVENT /* Error Interrupt */ if (disr & ERR_INT) { WrCmd(CMD_RD_ERR_STAT); val = RdCmdDat(DAT_RD_ERR_STAT); USB_Error_Event(val); goto isr_end; } #endif /* Endpoint's Slow Interrupt */ if (disr & EP_SLOW_INT) { while (EP_INT_STAT) { /* Endpoint Interrupt Status */ for (n = 0; n < USB_EP_NUM; n++) { /* Check All Endpoints */ if (EP_INT_STAT & (1 << n)) { m = n >> 1; EP_INT_CLR = 1 << n; while ((DEV_INT_STAT & CDFULL_INT) == 0); val = CMD_DATA; if ((n & 1) == 0) { /* OUT Endpoint */ if (n == 0) { /* Control OUT Endpoint */ if (val & EP_SEL_STP) { /* Setup Packet */ if (USB_P_EP[0]) { USB_P_EP[0](USB_EVT_SETUP); continue; } } } if (USB_P_EP[m]) { USB_P_EP[m](USB_EVT_OUT); }、、、、、、、断点处 } else { /* IN Endpoint */ if (USB_P_EP[m]) { USB_P_EP[m](USB_EVT_IN);。。。。。。。断点处 } } } } } } isr_end: // DEV_INT_CLR = disr; VICVectAddr = 0; /* Acknowledge Interrupt */ return; } |
|