Software APIs
sw
device
lib
testing
usb_testutils_simpleserial.h
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
5
#ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_USB_TESTUTILS_SIMPLESERIAL_H_
6
#define OPENTITAN_SW_DEVICE_LIB_TESTING_USB_TESTUTILS_SIMPLESERIAL_H_
7
8
#include <
stddef.h
>
9
#include <
stdint.h
>
10
11
#include "
sw/device/lib/dif/dif_usbdev.h
"
12
#include "sw/device/lib/testing/usb_testutils.h"
13
14
// This is only here because caller of _init needs it
15
typedef
struct
usb_testutils_ss_ctx
{
16
usb_testutils_ctx_t
*ctx;
17
uint8_t ep;
18
bool
sending;
19
dif_usbdev_buffer_t
cur_buf;
20
int
cur_cpos;
21
union
usb_ss_b2w
{
22
uint32_t data_w;
23
uint8_t data_b[4];
24
} chold;
25
void (*got_byte)(uint8_t);
26
}
usb_testutils_ss_ctx_t
;
27
28
/**
29
* Send a byte on a simpleserial endpoint
30
*
31
* @param ssctx instance context
32
* @param c byte to send
33
* @return `kOk(res)` Where `res` is true if the character was accepted for
34
* transmission
35
*/
36
OT_WARN_UNUSED_RESULT
37
status_t
usb_testutils_simpleserial_send_byte(
usb_testutils_ss_ctx_t
*ssctx,
38
uint8_t c);
39
40
/**
41
* Initialize a simpleserial endpoint
42
*
43
* @param ssctx unintialized simpleserial instance context
44
* @param ctx initialized usbdev context
45
* @param ep endpoint number for this instance
46
* @param got_byte callback function for when a byte is received
47
* @return The result of the operation
48
*/
49
OT_WARN_UNUSED_RESULT
50
status_t
usb_testutils_simpleserial_init(
usb_testutils_ss_ctx_t
*ssctx,
51
usb_testutils_ctx_t
*ctx, uint8_t ep,
52
void
(*got_byte)(uint8_t));
53
54
#endif
// OPENTITAN_SW_DEVICE_LIB_TESTING_USB_TESTUTILS_SIMPLESERIAL_H_
Return to
OpenTitan Documentation