refactor(gdma): pass channel count to retention test helper

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Chen Chen
2026-08-12 17:04:48 +08:00
co-authored by Cursor
parent 2dd71fddaa
commit 3acbac7b1c
3 changed files with 11 additions and 11 deletions
@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -10,7 +10,7 @@
#include "esp_private/sleep_retention.h" #include "esp_private/sleep_retention.h"
#include "hal/gdma_ll.h" #include "hal/gdma_ll.h"
void test_gdma_trigger_retention_backup(gdma_channel_handle_t chan, ...) void test_gdma_trigger_retention_backup(size_t chan_num, ...)
{ {
#if SOC_PAU_SUPPORTED && SOC_GDMA_SUPPORT_SLEEP_RETENTION #if SOC_PAU_SUPPORTED && SOC_GDMA_SUPPORT_SLEEP_RETENTION
// trigger a software retention to test GDMA retention correctnesss // trigger a software retention to test GDMA retention correctnesss
@@ -18,14 +18,13 @@ void test_gdma_trigger_retention_backup(gdma_channel_handle_t chan, ...)
sleep_retention_do_extra_retention(true); sleep_retention_do_extra_retention(true);
// 2. reset gdma registers to default value // 2. reset gdma registers to default value
gdma_channel_handle_t chan_itor = chan;
va_list args; va_list args;
int group_id = -1; int group_id = -1;
va_start(args, chan); va_start(args, chan_num);
while (chan_itor) { for (size_t i = 0; i < chan_num; i++) {
gdma_get_group_channel_id(chan_itor, &group_id, NULL); gdma_channel_handle_t chan = va_arg(args, gdma_channel_handle_t);
gdma_get_group_channel_id(chan, &group_id, NULL);
_gdma_ll_reset_register(group_id); _gdma_ll_reset_register(group_id);
chan_itor = va_arg(args, gdma_channel_handle_t);
} }
va_end(args); va_end(args);
@@ -7,6 +7,7 @@
#pragma once #pragma once
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_private/gdma.h" #include "esp_private/gdma.h"
@@ -28,10 +29,10 @@ extern "C" {
* *
* @note Call this help function after the gdma set up is completed. Then check the gdma functionality is still working. * @note Call this help function after the gdma set up is completed. Then check the gdma functionality is still working.
* *
* @param chan GDMA channel handle to be reset * @param chan_num Number of GDMA channel handles
* @param ... Other GDMA channel handle if any * @param ... GDMA channel handles to be reset
*/ */
void test_gdma_trigger_retention_backup(gdma_channel_handle_t chan, ...); void test_gdma_trigger_retention_backup(size_t chan_num, ...);
#ifdef __cplusplus #ifdef __cplusplus
} }
@@ -356,7 +356,7 @@ static void test_gdma_m2m_transaction(gdma_channel_handle_t tx_chan, gdma_channe
TEST_ESP_OK(gdma_link_mount_buffers(rx_link_list, 0, &rx_buf_mount_config, 1, NULL)); TEST_ESP_OK(gdma_link_mount_buffers(rx_link_list, 0, &rx_buf_mount_config, 1, NULL));
if (trig_retention_backup) { if (trig_retention_backup) {
test_gdma_trigger_retention_backup(tx_chan, rx_chan); test_gdma_trigger_retention_backup(2, tx_chan, rx_chan);
} }
TEST_ESP_OK(gdma_start(rx_chan, gdma_link_get_head_addr(rx_link_list))); TEST_ESP_OK(gdma_start(rx_chan, gdma_link_get_head_addr(rx_link_list)));