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