summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-09-10 17:41:20 +0700
committerhathach <[email protected]>2024-09-10 17:41:20 +0700
commitcc816dc9c04762f14468a0b7b1826768e731f53f (patch)
tree827540f82b0d768b2ce72ff6c52d7100defafcec /src/common
parentc0030810dda8d9cca9cd041f246180ff03dc6624 (diff)
change edpt stream api to take hwid from API to reduce memory footprint
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_private.h25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/common/tusb_private.h b/src/common/tusb_private.h
index ef0d5315e..71a395c79 100644
--- a/src/common/tusb_private.h
+++ b/src/common/tusb_private.h
@@ -42,14 +42,11 @@ typedef struct TU_ATTR_PACKED
}tu_edpt_state_t;
typedef struct {
- bool is_host; // host or device
- union {
- uint8_t daddr; // host mode
- uint8_t rhport; // device mode
- uint8_t hwid;
+ struct {
+ uint8_t is_host : 1; // host or device
+ uint8_t is_highspeed: 1; // is highspeed
};
uint8_t ep_addr;
- uint8_t ep_speed;
uint16_t ep_packetsize;
uint16_t ep_bufsize;
@@ -97,16 +94,14 @@ bool tu_edpt_stream_deinit(tu_edpt_stream_t* s);
// Open an stream for an endpoint
// hwid is either device address (host mode) or rhport (device mode)
TU_ATTR_ALWAYS_INLINE static inline
-void tu_edpt_stream_open(tu_edpt_stream_t* s, uint8_t hwid, tusb_desc_endpoint_t const *desc_ep) {
+void tu_edpt_stream_open(tu_edpt_stream_t* s, tusb_desc_endpoint_t const *desc_ep) {
tu_fifo_clear(&s->ff);
- s->hwid = hwid;
s->ep_addr = desc_ep->bEndpointAddress;
s->ep_packetsize = tu_edpt_packet_size(desc_ep);
}
TU_ATTR_ALWAYS_INLINE static inline
void tu_edpt_stream_close(tu_edpt_stream_t* s) {
- s->hwid = 0;
s->ep_addr = 0;
}
@@ -121,27 +116,27 @@ bool tu_edpt_stream_clear(tu_edpt_stream_t* s) {
//--------------------------------------------------------------------+
// Write to stream
-uint32_t tu_edpt_stream_write(tu_edpt_stream_t* s, void const *buffer, uint32_t bufsize);
+uint32_t tu_edpt_stream_write(uint8_t hwid, tu_edpt_stream_t* s, void const *buffer, uint32_t bufsize);
// Start an usb transfer if endpoint is not busy
-uint32_t tu_edpt_stream_write_xfer(tu_edpt_stream_t* s);
+uint32_t tu_edpt_stream_write_xfer(uint8_t hwid, tu_edpt_stream_t* s);
// Start an zero-length packet if needed
-bool tu_edpt_stream_write_zlp_if_needed(tu_edpt_stream_t* s, uint32_t last_xferred_bytes);
+bool tu_edpt_stream_write_zlp_if_needed(uint8_t hwid, tu_edpt_stream_t* s, uint32_t last_xferred_bytes);
// Get the number of bytes available for writing to FIFO
// Note: if no fifo, return endpoint size if not busy, 0 otherwise
-uint32_t tu_edpt_stream_write_available(tu_edpt_stream_t* s);
+uint32_t tu_edpt_stream_write_available(uint8_t hwid, tu_edpt_stream_t* s);
//--------------------------------------------------------------------+
// Stream Read
//--------------------------------------------------------------------+
// Read from stream
-uint32_t tu_edpt_stream_read(tu_edpt_stream_t* s, void* buffer, uint32_t bufsize);
+uint32_t tu_edpt_stream_read(uint8_t hwid, tu_edpt_stream_t* s, void* buffer, uint32_t bufsize);
// Start an usb transfer if endpoint is not busy
-uint32_t tu_edpt_stream_read_xfer(tu_edpt_stream_t* s);
+uint32_t tu_edpt_stream_read_xfer(uint8_t hwid, tu_edpt_stream_t* s);
// Must be called in the transfer complete callback
TU_ATTR_ALWAYS_INLINE static inline