From bba6bf387ec41712597b49506d6094dabdc75a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 29 Nov 2022 14:35:46 +0100 Subject: [PATCH] hopefully fix compilation errors --- src/modules/esp32/AudioModule.cpp | 16 ++++++++++++++-- src/modules/esp32/AudioModule.h | 12 ++---------- variants/heltec_v3/platformio.ini | 2 +- variants/heltec_wsl_v3/platformio.ini | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp index 0f95c306a..959366dec 100644 --- a/src/modules/esp32/AudioModule.cpp +++ b/src/modules/esp32/AudioModule.cpp @@ -1,4 +1,6 @@ + #include "configuration.h" +#if defined(ARCH_ESP32) #include "AudioModule.h" #include "MeshService.h" #include "NodeDB.h" @@ -44,8 +46,6 @@ #define AUDIO_MODULE_DATA_MAX Constants_DATA_PAYLOAD_LEN #define AUDIO_MODULE_MODE ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700 -#if defined(ARCH_ESP32) - AudioModule *audioModule; Codec2Thread *codec2Thread; @@ -67,12 +67,21 @@ uint8_t rx_raw_audio_value = 127; int IRAM_ATTR local_adc1_read(int channel) { uint16_t adc_value; +#if CONFIG_IDF_TARGET_ESP32S3 + SENS.sar_meas1_ctrl2.sar1_en_pad = (1 << channel); // only one channel is selected + while (SENS.sar_slave_addr1.meas_status != 0); + SENS.sar_meas1_ctrl2.meas1_start_sar = 0; + SENS.sar_meas1_ctrl2.meas1_start_sar = 1; + while (SENS.sar_meas1_ctrl2.meas1_done_sar == 0); + adc_value = SENS.sar_meas1_ctrl2.meas1_data_sar; +#else SENS.sar_meas_start1.sar1_en_pad = (1 << channel); // only one channel is selected while (SENS.sar_slave_addr1.meas_status != 0); SENS.sar_meas_start1.meas1_start_sar = 0; SENS.sar_meas_start1.meas1_start_sar = 1; while (SENS.sar_meas_start1.meas1_done_sar == 0); adc_value = SENS.sar_meas_start1.meas1_data_sar; +#endif return adc_value; } @@ -106,7 +115,10 @@ IRAM_ATTR void am_onTimer() //Get a value from audio_fifo and convert it to 0 - 255 to play it in the ADC if (audio_fifo.get(&v)) rx_raw_audio_value = (uint8_t)((v + 32768) / 256); + // comment out for now, S3 does not have Hardware-DAC. Consider I2S instead. +#if !CONFIG_IDF_TARGET_ESP32S3 dacWrite(moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP, rx_raw_audio_value); +#endif } portEXIT_CRITICAL_ISR(&timerMux); // exit critical code } diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h index c83160cfb..16705a141 100644 --- a/src/modules/esp32/AudioModule.h +++ b/src/modules/esp32/AudioModule.h @@ -3,15 +3,14 @@ #include "SinglePortModule.h" #include "concurrency/OSThread.h" #include "configuration.h" +#if defined(ARCH_ESP32) #include "NodeDB.h" #include #include #include -#if defined(ARCH_ESP32) #include #include #include -#endif #define ADC_BUFFER_SIZE 320 // 40ms of voice in 8KHz sampling frequency #define ENCODE_CODEC2_SIZE 8 @@ -19,7 +18,6 @@ class Codec2Thread : public concurrency::NotifiedWorkerThread { -#if defined(ARCH_ESP32) struct CODEC2* codec2_state = NULL; int16_t output_buffer[ADC_BUFFER_SIZE] = {}; @@ -28,16 +26,12 @@ class Codec2Thread : public concurrency::NotifiedWorkerThread protected: virtual void onNotify(uint32_t notification) override; -#endif }; class AudioModule : public SinglePortModule, private concurrency::OSThread { -#if defined(ARCH_ESP32) bool firstTime = true; hw_timer_t* adcTimer = NULL; - - FastAudioFIFO audio_fifo; uint16_t adc_buffer_index = 0; @@ -64,13 +58,11 @@ class AudioModule : public SinglePortModule, private concurrency::OSThread * @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it */ virtual ProcessMessage handleReceived(const MeshPacket &mp) override; -#endif }; extern AudioModule *audioModule; extern Codec2Thread *codec2Thread; -extern FastAudioFIFO audio_fifo; extern uint16_t adc_buffer[ADC_BUFFER_SIZE]; extern uint16_t adc_buffer_index; extern portMUX_TYPE timerMux; @@ -80,4 +72,4 @@ extern volatile RadioState radio_state; extern adc1_channel_t mic_chan; IRAM_ATTR void am_onTimer(); - +#endif \ No newline at end of file diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index 6cd75bed8..372f42d64 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -1,6 +1,6 @@ [env:heltec-v3] platform = https://github.com/Baptou88/platform-espressif32.git -extends = esp32_base +extends = esp32s3_base board = heltec_wifi_lora_32_V3 # Temporary: https://community.platformio.org/t/heltec-esp32-lora-v3-board-support/30406/2 platform_packages = diff --git a/variants/heltec_wsl_v3/platformio.ini b/variants/heltec_wsl_v3/platformio.ini index 8854b1a44..336e44936 100644 --- a/variants/heltec_wsl_v3/platformio.ini +++ b/variants/heltec_wsl_v3/platformio.ini @@ -1,6 +1,6 @@ [env:heltec-wsl-v3] platform = https://github.com/Baptou88/platform-espressif32.git -extends = esp32_base +extends = esp32s3_base board = heltec_wifi_lora_32_V3 # Temporary: https://community.platformio.org/t/heltec-esp32-lora-v3-board-support/30406/2 platform_packages =