sdm: correct concept duty to density

This commit is contained in:
laokaiyao
2023-01-04 15:11:45 +08:00
parent 59984e7d1f
commit 6b631b68d1
20 changed files with 99 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -37,7 +37,7 @@ TEST_CASE("sdm_channel_install_uninstall", "[sdm]")
}
}
TEST_CASE("sdm_channel_set_duty", "[sdm]")
TEST_CASE("sdm_channel_set_pulse_density", "[sdm]")
{
const int sdm_chan_gpios[2] = {0, 2};
sdm_config_t config = {
@@ -49,7 +49,7 @@ TEST_CASE("sdm_channel_set_duty", "[sdm]")
config.gpio_num = sdm_chan_gpios[i];
TEST_ESP_OK(sdm_new_channel(&config, &chans[i]));
// should see a ~250KHz (sample_rate/4) square wave
TEST_ESP_OK(sdm_channel_set_duty(chans[i], 0));
TEST_ESP_OK(sdm_channel_set_pulse_density(chans[i], 0));
TEST_ESP_OK(sdm_channel_enable(chans[i]));
}
vTaskDelay(pdMS_TO_TICKS(500));
@@ -57,8 +57,8 @@ TEST_CASE("sdm_channel_set_duty", "[sdm]")
// can't delete the channel if the channel is in the enable state
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, sdm_del_channel(chans[0]));
TEST_ESP_OK(sdm_channel_set_duty(chans[0], 127));
TEST_ESP_OK(sdm_channel_set_duty(chans[1], -128));
TEST_ESP_OK(sdm_channel_set_pulse_density(chans[0], 127));
TEST_ESP_OK(sdm_channel_set_pulse_density(chans[1], -128));
vTaskDelay(pdMS_TO_TICKS(500));
for (size_t i = 0; i < 2; i++) {