From f35bb64c2b8dbb72fd15f1880e4d01d263660910 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 6 Dec 2022 13:17:56 +1100 Subject: basic i2s output element --- src/drivers/include/dac.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/drivers/include') diff --git a/src/drivers/include/dac.hpp b/src/drivers/include/dac.hpp index 6d812b6a..dc03624b 100644 --- a/src/drivers/include/dac.hpp +++ b/src/drivers/include/dac.hpp @@ -5,7 +5,10 @@ #include #include "esp_err.h" +#include "freertos/portmacro.h" +#include "hal/i2s_types.h" #include "result.hpp" +#include "span.hpp" #include "gpio_expander.hpp" @@ -19,7 +22,9 @@ class AudioDac { enum Error { FAILED_TO_BOOT, FAILED_TO_CONFIGURE, + FAILED_TO_INSTALL_I2S, }; + static auto create(GpioExpander* expander) -> cpp::result, Error>; @@ -47,6 +52,22 @@ class AudioDac { /* Returns the current boot-up status and internal state of the DAC */ std::pair ReadPowerState(); + enum BitsPerSample { + BPS_16 = I2S_BITS_PER_SAMPLE_16BIT, + BPS_24 = I2S_BITS_PER_SAMPLE_24BIT, + BPS_32 = I2S_BITS_PER_SAMPLE_32BIT + }; + enum SampleRate { + SAMPLE_RATE_44_1 = 44100, + SAMPLE_RATE_48 = 48000, + }; + + // TODO(jacqueline): worth supporting channels here as well? + auto Reconfigure(BitsPerSample bps, SampleRate rate) -> bool; + + auto WriteData(const cpp::span& data, TickType_t max_wait) + -> std::size_t; + // Not copyable or movable. AudioDac(const AudioDac&) = delete; AudioDac& operator=(const AudioDac&) = delete; -- cgit v1.2.3