blob: 8a81875a01e50f24c4b8c874a420672baaee57cf [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
Miguel Young de la Sota960fd8e2020-01-14 13:52:13 -05005#ifndef OPENTITAN_SW_DEVICE_LIB_USB_SIMPLESERIAL_H_
6#define OPENTITAN_SW_DEVICE_LIB_USB_SIMPLESERIAL_H_
lowRISC Contributors802543a2019-08-31 12:12:56 +01007
Miguel Young de la Sotaf225d992019-12-17 10:19:22 -06008#include <stddef.h>
9#include <stdint.h>
10
Miguel Young de la Sota9ac2ac82020-02-03 16:04:50 -050011#include "sw/device/lib/usbdev.h"
lowRISC Contributors802543a2019-08-31 12:12:56 +010012
13// This is only here because caller of _init needs it
14typedef struct usb_ss_ctx {
15 void *ctx;
16 int ep;
17 int cur_buf;
18 int cur_cpos;
19 union usb_ss_b2w {
20 uint32_t data_w;
21 uint8_t data_b[4];
22 } chold;
23 void (*got_byte)(uint8_t);
24} usb_ss_ctx_t;
25
26/**
27 * Send a byte on a simpleserial endpoint
Tim Shepardae281b62019-10-17 10:33:33 -040028 *
29 * @param ssctx instance context
30 * @param c byte to send
lowRISC Contributors802543a2019-08-31 12:12:56 +010031 */
32void usb_simpleserial_send_byte(usb_ss_ctx_t *ssctx, uint8_t c);
33
34/**
35 * Initialize a simpleserial endpoint
36 *
Tim Shepardae281b62019-10-17 10:33:33 -040037 * @param ssctx unintialized simpleserial instance context
38 * @param ctx initialized usbdev context
39 * @param ep endpoint number for this instance
40 * @param got_byte callback function for when a byte is received
lowRISC Contributors802543a2019-08-31 12:12:56 +010041 */
42void usb_simpleserial_init(usb_ss_ctx_t *ssctx, usbdev_ctx_t *ctx, int ep,
43 void (*got_byte)(uint8_t));
44
Miguel Young de la Sota960fd8e2020-01-14 13:52:13 -050045#endif // OPENTITAN_SW_DEVICE_LIB_USB_SIMPLESERIAL_H_