diff options
| author | hathach <[email protected]> | 2013-03-11 12:00:25 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-03-11 12:00:25 +0700 |
| commit | 8eaad2326b26f542ba66ea305a40dd4c8e49f421 (patch) | |
| tree | dbb9cee9452ec973b6bd7f65c3c6590d09b55c38 /tinyusb/osal | |
| parent | c1ceec067f0e5a10b891b83a13ca765b673d3e3f (diff) | |
add semphore reset & queue flush API
modify test to check control pipe semaphore created with usbh_init
Diffstat (limited to 'tinyusb/osal')
| -rw-r--r-- | tinyusb/osal/osal.h | 3 | ||||
| -rw-r--r-- | tinyusb/osal/osal_none.h | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tinyusb/osal/osal.h b/tinyusb/osal/osal.h index b1f67055f..09b9560fb 100644 --- a/tinyusb/osal/osal.h +++ b/tinyusb/osal/osal.h @@ -147,6 +147,9 @@ typedef void* osal_semaphore_handle_t; #define OSAL_SEM_DEF(name)\ osal_semaphore_t name +#define OSAL_SEM_REF(name)\ + &name + osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * const sem); void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error); tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl); diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index da42a969a..82bef38b1 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -150,6 +150,7 @@ static inline uint32_t osal_tick_get(void) #define SUBTASK_ASSERT_STATUS_WITH_HANDLER(...) TASK_ASSERT_STATUS_WITH_HANDLER(__VA_ARGS__) #define SUBTASK_ASSERT(...) TASK_ASSERT(__VA_ARGS__) #define SUBTASK_ASSERT_WITH_HANDLER(...) TASK_ASSERT_WITH_HANDLER(__VA_ARGS__) + //--------------------------------------------------------------------+ // Semaphore API //--------------------------------------------------------------------+ @@ -177,6 +178,12 @@ static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const se return TUSB_ERROR_NONE; } +static inline void osal_sempahore_reset(osal_semaphore_handle_t const sem_hdl) ATTR_ALWAYS_INLINE; +static inline void osal_sempahore_reset(osal_semaphore_handle_t const sem_hdl) +{ + (*sem_hdl) = 0; +} + #define osal_semaphore_wait(sem_hdl, msec, p_error) \ do {\ timeout = osal_tick_get();\ @@ -242,6 +249,12 @@ static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, return TUSB_ERROR_NONE; } +static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl) ATTR_ALWAYS_INLINE; +static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl) +{ + queue_hdl->count = queue_hdl->rd_idx = queue_hdl->wr_idx = 0; +} + #define osal_queue_receive(queue_hdl, p_data, msec, p_error) \ do {\ timeout = osal_tick_get();\ |
