summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-09-10 20:39:29 +0700
committerhathach <[email protected]>2024-09-10 20:41:01 +0700
commit9b4bb61cbd1f95d4272c4bf30e843e3807d932d5 (patch)
treebaec4d86621083f3e5d97fa614850ea06e6bbcbd /src
parent7909a6256941d001ae888530080fc572c7410b3b (diff)
ep stream init: wrap with OSAL_MUTEX_REQUIRED, only create fifo mutex if needed
Diffstat (limited to 'src')
-rw-r--r--src/tusb.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/tusb.c b/src/tusb.c
index 80073c259..11690b203 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -216,13 +216,17 @@ uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf,
bool tu_edpt_stream_init(tu_edpt_stream_t* s, bool is_host, bool is_tx, bool overwritable,
void* ff_buf, uint16_t ff_bufsize, uint8_t* ep_buf, uint16_t ep_bufsize) {
- osal_mutex_t new_mutex = osal_mutex_create(&s->ff_mutexdef);
- (void) new_mutex;
(void) is_tx;
s->is_host = is_host;
tu_fifo_config(&s->ff, ff_buf, ff_bufsize, 1, overwritable);
- tu_fifo_config_mutex(&s->ff, is_tx ? new_mutex : NULL, is_tx ? NULL : new_mutex);
+
+ #if OSAL_MUTEX_REQUIRED
+ if (ff_buf && ff_bufsize) {
+ osal_mutex_t new_mutex = osal_mutex_create(&s->ff_mutexdef);
+ tu_fifo_config_mutex(&s->ff, is_tx ? new_mutex : NULL, is_tx ? NULL : new_mutex);
+ }
+ #endif
s->ep_buf = ep_buf;
s->ep_bufsize = ep_bufsize;