lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | // 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 Sota | 960fd8e | 2020-01-14 13:52:13 -0500 | [diff] [blame] | 5 | #ifndef OPENTITAN_SW_DEVICE_LIB_USB_SIMPLESERIAL_H_ |
| 6 | #define OPENTITAN_SW_DEVICE_LIB_USB_SIMPLESERIAL_H_ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 7 | |
Miguel Young de la Sota | f225d99 | 2019-12-17 10:19:22 -0600 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
Miguel Young de la Sota | 9ac2ac8 | 2020-02-03 16:04:50 -0500 | [diff] [blame] | 11 | #include "sw/device/lib/usbdev.h" |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 12 | |
| 13 | // This is only here because caller of _init needs it |
| 14 | typedef 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 Shepard | ae281b6 | 2019-10-17 10:33:33 -0400 | [diff] [blame] | 28 | * |
| 29 | * @param ssctx instance context |
| 30 | * @param c byte to send |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 31 | */ |
| 32 | void usb_simpleserial_send_byte(usb_ss_ctx_t *ssctx, uint8_t c); |
| 33 | |
| 34 | /** |
| 35 | * Initialize a simpleserial endpoint |
| 36 | * |
Tim Shepard | ae281b6 | 2019-10-17 10:33:33 -0400 | [diff] [blame] | 37 | * @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 Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 41 | */ |
| 42 | void 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 Sota | 960fd8e | 2020-01-14 13:52:13 -0500 | [diff] [blame] | 45 | #endif // OPENTITAN_SW_DEVICE_LIB_USB_SIMPLESERIAL_H_ |