samples/bluetooth/hci_usb/src/main.c
/* EP Bulk OUT handler, used to read the data received from the Host */
EP Bulk OUT handler, used to read the data received from the Host
EP Bulk OUT handler used to read the data received from the Host
static void btusb_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
{
	struct net_buf *buf;
	u32_t len, read = 0;
	u8_t tmp[4];
	SYS_LOG_DBG("ep %x status %d", ep, ep_status);
	usb_read(ep, NULL, 0, &len);
	if (!len || len > BT_BUF_ACL_SIZE) {
		SYS_LOG_ERR("Incorrect length: %u\n", len);
		return;
	}
	buf = net_buf_alloc(&acl_tx_pool, K_NO_WAIT);
	if (!buf) {
		SYS_LOG_ERR("Cannot get free buffer\n");
		return;
	}
	while (len > buf->len) {
		usb_read(ep, tmp, 4, NULL);
		read += 4;
		if (len > read) {
			net_buf_add_mem(buf, tmp, 4);
		} else {
			u8_t remains = 4 - (read - len);
			net_buf_add_mem(buf, tmp, remains);
		}
	}
	hexdump(">", buf->data, buf->len);
	bt_buf_set_type(buf, BT_BUF_ACL_OUT);
	bt_send(buf);
}
static void btusb_bulk_out ( u8_t ep , enum usb_dc_ep_cb_status_code ep_status ) { struct net_buf * buf ; u32_t len , read = 0 ; u8_t tmp [ 4 ] ; SYS_LOG_DBG ( " " , ep , ep_status ) ; usb_read ( ep , NULL , 0 , & len ) ; if ( ! len || len > BT_BUF_ACL_SIZE ) { SYS_LOG_ERR ( " \n " , len ) ; return ; } buf = net_buf_alloc ( & acl_tx_pool , K_NO_WAIT ) ; if ( ! buf ) { SYS_LOG_ERR ( " \n " ) ; return ; } while ( len > buf -> len ) { usb_read ( ep , tmp , 4 , NULL ) ; read += 4 ; if ( len > read ) { net_buf_add_mem ( buf , tmp , 4 ) ; } else { u8_t remains = 4 - ( read - len ) ; net_buf_add_mem ( buf , tmp , remains ) ; } } hexdump ( " " , buf -> data , buf -> len ) ; bt_buf_set_type ( buf , BT_BUF_ACL_OUT ) ; bt_send ( buf ) ; }
EP Bulk OUT handler, used to read the data received from the Host
EP Bulk OUT handler used to read the data received from the Host
/* Read number of butes to read */ /**
	 * Quark SE USB controller is always storing data
	 * in the FIFOs per 32-bit words.
	 */