diff --git a/src/W800_SDK_v1.00.10/Makefile b/src/W800_SDK_v1.00.10/Makefile index c29304e..a279fe5 100644 --- a/src/W800_SDK_v1.00.10/Makefile +++ b/src/W800_SDK_v1.00.10/Makefile @@ -30,11 +30,12 @@ endif endif COMPONENTS_$(TARGET) = \ - $(TOP_DIR)/app/libuser$(LIB_EXT) \ - $(TOP_DIR)/app/app_drivers/libappdrivers$(LIB_EXT) \ + $(TOP_DIR)/app/libuser$(LIB_EXT) \ + $(TOP_DIR)/app/app_drivers/libappdrivers$(LIB_EXT) \ $(TOP_DIR)/app/persistency/libpersistency$(LIB_EXT) \ $(TOP_DIR)/app/translation/libtranslation$(LIB_EXT) \ - $(TOP_DIR)/app/ble/libble$(LIB_EXT) \ + $(TOP_DIR)/app/ble/libble$(LIB_EXT) \ + $(TOP_DIR)/app/app_utils/libapputils$(LIB_EXT) \ $(TOP_DIR)/lvgl/liblvgl$(LIB_EXT) ifeq ($(USE_LIB), 0) diff --git a/src/W800_SDK_v1.00.10/app/app_utils/Makefile b/src/W800_SDK_v1.00.10/app/app_utils/Makefile new file mode 100644 index 0000000..5229aba --- /dev/null +++ b/src/W800_SDK_v1.00.10/app/app_utils/Makefile @@ -0,0 +1,15 @@ +TOP_DIR = ../.. +sinclude $(TOP_DIR)/tools/w800/conf.mk + +ifndef PDIR +GEN_LIBS = libapputils$(LIB_EXT) +endif + +#DEFINES += + +sinclude $(TOP_DIR)/tools/w800/rules.mk + +INCLUDES := $(INCLUDES) -I $(PDIR)include + +PDIR := ../$(PDIR) +sinclude $(PDIR)Makefile \ No newline at end of file diff --git a/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c new file mode 100644 index 0000000..158317a --- /dev/null +++ b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c @@ -0,0 +1,61 @@ +#include "app_utils.h" +#include "app_log.h" + +static uint32_t _elapsed_ms = 0; + +void us_delay(uint32_t us) +{ + struct tls_timer_cfg timer_config = + { + .is_repeat = false, + .unit = TLS_TIMER_UNIT_US, + .timeout = 0xFFFFFFFF, + }; + + uint8_t timer_id = tls_timer_create(&timer_config); + + if(WM_TIMER_ID_INVALID == timer_id) + { + APP_LOG_ERROR("Failed to create timer"); + return; + } + + tls_timer_start(timer_id); + + // Perform a blocking delay + while(tls_timer_read(timer_id) < us); + + // Don't forget to free the used timer + tls_timer_destroy(timer_id); +} + +void ms_delay(uint32_t ms) +{ + struct tls_timer_cfg timer_config = + { + .is_repeat = false, + .unit = TLS_TIMER_UNIT_MS, + .timeout = 0xFFFFFFFF, + }; + + uint8_t timer_id = tls_timer_create(&timer_config); + + if(WM_TIMER_ID_INVALID == timer_id) + { + APP_LOG_ERROR("Failed to create timer"); + return; + } + + tls_timer_start(timer_id); + + // Perform a blocking delay + while(tls_timer_read(timer_id) < ms); + + // Don't forget to free the used timer + tls_timer_destroy(timer_id); +} + +uint32_t elapsed_ms(void) +{ + return _elapsed_ms; +} \ No newline at end of file diff --git a/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h new file mode 100644 index 0000000..08b8144 --- /dev/null +++ b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h @@ -0,0 +1,27 @@ +#ifndef APP_UTILS_H +#define APP_UTILS_H + +#include "wm_include.h" + +/** + * @brief Wait for the specified time in micro seconds. This is a blocking function ! + * + * @param us the specified time to wait in µs. + */ +void us_delay(uint32_t us); + +/** + * @brief Wait for the specified time in milli seconds. This is a blocking function ! + * + * @param ms the specified time to wait in ms. + */ +void ms_delay(uint32_t ms); + +/** + * @brief Returns the current milli seconds count elapsed since the start of the program. + * + * @return uint32_t the elapsed time in ms + */ +uint32_t elapsed_ms(void); + +#endif //APP_UTILS_H \ No newline at end of file diff --git a/src/W800_SDK_v1.00.10/src/os/rtos/include/FreeRTOSConfig.h b/src/W800_SDK_v1.00.10/src/os/rtos/include/FreeRTOSConfig.h index 8de80bf..252b03d 100644 --- a/src/W800_SDK_v1.00.10/src/os/rtos/include/FreeRTOSConfig.h +++ b/src/W800_SDK_v1.00.10/src/os/rtos/include/FreeRTOSConfig.h @@ -70,7 +70,7 @@ #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 1 //ʹ�ÿ��й��� -#define configUSE_TICK_HOOK 1 +#define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( ( unsigned long ) 40000000 ) /* =12.0MHz xtal multiplied by 5 using the PLL. *///??????????????? diff --git a/src/W800_SDK_v1.00.10/tools/w800/inc.mk b/src/W800_SDK_v1.00.10/tools/w800/inc.mk index 2791b23..96897e0 100644 --- a/src/W800_SDK_v1.00.10/tools/w800/inc.mk +++ b/src/W800_SDK_v1.00.10/tools/w800/inc.mk @@ -51,6 +51,7 @@ INCLUDES += -I $(TOP_DIR)/app/app_drivers/i2c INCLUDES += -I $(TOP_DIR)/app/app_drivers/watch_peripherals INCLUDES += -I $(TOP_DIR)/app/app_include INCLUDES += -I $(TOP_DIR)/app/ble +INCLUDES += -I $(TOP_DIR)/app/app_utils INCLUDES += -I $(TOP_DIR)/app/gfx INCLUDES += -I $(TOP_DIR)/app/persistency INCLUDES += -I $(TOP_DIR)/app/translation