forked from espressif/esp-idf
Merge branch 'feature/gptimer_linker_file' into 'master'
feat(gptimer): add gptimer linker.lf to control the placement of driver and hal See merge request espressif/esp-idf!24598
This commit is contained in:
@@ -216,7 +216,7 @@ else()
|
|||||||
INCLUDE_DIRS ${includes}
|
INCLUDE_DIRS ${includes}
|
||||||
PRIV_REQUIRES efuse esp_timer
|
PRIV_REQUIRES efuse esp_timer
|
||||||
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
|
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
|
||||||
LDFRAGMENTS linker.lf)
|
LDFRAGMENTS linker.lf gptimer/linker.lf)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# If system needs to monitor USJ connection status, then usb_serial_jtag_connection_monitor object file has to be linked
|
# If system needs to monitor USJ connection status, then usb_serial_jtag_connection_monitor object file has to be linked
|
||||||
|
17
components/driver/gptimer/linker.lf
Normal file
17
components/driver/gptimer/linker.lf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[mapping:gptimer_driver]
|
||||||
|
archive: libdriver.a
|
||||||
|
entries:
|
||||||
|
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
||||||
|
gptimer: gptimer_set_raw_count (noflash)
|
||||||
|
gptimer: gptimer_get_raw_count (noflash)
|
||||||
|
gptimer: gptimer_get_captured_count (noflash)
|
||||||
|
gptimer: gptimer_set_alarm_action (noflash)
|
||||||
|
gptimer: gptimer_start (noflash)
|
||||||
|
gptimer: gptimer_stop (noflash)
|
||||||
|
|
||||||
|
[mapping:gptimer_hal]
|
||||||
|
archive: libhal.a
|
||||||
|
entries:
|
||||||
|
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
||||||
|
timer_hal: timer_hal_set_counter_value (noflash)
|
||||||
|
timer_hal: timer_hal_capture_and_get_counter_value (noflash)
|
@@ -59,7 +59,7 @@ if(NOT BOOTLOADER_BUILD)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SOC_GPTIMER_SUPPORTED)
|
if(CONFIG_SOC_GPTIMER_SUPPORTED)
|
||||||
list(APPEND srcs "timer_hal.c" "timer_hal_iram.c")
|
list(APPEND srcs "timer_hal.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SOC_LEDC_SUPPORTED)
|
if(CONFIG_SOC_LEDC_SUPPORTED)
|
||||||
|
@@ -193,6 +193,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
||||||
@@ -204,6 +205,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tx_load = 1;
|
hw->hw_timer[timer_num].load.tx_load = 1;
|
||||||
|
@@ -193,6 +193,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
||||||
@@ -204,6 +205,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tx_load = 1;
|
hw->hw_timer[timer_num].load.tx_load = 1;
|
||||||
|
@@ -193,6 +193,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
||||||
@@ -204,6 +205,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tx_load = 1;
|
hw->hw_timer[timer_num].load.tx_load = 1;
|
||||||
|
@@ -235,6 +235,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
||||||
@@ -246,6 +247,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tx_load = 1;
|
hw->hw_timer[timer_num].load.tx_load = 1;
|
||||||
|
@@ -235,6 +235,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
||||||
@@ -246,6 +247,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tx_load = 1;
|
hw->hw_timer[timer_num].load.tx_load = 1;
|
||||||
|
@@ -197,6 +197,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tx_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tx_load_lo);
|
||||||
@@ -208,6 +209,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tx_load = 1;
|
hw->hw_timer[timer_num].load.tx_load = 1;
|
||||||
|
@@ -196,6 +196,7 @@ static inline void timer_ll_set_reload_value(timg_dev_t *hw, uint32_t timer_num,
|
|||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
* @return reload count value
|
* @return reload count value
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tn_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tn_load_lo);
|
return ((uint64_t)hw->hw_timer[timer_num].loadhi.tn_load_hi << 32) | (hw->hw_timer[timer_num].loadlo.tn_load_lo);
|
||||||
@@ -207,6 +208,7 @@ static inline uint64_t timer_ll_get_reload_value(timg_dev_t *hw, uint32_t timer_
|
|||||||
* @param hw Timer Group register base address
|
* @param hw Timer Group register base address
|
||||||
* @param timer_num Timer number in the group
|
* @param timer_num Timer number in the group
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
static inline void timer_ll_trigger_soft_reload(timg_dev_t *hw, uint32_t timer_num)
|
||||||
{
|
{
|
||||||
hw->hw_timer[timer_num].load.tn_load = 1;
|
hw->hw_timer[timer_num].load.tn_load = 1;
|
||||||
|
@@ -30,8 +30,6 @@ entries:
|
|||||||
twai_hal_iram (noflash)
|
twai_hal_iram (noflash)
|
||||||
if IDF_TARGET_ESP32 = n:
|
if IDF_TARGET_ESP32 = n:
|
||||||
spi_flash_hal_gpspi (noflash)
|
spi_flash_hal_gpspi (noflash)
|
||||||
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
|
||||||
timer_hal_iram (noflash)
|
|
||||||
if GPIO_CTRL_FUNC_IN_IRAM = y:
|
if GPIO_CTRL_FUNC_IN_IRAM = y:
|
||||||
gpio_hal: gpio_hal_intr_disable (noflash)
|
gpio_hal: gpio_hal_intr_disable (noflash)
|
||||||
if LCD_RGB_ISR_IRAM_SAFE = y:
|
if LCD_RGB_ISR_IRAM_SAFE = y:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -38,3 +38,25 @@ void timer_hal_deinit(timer_hal_context_t *hal)
|
|||||||
#endif
|
#endif
|
||||||
hal->dev = NULL;
|
hal->dev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void timer_hal_set_counter_value(timer_hal_context_t *hal, uint64_t load_val)
|
||||||
|
{
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// - `timer_ll_set_reload_value()` will only indicate the `reload_value`
|
||||||
|
// - `timer_ll_set_reload_value()` + ``timer_ll_trigger_soft_reload()` can update the HW counter value by software
|
||||||
|
// Therefore, after updating the HW counter value, we need to restore the previous `reload_value`.
|
||||||
|
// Attention: The following process should be protected by a lock in the driver layer.
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// save current reload value
|
||||||
|
uint64_t old_reload = timer_ll_get_reload_value(hal->dev, hal->timer_id);
|
||||||
|
timer_ll_set_reload_value(hal->dev, hal->timer_id, load_val);
|
||||||
|
timer_ll_trigger_soft_reload(hal->dev, hal->timer_id);
|
||||||
|
// restore the previous reload value
|
||||||
|
timer_ll_set_reload_value(hal->dev, hal->timer_id, old_reload);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t timer_hal_capture_and_get_counter_value(timer_hal_context_t *hal)
|
||||||
|
{
|
||||||
|
timer_ll_trigger_soft_capture(hal->dev, hal->timer_id);
|
||||||
|
return timer_ll_get_counter_value(hal->dev, hal->timer_id);
|
||||||
|
}
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "hal/timer_hal.h"
|
|
||||||
#include "hal/timer_ll.h"
|
|
||||||
|
|
||||||
void timer_hal_set_counter_value(timer_hal_context_t *hal, uint64_t load_val)
|
|
||||||
{
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// - `timer_ll_set_reload_value()` will only indicate the `reload_value`
|
|
||||||
// - `timer_ll_set_reload_value()` + ``timer_ll_trigger_soft_reload()` can update the HW counter value by software
|
|
||||||
// Therefore, after updating the HW counter value, we need to restore the previous `reload_value`.
|
|
||||||
// Attention: The following process should be protected by a lock in the driver layer.
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// save current reload value
|
|
||||||
uint64_t old_reload = timer_ll_get_reload_value(hal->dev, hal->timer_id);
|
|
||||||
timer_ll_set_reload_value(hal->dev, hal->timer_id, load_val);
|
|
||||||
timer_ll_trigger_soft_reload(hal->dev, hal->timer_id);
|
|
||||||
// restore the previous reload value
|
|
||||||
timer_ll_set_reload_value(hal->dev, hal->timer_id, old_reload);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t timer_hal_capture_and_get_counter_value(timer_hal_context_t *hal)
|
|
||||||
{
|
|
||||||
timer_ll_trigger_soft_capture(hal->dev, hal->timer_id);
|
|
||||||
return timer_ll_get_counter_value(hal->dev, hal->timer_id);
|
|
||||||
}
|
|
Reference in New Issue
Block a user