diff options
| author | hathach <[email protected]> | 2018-07-23 23:41:14 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-07-23 23:41:14 +0700 |
| commit | 5f6cd4903101b0486771efdb2bb435ddf6cf8e7a (patch) | |
| tree | 6491459014c35ac6a8e4ec7ac46ef2e3486b0222 /src/common | |
| parent | 51903a60c51bd1006bec9266dbe1bfb35e282675 (diff) | |
clean up include
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_common.h | 6 | ||||
| -rw-r--r-- | src/common/tusb_timeout.h | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index ddfceabdb..44f31ffe0 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -61,15 +61,13 @@ //------------- TUSB Option Header -------------//
#include "tusb_option.h"
-//------------- General Header -------------//
+//------------- Common Header -------------//
#include "tusb_compiler.h"
#include "tusb_verify.h"
#include "binary.h"
#include "tusb_error.h"
-#include "tusb_hal.h"
#include "tusb_fifo.h"
-
-//------------- TUSB Header -------------//
+#include "tusb_timeout.h"
#include "tusb_types.h"
//--------------------------------------------------------------------+
diff --git a/src/common/tusb_timeout.h b/src/common/tusb_timeout.h index 7c51ff36f..9d80f5fe7 100644 --- a/src/common/tusb_timeout.h +++ b/src/common/tusb_timeout.h @@ -45,7 +45,6 @@ #define _TUSB_TIMEOUT_H_
#include "tusb_compiler.h"
-#include "tusb_hal.h"
#ifdef __cplusplus
extern "C" {
@@ -56,6 +55,8 @@ typedef struct { uint32_t interval;
}tu_timeout_t;
+extern uint32_t tusb_hal_millis(void);
+
static inline void tu_timeout_set(tu_timeout_t* tt, uint32_t msec)
{
tt->interval = msec;
@@ -67,6 +68,18 @@ static inline bool tu_timeout_expired(tu_timeout_t* tt) return ( tusb_hal_millis() - tt->start ) >= tt->interval;
}
+// For used with periodic event to prevent drift
+static inline void tu_timeout_reset(tu_timeout_t* tt)
+{
+ tt->start += tt->interval;
+}
+
+static inline void tu_timeout_restart(tu_timeout_t* tt)
+{
+ tt->start = tusb_hal_millis();
+}
+
+
static inline void tu_timeout_wait(uint32_t msec)
{
tu_timeout_t tt;
|
