/** * @brief Triggers IN endpoint transfer. * * @param[in] p_kbd HID keyboard instance. * * @return Standard error code. */ static inline ret_code_t hid_kbd_transfer_set(app_usbd_hid_kbd_t const * p_kbd) { app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_kbd; app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd); nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); app_usbd_hid_state_flag_clr(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); if (!hid_kbd_transfer_next(p_kbd)) { /* Transfer buffer hasn't changed since last transfer. No need to setup * next transfer. * */ return NRF_SUCCESS; } app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd); NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buffer->p_buff, p_rep_buffer->size); ret_code_t ret; CRITICAL_REGION_ENTER(); ret = app_usbd_core_ep_transfer(ep_addr, &transfer); if (ret == NRF_SUCCESS) { app_usbd_hid_state_flag_set(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); } CRITICAL_REGION_EXIT(); return ret; }
ret_code_t app_usbd_audio_class_tx_start( app_usbd_class_inst_t const * p_inst, const void * p_buff, size_t size) { nrf_drv_usbd_ep_t ep_addr; ep_addr = ep_iso_addr_get(p_inst); ASSERT(NRF_USBD_EPISO_CHECK(ep_addr)); NRF_DRV_USBD_TRANSFER_IN(transfer, p_buff, size); return app_usbd_ep_transfer(ep_addr, &transfer); }
ret_code_t app_usbd_cdc_acm_write(app_usbd_cdc_acm_t const * p_cdc_acm, const void * p_buf, size_t length) { app_usbd_class_inst_t const * p_inst = app_usbd_cdc_acm_class_inst_get(p_cdc_acm); app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); bool dtr_state = (p_cdc_acm_ctx->line_state & APP_USBD_CDC_ACM_LINE_STATE_DTR) ? true : false; if (!dtr_state) { /*Port is not opened*/ return NRF_ERROR_INVALID_STATE; } nrf_drv_usbd_ep_t ep = data_ep_in_addr_get(p_inst); NRF_DRV_USBD_TRANSFER_IN(transfer, p_buf, length); return app_usbd_ep_transfer(ep, &transfer); }