uni project for eq system
Fork of AUDIO_DISCO_F746NG by
AUDIO_DISCO_F746NG.h@1:7046ce26b7ed, 2017-03-22 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Wed Mar 22 11:06:58 2017 +0100
- Revision:
- 1:7046ce26b7ed
- Parent:
- 0:6f035eff38e4
STM32Cube_FW_F7_V1.6.0 BSP_DISCO_F746NG
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adustm | 0:6f035eff38e4 | 1 | /* Copyright (c) 2010-2016 mbed.org, MIT License |
adustm | 0:6f035eff38e4 | 2 | * |
adustm | 0:6f035eff38e4 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
adustm | 0:6f035eff38e4 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
adustm | 0:6f035eff38e4 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
adustm | 0:6f035eff38e4 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
adustm | 0:6f035eff38e4 | 7 | * Software is furnished to do so, subject to the following conditions: |
adustm | 0:6f035eff38e4 | 8 | * |
adustm | 0:6f035eff38e4 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
adustm | 0:6f035eff38e4 | 10 | * substantial portions of the Software. |
adustm | 0:6f035eff38e4 | 11 | * |
adustm | 0:6f035eff38e4 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
adustm | 0:6f035eff38e4 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
adustm | 0:6f035eff38e4 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
adustm | 0:6f035eff38e4 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
adustm | 0:6f035eff38e4 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
adustm | 0:6f035eff38e4 | 17 | */ |
adustm | 0:6f035eff38e4 | 18 | |
adustm | 0:6f035eff38e4 | 19 | #ifndef __AUDIO_DISCO_F746NG_H |
adustm | 0:6f035eff38e4 | 20 | #define __AUDIO_DISCO_F746NG_H |
adustm | 0:6f035eff38e4 | 21 | |
adustm | 0:6f035eff38e4 | 22 | #ifdef TARGET_DISCO_F746NG |
adustm | 0:6f035eff38e4 | 23 | |
adustm | 0:6f035eff38e4 | 24 | #include "mbed.h" |
adustm | 0:6f035eff38e4 | 25 | #include "stm32746g_discovery_audio.h" |
adustm | 0:6f035eff38e4 | 26 | |
adustm | 0:6f035eff38e4 | 27 | /* |
adustm | 0:6f035eff38e4 | 28 | This class drives the uSD card driver mounted on DISCO_F746NG board. |
adustm | 0:6f035eff38e4 | 29 | |
adustm | 0:6f035eff38e4 | 30 | Usage: |
adustm | 0:6f035eff38e4 | 31 | |
adustm | 0:6f035eff38e4 | 32 | #include "mbed.h" |
adustm | 0:6f035eff38e4 | 33 | #include "AUDIO_DISCO_F746NG.h" |
adustm | 0:6f035eff38e4 | 34 | |
adustm | 0:6f035eff38e4 | 35 | AUDIO_DISCO_F746NG audio; |
adustm | 0:6f035eff38e4 | 36 | |
adustm | 0:6f035eff38e4 | 37 | int main() |
adustm | 0:6f035eff38e4 | 38 | { |
adustm | 0:6f035eff38e4 | 39 | audio.IN_OUT_Init(INPUT_DEVICE_DIGITAL_MICROPHONE_2, OUTPUT_DEVICE_HEADPHONE, 90, DEFAULT_AUDIO_IN_FREQ): |
adustm | 0:6f035eff38e4 | 40 | audio.IN_Record((uint16_t*)AUDIO_BUFFER_IN, AUDIO_BLOCK_SIZE); |
adustm | 0:6f035eff38e4 | 41 | audio.OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02); |
adustm | 0:6f035eff38e4 | 42 | audio.OUT_Play((uint16_t*)AUDIO_BUFFER_OUT, AUDIO_BLOCK_SIZE * 2); |
adustm | 0:6f035eff38e4 | 43 | while 1 {} |
Jerome Coutant
1:7046ce26b7ed
|
44
|
|
|
adustm | 0:6f035eff38e4 | 45 | } |
adustm | 0:6f035eff38e4 | 46 | */ |
adustm | 0:6f035eff38e4 | 47 | class AUDIO_DISCO_F746NG |
adustm | 0:6f035eff38e4 | 48 | { |
Jerome Coutant
1:7046ce26b7ed
|
49
|
|
|
adustm | 0:6f035eff38e4 | 50 | public: |
Jerome Coutant
1:7046ce26b7ed
|
51
|
//! Constructor
|
|
Jerome Coutant
1:7046ce26b7ed
|
52
|
AUDIO_DISCO_F746NG();
|
|
Jerome Coutant
1:7046ce26b7ed
|
53
|
|
|
Jerome Coutant
1:7046ce26b7ed
|
54
|
//! Destructor
|
|
Jerome Coutant
1:7046ce26b7ed
|
55
|
~AUDIO_DISCO_F746NG();
|
|
adustm | 0:6f035eff38e4 | 56 | |
Jerome Coutant
1:7046ce26b7ed
|
57
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
58
|
* @brief Configures the audio peripherals.
|
|
Jerome Coutant
1:7046ce26b7ed
|
59
|
* @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE,
|
|
Jerome Coutant
1:7046ce26b7ed
|
60
|
* or OUTPUT_DEVICE_BOTH.
|
|
Jerome Coutant
1:7046ce26b7ed
|
61
|
* @param Volume: Initial volume level (from 0 (Mute); to 100 (Max))
|
|
Jerome Coutant
1:7046ce26b7ed
|
62
|
* @param AudioFreq: Audio frequency used to play the audio stream.
|
|
Jerome Coutant
1:7046ce26b7ed
|
63
|
* @note The I2S PLL input clock must be done in the user application.
|
|
Jerome Coutant
1:7046ce26b7ed
|
64
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
65
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
66
|
uint8_t OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
|
|
adustm | 0:6f035eff38e4 | 67 | |
Jerome Coutant
1:7046ce26b7ed
|
68
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
69
|
* @brief Starts playing audio stream from a data buffer for a determined size.
|
|
Jerome Coutant
1:7046ce26b7ed
|
70
|
* @param pBuffer: Pointer to the buffer
|
|
Jerome Coutant
1:7046ce26b7ed
|
71
|
* @param Size: Number of audio data in BYTES unit.
|
|
Jerome Coutant
1:7046ce26b7ed
|
72
|
* In memory, first element is for left channel, second element is for right channel
|
|
Jerome Coutant
1:7046ce26b7ed
|
73
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
74
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
75
|
uint8_t OUT_Play(uint16_t* pBuffer, uint32_t Size);
|
|
adustm | 0:6f035eff38e4 | 76 | |
Jerome Coutant
1:7046ce26b7ed
|
77
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
78
|
* @brief Sends n-Bytes on the SAI interface.
|
|
Jerome Coutant
1:7046ce26b7ed
|
79
|
* @param pData: pointer on data address
|
|
Jerome Coutant
1:7046ce26b7ed
|
80
|
* @param Size: number of data to be written
|
|
Jerome Coutant
1:7046ce26b7ed
|
81
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
82
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
83
|
void OUT_ChangeBuffer(uint16_t *pData, uint16_t Size);
|
|
adustm | 0:6f035eff38e4 | 84 | |
Jerome Coutant
1:7046ce26b7ed
|
85
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
86
|
* @brief This function Pauses the audio file stream. In case
|
|
Jerome Coutant
1:7046ce26b7ed
|
87
|
* of using DMA, the DMA Pause feature is used.
|
|
Jerome Coutant
1:7046ce26b7ed
|
88
|
* @note When calling OUT_Pause(); function for pause, only
|
|
Jerome Coutant
1:7046ce26b7ed
|
89
|
* OUT_Resume(); function should be called for resume (use of BSP_AUDIO_OUT_Play()
|
|
Jerome Coutant
1:7046ce26b7ed
|
90
|
* function for resume could lead to unexpected behaviour);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
91
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
92
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
93
|
uint8_t OUT_Pause(void);
|
|
adustm | 0:6f035eff38e4 | 94 | |
Jerome Coutant
1:7046ce26b7ed
|
95
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
96
|
* @brief This function Resumes the audio file stream.
|
|
Jerome Coutant
1:7046ce26b7ed
|
97
|
* @note When calling OUT_Pause(); function for pause, only
|
|
Jerome Coutant
1:7046ce26b7ed
|
98
|
* OUT_Resume(); function should be called for resume (use of BSP_AUDIO_OUT_Play()
|
|
Jerome Coutant
1:7046ce26b7ed
|
99
|
* function for resume could lead to unexpected behaviour);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
100
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
101
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
102
|
uint8_t OUT_Resume(void);
|
|
adustm | 0:6f035eff38e4 | 103 | |
Jerome Coutant
1:7046ce26b7ed
|
104
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
105
|
* @brief Stops audio playing and Power down the Audio Codec.
|
|
Jerome Coutant
1:7046ce26b7ed
|
106
|
* @param Option: could be one of the following parameters
|
|
Jerome Coutant
1:7046ce26b7ed
|
107
|
* - CODEC_PDWN_SW: for software power off (by writing registers);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
108
|
* Then no need to reconfigure the Codec after power on.
|
|
Jerome Coutant
1:7046ce26b7ed
|
109
|
* - CODEC_PDWN_HW: completely shut down the codec (physically);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
110
|
* Then need to reconfigure the Codec after power on.
|
|
Jerome Coutant
1:7046ce26b7ed
|
111
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
112
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
113
|
uint8_t OUT_Stop(uint32_t Option);
|
|
adustm | 0:6f035eff38e4 | 114 | |
Jerome Coutant
1:7046ce26b7ed
|
115
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
116
|
* @brief Controls the current audio volume level.
|
|
Jerome Coutant
1:7046ce26b7ed
|
117
|
* @param Volume: Volume level to be set in percentage from 0% to 100% (0 for
|
|
Jerome Coutant
1:7046ce26b7ed
|
118
|
* Mute and 100 for Max volume level);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
119
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
120
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
121
|
uint8_t OUT_SetVolume(uint8_t Volume);
|
|
adustm | 0:6f035eff38e4 | 122 | |
Jerome Coutant
1:7046ce26b7ed
|
123
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
124
|
* @brief Enables or disables the MUTE mode by software
|
|
Jerome Coutant
1:7046ce26b7ed
|
125
|
* @param Cmd: Could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to
|
|
Jerome Coutant
1:7046ce26b7ed
|
126
|
* unmute the codec and restore previous volume level.
|
|
Jerome Coutant
1:7046ce26b7ed
|
127
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
128
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
129
|
uint8_t OUT_SetMute(uint32_t Cmd);
|
|
adustm | 0:6f035eff38e4 | 130 | |
Jerome Coutant
1:7046ce26b7ed
|
131
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
132
|
* @brief Switch dynamically (while audio file is played); the output target
|
|
Jerome Coutant
1:7046ce26b7ed
|
133
|
* (speaker or headphone);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
134
|
* @param Output: The audio output target: OUTPUT_DEVICE_SPEAKER,
|
|
Jerome Coutant
1:7046ce26b7ed
|
135
|
* OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH
|
|
Jerome Coutant
1:7046ce26b7ed
|
136
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
137
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
138
|
uint8_t OUT_SetOutputMode(uint8_t Output);
|
|
adustm | 0:6f035eff38e4 | 139 | |
Jerome Coutant
1:7046ce26b7ed
|
140
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
141
|
* @brief Updates the audio frequency.
|
|
Jerome Coutant
1:7046ce26b7ed
|
142
|
* @param AudioFreq: Audio frequency used to play the audio stream.
|
|
Jerome Coutant
1:7046ce26b7ed
|
143
|
* @note This API should be called after the OUT_Init(); to adjust the
|
|
Jerome Coutant
1:7046ce26b7ed
|
144
|
* audio frequency.
|
|
Jerome Coutant
1:7046ce26b7ed
|
145
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
146
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
147
|
void OUT_SetFrequency(uint32_t AudioFreq);
|
|
adustm | 0:6f035eff38e4 | 148 | |
Jerome Coutant
1:7046ce26b7ed
|
149
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
150
|
* @brief Updates the Audio frame slot configuration.
|
|
Jerome Coutant
1:7046ce26b7ed
|
151
|
* @param AudioFrameSlot: specifies the audio Frame slot
|
|
Jerome Coutant
1:7046ce26b7ed
|
152
|
* This parameter can be one of the following values
|
|
Jerome Coutant
1:7046ce26b7ed
|
153
|
* @arg CODEC_AUDIOFRAME_SLOT_0123
|
|
Jerome Coutant
1:7046ce26b7ed
|
154
|
* @arg CODEC_AUDIOFRAME_SLOT_02
|
|
Jerome Coutant
1:7046ce26b7ed
|
155
|
* @arg CODEC_AUDIOFRAME_SLOT_13
|
|
Jerome Coutant
1:7046ce26b7ed
|
156
|
* @note This API should be called after the OUT_Init(); to adjust the
|
|
Jerome Coutant
1:7046ce26b7ed
|
157
|
* audio frame slot.
|
|
Jerome Coutant
1:7046ce26b7ed
|
158
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
159
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
160
|
void OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot);
|
|
adustm | 0:6f035eff38e4 | 161 | |
Jerome Coutant
1:7046ce26b7ed
|
162
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
163
|
* @brief Deinit the audio peripherals.
|
|
Jerome Coutant
1:7046ce26b7ed
|
164
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
165
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
166
|
void OUT_DeInit(void);
|
|
adustm | 0:6f035eff38e4 | 167 | |
Jerome Coutant
1:7046ce26b7ed
|
168
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
169
|
* @brief Tx Transfer completed callbacks.
|
|
Jerome Coutant
1:7046ce26b7ed
|
170
|
* @param hsai: SAI handle
|
|
Jerome Coutant
1:7046ce26b7ed
|
171
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
172
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
173
|
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
|
|
adustm | 0:6f035eff38e4 | 174 | |
Jerome Coutant
1:7046ce26b7ed
|
175
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
176
|
* @brief Tx Half Transfer completed callbacks.
|
|
Jerome Coutant
1:7046ce26b7ed
|
177
|
* @param hsai: SAI handle
|
|
Jerome Coutant
1:7046ce26b7ed
|
178
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
179
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
180
|
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
|
|
adustm | 0:6f035eff38e4 | 181 | |
Jerome Coutant
1:7046ce26b7ed
|
182
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
183
|
* @brief SAI error callbacks.
|
|
Jerome Coutant
1:7046ce26b7ed
|
184
|
* @param hsai: SAI handle
|
|
Jerome Coutant
1:7046ce26b7ed
|
185
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
186
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
187
|
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
|
|
adustm | 0:6f035eff38e4 | 188 | |
Jerome Coutant
1:7046ce26b7ed
|
189
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
190
|
* @brief Initializes the output Audio Codec audio interface (SAI);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
191
|
* @param AudioFreq: Audio frequency to be configured for the SAI peripheral.
|
|
Jerome Coutant
1:7046ce26b7ed
|
192
|
* @note The default SlotActive configuration is set to CODEC_AUDIOFRAME_SLOT_0123
|
|
Jerome Coutant
1:7046ce26b7ed
|
193
|
* and user can update this configuration using
|
|
Jerome Coutant
1:7046ce26b7ed
|
194
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
195
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
196
|
static void SAIx_Out_Init(uint32_t AudioFreq);
|
|
adustm | 0:6f035eff38e4 | 197 | |
Jerome Coutant
1:7046ce26b7ed
|
198
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
199
|
* @brief Deinitializes the output Audio Codec audio interface (SAI);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
200
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
201
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
202
|
static void SAIx_Out_DeInit(void);
|
|
adustm | 0:6f035eff38e4 | 203 | |
Jerome Coutant
1:7046ce26b7ed
|
204
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
205
|
* @brief Initializes wave recording.
|
|
Jerome Coutant
1:7046ce26b7ed
|
206
|
* @param InputDevice: INPUT_DEVICE_DIGITAL_MICROPHONE_2 or INPUT_DEVICE_INPUT_LINE_1
|
|
Jerome Coutant
1:7046ce26b7ed
|
207
|
* @param Volume: Initial volume level (in range 0(Mute);..80(+0dB)..100(+17.625dB))
|
|
Jerome Coutant
1:7046ce26b7ed
|
208
|
* @param AudioFreq: Audio frequency to be configured for the SAI peripheral.
|
|
Jerome Coutant
1:7046ce26b7ed
|
209
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
210
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
211
|
uint8_t IN_Init(uint16_t InputDevice, uint8_t Volume, uint32_t AudioFreq);
|
|
adustm | 0:6f035eff38e4 | 212 | |
Jerome Coutant
1:7046ce26b7ed
|
213
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
214
|
* @brief Initializes wave recording and playback in parallel.
|
|
Jerome Coutant
1:7046ce26b7ed
|
215
|
* @param InputDevice: INPUT_DEVICE_DIGITAL_MICROPHONE_2
|
|
Jerome Coutant
1:7046ce26b7ed
|
216
|
* @param OutputDevice: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE,
|
|
Jerome Coutant
1:7046ce26b7ed
|
217
|
* or OUTPUT_DEVICE_BOTH.
|
|
Jerome Coutant
1:7046ce26b7ed
|
218
|
* @param AudioFreq: Audio frequency to be configured for the SAI peripheral.
|
|
Jerome Coutant
1:7046ce26b7ed
|
219
|
* @param BitRes: Audio frequency to be configured.
|
|
Jerome Coutant
1:7046ce26b7ed
|
220
|
* @param ChnlNbr: Channel number.
|
|
Jerome Coutant
1:7046ce26b7ed
|
221
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
222
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
223
|
uint8_t IN_OUT_Init(uint16_t InputDevice, uint16_t OutputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
|
|
adustm | 0:6f035eff38e4 | 224 | |
Jerome Coutant
1:7046ce26b7ed
|
225
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
226
|
* @brief Starts audio recording.
|
|
Jerome Coutant
1:7046ce26b7ed
|
227
|
* @param pbuf: Main buffer pointer for the recorded data storing
|
|
Jerome Coutant
1:7046ce26b7ed
|
228
|
* @param size: size of the recorded buffer in number of elements (typically number of half-words);
|
|
Jerome Coutant
1:7046ce26b7ed
|
229
|
* Be careful that it is not the same unit than OUT_Play function
|
|
Jerome Coutant
1:7046ce26b7ed
|
230
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
231
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
232
|
uint8_t IN_Record(uint16_t* pbuf, uint32_t size);
|
|
adustm | 0:6f035eff38e4 | 233 | |
Jerome Coutant
1:7046ce26b7ed
|
234
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
235
|
* @brief Stops audio recording.
|
|
Jerome Coutant
1:7046ce26b7ed
|
236
|
* @param Option: could be one of the following parameters
|
|
Jerome Coutant
1:7046ce26b7ed
|
237
|
* - CODEC_PDWN_SW: for software power off (by writing registers);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
238
|
* Then no need to reconfigure the Codec after power on.
|
|
Jerome Coutant
1:7046ce26b7ed
|
239
|
* - CODEC_PDWN_HW: completely shut down the codec (physically);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
240
|
* Then need to reconfigure the Codec after power on.
|
|
Jerome Coutant
1:7046ce26b7ed
|
241
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
242
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
243
|
uint8_t IN_Stop(uint32_t Option);
|
|
adustm | 0:6f035eff38e4 | 244 | |
Jerome Coutant
1:7046ce26b7ed
|
245
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
246
|
* @brief Pauses the audio file stream.
|
|
Jerome Coutant
1:7046ce26b7ed
|
247
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
248
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
249
|
uint8_t IN_Pause(void);
|
|
adustm | 0:6f035eff38e4 | 250 | |
Jerome Coutant
1:7046ce26b7ed
|
251
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
252
|
* @brief Resumes the audio file stream.
|
|
Jerome Coutant
1:7046ce26b7ed
|
253
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
254
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
255
|
uint8_t IN_Resume(void);
|
|
adustm | 0:6f035eff38e4 | 256 | |
Jerome Coutant
1:7046ce26b7ed
|
257
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
258
|
* @brief Controls the audio in volume level.
|
|
Jerome Coutant
1:7046ce26b7ed
|
259
|
* @param Volume: Volume level in range 0(Mute);..80(+0dB)..100(+17.625dB)
|
|
Jerome Coutant
1:7046ce26b7ed
|
260
|
* @retval AUDIO_OK if correct communication, else wrong communication
|
|
Jerome Coutant
1:7046ce26b7ed
|
261
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
262
|
uint8_t IN_SetVolume(uint8_t Volume);
|
|
adustm | 0:6f035eff38e4 | 263 | |
Jerome Coutant
1:7046ce26b7ed
|
264
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
265
|
* @brief Deinit the audio IN peripherals.
|
|
Jerome Coutant
1:7046ce26b7ed
|
266
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
267
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
268
|
void IN_DeInit(void);
|
|
adustm | 0:6f035eff38e4 | 269 | |
Jerome Coutant
1:7046ce26b7ed
|
270
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
271
|
* @brief Rx Transfer completed callbacks.
|
|
Jerome Coutant
1:7046ce26b7ed
|
272
|
* @param hsai: SAI handle
|
|
Jerome Coutant
1:7046ce26b7ed
|
273
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
274
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
275
|
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
|
|
adustm | 0:6f035eff38e4 | 276 | |
Jerome Coutant
1:7046ce26b7ed
|
277
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
278
|
* @brief Rx Half Transfer completed callbacks.
|
|
Jerome Coutant
1:7046ce26b7ed
|
279
|
* @param hsai: SAI handle
|
|
Jerome Coutant
1:7046ce26b7ed
|
280
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
281
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
282
|
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
|
|
adustm | 0:6f035eff38e4 | 283 | |
Jerome Coutant
1:7046ce26b7ed
|
284
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
285
|
* @brief Initializes the input Audio Codec audio interface (SAI);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
286
|
* @param SaiOutMode: SAI_MODEMASTER_TX (for record and playback in parallel);
|
|
Jerome Coutant
1:7046ce26b7ed
|
287
|
* or SAI_MODEMASTER_RX (for record only);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
288
|
* @param SlotActive: CODEC_AUDIOFRAME_SLOT_02 or CODEC_AUDIOFRAME_SLOT_13
|
|
Jerome Coutant
1:7046ce26b7ed
|
289
|
* @param AudioFreq: Audio frequency to be configured for the SAI peripheral.
|
|
Jerome Coutant
1:7046ce26b7ed
|
290
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
291
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
292
|
static void SAIx_In_Init(uint32_t SaiOutMode, uint32_t SlotActive, uint32_t AudioFreq);
|
|
adustm | 0:6f035eff38e4 | 293 | |
Jerome Coutant
1:7046ce26b7ed
|
294
|
/**
|
|
Jerome Coutant
1:7046ce26b7ed
|
295
|
* @brief Deinitializes the output Audio Codec audio interface (SAI);.
|
|
Jerome Coutant
1:7046ce26b7ed
|
296
|
* @retval None
|
|
Jerome Coutant
1:7046ce26b7ed
|
297
|
*/
|
|
Jerome Coutant
1:7046ce26b7ed
|
298
|
static void SAIx_In_DeInit(void);
|
|
adustm | 0:6f035eff38e4 | 299 | |
adustm | 0:6f035eff38e4 | 300 | private: |
adustm | 0:6f035eff38e4 | 301 | |
adustm | 0:6f035eff38e4 | 302 | }; |
adustm | 0:6f035eff38e4 | 303 | |
adustm | 0:6f035eff38e4 | 304 | #else |
adustm | 0:6f035eff38e4 | 305 | #error "This class must be used with DISCO_F746NG board only." |
adustm | 0:6f035eff38e4 | 306 | #endif // TARGET_DISCO_F746NG |
adustm | 0:6f035eff38e4 | 307 | |
adustm | 0:6f035eff38e4 | 308 | #endif |