mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(driver_twai): new driver sleep retention support
This commit is contained in:
@@ -1387,6 +1387,10 @@ config SOC_TWAI_SUPPORT_TIMESTAMP
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TWAI_SUPPORT_SLEEP_RETENTION
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_EFUSE_DIS_PAD_JTAG
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -45,6 +45,8 @@ typedef enum periph_retention_module {
|
||||
SLEEP_RETENTION_MODULE_LEDC = 21,
|
||||
SLEEP_RETENTION_MODULE_PCNT0 = 22,
|
||||
SLEEP_RETENTION_MODULE_MCPWM0 = 23,
|
||||
SLEEP_RETENTION_MODULE_TWAI0 = 24,
|
||||
SLEEP_RETENTION_MODULE_TWAI1 = 25,
|
||||
|
||||
/* modem module, which includes WiFi, BLE and 802.15.4 */
|
||||
SLEEP_RETENTION_MODULE_WIFI_MAC = 26,
|
||||
@@ -82,6 +84,8 @@ typedef enum periph_retention_module {
|
||||
: ((m) == SLEEP_RETENTION_MODULE_LEDC) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_PCNT0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_MCPWM0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_TWAI0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_TWAI1) ? true \
|
||||
: false)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -528,6 +528,7 @@
|
||||
#define SOC_TWAI_SUPPORTS_RX_STATUS 1
|
||||
#define SOC_TWAI_SUPPORT_FD 1
|
||||
#define SOC_TWAI_SUPPORT_TIMESTAMP 1
|
||||
#define SOC_TWAI_SUPPORT_SLEEP_RETENTION 1
|
||||
|
||||
/*-------------------------- eFuse CAPS----------------------------*/
|
||||
#define SOC_EFUSE_DIS_PAD_JTAG 1
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/twai_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/soc.h"
|
||||
|
||||
const twai_controller_signal_conn_t twai_controller_periph_signals = {
|
||||
.controllers = {
|
||||
@@ -31,3 +32,75 @@ const twai_controller_signal_conn_t twai_controller_periph_signals = {
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* TWAI Registers to be saved during sleep retention
|
||||
* - TWAIFD_MODE_SETTINGS_REG
|
||||
* - TWAIFD_STATUS_REG
|
||||
* - TWAIFD_COMMAND_REG
|
||||
* - TWAIFD_INT_ENA_SET_REG
|
||||
* - TWAIFD_INT_ENA_CLR_REG
|
||||
* - TWAIFD_BTR_REG
|
||||
* - TWAIFD_BTR_FD_REG
|
||||
* - TWAIFD_EWL_ERP_FAULT_STATE_REG
|
||||
* - TWAIFD_REC_TEC_REG
|
||||
* - TWAIFD_ERR_NORM_ERR_FD_REG
|
||||
* - TWAIFD_FILTER_A_MASK_REG
|
||||
* - TWAIFD_FILTER_A_VAL_REG
|
||||
* - TWAIFD_FILTER_B_MASK_REG
|
||||
* - TWAIFD_FILTER_B_VAL_REG
|
||||
* - TWAIFD_FILTER_C_MASK_REG
|
||||
* - TWAIFD_FILTER_C_VAL_REG
|
||||
* - TWAIFD_FILTER_RAN_LOW_REG
|
||||
* - TWAIFD_FILTER_RAN_HIGH_REG
|
||||
* - TWAIFD_FILTER_CONTROL_FILTER_STATUS_REG
|
||||
* - TWAIFD_RX_STATUS_RX_SETTINGS_REG
|
||||
* - TWAIFD_TX_COMMAND_TXTB_INFO_REG
|
||||
* - TWAIFD_TX_PRIORITY_REG
|
||||
* - TWAIFD_TRV_DELAY_SSP_CFG_REG
|
||||
* - TWAIFD_RX_FR_CTR_REG
|
||||
* - TWAIFD_TX_FR_CTR_REG
|
||||
*/
|
||||
#define TWAI_RETENTION_REGS_CNT 25
|
||||
#define TWAI_RETENTION_REGS_BASE(i) REG_TWAI_BASE(i)
|
||||
static const uint32_t twai_regs_map[4] = {0xb27fdf37, 0x3, 0x0, 0x0};
|
||||
|
||||
// twai timer registers is far away from twai registers, so we need a separate link
|
||||
// - TWAIFD_TIMER_INT_ENA_REG
|
||||
// - TWAIFD_TIMER_CFG_REG
|
||||
#define TWAI_TIMER_RETENTION_REGS_CNT 2
|
||||
#define TWAI_TIMER_RETENTION_REGS_BASE(i) (REG_TWAI_BASE(i) + 0xfe0)
|
||||
static const uint32_t twai_timer_regs_map[4] = {0x5, 0x0, 0x0, 0x0};
|
||||
|
||||
#define TWAI_SLEEP_RETENTION_ENTRIES(id) { \
|
||||
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT( \
|
||||
REGDMA_TWAI_LINK(0x00), \
|
||||
TWAI_RETENTION_REGS_BASE(id), TWAI_RETENTION_REGS_BASE(id), \
|
||||
TWAI_RETENTION_REGS_CNT, 0, 0, \
|
||||
twai_regs_map[0], twai_regs_map[1], \
|
||||
twai_regs_map[2], twai_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2) }, \
|
||||
[1] = { .config = REGDMA_LINK_ADDR_MAP_INIT( \
|
||||
REGDMA_TWAI_LINK(0x01), \
|
||||
TWAI_TIMER_RETENTION_REGS_BASE(id), TWAI_TIMER_RETENTION_REGS_BASE(id), \
|
||||
TWAI_TIMER_RETENTION_REGS_CNT, 0, 0, \
|
||||
twai_timer_regs_map[0], twai_timer_regs_map[1], \
|
||||
twai_timer_regs_map[2], twai_timer_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2) }, \
|
||||
}
|
||||
|
||||
static const regdma_entries_config_t twai0_regs_retention[] = TWAI_SLEEP_RETENTION_ENTRIES(0);
|
||||
static const regdma_entries_config_t twai1_regs_retention[] = TWAI_SLEEP_RETENTION_ENTRIES(1);
|
||||
|
||||
const twai_reg_retention_info_t twai_reg_retention_info[2] = {
|
||||
[0] = {
|
||||
.module_id = SLEEP_RETENTION_MODULE_TWAI0,
|
||||
.entry_array = twai0_regs_retention,
|
||||
.array_size = ARRAY_SIZE(twai0_regs_retention)
|
||||
},
|
||||
[1] = {
|
||||
.module_id = SLEEP_RETENTION_MODULE_TWAI1,
|
||||
.entry_array = twai1_regs_retention,
|
||||
.array_size = ARRAY_SIZE(twai1_regs_retention)
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user