mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
complete define osal_freeRTOS for semaphore and queue
This commit is contained in:
parent
dd9da7846a
commit
5e8d70a184
@ -69,6 +69,7 @@
|
||||
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
|
||||
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\
|
||||
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
|
||||
ENTRY(TUSB_ERROR_OSAL_SEMAPHORE_FAILED)\
|
||||
ENTRY(TUSB_ERROR_FAILED)\
|
||||
|
||||
|
||||
|
@ -130,12 +130,13 @@ void tusbh_device_mounted_cb (tusb_error_t const error, tusb_handle_devi
|
||||
tusb_error_t tusbh_configuration_set (tusb_handle_device_t const device_hdl, uint8_t const configure_number) ATTR_WARN_UNUSED_RESULT;
|
||||
tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device_hdl) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
#if TUSB_CFG_OS == TUSB_OS_NONE // TODO move later
|
||||
static inline void tusb_tick_tock(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void tusb_tick_tock(void)
|
||||
{
|
||||
osal_tick_tock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// CLASS-USBD API
|
||||
|
@ -85,10 +85,23 @@
|
||||
#define OSAL_SEM_DEF(name)
|
||||
typedef xSemaphoreHandle osal_semaphore_handle_t;
|
||||
|
||||
// create FreeRTOS binary semaphore with zero as init value
|
||||
// create FreeRTOS binary semaphore with zero as init value TODO: omit semaphore take from vSemaphoreCreateBinary API, should double checks this
|
||||
#define osal_semaphore_create(x) \
|
||||
xQueueGenericCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )
|
||||
|
||||
static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl)
|
||||
{
|
||||
portBASE_TYPE taskWaken;
|
||||
return (xSemaphoreGiveFromISR(sem_hdl, &taskWaken) == pdTRUE) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;
|
||||
}
|
||||
|
||||
static inline void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
(*p_error) = ( xSemaphoreTake(sem_hdl, osal_tick_from_msec(msec)) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// QUEUE API
|
||||
//--------------------------------------------------------------------+
|
||||
@ -106,6 +119,19 @@ typedef xQueueHandle osal_queue_handle_t;
|
||||
#define osal_queue_create(p_queue) \
|
||||
xQueueCreate((p_queue)->depth, sizeof(uint32_t))
|
||||
|
||||
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
(*p_error) = ( xQueueReceive(queue_hdl, p_data, osal_tick_from_msec(msec)) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, uint32_t data) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, uint32_t data)
|
||||
{
|
||||
portBASE_TYPE taskWaken;
|
||||
return ( xQueueSendFromISR(queue_hdl, &data, &taskWaken) == pdTRUE ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_QUEUE_FAILED;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user