summaryrefslogtreecommitdiff
path: root/src/drivers/include/dac.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2022-12-06 13:17:56 +1100
committerjacqueline <me@jacqueline.id.au>2022-12-06 13:17:56 +1100
commitf35bb64c2b8dbb72fd15f1880e4d01d263660910 (patch)
tree4696065116c21147da02b6e6470a6215b343081f /src/drivers/include/dac.hpp
parente0b2562cc4e0e5ae73efacddf68b83bd9fbb6acb (diff)
downloadtangara-fw-f35bb64c2b8dbb72fd15f1880e4d01d263660910.tar.gz
basic i2s output element
Diffstat (limited to 'src/drivers/include/dac.hpp')
-rw-r--r--src/drivers/include/dac.hpp21
1 files changed, 21 insertions, 0 deletions
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 <functional>
#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<std::unique_ptr<AudioDac>, Error>;
@@ -47,6 +52,22 @@ class AudioDac {
/* Returns the current boot-up status and internal state of the DAC */
std::pair<bool, PowerState> 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<std::byte>& data, TickType_t max_wait)
+ -> std::size_t;
+
// Not copyable or movable.
AudioDac(const AudioDac&) = delete;
AudioDac& operator=(const AudioDac&) = delete;