mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
gptimer: add API to get captured count value
This commit is contained in:
@@ -115,6 +115,22 @@ static inline void timer_ll_enable_counter(timg_dev_t *hw, uint32_t timer_num, b
|
||||
hw->hw_timer[timer_num].config.tx_en = en;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigger software capture event
|
||||
*
|
||||
* @param hw Timer Group register base address
|
||||
* @param timer_num Timer number in the group
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
static inline void timer_ll_trigger_soft_capture(timg_dev_t *hw, uint32_t timer_num)
|
||||
{
|
||||
hw->hw_timer[timer_num].update.tx_update = 1;
|
||||
// Timer register is in a different clock domain from Timer hardware logic
|
||||
// We need to wait for the update to take effect before fetching the count value
|
||||
while (hw->hw_timer[timer_num].update.tx_update) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get counter value
|
||||
*
|
||||
@@ -126,11 +142,6 @@ static inline void timer_ll_enable_counter(timg_dev_t *hw, uint32_t timer_num, b
|
||||
__attribute__((always_inline))
|
||||
static inline uint64_t timer_ll_get_counter_value(timg_dev_t *hw, uint32_t timer_num)
|
||||
{
|
||||
hw->hw_timer[timer_num].update.tx_update = 1;
|
||||
// Timer register is in a different clock domain from Timer hardware logic
|
||||
// We need to wait for the update to take effect before fetching the count value
|
||||
while (hw->hw_timer[timer_num].update.tx_update) {
|
||||
}
|
||||
return ((uint64_t) hw->hw_timer[timer_num].hi.tx_hi << 32) | (hw->hw_timer[timer_num].lo.tx_lo);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user