mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 11:03:11 +00:00
Merge branch 'fix/fix_spi_sleep_retention_power_hold_v5.3' into 'release/v5.3'
fix(driver_spi): fixed spi sleep still power down even no allow_pd (v5.3) See merge request espressif/esp-idf!46244
This commit is contained in:
@@ -1858,7 +1858,6 @@ TEST_CASE("test_spi_master_sleep_retention", "[spi]")
|
||||
spi_bus_config_t buscfg = SPI_BUS_TEST_DEFAULT_CONFIG();
|
||||
spi_device_interface_config_t devcfg = SPI_DEVICE_TEST_DEFAULT_CONFIG();
|
||||
buscfg.flags |= SPICOMMON_BUSFLAG_GPIO_PINS;
|
||||
buscfg.flags |= SPICOMMON_BUSFLAG_SLP_ALLOW_PD;
|
||||
uint8_t send[16] = "hello spi x\n";
|
||||
uint8_t recv[16];
|
||||
spi_transaction_t trans_cfg = {
|
||||
@@ -1867,38 +1866,42 @@ TEST_CASE("test_spi_master_sleep_retention", "[spi]")
|
||||
.rx_buffer = recv,
|
||||
};
|
||||
|
||||
for (int periph = SPI2_HOST; periph < SPI_HOST_MAX; periph ++) {
|
||||
for (int test_dma = 0; test_dma <= 1; test_dma ++) {
|
||||
int use_dma = SPI_DMA_DISABLED;
|
||||
for (int power_down = 0; power_down <= 1; power_down++) {
|
||||
printf("\nTest with power down: %s\n", power_down ? "YES" : "NO");
|
||||
buscfg.flags |= power_down ? SPICOMMON_BUSFLAG_SLP_ALLOW_PD : 0;
|
||||
for (int periph = SPI2_HOST; periph < SPI_HOST_MAX; periph ++) {
|
||||
for (int test_dma = 0; test_dma <= 1; test_dma ++) {
|
||||
int use_dma = SPI_DMA_DISABLED;
|
||||
#if SOC_GDMA_SUPPORT_SLEEP_RETENTION // TODO: IDF-11317 test dma on esp32 and s2
|
||||
use_dma = test_dma ? SPI_DMA_CH_AUTO : SPI_DMA_DISABLED;
|
||||
use_dma = test_dma ? SPI_DMA_CH_AUTO : SPI_DMA_DISABLED;
|
||||
#endif
|
||||
printf("Retention on GPSPI%d with dma: %d\n", periph + 1, use_dma);
|
||||
TEST_ESP_OK(spi_bus_initialize(periph, &buscfg, use_dma));
|
||||
// set spi "self-loop" after bus initialized
|
||||
spitest_gpio_output_sel(buscfg.miso_io_num, FUNC_GPIO, spi_periph_signal[periph].spid_out);
|
||||
TEST_ESP_OK(spi_bus_add_device(periph, &devcfg, &dev_handle));
|
||||
printf("Retention on GPSPI%d with dma: %d\n", periph + 1, use_dma);
|
||||
TEST_ESP_OK(spi_bus_initialize(periph, &buscfg, use_dma));
|
||||
// set spi "self-loop" after bus initialized
|
||||
spitest_gpio_output_sel(buscfg.miso_io_num, FUNC_GPIO, spi_periph_signal[periph].spid_out);
|
||||
TEST_ESP_OK(spi_bus_add_device(periph, &devcfg, &dev_handle));
|
||||
|
||||
for (uint8_t cnt = 0; cnt < 3; cnt ++) {
|
||||
printf("Going into sleep...\n");
|
||||
TEST_ESP_OK(esp_light_sleep_start());
|
||||
printf("Waked up!\n");
|
||||
for (uint8_t cnt = 0; cnt < 3; cnt ++) {
|
||||
printf("Going into sleep...\n");
|
||||
TEST_ESP_OK(esp_light_sleep_start());
|
||||
printf("Waked up!\n");
|
||||
|
||||
// check if the sleep happened as expected
|
||||
TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result);
|
||||
// check if the sleep happened as expected
|
||||
TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result);
|
||||
#if SOC_SPI_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
||||
// check if the power domain also is powered down
|
||||
TEST_ASSERT_EQUAL((buscfg.flags & SPICOMMON_BUSFLAG_SLP_ALLOW_PD) ? PMU_SLEEP_PD_TOP : 0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP);
|
||||
// check if the power domain also is powered down
|
||||
TEST_ASSERT_EQUAL((buscfg.flags & SPICOMMON_BUSFLAG_SLP_ALLOW_PD) ? PMU_SLEEP_PD_TOP : 0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP);
|
||||
#endif
|
||||
memset(recv, 0, sizeof(recv));
|
||||
send[10] = cnt + 'A';
|
||||
TEST_ESP_OK(spi_device_transmit(dev_handle, &trans_cfg));
|
||||
printf("%s", recv);
|
||||
spitest_cmp_or_dump(trans_cfg.tx_buffer, trans_cfg.rx_buffer, sizeof(send));
|
||||
}
|
||||
memset(recv, 0, sizeof(recv));
|
||||
send[10] = cnt + 'A';
|
||||
TEST_ESP_OK(spi_device_transmit(dev_handle, &trans_cfg));
|
||||
printf("%s", recv);
|
||||
spitest_cmp_or_dump(trans_cfg.tx_buffer, trans_cfg.rx_buffer, sizeof(send));
|
||||
}
|
||||
|
||||
TEST_ESP_OK(spi_bus_remove_device(dev_handle));
|
||||
TEST_ESP_OK(spi_bus_free(periph));
|
||||
TEST_ESP_OK(spi_bus_remove_device(dev_handle));
|
||||
TEST_ESP_OK(spi_bus_free(periph));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,10 @@ bool peripheral_domain_pd_allowed(void)
|
||||
mask.bitmap[SLEEP_RETENTION_MODULE_MCPWM0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_MCPWM0 % 32);
|
||||
#endif
|
||||
|
||||
#if SOC_SPI_SUPPORT_SLEEP_RETENTION
|
||||
mask.bitmap[SLEEP_RETENTION_MODULE_GPSPI2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_GPSPI2 % 32);
|
||||
#endif
|
||||
|
||||
const sleep_retention_module_bitmap_t peripheral_domain_inited_modules = sleep_retention_module_bitmap_and(inited_modules, mask);
|
||||
const sleep_retention_module_bitmap_t peripheral_domain_created_modules = sleep_retention_module_bitmap_and(created_modules, mask);
|
||||
return sleep_retention_module_bitmap_eq(peripheral_domain_inited_modules, peripheral_domain_created_modules);
|
||||
|
||||
Reference in New Issue
Block a user