feat(twai): Add twai linker.lf to control the placement of driver and hal

- Replace TWAI_ISR_ATTR flag with linker.lf
- Use the linker.lf to control the placement of the driver functions
This commit is contained in:
Planck (Lu Zeyu) 2023-08-02 11:37:59 +08:00
parent 7d87b6f47f
commit 7469f34948
4 changed files with 17 additions and 9 deletions

View File

@ -216,7 +216,7 @@ else()
INCLUDE_DIRS ${includes}
PRIV_REQUIRES efuse esp_timer
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
LDFRAGMENTS linker.lf gptimer/linker.lf gpio/linker.lf)
LDFRAGMENTS linker.lf gptimer/linker.lf gpio/linker.lf twai/linker.lf)
endif()
# If system needs to monitor USJ connection status, then usb_serial_jtag_connection_monitor object file has to be linked

View File

@ -0,0 +1,14 @@
[mapping:twai_hal]
archive: libhal.a
entries:
if TWAI_ISR_IN_IRAM = y:
twai_hal_iram (noflash)
[mapping:twai_driver]
archive: libdriver.a
entries:
if TWAI_ISR_IN_IRAM = y:
twai: twai_alert_handler (noflash)
twai: twai_handle_rx_buffer_frames (noflash)
twai: twai_handle_tx_buffer_frame (noflash)
twai: twai_intr_handler_main (noflash)

View File

@ -44,11 +44,9 @@
#define TWAI_SET_FLAG(var, mask) ((var) |= (mask))
#define TWAI_RESET_FLAG(var, mask) ((var) &= ~(mask))
#ifdef CONFIG_TWAI_ISR_IN_IRAM
#define TWAI_ISR_ATTR IRAM_ATTR
#define TWAI_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#else
#define TWAI_TAG "TWAI"
#define TWAI_ISR_ATTR
#define TWAI_MALLOC_CAPS MALLOC_CAP_DEFAULT
#endif //CONFIG_TWAI_ISR_IN_IRAM
@ -103,7 +101,7 @@ static twai_hal_context_t twai_context;
/* -------------------- Interrupt and Alert Handlers ------------------------ */
TWAI_ISR_ATTR static void twai_alert_handler(uint32_t alert_code, int *alert_req)
static void twai_alert_handler(uint32_t alert_code, int *alert_req)
{
if (p_twai_obj->alerts_enabled & alert_code) {
//Signify alert has occurred
@ -123,7 +121,6 @@ TWAI_ISR_ATTR static void twai_alert_handler(uint32_t alert_code, int *alert_req
}
}
TWAI_ISR_ATTR
static inline void twai_handle_rx_buffer_frames(BaseType_t *task_woken, int *alert_req)
{
#ifdef SOC_TWAI_SUPPORTS_RX_STATUS
@ -173,7 +170,6 @@ static inline void twai_handle_rx_buffer_frames(BaseType_t *task_woken, int *ale
#endif //SOC_TWAI_SUPPORTS_RX_STATUS
}
TWAI_ISR_ATTR
static inline void twai_handle_tx_buffer_frame(BaseType_t *task_woken, int *alert_req)
{
//Handle previously transmitted frame
@ -203,7 +199,7 @@ static inline void twai_handle_tx_buffer_frame(BaseType_t *task_woken, int *aler
}
}
TWAI_ISR_ATTR static void twai_intr_handler_main(void *arg)
static void twai_intr_handler_main(void *arg)
{
BaseType_t task_woken = pdFALSE;
int alert_req = 0;

View File

@ -26,8 +26,6 @@ entries:
wdt_hal_iram (noflash)
if SOC_SYSTIMER_SUPPORTED = y && HAL_SYSTIMER_USE_ROM_IMPL = n:
systimer_hal (noflash)
if TWAI_ISR_IN_IRAM = y:
twai_hal_iram (noflash)
if SOC_GPSPI_SUPPORTED = y && IDF_TARGET_ESP32 = n:
spi_flash_hal_gpspi (noflash)
if SOC_PMU_SUPPORTED = y: