Raspberry Pio Pico Drivers project
Loading...
Searching...
No Matches
adau1361.hpp
Go to the documentation of this file.
1
10#ifndef PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_
11#define PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_
12#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>) || DOXYGEN_COMPILE
13
14#include <i2c/i2cmaster.hpp>
15
16#include "adau1361lower.hpp"
17namespace rpp_driver {
18
83class Adau1361 {
84 public:
97 };
98
143 explicit Adau1361(unsigned int fs, unsigned int master_clock,
144 Adau1361Lower& adau1361_lower);
145 Adau1361() = delete;
163 virtual void Start(void);
173 virtual void SetGain(CodecChannel channel, float left_gain, float right_gain);
174
180 virtual void Mute(CodecChannel channel, bool mute = true);
181
182 private:
183 const unsigned int fs_;
184 const unsigned int master_clock_;
185 Adau1361Lower& adau1361_lower_;
186
187 float line_input_left_gain_;
188 float line_input_right_gain_;
189 float aux_input_left_gain_;
190 float aux_input_right_gain_;
191 float line_output_left_gain_;
192 float line_output_right_gain_;
193 float hp_output_left_gain_; // headphone
194 float hp_output_right_gain_;
195
196 bool line_input_mute_;
197 bool aux_input_mute_;
198 bool line_output_mute_;
199 bool hp_output_mute_; // headphone
200};
201
202#if __has_include(<gmock/gmock.h>) || DOXYGEN_COMPILE
203// GCOVR_EXCL_START
207class MockAdau1361 : public Adau1361 {
208 public:
209 MockAdau1361(Adau1361Lower& adau1361_lower)
210 : Adau1361(48'000, 12'000'000, adau1361_lower) {
211 } // with dummy fs and dummy mclock
212
213 MOCK_METHOD0(Start, void(void));
214 MOCK_METHOD3(SetGain,
215 void(CodecChannel channel, float left_gain, float right_gain));
216 MOCK_METHOD2(Mute, void(CodecChannel channel, bool mute));
217 MOCK_METHOD1(Mute, void(CodecChannel channel));
218};
219// GCOVR_EXCL_STOP
220#endif // __has_include(<gmock/gmock.h>)
221
222} // namespace rpp_driver
223
224#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
225
226#endif /* PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_ */
Lower class for the ADAU1361.
lower part of the Adau1361 CODEC controller class.
Definition: adau1361lower.hpp:49
Analog Device ADAU1361A audio codec control class.
Definition: adau1361.hpp:83
virtual void SetGain(CodecChannel channel, float left_gain, float right_gain)
Set channel gain.
CodecChannel
Signal path definition.
Definition: adau1361.hpp:92
@ AuxInput
Physical input channel as aux in audio.
Definition: adau1361.hpp:94
@ LineInput
Physical input channel as line in audio.
Definition: adau1361.hpp:93
@ LineOutput
Physical output channel as line out audio.
Definition: adau1361.hpp:95
@ HeadphoneOutput
Physical output channel as head phone out audio.
Definition: adau1361.hpp:96
Adau1361(unsigned int fs, unsigned int master_clock, Adau1361Lower &adau1361_lower)
constructor.
virtual void Start(void)
Set up the ADAU1361 codec, and then, start the codec.
virtual void Mute(CodecChannel channel, bool mute=true)
Mute the specific channel.
Mock class for test.
Definition: adau1361.hpp:207
I2C Master Controller.
Collection of the RP2040/RP2350 control.
Definition: adau1361.hpp:17