blob: 52ca8be3fd66284d89260eaf597f750abcc5551f [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef __USB_SIMPLESERIAL_H__
6#define __USB_SIMPLESERIAL_H__
7
8#include "common.h"
9#include "usbdev.h"
10
11// This is only here because caller of _init needs it
12typedef struct usb_ss_ctx {
13 void *ctx;
14 int ep;
15 int cur_buf;
16 int cur_cpos;
17 union usb_ss_b2w {
18 uint32_t data_w;
19 uint8_t data_b[4];
20 } chold;
21 void (*got_byte)(uint8_t);
22} usb_ss_ctx_t;
23
24/**
25 * Send a byte on a simpleserial endpoint
26 * ssctx - instance context
27 * c - byte to send
28 */
29void usb_simpleserial_send_byte(usb_ss_ctx_t *ssctx, uint8_t c);
30
31/**
32 * Initialize a simpleserial endpoint
33 *
34 * ctx - initialized usbdev context
35 * ep - endpoint number for this instance
36 * ssctx - unintialized simpleserial instance context
37 * got_byte - callback function for when a byte is received
38 */
39void usb_simpleserial_init(usb_ss_ctx_t *ssctx, usbdev_ctx_t *ctx, int ep,
40 void (*got_byte)(uint8_t));
41
42#endif