From 5f6cd4903101b0486771efdb2bb435ddf6cf8e7a Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 23 Jul 2018 23:41:14 +0700 Subject: [PATCH] clean up include --- src/class/hid/hid_device.c | 1 - src/common/tusb_common.h | 6 ++---- src/common/tusb_timeout.h | 15 ++++++++++++++- src/host/ehci/ehci.c | 1 - src/host/ohci/ohci.c | 1 - .../nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c | 1 - src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 1 - 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 82c7e3d3..7aca8ef8 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -45,7 +45,6 @@ // INCLUDE //--------------------------------------------------------------------+ #include "common/tusb_common.h" -#include "common/tusb_timeout.h" #include "hid_device.h" #include "device/usbd_pvt.h" diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index ddfceabd..44f31ffe 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 7c51ff36..9d80f5fe 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; diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index ba23319c..09f2f573 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -44,7 +44,6 @@ //--------------------------------------------------------------------+ #include "hal/hal.h" #include "osal/osal.h" -#include "common/tusb_timeout.h" #include "../hcd.h" #include "../usbh_hcd.h" diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c index 73e9d887..644dbfa0 100644 --- a/src/host/ohci/ohci.c +++ b/src/host/ohci/ohci.c @@ -44,7 +44,6 @@ //--------------------------------------------------------------------+ #include "hal/hal.h" #include "osal/osal.h" -#include "common/tusb_timeout.h" #include "../hcd.h" #include "../usbh_hcd.h" diff --git a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c index 0bb79090..68eef47e 100644 --- a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c +++ b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c @@ -51,7 +51,6 @@ #include "common/tusb_common.h" #include "hal/hal.h" #include "osal/osal.h" -#include "common/tusb_timeout.h" #include "device/dcd.h" #include "usbd_dcd.h" diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 6c076baa..0b48ad1e 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -46,7 +46,6 @@ #include "common/tusb_common.h" #include "tusb_hal.h" #include "osal/osal.h" -#include "common/tusb_timeout.h" #include "device/dcd.h" #include "dcd_lpc43xx.h"