Exemple #1
0
void
dfu_init(const struct usbd_function *f, int enable)
{
        const struct dfu_function *dfuf = (void *)f;
        struct dfu_ctx *ctx = dfuf->ctx;

        if (enable) {
                ctx->dfuf = dfuf;
                ctx->state = DFU_STATE_dfuIDLE;
                usb_attach_function(&dfuf->func, &ctx->header);
        }
}
Exemple #2
0
void
hid_init(const struct usbd_function *f, int enable)
{
    const struct hid_function *hidf = (void *)f;
    struct hid_ctx *ctx = hidf->ctx;

    if (enable) {
        ctx->hidf = hidf;
        usb_attach_function(&hidf->usb_func, &ctx->header);
        if (hidf->report_max_size > 0)
            ctx->tx_pipe = usb_init_ep(&ctx->header, HID_TX_EP, USB_EP_TX, hidf->report_max_size);
    }
}
Exemple #3
0
void
cdc_init(void (*data_ready_cb)(uint8_t *, size_t), void (*data_sent_cb)(size_t), struct cdc_ctx *ctx)
{
  usb_attach_function(&cdc_function, &ctx->header);
  ctx->data_ready_cb = data_ready_cb;
  ctx->data_sent_cb = data_sent_cb;
  ctx->out_queued = 0;
  ctx->notice_pipe = usb_init_ep(&ctx->header, CDC_NOTICE_EP, USB_EP_TX, CDC_NOTICE_SIZE);
  ctx->tx_pipe = usb_init_ep(&ctx->header, CDC_TX_EP, USB_EP_TX, CDC_TX_SIZE);
  ctx->rx_pipe = usb_init_ep(&ctx->header, CDC_RX_EP, USB_EP_RX, CDC_RX_SIZE);
  cdc_read_more(ctx);
  cdc_tx_done(ctx->outbuf, -1, ctx);
}