summaryrefslogtreecommitdiff
path: root/src/osal
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-10-23 15:53:29 +0700
committerhathach <[email protected]>2018-10-23 15:53:29 +0700
commit3dd635f4c14c6e23ed1a3d2254ecf58b7398e2d7 (patch)
tree25bd4b0a36a3f8e11a132036f201a007092a85fb /src/osal
parent9ba624a97471383a74576e6a383e84b7c4d4fc0d (diff)
merge osal_queue_send_isr to osal_queue_send, osal_semaphore_post_isr to osal_semaphore_post
Diffstat (limited to 'src/osal')
-rw-r--r--src/osal/osal.h6
-rw-r--r--src/osal/osal_freertos.h18
-rw-r--r--src/osal/osal_mynewt.h11
-rw-r--r--src/osal/osal_none.h10
4 files changed, 15 insertions, 30 deletions
diff --git a/src/osal/osal.h b/src/osal/osal.h
index d64837205..93ac48b13 100644
--- a/src/osal/osal.h
+++ b/src/osal/osal.h
@@ -80,15 +80,13 @@ typedef void (*osal_task_func_t)( void * );
* osal_queue_def_t, osal_queue_t
* osal_queue_t osal_queue_create(osal_queue_def_t* qdef)
* osal_queue_receive (osal_queue_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error)
- * bool osal_queue_send_isr(osal_queue_t const queue_hdl, void const * data)
- * bool osal_queue_send(osal_queue_t const queue_hdl, void const * data)
+ * bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
* osal_queue_flush() TODO remove
*
* Semaphore
* osal_semaphore_def_t, osal_semaphore_t
* osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef)
- * bool osal_semaphore_post_isr(osal_semaphore_t sem_hdl)
- * bool osal_semaphore_post(osal_semaphore_t sem_hdl)
+ * bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
* void osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec, tusb_error_t *p_error)
* void osal_semaphore_reset_isr(osal_semaphore_t const sem_hdl)
*
diff --git a/src/osal/osal_freertos.h b/src/osal/osal_freertos.h
index 52d34c187..be7e6b38b 100644
--- a/src/osal/osal_freertos.h
+++ b/src/osal/osal_freertos.h
@@ -120,14 +120,9 @@ static inline void osal_queue_receive (osal_queue_t const queue_hdl, void *p_dat
(*p_error) = ( xQueueReceive(queue_hdl, p_data, ticks) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT);
}
-static inline bool osal_queue_send_isr(osal_queue_t const queue_hdl, void const * data)
+static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
{
- return xQueueSendToBackFromISR(queue_hdl, data, NULL);
-}
-
-static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data)
-{
- return xQueueSendToBack(queue_hdl, data, OSAL_TIMEOUT_WAIT_FOREVER) == pdTRUE;
+ return in_isr ? xQueueSendToBackFromISR(queue_hdl, data, NULL) : xQueueSendToBack(queue_hdl, data, OSAL_TIMEOUT_WAIT_FOREVER);
}
static inline void osal_queue_flush(osal_queue_t const queue_hdl)
@@ -147,14 +142,9 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
return xSemaphoreCreateBinaryStatic(semdef);
}
-static inline bool osal_semaphore_post_isr(osal_semaphore_t sem_hdl)
-{
- return xSemaphoreGiveFromISR(sem_hdl, NULL) == pdTRUE;
-}
-
-static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl)
+static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
{
- return xSemaphoreGive(sem_hdl) == pdTRUE;
+ return in_isr ? xSemaphoreGiveFromISR(sem_hdl, NULL) : xSemaphoreGive(sem_hdl);
}
static inline void osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec, tusb_error_t *p_error)
diff --git a/src/osal/osal_mynewt.h b/src/osal/osal_mynewt.h
index 59cd1b821..cb09680e0 100644
--- a/src/osal/osal_mynewt.h
+++ b/src/osal/osal_mynewt.h
@@ -129,10 +129,10 @@ static inline void osal_queue_receive (osal_queue_t const queue_hdl, void *p_dat
*p_error = TUSB_ERROR_NONE;
}
-#define osal_queue_send_isr osal_queue_send
-
-static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data)
+static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
{
+ (void) in_isr;
+
// get a block from mem pool for data
void* ptr = os_memblock_get(&queue_hdl->mpool);
if (!ptr) return false;
@@ -169,10 +169,9 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
return (os_sem_init(semdef, 0) == OS_OK) ? (osal_semaphore_t) semdef : NULL;
}
-#define osal_semaphore_post_isr osal_semaphore_post
-
-static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl)
+static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
{
+ (void) in_isr;
return os_sem_release(sem_hdl) == OS_OK;
}
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h
index 22c89868a..91848f221 100644
--- a/src/osal/osal_none.h
+++ b/src/osal/osal_none.h
@@ -133,13 +133,12 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef)
return (osal_queue_t) qdef;
}
-static inline bool osal_queue_send_isr(osal_queue_t const queue_hdl, void const * data)
+static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
{
+ (void) in_isr;
return tu_fifo_write( (tu_fifo_t*) queue_hdl, data);
}
-#define osal_queue_send osal_queue_send_isr
-
static inline void osal_queue_flush(osal_queue_t const queue_hdl)
{
queue_hdl->count = queue_hdl->rd_idx = queue_hdl->wr_idx = 0;
@@ -182,10 +181,9 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
return semdef;
}
-#define osal_semaphore_post_isr osal_semaphore_post
-
-static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl)
+static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
{
+ (void) in_isr;
if (sem_hdl->count < sem_hdl->max_count ) sem_hdl->count++;
return true;
}