本帖最后由 moses1202 于 2016-4-26 11:42 编辑
我用nu-link debug發現其實他能夠動,只是範例程式燒進去根本不能讓PC讀到裝置。以下是USB的code:- /**
- * @brief This function makes USBD module to be ready to use
- *
- * @param[in] param The structure of USBD information.
- * @param[in] pfnClassReq USB Class request callback function.
- * @param[in] pfnSetInterface USB Set Interface request callback function.
- *
- * @return None
- *
- * @details This function will enable USB controller, USB PHY transceiver and pull-up resistor of USB_D+ pin. USB PHY will drive SE0 to bus.
- */
- void USBD_Open(const S_USBD_INFO_T *param, CLASS_REQ pfnClassReq, SET_INTERFACE_REQ pfnSetInterface)
- {
- g_usbd_sInfo = param;
- g_usbd_pfnClassRequest = pfnClassReq;
- g_usbd_pfnSetInterface = pfnSetInterface;
- /* get EP0 maximum packet size */
- g_usbd_CtrlMaxPktSize = g_usbd_sInfo->gu8DevDesc[7];
- /* Initial USB engine */
- USBD->ATTR = 0x7D0;
- /* Force SE0 */
- USBD_SET_SE0();
- }
- /**
- * @brief This function makes USB host to recognize the device
- *
- * @param None
- *
- * @return None
- *
- * @details Enable WAKEUP, FLDET, USB and BUS interrupts. Disable software-disconnect function after 100ms delay with SysTick timer.
- */
- void USBD_Start(void)
- {
- CLK_SysTickDelay(100000);
- /* Disable software-disconnect function */
- USBD_CLR_SE0();
- /* Clear USB-related interrupts before enable interrupt */
- USBD_CLR_INT_FLAG(USBD_INT_BUS | USBD_INT_USB | USBD_INT_FLDET | USBD_INT_WAKEUP);
- /* Enable USB-related interrupts. */
- USBD_ENABLE_INT(USBD_INT_BUS | USBD_INT_USB | USBD_INT_FLDET | USBD_INT_WAKEUP);
- }
复制代码
在main裡面是這樣叫的:
- USBD_Open(&gsInfo, UAC_ClassRequest, (SET_INTERFACE_REQ)UAC_SetInterface);
- /* Endpoint configuration */
- UAC_Init();
- USBD_Start();
复制代码 請問這段code是否無誤? 因為我燒錄其他firmware進去都是可以讓PC認得裝置的,唯獨nuvoton的範例程式無法。
|