arduino-audio-tools
Loading...
Searching...
No Matches
I2SSAMD.h
Go to the documentation of this file.
1#pragma once
2
3#if defined(ARDUINO_ARCH_SAMD)
4#include <I2S.h>
6
7#define IS_I2S_IMPLEMENTED
8
9namespace audio_tools {
10
18 friend class I2SStream;
19
20 public:
23 I2SConfigStd c(mode);
24 return c;
25 }
26
28 bool setAudioInfo(AudioInfo) { return false; }
29
31 bool begin(RxTxMode mode) { return begin(defaultConfig(mode)); }
32
35 this->cfg = cfg;
37 }
38
39 bool begin() { return begin(cfg); }
40
42 void end() { I2S.end(); }
43
45 I2SConfigStd config() { return cfg; }
46
47 size_t writeBytes(const void *src, size_t size_bytes) {
48 return I2S.write((const uint8_t *)src, size_bytes);
49 }
50
51 size_t readBytes(void *src, size_t size_bytes) {
52 return I2S.read(src, size_bytes);
53 }
54
55 int available() { return I2S.available(); }
56
57 int availableForWrite() { return I2S.availableForWrite(); }
58
59 protected:
61};
62
64
65} // namespace audio_tools
66
67#endif
Configuration for i2s.
Definition I2SConfigStd.h:17
I2SFormat i2s_format
Definition I2SConfigStd.h:50
Basic I2S API - for the ESP32. If we receive 1 channel, we expand the result to 2 channels.
Definition I2SESP32.h:25
Basic I2S API - for the SAMD.
Definition I2SSAMD.h:17
bool setAudioInfo(AudioInfo)
Potentially updates the sample rate (if supported)
Definition I2SSAMD.h:28
I2SConfigStd config()
provides the actual configuration
Definition I2SSAMD.h:45
int available()
Definition I2SSAMD.h:55
bool begin()
Definition I2SSAMD.h:39
I2SConfigStd defaultConfig(RxTxMode mode)
Provides the default configuration.
Definition I2SSAMD.h:22
int availableForWrite()
Definition I2SSAMD.h:57
size_t readBytes(void *src, size_t size_bytes)
Definition I2SSAMD.h:51
bool begin(I2SConfigStd cfg)
starts the DAC
Definition I2SSAMD.h:34
void end()
stops the I2C and unistalls the driver
Definition I2SSAMD.h:42
bool begin(RxTxMode mode)
starts the DAC with the default config
Definition I2SSAMD.h:31
size_t writeBytes(const void *src, size_t size_bytes)
Definition I2SSAMD.h:47
I2SConfigStd cfg
Definition I2SSAMD.h:60
We support the Stream interface for the I2S access. In addition we allow a separate mute pin which mi...
Definition I2SStream.h:33
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition AudioTypes.h:30
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:512
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:55
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:57
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:61