From 610e6a11ef0943872da5d863681fccf4cd36598f Mon Sep 17 00:00:00 2001
From: chenwu <chenwu@espressif.com>
Date: Thu, 26 Jul 2018 15:03:03 +0800
Subject: [PATCH] feat: configurate FreeRTOS HZ

---
 components/freertos/Kconfig                                | 7 +++++++
 .../port/esp8266/include/freertos/FreeRTOSConfig.h         | 2 +-
 .../freertos/port/esp8266/include/freertos/xtensa_timer.h  | 4 +++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig
index b50d1871..ac00535d 100644
--- a/components/freertos/Kconfig
+++ b/components/freertos/Kconfig
@@ -9,4 +9,11 @@ config FREERTOS_ENABLE_REENT
 
         The configuration will enable newlib.
 
+config FREERTOS_HZ
+    int "Tick rate (Hz)"
+    range 1 1000
+    default 100
+    help
+        Select the tick rate at which FreeRTOS does pre-emptive context switching.
+        
 endmenu
diff --git a/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h b/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h
index 7d17f785..c715c6eb 100644
--- a/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h
+++ b/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h
@@ -84,7 +84,7 @@
 #define configUSE_TICK_HOOK			0
 #define configUSE_TICKLESS_IDLE 	1
 #define configCPU_CLOCK_HZ			( ( unsigned long ) 80000000 )	
-#define configTICK_RATE_HZ			( ( portTickType ) 100 )
+#define configTICK_RATE_HZ			( ( portTickType ) CONFIG_FREERTOS_HZ )
 #define configMAX_PRIORITIES		15
 #define configMINIMAL_STACK_SIZE	( ( unsigned short ) 768 )
 //#define configTOTAL_HEAP_SIZE		( ( size_t ) ( 17 * 1024 ) )
diff --git a/components/freertos/port/esp8266/include/freertos/xtensa_timer.h b/components/freertos/port/esp8266/include/freertos/xtensa_timer.h
index 1121543e..76f87957 100644
--- a/components/freertos/port/esp8266/include/freertos/xtensa_timer.h
+++ b/components/freertos/port/esp8266/include/freertos/xtensa_timer.h
@@ -26,6 +26,8 @@ and the Xtensa core configuration need not have a timer.
 #ifndef XTENSA_TIMER_H
 #define XTENSA_TIMER_H
 
+#include "freertos/FreeRTOSConfig.h"
+
 #ifdef XT_RTOS_TIMER_INT        /* skip all this stuff if no timer int */
 
 #ifdef __ASSEMBLER__
@@ -125,7 +127,7 @@ editing this here or in xtensa_rtos.h, or compiling with xt-xcc option
 "-DXT_TICKS_PER_SEC <value>" where <value> is a suitable number.
 */
 #ifndef XT_TICK_PER_SEC
-#define XT_TICK_PER_SEC     100         /* 10 ms tick = 100 ticks per second */
+#define XT_TICK_PER_SEC     CONFIG_FREERTOS_HZ         /* 10 ms tick = 100 ticks per second */
 #endif
 
 /*