mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-02 02:10:19 +08:00
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:
@ -26,20 +26,6 @@ extern "C" {
|
||||
typedef uint32_t esp_tick_t;
|
||||
typedef uint32_t esp_irqflag_t;
|
||||
|
||||
static inline esp_tick_t soc_get_ticks(void)
|
||||
{
|
||||
esp_tick_t ticks;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"rsr %0, ccount\n"
|
||||
: "=a"(ticks)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return ticks;
|
||||
}
|
||||
|
||||
static inline esp_irqflag_t soc_save_local_irq(void)
|
||||
{
|
||||
esp_irqflag_t flag;
|
||||
@ -102,6 +88,16 @@ static inline uint32_t soc_get_ccount(void)
|
||||
return ticks;
|
||||
}
|
||||
|
||||
static inline void soc_set_ccount(uint32_t ticks)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"wsr %0, ccount\n"
|
||||
:
|
||||
: "a"(ticks)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
static inline void soc_clear_int_mask(uint32_t mask)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
|
Reference in New Issue
Block a user