Skip to content

Commit 9b989f5

Browse files
committed
refactor(mspi): improved timing tuning max consecutive success points calculation
1 parent cc4fc21 commit 9b989f5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

components/esp_hw_support/mspi_timing_tuning/mspi_timing_tuning.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -270,8 +270,17 @@ static void s_find_max_consecutive_success_points(uint32_t *array, uint32_t size
270270
i++;
271271
}
272272

273-
*out_length = match_num > max ? match_num : max;
274-
*out_end_index = match_num == size ? size : end;
273+
/**
274+
* this is to deal with the case when the last points are consecutive 1, e.g.
275+
* {1, 0, 0, 1, 1, 1, 1, 1, 1}
276+
*/
277+
if (match_num > max) {
278+
max = match_num;
279+
end = i - 1;
280+
}
281+
282+
*out_length = max;
283+
*out_end_index = end;
275284
}
276285

277286
static void s_select_best_tuning_config(mspi_timing_config_t *config, uint32_t consecutive_length, uint32_t end, const uint8_t *reference_data, bool is_flash)

0 commit comments

Comments
 (0)