Final version.
Fork of F746_SAI_IO by
Diff: SAI_InOut.hpp
- Revision:
- 5:20cc265d7aec
- Parent:
- 4:2170289dfe94
- Child:
- 9:25a9655d6a0e
--- a/SAI_InOut.hpp Wed Jun 15 12:53:20 2016 +0000 +++ b/SAI_InOut.hpp Sat Jul 23 06:13:40 2016 +0000 @@ -1,6 +1,6 @@ //----------------------------------------------------------- // SiaIO class (Header) -// 2016/06/16, Copyright (c) 2016 MIKAMI, Naoki +// 2016/07/23, Copyright (c) 2016 MIKAMI, Naoki //----------------------------------------------------------- #ifndef F746_SAI_IO_HPP @@ -10,6 +10,7 @@ #include "stm32746g_discovery_audio.h" #include "BSP_AudioIn_Overwrite.hpp" #include "BSP_AudioOut_Overwrite.hpp" +#include "Array.hpp" namespace Mikami { @@ -25,7 +26,7 @@ // inputDevice == 0 : not use input device SaiIO(InOutBoth ioBoth, int size, int fs, uint16_t inputDevice = 0); - ~SaiIO(); + virtual ~SaiIO() {} int32_t GetLength() { return nData_; } @@ -36,7 +37,9 @@ bool IsCaptured(); void ResetCaptured() { captured_ = false; } - void Input(int16_t &xL, int16_t &xR); + // Input using SAI + void Input(int16_t &xL, int16_t &xR) + { (this->*InputFp)(xL, xR); } void StopIn() { BSP_AUDIO_IN_Stop(CODEC_PDWN_SW); } void PauseIn() { BSP_AUDIO_IN_Pause(); } @@ -45,6 +48,7 @@ void PlayOut(); bool IsXferred(); void ResetXferred() { xferred_ = false; } + // Output using SAI void Output(int16_t xL, int16_t xR); void StopOut() { BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW); } @@ -76,9 +80,9 @@ const int FS_; const InOutBoth IOBOTH_; - int16_t* inBuffer_; - static int16_t* outBuffer_; - static int16_t* tmp_; + Array<int16_t> inBuffer_; + static Array<int16_t> outBuffer_; + static Array<int16_t> tmp_; __IO int32_t inIndex_; __IO int32_t tmpIndex_; @@ -88,13 +92,20 @@ static __IO int32_t inOffset_; static __IO bool xferred_; - void InitCodec(uint16_t inputDevice); void InitInput(uint16_t inputDevice); void SetInput(); void SetOutput(); void ClearBuffer(); + // This function pointer is assigned by + // InputNormal() or InputReversal() + void (SaiIO::*InputFp)(int16_t &, int16_t &); + // For line input + void InputNormal(int16_t &xL, int16_t &xR); + // For MEMS microphone input + void InputReversal(int16_t &xL, int16_t &xR); + static void Captured(int32_t offset); static void FillBuffer(uint32_t offset); };