feat(esp8266): refactor CCOMPARE timer and system time by microseconds

old: CCOMPARE timer triggers when CCOUNT increase to equal to CCOMPARE, then ISR will increase integer of "_xt_tick_divisor"
     to CCOMPARE and wait for next interrupt triggering

now: CCOMPARE timer triggers when CCOUNT increase to equal to CCOMPARE, then ISR will reset CCOUNT to be 0 and reset CCOMPARE
     to be integer of "_xt_tick_divisor", then wait for next interrupt triggering

Using the new method, we may get the CCOUNT value without considing if it has overflowed.
System running microseconds = g_os_ticks * microseconds per tick + CCOUNT.
This commit is contained in:
dongheng
2019-08-16 19:20:06 +08:00
parent 8680849684
commit b061230056
7 changed files with 85 additions and 61 deletions

View File

@ -158,8 +158,11 @@ NVIC value of 255. */
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_CPU_CLK
#ifndef __ASSEMBLER__
extern uint64_t g_esp_os_cpu_clk;
#define portGET_RUN_TIME_COUNTER_VALUE() g_esp_os_cpu_clk
#endif
/* Fine resolution time */
#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount()
#elif defined(CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER)
/* Coarse resolution time (us) */
#ifndef __ASSEMBLER__