Expose more usbdev_stream methods
- Expose a few methods in USBDevStream that were previously protected.
- Mark the `main` method in the stream_test library as weak, so it can
be overridden by downstream users.
Change-Id: If1254375409a837efb0f4e5e59143cb2dae41d14
diff --git a/sw/host/tests/usbdev/usbdev_stream/stream_test.cc b/sw/host/tests/usbdev/usbdev_stream/stream_test.cc
index 0b042a6..5fcae50 100644
--- a/sw/host/tests/usbdev/usbdev_stream/stream_test.cc
+++ b/sw/host/tests/usbdev/usbdev_stream/stream_test.cc
@@ -482,6 +482,7 @@
return 0;
}
+__attribute__((weak))
int main(int argc, char *argv[]) {
const uint16_t kVendorID = 0x18d1u;
const uint16_t kProductID = 0x503au;
diff --git a/sw/host/tests/usbdev/usbdev_stream/usbdev_stream.h b/sw/host/tests/usbdev/usbdev_stream/usbdev_stream.h
index 9012422..d722d42 100644
--- a/sw/host/tests/usbdev/usbdev_stream/usbdev_stream.h
+++ b/sw/host/tests/usbdev/usbdev_stream/usbdev_stream.h
@@ -176,6 +176,26 @@
}
}
+ /**
+ * Add the specified number of bytes to the circular buffer; if `data` is NULL
+ * then the bytes shall already be present in the buffer and copying is not
+ * performed.
+ *
+ * @param data The data to be added to the buffer, or NULL
+ * @param len The number of bytes to be added.
+ * @return The success of the operation.
+ */
+ bool AddData(const uint8_t *data, uint32_t len);
+ /**
+ * Returns the amount of contiguous free space available in the buffer,
+ * and optionally a pointer to the start of the free space.
+ *
+ * @param space Receives the pointer to the start of the free space,
+ * or NULL iff pointer not required.
+ * @return The contiguous free space available (in bytes).
+ */
+ uint32_t SpaceAvailable(uint8_t **space);
+
protected:
/**
* Provision the given number of bytes of contiguous space,
@@ -188,25 +208,6 @@
*/
bool ProvisionSpace(uint8_t **space, uint32_t len);
/**
- * Returns the amount of contiguous free space available in the buffer,
- * and optionally a pointer to the start of the free space.
- *
- * @param space Receives the pointer to the start of the free space,
- * or NULL iff pointer not required.
- * @return The contiguous free space available (in bytes).
- */
- uint32_t SpaceAvailable(uint8_t **space);
- /**
- * Add the specified number of bytes to the circular buffer; if `data` is NULL
- * then the bytes shall already be present in the buffer and copying is not
- * performed.
- *
- * @param data The data to be added to the buffer, or NULL
- * @param len The number of bytes to be added.
- * @return The success of the operation.
- */
- bool AddData(const uint8_t *data, uint32_t len);
- /**
* Record that the specified number of bytes have been added to the circular
* buffer. The space must already have provisioned and the data bytes shall
* already be in the buffer.