Merge pull request #1799 from hathach/update-osal-mutex

Update osal mutex
This commit is contained in:
Ha Thach
2022-12-16 17:05:25 +07:00
committed by GitHub
13 changed files with 75 additions and 85 deletions

View File

@@ -272,10 +272,12 @@ static uint8_t _usbd_rhport = RHPORT_INVALID;
OSAL_QUEUE_DEF(usbd_int_set, _usbd_qdef, CFG_TUD_TASK_QUEUE_SZ, dcd_event_t);
static osal_queue_t _usbd_q;
// Mutex for claiming endpoint, only needed when using with preempted RTOS
#if CFG_TUSB_OS != OPT_OS_NONE
static osal_mutex_def_t _ubsd_mutexdef;
static osal_mutex_t _usbd_mutex;
// Mutex for claiming endpoint
#if OSAL_MUTEX_REQUIRED
static osal_mutex_def_t _ubsd_mutexdef;
static osal_mutex_t _usbd_mutex;
#else
#define _usbd_mutex NULL
#endif
@@ -389,7 +391,7 @@ bool tud_init (uint8_t rhport)
tu_varclr(&_usbd_dev);
#if CFG_TUSB_OS != OPT_OS_NONE
#if OSAL_MUTEX_REQUIRED
// Init device mutex
_usbd_mutex = osal_mutex_create(&_ubsd_mutexdef);
TU_ASSERT(_usbd_mutex);
@@ -1209,11 +1211,7 @@ bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr)
uint8_t const dir = tu_edpt_dir(ep_addr);
tu_edpt_state_t* ep_state = &_usbd_dev.ep_status[epnum][dir];
#if TUSB_OPT_MUTEX
return tu_edpt_claim(ep_state, _usbd_mutex);
#else
return tu_edpt_claim(ep_state, NULL);
#endif
}
bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr)
@@ -1224,11 +1222,7 @@ bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr)
uint8_t const dir = tu_edpt_dir(ep_addr);
tu_edpt_state_t* ep_state = &_usbd_dev.ep_status[epnum][dir];
#if TUSB_OPT_MUTEX
return tu_edpt_release(ep_state, _usbd_mutex);
#else
return tu_edpt_release(ep_state, NULL);
#endif
}
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)