/* communication interface reset function, should enable EP, but we do not use this interrupt EP so not enable it */ void USB_Acm_CommIf_Reset(void) { g_UsbACM.intrpipe = &g_UsbACM.comm_ep_intr_info->ep_status.epin_status; /*Non-DMA*/ USB_TxEPEn(g_UsbACM.intrpipe->byEP, KAL_FALSE); }
/* data interface reset function, enable EP*/ void USB_Acm_DataIf_Reset(void) { g_UsbACM.txpipe = &g_UsbACM.data_ep_in_info->ep_status.epin_status; g_UsbACM.rxpipe = &g_UsbACM.data_ep_out_info->ep_status.epout_status; /*DMA*/ USB_TxEPEn(g_UsbACM.data_ep_in_info->ep_status.epin_status.byEP, KAL_TRUE); /*Non-DMA*/ USB_RxEPEn(g_UsbACM.data_ep_out_info->ep_status.epout_status.byEP, KAL_FALSE); if((g_UsbACM.send_UARTilm == KAL_TRUE)&&(USB2UARTPort.ownerid != MOD_DRV_HISR)) { g_UsbACM.send_UARTilm = KAL_FALSE; USB_Send_Msg(USB_SEND_MSG_UART_PLUG_OUT, 0, KAL_TRUE); } }
/* open USB2UART port , actually port is no use because only support one USB port */ static kal_bool USB2UART_open(UART_PORT port, module_type owner) { #ifndef __USB_ENABLE__ ASSERT(0); #endif if(g_UsbACM.acm_owner == USB_ACM_OWNER_DSP) { ASSERT(0); } if(g_UsbACM.acm_owner == USB_ACM_OWNER_FT) { #ifdef __USB_DOWNLOAD__ if(gUsbDevice.is_usb_download_mode == KAL_FALSE) ASSERT(0); #else ASSERT(0); #endif } /* It cannot be opened if uart owner did not close it before */ if(USB2UARTPort.ownerid != MOD_DRV_HISR) { return KAL_FALSE; } #ifndef __PRODUCTION_RELEASE__ if(INT_Exception_Enter != 0) { drv_trace0(TRACE_FUNC, USBACM_OPEN); // kal_prompt_trace(MOD_USB, "USB Open"); } #endif /* __PRODUCTION_RELEASE__ */ USB2UARTPort.initialized = KAL_TRUE; USB2UARTPort.ownerid = owner; g_UsbACM.send_Txilm = KAL_FALSE; g_UsbACM.send_Rxilm = KAL_TRUE; if(INT_Exception_Enter != 0) { drv_trace1(TRACE_FUNC, USBACM_OPEN_READY_TO_READ_FLAG, owner); // kal_prompt_trace(MOD_USB, "open RDY R %d", owner); } g_UsbACM.config_send_Txilm = KAL_FALSE; g_UsbACM.threshold_enable = KAL_FALSE; if( (USB2UARTPort.RingBuffers.rx_buffer==NULL) || (USB2UARTPort.RingBuffers.tx_buffer==NULL) || (USB2UARTPort.RingBuffers.txISR_buffer==NULL) ) { EXT_ASSERT(0, (kal_uint32)USB2UARTPort.RingBuffers.rx_buffer, (kal_uint32)USB2UARTPort.RingBuffers.tx_buffer, (kal_uint32)USB2UARTPort.RingBuffers.txISR_buffer); } Buf_init(&(USB2UARTPort.Rx_Buffer),(kal_uint8 *)(USB2UARTPort.RingBuffers.rx_buffer), g_UsbACM.acm_param->rx_ringbuff_size); Buf_init(&(USB2UARTPort.Tx_Buffer),(kal_uint8 *)(USB2UARTPort.RingBuffers.tx_buffer), g_UsbACM.acm_param->tx_ringbuff_size); Buf_init(&(USB2UARTPort.Tx_Buffer_ISR),(kal_uint8 *)(USB2UARTPort.RingBuffers.txISR_buffer), g_UsbACM.acm_param->txisr_ringbuff_size); if(g_UsbACM.ring_buffer_timer_counting == KAL_TRUE) { GPTI_StopItem(g_UsbACM.ring_buffer_handle); g_UsbACM.ring_buffer_timer_counting = KAL_FALSE; } if ((gUsbDevice.device_type == USB_CDC_ACM)&&(gUsbDevice.nDevState==DEVSTATE_CONFIG)) { /* Only out EP needs to be enabled since IN EP will use DMA polling*/ USB_TxEPEn(g_UsbACM.txpipe->byEP, KAL_TRUE); USB_RxEPEn(g_UsbACM.rxpipe->byEP, KAL_FALSE); USB_Set_UnMask_Irq(KAL_TRUE); } return KAL_TRUE; }