build fixes for new compiler version and standard

custom
jacqueline 2 years ago
parent 8cb9e9361c
commit c7901ae429
  1. 1
      CMakeLists.txt
  2. 8
      dependencies.lock
  3. 9
      src/audio/audio_element_handle.cpp
  4. 20
      src/drivers/battery.cpp
  5. 6
      src/drivers/dac.cpp
  6. 2
      src/drivers/display.cpp
  7. 3
      src/drivers/include/battery.hpp
  8. 1
      src/drivers/include/dac.hpp
  9. 3
      src/drivers/include/display.hpp
  10. 2
      src/drivers/include/gpio_expander.hpp
  11. 2
      src/drivers/include/i2c.hpp
  12. 2
      src/main/main.cpp

@ -5,6 +5,7 @@ set(SDKCONFIG_DEFAULTS "sdkconfig.common")
# No exceptions in app builds (this is different in test builds). # 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 "-DRESULT_DISABLE_EXCEPTIONS" APPEND)
idf_build_set_property(COMPILE_OPTIONS "-DTCB_SPAN_NO_CONTRACT_CHECKING" APPEND)
# Include all app components. # Include all app components.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/src") list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/src")

@ -1,3 +1,9 @@
manifest_hash: e0cfd1319bfb46d732ec9d319e9dc49e36898e504018c81401232151605e3547 dependencies:
idf:
component_hash: null
source:
type: idf
version: 5.0.0
manifest_hash: 7e6103d8e34e5eabd5a6a51c49836c58f1686c3aa287f2e288b1ad76243aa61a
target: esp32 target: esp32
version: 1.0.0 version: 1.0.0

@ -1,6 +1,7 @@
#include "audio_element_handle.hpp" #include "audio_element_handle.hpp"
#include "audio_element.hpp" #include "audio_element.hpp"
#include "freertos/projdefs.h" #include "freertos/projdefs.h"
#include "freertos/task.h"
namespace audio { namespace audio {
@ -47,7 +48,7 @@ auto AudioElementHandle::QuitSync() -> void {
} }
auto AudioElementHandle::MonitorUtilState(eTaskState desired) -> void { auto AudioElementHandle::MonitorUtilState(eTaskState desired) -> void {
while (eTaskGetState(task_.get()) != desired) { while (eTaskGetState(*task_) != desired) {
WakeUpTask(); WakeUpTask();
vTaskDelay(pdMS_TO_TICKS(1)); 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 // between now and its next element state check. Also think about chunk blocks
// nested in element bodies. // nested in element bodies.
// Maybe we need a big mutex or semaphore somewhere in here. // Maybe we need a big mutex or semaphore somewhere in here.
switch (eTaskGetState(task_.get())) { switch (eTaskGetState(*task_)) {
case eBlocked: case eBlocked:
// TODO: when is this safe? // TODO: when is this safe?
xTaskAbortDelay(task_.get()); xTaskAbortDelay(*task_);
break; break;
case eSuspended: case eSuspended:
vTaskResume(task_.get()); vTaskResume(*task_);
break; break;
default: default:
return; return;

@ -2,17 +2,19 @@
#include <cstdint> #include <cstdint>
#include "esp_adc/adc_oneshot.h" #include "esp_adc/adc_oneshot.h"
#include "esp_adc/adc_cali.h"
#include "esp_adc/adc_cali_scheme.h"
#include "hal/adc_types.h" #include "hal/adc_types.h"
namespace drivers { namespace drivers {
static const uint8_t kAdcBitWidth = ADC_BITWIDTH_12; static const adc_bitwidth_t kAdcBitWidth = ADC_BITWIDTH_12;
static const uint8_t kAdcUnit = ADC_UNIT_1; 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 // 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. // 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. // Corresponds to GPIO 34.
static const uint8_t kAdcChannel = ADC_CHANNEL_6; static const adc_channel_t kAdcChannel = ADC_CHANNEL_6;
Battery::Battery() { Battery::Battery() {
adc_oneshot_unit_init_cfg_t unit_config = { 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_)); ESP_ERROR_CHECK(adc_oneshot_new_unit(&unit_config, &adc_handle_));
adc_oneshot_chan_cfg_t channel_config = { adc_oneshot_chan_cfg_t channel_config = {
.bitwidth = kAdcBitWidth,
.atten = kAdcAttenuation, .atten = kAdcAttenuation,
.bitwidth = kAdcBitWidth,
}; };
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_handle_, kAdcChannel, &channel_config)); ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_handle_, kAdcChannel, &channel_config));
@ -42,11 +44,11 @@ Battery::~Battery() {
auto Battery::Millivolts() -> uint32_t { auto Battery::Millivolts() -> uint32_t {
// GPIO 34 // GPIO 34
int raw; int raw = 0;
ESP_ERROR_CHECK(adc_oneshot_read(adc_handle, kAdcChannel &raw)); ESP_ERROR_CHECK(adc_oneshot_read(adc_handle_, kAdcChannel, &raw));
int voltage; int voltage = 0;
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_calibration_handle, raw, &voltage)); ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_calibration_handle_, raw, &voltage));
return voltage; return voltage;
} }

@ -5,6 +5,8 @@
#include "assert.h" #include "assert.h"
#include "driver/i2c.h" #include "driver/i2c.h"
#include "driver/i2s.h" #include "driver/i2s.h"
#include "driver/i2s_types.h"
#include "driver/i2s_types_legacy.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_log.h" #include "esp_log.h"
#include "hal/i2c_types.h" #include "hal/i2c_types.h"
@ -17,7 +19,7 @@ namespace drivers {
static const char* kTag = "AUDIODAC"; static const char* kTag = "AUDIODAC";
static const uint8_t kPcm5122Address = 0x4C; 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 i2s_port_t kI2SPort = I2S_NUM_0;
static const AudioDac::SampleRate kDefaultSampleRate = static const AudioDac::SampleRate kDefaultSampleRate =
@ -46,7 +48,7 @@ auto AudioDac::create(GpioExpander* expander)
.use_apll = false, .use_apll = false,
.tx_desc_auto_clear = false, .tx_desc_auto_clear = false,
.fixed_mclk = 0, .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, .bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT,
}; };

@ -122,7 +122,7 @@ auto Display::create(GpioExpander* expander,
ESP_LOGI(kTag, "Registering driver"); ESP_LOGI(kTag, "Registering driver");
display->display_ = lv_disp_drv_register(&display->driver_); display->display_ = lv_disp_drv_register(&display->driver_);
return std::move(display); return display;
} }
Display::Display(GpioExpander* gpio, spi_device_handle_t handle) Display::Display(GpioExpander* gpio, spi_device_handle_t handle)

@ -3,6 +3,7 @@
#include <cstdint> #include <cstdint>
#include "esp_adc/adc_oneshot.h" #include "esp_adc/adc_oneshot.h"
#include "esp_adc/adc_cali.h"
#include "esp_err.h" #include "esp_err.h"
#include "result.hpp" #include "result.hpp"
@ -18,7 +19,7 @@ class Battery {
*/ */
auto Millivolts() -> uint32_t; auto Millivolts() -> uint32_t;
private: private:
adc_oneshot_handle_t adc_handle_; adc_oneshot_unit_handle_t adc_handle_;
adc_cali_handle_t adc_calibration_handle_; adc_cali_handle_t adc_calibration_handle_;
}; };

@ -9,6 +9,7 @@
#include "hal/i2s_types.h" #include "hal/i2s_types.h"
#include "result.hpp" #include "result.hpp"
#include "span.hpp" #include "span.hpp"
#include "driver/i2s_types_legacy.h"
#include "gpio_expander.hpp" #include "gpio_expander.hpp"

@ -8,6 +8,7 @@
#include "display_init.hpp" #include "display_init.hpp"
#include "gpio_expander.hpp" #include "gpio_expander.hpp"
#include "sys/_stdint.h"
namespace drivers { namespace drivers {
@ -63,7 +64,7 @@ class Display {
void SendTransaction(TransactionType type, void SendTransaction(TransactionType type,
const uint8_t* data, const uint8_t* data,
size_t length, size_t length,
uintptr_t flags = 0); uint32_t flags = 0);
}; };
} // namespace drivers } // namespace drivers

@ -32,7 +32,7 @@ class GpioExpander {
~GpioExpander(); ~GpioExpander();
static const uint8_t kPca8575Address = 0x20; 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: // Port A:
// 0 - audio power enable // 0 - audio power enable

@ -20,7 +20,7 @@ esp_err_t deinit_i2c(void);
*/ */
class I2CTransaction { class I2CTransaction {
public: public:
static const uint8_t kI2CTimeout = 100 / portTICK_RATE_MS; static const uint8_t kI2CTimeout = pdMS_TO_TICKS(100);
I2CTransaction(); I2CTransaction();
~I2CTransaction(); ~I2CTransaction();

@ -106,7 +106,7 @@ extern "C" void app_main(void) {
ESP_LOGI(TAG, "Init battery measurement"); ESP_LOGI(TAG, "Init battery measurement");
drivers::Battery* battery = new drivers::Battery(); 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"); ESP_LOGI(TAG, "Init SD card");
auto storage_res = drivers::SdStorage::create(expander); auto storage_res = drivers::SdStorage::create(expander);

Loading…
Cancel
Save