Raspberry Pio Pico Drivers project
Loading...
Searching...
No Matches
i2sslaveduplex.hpp
Go to the documentation of this file.
1
6#ifndef PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_
7#define PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_
8#if __has_include(<hardware/pio.h>) || __has_include(<gmock/gmock.h>) || DOXYGEN_COMPILE
9
10#if __has_include(<hardware/pio.h>)
11#include "hardware/pio.h"
12#else
13// Alternate definition for unit test.
14#define i2s_slave_duplex_program_get_default_config(config) 1
15#define clk_sys 51
16#endif //__has_include(<hardware/i2c.h>)
17
18#if __has_include(<gmock/gmock.h>)
19#include <gmock/gmock.h>
20#endif
21
22#include "sdk/sdkwrapper.hpp"
23
24namespace rpp_driver {
94 private:
96 PIO pio_;
97 const uint32_t sm_; // State machine ( 0..3 )
98 const uint pin_base_; // first GPIO pin number of the I2S signal.
99
100 public:
101 I2sSlaveDuplex(/* args */) = delete;
116 I2sSlaveDuplex(::rpp_driver::SdkWrapper &sdk, PIO pio, uint pin_base);
129 I2sSlaveDuplex(::rpp_driver::SdkWrapper &sdk, PIO pio, uint32_t sm,
130 uint pin_base);
131
136
143 virtual void Start();
150 virtual void Stop();
158 virtual uint32_t GetStateMachine();
170 virtual int32_t GetFifoBlocking();
179 virtual void PutFifoBlocking(int32_t value);
180};
181
182#if __has_include(<gmock/gmock.h>) || DOXYGEN_COMPILE
183// GCOVR_EXCL_START
188 public:
190 : I2sSlaveDuplex(sdk, 0, 0) {} // 0 is dummy. We don't care.
191 MOCK_METHOD0(GetStateMachine, uint32_t(void));
192 MOCK_METHOD0(Start, void(void));
193 MOCK_METHOD0(Stop, void(void));
194 MOCK_METHOD1(PutFifoBlocking, void(int32_t value));
195 MOCK_METHOD0(GetFifoBlocking, int32_t());
196};
197// GCOVR_EXCL_STOP
198#endif // __has_include(<gmock/gmock.h>)
199} // namespace rpp_driver
200
201#endif // __has_include(<hardware/pio.h>) || __has_include(<gmock/gmock.h>)
202
203#endif // PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_
Duplex Slave I2S controller class.
Definition: i2sslaveduplex.hpp:93
virtual void PutFifoBlocking(int32_t value)
Put one audio data to TX FIFO.
virtual int32_t GetFifoBlocking()
Get one audio data from RX FIFO.
I2sSlaveDuplex(::rpp_driver::SdkWrapper &sdk, PIO pio, uint32_t sm, uint pin_base)
Construct a new Duplex Slave I2S object.
I2sSlaveDuplex(::rpp_driver::SdkWrapper &sdk, PIO pio, uint pin_base)
Construct a new Duplex Slave I2S object.
virtual void Start()
Initialize the I2S port, and run.
virtual void Stop()
Stop the I2S port and disable the PIO state machine in use.
virtual uint32_t GetStateMachine()
Get the State Machine object.
~I2sSlaveDuplex()
Unclaim the state machine. No actual processing.
Mock class for test.
Definition: i2sslaveduplex.hpp:187
Wrapper class for the RasPi Pico SDK functions.
Definition: sdkwrapper.hpp:74
Collection of the RP2040/RP2350 control.
Definition: adau1361.hpp:17
Wrapper for RasPi Pico SDK API.