Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Berry ULP: no assertion when adc_config fails #22696

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/libesp32/berry_tasmota/src/be_ULP_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ BE_FUNC_CTYPE_DECLARE(be_ULP_get_mem, "i", "i");
extern int32_t be_ULP_gpio_init(int32_t pin, int32_t mode);
BE_FUNC_CTYPE_DECLARE(be_ULP_gpio_init, "i", "ii");

extern void be_ULP_adc_config(struct bvm *vm, int32_t channel, int32_t attenuation, int32_t width);
BE_FUNC_CTYPE_DECLARE(be_ULP_adc_config, "", "@iii");
extern int32_t be_ULP_adc_config(struct bvm *vm, int32_t channel, int32_t attenuation, int32_t width);
BE_FUNC_CTYPE_DECLARE(be_ULP_adc_config, "i", "@iii");

extern void be_ULP_sleep(int32_t wake_up_s);
BE_FUNC_CTYPE_DECLARE(be_ULP_sleep, "", "[i]"); // optional int arg
Expand Down
37 changes: 10 additions & 27 deletions tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_ulp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,20 @@
#ifdef USE_BERRY_ULP
#include <berry.h>

// #if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_ULP_COPROC_TYPE_LP_CORE)
#if defined(CONFIG_ULP_COPROC_ENABLED)

#if defined(CONFIG_IDF_TARGET_ESP32)
#include "esp32/ulp.h"
#endif // esp32
// #if ESP_IDF_VERSION_MAJOR < 5
// #if defined(CONFIG_IDF_TARGET_ESP32S2)
// #include "esp32s2/ulp.h"
// #include "esp32s2/ulp_riscv.h"
// #include "esp32s2/ulp_riscv_adc.h"
// #endif // s2
// #if defined(CONFIG_IDF_TARGET_ESP32S3)
// #include "esp32s3/ulp.h"
// #include "esp32s3/ulp_riscv.h"
// #include "esp32s3/ulp_riscv_adc.h"
// #endif //s3
// #endif // ESP_IDF_VERSION_MAJOR < 5

#include "driver/rtc_io.h"
#include "driver/gpio.h"
// #if ESP_IDF_VERSION_MAJOR >= 5
#include "esp_adc/adc_oneshot.h"
#include "ulp_adc.h"
#if defined(CONFIG_ULP_COPROC_TYPE_RISCV) // S2 or S3
#include "ulp_riscv.h"
#endif // defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
// #else
// #include "driver/adc.h"
// #endif // ESP_IDF_VERSION_MAJOR >= 5

#include "ulp_adc.h"
#if defined(CONFIG_ULP_COPROC_TYPE_RISCV) // S2 or S3
#include "ulp_riscv.h"
#endif // defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)

#ifdef CONFIG_ULP_COPROC_TYPE_LP_CORE
#include "ulp_lp_core.h"
ulp_lp_core_cfg_t be_ulp_lp_core_cfg;
Expand Down Expand Up @@ -109,10 +94,10 @@ extern "C" {
}
}

// `ULP.adc_config(channel:int, attenuation:int, width:int) -> nil`
// `ULP.adc_config(channel:int, attenuation:int, width:int) -> error:int`
//
// enums: channel 0-7, attenuation 0-3, width 0-3
void be_ULP_adc_config(struct bvm *vm, int32_t channel, int32_t attenuation, int32_t width) {
int32_t be_ULP_adc_config(struct bvm *vm, int32_t channel, int32_t attenuation, int32_t width) {
#if defined(CONFIG_IDF_TARGET_ESP32)
ulp_adc_cfg_t cfg = {
.adc_n = ADC_UNIT_1,
Expand Down Expand Up @@ -141,9 +126,7 @@ extern "C" {
be_raisef(vm, "ulp_adc_config_error", "ULP: not supported before ESP-IDF 5.4");
esp_err_t err = ESP_FAIL;
#endif
if (err != ESP_OK) {
be_raisef(vm, "ulp_adc_config_error", "ULP: invalid code err=%i", err);
}
return err;
}

/**
Expand Down
Loading