diff options
| author | hathach <[email protected]> | 2018-12-12 00:51:56 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-12-12 00:51:56 +0700 |
| commit | b7ad49332cd9a5539e35a75785adb5ca2e79715a (patch) | |
| tree | 21530d34defa6dd890de30fcf4ace8ec21c5a49a /src/osal | |
| parent | b2ec8230d9acffbc0df280832b0341b82584b226 (diff) | |
| parent | c88e16bd116a826ebd2d9fb348fd3704f6b1f14d (diff) | |
Merge pull request #20 from hathach/devlocal
Host stack rework
Diffstat (limited to 'src/osal')
| -rw-r--r-- | src/osal/osal.h | 2 | ||||
| -rw-r--r-- | src/osal/osal_freertos.h | 4 | ||||
| -rw-r--r-- | src/osal/osal_none.h | 29 |
3 files changed, 20 insertions, 15 deletions
diff --git a/src/osal/osal.h b/src/osal/osal.h index 6846b5757..55e3e077c 100644 --- a/src/osal/osal.h +++ b/src/osal/osal.h @@ -83,7 +83,7 @@ typedef void (*osal_task_func_t)( void * ); * osal_semaphore_def_t, osal_semaphore_t
* osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef)
* bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
- * void osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec, uint32_t *p_error)
+ * bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec)
* void osal_semaphore_reset(osal_semaphore_t const sem_hdl)
*
* Mutex
diff --git a/src/osal/osal_freertos.h b/src/osal/osal_freertos.h index 704aafd64..acec4a95d 100644 --- a/src/osal/osal_freertos.h +++ b/src/osal/osal_freertos.h @@ -107,10 +107,10 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) return in_isr ? xSemaphoreGiveFromISR(sem_hdl, NULL) : xSemaphoreGive(sem_hdl); } -static inline void osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec, uint32_t *err) +static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec); - (*err) = (xSemaphoreTake(sem_hdl, ticks) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT); + return xSemaphoreTake(sem_hdl, ticks); } static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index 4d5a4dd57..ff37113c6 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -62,6 +62,12 @@ static inline bool osal_task_create(osal_task_def_t* taskdef) return true;
}
+static inline void osal_task_delay(uint32_t msec)
+{
+ uint32_t start = tusb_hal_millis();
+ while ( ( tusb_hal_millis() - start ) < msec ) {}
+}
+
//--------------------------------------------------------------------+
// Binary Semaphore API
//--------------------------------------------------------------------+
@@ -90,16 +96,15 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) sem_hdl->count = 0;
}
-static inline tusb_error_t osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) {
+// TODO blocking for now
+static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec)
+{
(void) msec;
- while (true) {
- while (sem_hdl->count == 0) { }
- if (sem_hdl->count == 0) {
- sem_hdl->count--;
- break;
- }
- }
- return TUSB_ERROR_NONE;
+
+ while (sem_hdl->count == 0) { }
+ sem_hdl->count--;
+
+ return true;
}
//--------------------------------------------------------------------+
@@ -129,7 +134,7 @@ extern void dcd_int_disable(uint8_t rhport); extern void dcd_int_enable(uint8_t rhport);
#endif
-#if MODE_HOST_SUPPORTED
+#if TUSB_OPT_HOST_ENABLED
extern void hcd_int_disable(uint8_t rhport);
extern void hcd_int_enable(uint8_t rhport);
#endif
@@ -162,7 +167,7 @@ static inline void _osal_q_lock(osal_queue_t qhdl) if (qhdl->role == OPT_MODE_DEVICE) dcd_int_disable(TUD_OPT_RHPORT);
#endif
-#if MODE_HOST_SUPPORTED
+#if TUSB_OPT_HOST_ENABLED
if (qhdl->role == OPT_MODE_HOST) hcd_int_disable(TUH_OPT_RHPORT);
#endif
}
@@ -174,7 +179,7 @@ static inline void _osal_q_unlock(osal_queue_t qhdl) if (qhdl->role == OPT_MODE_DEVICE) dcd_int_enable(TUD_OPT_RHPORT);
#endif
-#if MODE_HOST_SUPPORTED
+#if TUSB_OPT_HOST_ENABLED
if (qhdl->role == OPT_MODE_HOST) hcd_int_enable(TUH_OPT_RHPORT);
#endif
}
|
