diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f56397f..86c54a3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ set(SDKCONFIG_DEFAULTS "sdkconfig.common") # No exceptions in app builds (this is different in test builds). idf_build_set_property(COMPILE_OPTIONS "-DRESULT_DISABLE_EXCEPTIONS" APPEND) +idf_build_set_property(COMPILE_OPTIONS "-DTCB_SPAN_NO_CONTRACT_CHECKING" APPEND) # Include all app components. list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/src") diff --git a/dependencies.lock b/dependencies.lock index 21edf3ef..888b56a2 100644 --- a/dependencies.lock +++ b/dependencies.lock @@ -1,3 +1,9 @@ -manifest_hash: e0cfd1319bfb46d732ec9d319e9dc49e36898e504018c81401232151605e3547 +dependencies: + idf: + component_hash: null + source: + type: idf + version: 5.0.0 +manifest_hash: 7e6103d8e34e5eabd5a6a51c49836c58f1686c3aa287f2e288b1ad76243aa61a target: esp32 version: 1.0.0 diff --git a/src/audio/audio_element_handle.cpp b/src/audio/audio_element_handle.cpp index 4b746db3..1250bbcf 100644 --- a/src/audio/audio_element_handle.cpp +++ b/src/audio/audio_element_handle.cpp @@ -1,6 +1,7 @@ #include "audio_element_handle.hpp" #include "audio_element.hpp" #include "freertos/projdefs.h" +#include "freertos/task.h" namespace audio { @@ -47,7 +48,7 @@ auto AudioElementHandle::QuitSync() -> void { } auto AudioElementHandle::MonitorUtilState(eTaskState desired) -> void { - while (eTaskGetState(task_.get()) != desired) { + while (eTaskGetState(*task_) != desired) { WakeUpTask(); vTaskDelay(pdMS_TO_TICKS(1)); } @@ -63,13 +64,13 @@ auto AudioElementHandle::WakeUpTask() -> void { // between now and its next element state check. Also think about chunk blocks // nested in element bodies. // Maybe we need a big mutex or semaphore somewhere in here. - switch (eTaskGetState(task_.get())) { + switch (eTaskGetState(*task_)) { case eBlocked: // TODO: when is this safe? - xTaskAbortDelay(task_.get()); + xTaskAbortDelay(*task_); break; case eSuspended: - vTaskResume(task_.get()); + vTaskResume(*task_); break; default: return; diff --git a/src/drivers/battery.cpp b/src/drivers/battery.cpp index b45e20cf..29224e2d 100644 --- a/src/drivers/battery.cpp +++ b/src/drivers/battery.cpp @@ -2,17 +2,19 @@ #include #include "esp_adc/adc_oneshot.h" +#include "esp_adc/adc_cali.h" +#include "esp_adc/adc_cali_scheme.h" #include "hal/adc_types.h" namespace drivers { -static const uint8_t kAdcBitWidth = ADC_BITWIDTH_12; -static const uint8_t kAdcUnit = ADC_UNIT_1; +static const adc_bitwidth_t kAdcBitWidth = ADC_BITWIDTH_12; +static const adc_unit_t kAdcUnit = ADC_UNIT_1; // Max battery voltage should be a little over 2V due to our divider, so we need // the max attenuation to properly handle the full range. -static const uint8_t kAdcAttenuation = ADC_ATTEN_DB_11; +static const adc_atten_t kAdcAttenuation = ADC_ATTEN_DB_11; // Corresponds to GPIO 34. -static const uint8_t kAdcChannel = ADC_CHANNEL_6; +static const adc_channel_t kAdcChannel = ADC_CHANNEL_6; Battery::Battery() { adc_oneshot_unit_init_cfg_t unit_config = { @@ -21,8 +23,8 @@ Battery::Battery() { ESP_ERROR_CHECK(adc_oneshot_new_unit(&unit_config, &adc_handle_)); adc_oneshot_chan_cfg_t channel_config = { - .bitwidth = kAdcBitWidth, .atten = kAdcAttenuation, + .bitwidth = kAdcBitWidth, }; ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_handle_, kAdcChannel, &channel_config)); @@ -42,11 +44,11 @@ Battery::~Battery() { auto Battery::Millivolts() -> uint32_t { // GPIO 34 - int raw; - ESP_ERROR_CHECK(adc_oneshot_read(adc_handle, kAdcChannel &raw)); + int raw = 0; + ESP_ERROR_CHECK(adc_oneshot_read(adc_handle_, kAdcChannel, &raw)); - int voltage; - ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_calibration_handle, raw, &voltage)); + int voltage = 0; + ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_calibration_handle_, raw, &voltage)); return voltage; } diff --git a/src/drivers/dac.cpp b/src/drivers/dac.cpp index 23c67e88..78bf94c4 100644 --- a/src/drivers/dac.cpp +++ b/src/drivers/dac.cpp @@ -5,6 +5,8 @@ #include "assert.h" #include "driver/i2c.h" #include "driver/i2s.h" +#include "driver/i2s_types.h" +#include "driver/i2s_types_legacy.h" #include "esp_err.h" #include "esp_log.h" #include "hal/i2c_types.h" @@ -17,7 +19,7 @@ namespace drivers { static const char* kTag = "AUDIODAC"; static const uint8_t kPcm5122Address = 0x4C; -static const uint8_t kPcm5122Timeout = 100 / portTICK_RATE_MS; +static const uint8_t kPcm5122Timeout = pdMS_TO_TICKS(100); static const i2s_port_t kI2SPort = I2S_NUM_0; static const AudioDac::SampleRate kDefaultSampleRate = @@ -46,7 +48,7 @@ auto AudioDac::create(GpioExpander* expander) .use_apll = false, .tx_desc_auto_clear = false, .fixed_mclk = 0, - .mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, + .mclk_multiple = I2S_MCLK_MULTIPLE_512, // TODO: double check .bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT, }; diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp index 8aaca4a4..83710f45 100644 --- a/src/drivers/display.cpp +++ b/src/drivers/display.cpp @@ -122,7 +122,7 @@ auto Display::create(GpioExpander* expander, ESP_LOGI(kTag, "Registering driver"); display->display_ = lv_disp_drv_register(&display->driver_); - return std::move(display); + return display; } Display::Display(GpioExpander* gpio, spi_device_handle_t handle) diff --git a/src/drivers/include/battery.hpp b/src/drivers/include/battery.hpp index 9366a5b1..dea46d7c 100644 --- a/src/drivers/include/battery.hpp +++ b/src/drivers/include/battery.hpp @@ -3,6 +3,7 @@ #include #include "esp_adc/adc_oneshot.h" +#include "esp_adc/adc_cali.h" #include "esp_err.h" #include "result.hpp" @@ -18,7 +19,7 @@ class Battery { */ auto Millivolts() -> uint32_t; private: - adc_oneshot_handle_t adc_handle_; + adc_oneshot_unit_handle_t adc_handle_; adc_cali_handle_t adc_calibration_handle_; }; diff --git a/src/drivers/include/dac.hpp b/src/drivers/include/dac.hpp index dc03624b..2d4e812f 100644 --- a/src/drivers/include/dac.hpp +++ b/src/drivers/include/dac.hpp @@ -9,6 +9,7 @@ #include "hal/i2s_types.h" #include "result.hpp" #include "span.hpp" +#include "driver/i2s_types_legacy.h" #include "gpio_expander.hpp" diff --git a/src/drivers/include/display.hpp b/src/drivers/include/display.hpp index 75b2f9a6..5f6d6f58 100644 --- a/src/drivers/include/display.hpp +++ b/src/drivers/include/display.hpp @@ -8,6 +8,7 @@ #include "display_init.hpp" #include "gpio_expander.hpp" +#include "sys/_stdint.h" namespace drivers { @@ -63,7 +64,7 @@ class Display { void SendTransaction(TransactionType type, const uint8_t* data, size_t length, - uintptr_t flags = 0); + uint32_t flags = 0); }; } // namespace drivers diff --git a/src/drivers/include/gpio_expander.hpp b/src/drivers/include/gpio_expander.hpp index 8875e954..a6e96d87 100644 --- a/src/drivers/include/gpio_expander.hpp +++ b/src/drivers/include/gpio_expander.hpp @@ -32,7 +32,7 @@ class GpioExpander { ~GpioExpander(); static const uint8_t kPca8575Address = 0x20; - static const uint8_t kPca8575Timeout = 100 / portTICK_RATE_MS; + static const uint8_t kPca8575Timeout = pdMS_TO_TICKS(100); // Port A: // 0 - audio power enable diff --git a/src/drivers/include/i2c.hpp b/src/drivers/include/i2c.hpp index 3704509d..dbdd8a11 100644 --- a/src/drivers/include/i2c.hpp +++ b/src/drivers/include/i2c.hpp @@ -20,7 +20,7 @@ esp_err_t deinit_i2c(void); */ class I2CTransaction { public: - static const uint8_t kI2CTimeout = 100 / portTICK_RATE_MS; + static const uint8_t kI2CTimeout = pdMS_TO_TICKS(100); I2CTransaction(); ~I2CTransaction(); diff --git a/src/main/main.cpp b/src/main/main.cpp index ad4b2d01..2f874bc7 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -106,7 +106,7 @@ extern "C" void app_main(void) { ESP_LOGI(TAG, "Init battery measurement"); drivers::Battery* battery = new drivers::Battery(); - ESP_LOGI(TAG, "it's reading %dmV!", battery->Millivolts()); + ESP_LOGI(TAG, "it's reading %d mV!", (int) battery->Millivolts()); ESP_LOGI(TAG, "Init SD card"); auto storage_res = drivers::SdStorage::create(expander);