Lines Matching refs:dev_state

146 static struct usb_dc_state dev_state;  variable
174 if (dev_state.dev_struct.controllerHandle != NULL) { in usb_dc_reset()
175 dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_reset()
176 dev_state.dev_struct.controllerHandle, in usb_dc_reset()
187 dev_state.eps = &s_ep_ctrl[0]; in usb_dc_attach()
188 if (dev_state.attached) { in usb_dc_attach()
193 dev_state.dev_struct.controllerInterface = &mcux_usb_iface; in usb_dc_attach()
194 status = dev_state.dev_struct.controllerInterface->deviceInit(CONTROLLER_ID, in usb_dc_attach()
195 &dev_state.dev_struct, in usb_dc_attach()
196 &dev_state.dev_struct.controllerHandle); in usb_dc_attach()
204 dev_state.attached = true; in usb_dc_attach()
205 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_attach()
206 dev_state.dev_struct.controllerHandle, in usb_dc_attach()
218 if (dev_state.dev_struct.controllerHandle == NULL) { in usb_dc_detach()
223 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_detach()
224 dev_state.dev_struct.controllerHandle, in usb_dc_detach()
231 status = dev_state.dev_struct.controllerInterface->deviceDeinit( in usb_dc_detach()
232 dev_state.dev_struct.controllerHandle); in usb_dc_detach()
237 dev_state.dev_struct.controllerHandle = NULL; in usb_dc_detach()
238 dev_state.attached = false; in usb_dc_detach()
248 dev_state.dev_struct.deviceAddress = addr; in usb_dc_set_address()
249 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_set_address()
250 dev_state.dev_struct.controllerHandle, in usb_dc_set_address()
252 &dev_state.dev_struct.deviceAddress); in usb_dc_set_address()
282 struct usb_ep_ctrl_data *eps = &dev_state.eps[ep_abs_idx]; in usb_dc_ep_configure()
296 if (dev_state.eps[ep_abs_idx].ep_enabled) { in usb_dc_ep_configure()
302 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_ep_configure()
303 dev_state.dev_struct.controllerHandle, in usb_dc_ep_configure()
332 dev_state.eps[ep_abs_idx].ep_mps = cfg->ep_mps; in usb_dc_ep_configure()
333 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_ep_configure()
334 dev_state.dev_struct.controllerHandle, in usb_dc_ep_configure()
347 dev_state.eps[ep_abs_idx].ep_occupied = true; in usb_dc_ep_configure()
349 dev_state.eps[ep_abs_idx].ep_enabled = true; in usb_dc_ep_configure()
365 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_ep_set_stall()
366 dev_state.dev_struct.controllerHandle, in usb_dc_ep_set_stall()
387 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_ep_clear_stall()
388 dev_state.dev_struct.controllerHandle, in usb_dc_ep_clear_stall()
397 status = dev_state.dev_struct.controllerInterface->deviceRecv( in usb_dc_ep_clear_stall()
398 dev_state.dev_struct.controllerHandle, ep, in usb_dc_ep_clear_stall()
399 (uint8_t *)dev_state.eps[ep_abs_idx].block, in usb_dc_ep_clear_stall()
400 (uint32_t)dev_state.eps[ep_abs_idx].ep_mps); in usb_dc_ep_clear_stall()
406 dev_state.eps[ep_abs_idx].ep_occupied = true; in usb_dc_ep_clear_stall()
430 status = dev_state.dev_struct.controllerInterface->deviceControl( in usb_dc_ep_is_stalled()
431 dev_state.dev_struct.controllerHandle, in usb_dc_ep_is_stalled()
466 if (dev_state.eps[ep_abs_idx].ep_occupied) { in usb_dc_ep_enable()
473 status = dev_state.dev_struct.controllerInterface->deviceRecv( in usb_dc_ep_enable()
474 dev_state.dev_struct.controllerHandle, ep, in usb_dc_ep_enable()
475 (uint8_t *)dev_state.eps[ep_abs_idx].block, in usb_dc_ep_enable()
476 (uint32_t)dev_state.eps[ep_abs_idx].ep_mps); in usb_dc_ep_enable()
482 dev_state.eps[ep_abs_idx].ep_occupied = true; in usb_dc_ep_enable()
488 dev_state.eps[ep_abs_idx].ep_occupied = true; in usb_dc_ep_enable()
504 if (dev_state.dev_struct.controllerHandle != NULL) { in usb_dc_ep_disable()
505 status = dev_state.dev_struct.controllerInterface->deviceCancel( in usb_dc_ep_disable()
506 dev_state.dev_struct.controllerHandle, in usb_dc_ep_disable()
514 dev_state.eps[ep_abs_idx].ep_enabled = false; in usb_dc_ep_disable()
515 dev_state.eps[ep_abs_idx].ep_occupied = false; in usb_dc_ep_disable()
557 buffer = (uint8_t *)dev_state.eps[ep_abs_idx].block; in usb_dc_ep_write()
559 if (data_len > dev_state.eps[ep_abs_idx].ep_mps) { in usb_dc_ep_write()
560 len_to_send = dev_state.eps[ep_abs_idx].ep_mps; in usb_dc_ep_write()
573 status = dev_state.dev_struct.controllerInterface->deviceSend( in usb_dc_ep_write()
574 dev_state.dev_struct.controllerHandle, in usb_dc_ep_write()
597 dev_state.setup_data_stage = SETUP_DATA_STAGE_DONE; in update_control_stage()
599 dev_state.setup_data_stage = SETUP_DATA_STAGE_IN; in update_control_stage()
601 dev_state.setup_data_stage = SETUP_DATA_STAGE_OUT; in update_control_stage()
604 if (dev_state.setup_data_stage != SETUP_DATA_STAGE_DONE) { in update_control_stage()
606 (data_len < dev_state.eps[0].ep_mps)) { in update_control_stage()
607 dev_state.setup_data_stage = SETUP_DATA_STAGE_DONE; in update_control_stage()
620 if (dev_state.eps[ep_abs_idx].ep_occupied) { in usb_dc_ep_read_wait()
641 bufp = dev_state.eps[ep_abs_idx].transfer_message.buffer; in usb_dc_ep_read_wait()
642 data_len = dev_state.eps[ep_abs_idx].transfer_message.length; in usb_dc_ep_read_wait()
676 update_control_stage(&dev_state.eps[0].transfer_message, in usb_dc_ep_read_wait()
694 if (dev_state.eps[ep_abs_idx].ep_occupied) { in usb_dc_ep_read_continue()
700 if (dev_state.setup_data_stage == SETUP_DATA_STAGE_DONE) { in usb_dc_ep_read_continue()
704 if (dev_state.setup_data_stage == SETUP_DATA_STAGE_IN) { in usb_dc_ep_read_continue()
705 dev_state.setup_data_stage = SETUP_DATA_STAGE_DONE; in usb_dc_ep_read_continue()
709 status = dev_state.dev_struct.controllerInterface->deviceRecv( in usb_dc_ep_read_continue()
710 dev_state.dev_struct.controllerHandle, ep, in usb_dc_ep_read_continue()
711 (uint8_t *)dev_state.eps[ep_abs_idx].block, in usb_dc_ep_read_continue()
712 dev_state.eps[ep_abs_idx].ep_mps); in usb_dc_ep_read_continue()
718 dev_state.eps[ep_abs_idx].ep_occupied = true; in usb_dc_ep_read_continue()
752 if (!dev_state.attached) { in usb_dc_ep_set_callback()
755 dev_state.eps[ep_abs_idx].callback = cb; in usb_dc_ep_set_callback()
762 dev_state.status_cb = cb; in usb_dc_set_status_callback()
774 return dev_state.eps[ep_abs_idx].ep_mps; in usb_dc_ep_mps()
783 dev_state.dev_struct.deviceAddress = 0; in handle_bus_reset()
784 status = dev_state.dev_struct.controllerInterface->deviceControl( in handle_bus_reset()
785 dev_state.dev_struct.controllerHandle, in handle_bus_reset()
792 dev_state.eps[i].ep_occupied = false; in handle_bus_reset()
793 dev_state.eps[i].ep_enabled = false; in handle_bus_reset()
802 dev_state.eps[ep_abs_idx].ep_mps = USB_CONTROL_EP_MPS; in handle_bus_reset()
804 status = dev_state.dev_struct.controllerInterface->deviceControl( in handle_bus_reset()
805 dev_state.dev_struct.controllerHandle, in handle_bus_reset()
811 dev_state.eps[ep_abs_idx].ep_occupied = false; in handle_bus_reset()
812 dev_state.eps[ep_abs_idx].ep_enabled = true; in handle_bus_reset()
816 dev_state.eps[ep_abs_idx].ep_mps = USB_CONTROL_EP_MPS; in handle_bus_reset()
817 status = dev_state.dev_struct.controllerInterface->deviceControl( in handle_bus_reset()
818 dev_state.dev_struct.controllerHandle, in handle_bus_reset()
824 dev_state.eps[ep_abs_idx].ep_occupied = false; in handle_bus_reset()
825 dev_state.eps[ep_abs_idx].ep_enabled = true; in handle_bus_reset()
835 dev_state.eps[ep_abs_idx].ep_occupied = false; in handle_transfer_msg()
850 if ((dev_state.dev_struct.deviceAddress != 0) && (ep_abs_idx == 1)) { in handle_transfer_msg()
855 status = dev_state.dev_struct.controllerInterface->deviceControl( in handle_transfer_msg()
856 dev_state.dev_struct.controllerHandle, in handle_transfer_msg()
858 &dev_state.dev_struct.deviceAddress); in handle_transfer_msg()
863 dev_state.dev_struct.deviceAddress = 0; in handle_transfer_msg()
873 if (dev_state.eps[ep_abs_idx].callback) { in handle_transfer_msg()
880 dev_state.eps[ep_abs_idx].callback(ep, ep_status_code); in handle_transfer_msg()
906 dev_state.status_cb(USB_DC_RESET, NULL); in usb_mcux_thread_main()
909 dev_state.status_cb(USB_DC_ERROR, NULL); in usb_mcux_thread_main()
912 dev_state.status_cb(USB_DC_SUSPEND, NULL); in usb_mcux_thread_main()
915 dev_state.status_cb(USB_DC_RESUME, NULL); in usb_mcux_thread_main()
925 memcpy(&dev_state.eps[ep_abs_idx].transfer_message, &msg, in usb_mcux_thread_main()
927 handle_transfer_msg(&dev_state.eps[ep_abs_idx].transfer_message); in usb_mcux_thread_main()
944 USB_DeviceEhciIsrFunction(&dev_state); in usb_isr_handler()
946 USB_DeviceLpcIp3511IsrFunction(&dev_state); in usb_isr_handler()
954 k_thread_create(&dev_state.thread, dev_state.thread_stack, in usb_mcux_init()
958 k_thread_name_set(&dev_state.thread, "usb_mcux"); in usb_mcux_init()