BSP files for STM32H747I-Discovery Copy from ST Cube delivery
Dependents: DISCO_H747I_LCD_demo DISCO_H747I_AUDIO_demo
STM32H747I-Discovery/stm32h747i_discovery_audio.h@3:bc403474b366, 2019-11-06 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Wed Nov 06 11:32:01 2019 +0100
- Revision:
- 3:bc403474b366
- Parent:
- 2:53134782cc12
Add PDM lib
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
0:146cf26a9bbb
|
1
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
2
|
******************************************************************************
|
|
Jerome Coutant
0:146cf26a9bbb
|
3
|
* @file stm32h747i_discovery_audio.h
|
|
Jerome Coutant
0:146cf26a9bbb
|
4
|
* @author MCD Application Team
|
|
Jerome Coutant
0:146cf26a9bbb
|
5
|
* @brief This file contains the common defines and functions prototypes for
|
|
Jerome Coutant
0:146cf26a9bbb
|
6
|
* the stm32h747i_discovery_audio.c driver.
|
|
Jerome Coutant
0:146cf26a9bbb
|
7
|
******************************************************************************
|
|
Jerome Coutant
0:146cf26a9bbb
|
8
|
* @attention
|
|
Jerome Coutant
0:146cf26a9bbb
|
9
|
*
|
|
Jerome Coutant
0:146cf26a9bbb
|
10
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
|
Jerome Coutant
0:146cf26a9bbb
|
11
|
* All rights reserved.</center></h2>
|
|
Jerome Coutant
0:146cf26a9bbb
|
12
|
*
|
|
Jerome Coutant
0:146cf26a9bbb
|
13
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
Jerome Coutant
0:146cf26a9bbb
|
14
|
* the "License"; You may not use this file except in compliance with the
|
|
Jerome Coutant
0:146cf26a9bbb
|
15
|
* License. You may obtain a copy of the License at:
|
|
Jerome Coutant
0:146cf26a9bbb
|
16
|
* opensource.org/licenses/BSD-3-Clause
|
|
Jerome Coutant
0:146cf26a9bbb
|
17
|
*
|
|
Jerome Coutant
0:146cf26a9bbb
|
18
|
******************************************************************************
|
|
Jerome Coutant
0:146cf26a9bbb
|
19
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
20
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
21
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
22
|
#ifndef __STM32H747I_DISCOVERY_AUDIO_H
|
|
Jerome Coutant
0:146cf26a9bbb
|
23
|
#define __STM32H747I_DISCOVERY_AUDIO_H
|
|
Jerome Coutant
0:146cf26a9bbb
|
24
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
25
|
#ifdef __cplusplus
|
|
Jerome Coutant
0:146cf26a9bbb
|
26
|
extern "C" {
|
|
Jerome Coutant
0:146cf26a9bbb
|
27
|
#endif
|
|
Jerome Coutant
0:146cf26a9bbb
|
28
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
29
|
/* Includes ------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
30
|
/* Include audio component Driver */
|
|
Jerome Coutant
0:146cf26a9bbb
|
31
|
#include "../Components/wm8994/wm8994.h"
|
|
Jerome Coutant
0:146cf26a9bbb
|
32
|
#include "stm32h747i_discovery.h"
|
|
Jerome Coutant
0:146cf26a9bbb
|
33
|
#include <stdlib.h>
|
|
Jerome Coutant
0:146cf26a9bbb
|
34
|
/* Include PDM to PCM lib header file */
|
|
Jerome Coutant
2:53134782cc12
|
35
|
#include "pdm2pcm_glo.h"
|
|
Jerome Coutant
0:146cf26a9bbb
|
36
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
37
|
/** @addtogroup BSP
|
|
Jerome Coutant
0:146cf26a9bbb
|
38
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
39
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
40
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
41
|
/** @addtogroup STM32H747I_DISCOVERY
|
|
Jerome Coutant
0:146cf26a9bbb
|
42
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
43
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
44
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
45
|
/** @addtogroup STM32H747I_DISCOVERY_AUDIO
|
|
Jerome Coutant
0:146cf26a9bbb
|
46
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
47
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
48
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
49
|
/** @defgroup STM32H747I_DISCOVERY_AUDIO_Exported_Types Exported Types
|
|
Jerome Coutant
0:146cf26a9bbb
|
50
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
51
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
52
|
typedef struct
|
|
Jerome Coutant
0:146cf26a9bbb
|
53
|
{
|
|
Jerome Coutant
0:146cf26a9bbb
|
54
|
uint32_t Frequency; /* Record Frequency */
|
|
Jerome Coutant
0:146cf26a9bbb
|
55
|
uint32_t BitResolution; /* Record bit resolution */
|
|
Jerome Coutant
0:146cf26a9bbb
|
56
|
uint32_t ChannelNbr; /* Record Channel Number */
|
|
Jerome Coutant
0:146cf26a9bbb
|
57
|
uint16_t *pRecBuf; /* Pointer to record user buffer */
|
|
Jerome Coutant
0:146cf26a9bbb
|
58
|
uint32_t RecSize; /* Size to record in mono, double size to record in stereo */
|
|
Jerome Coutant
0:146cf26a9bbb
|
59
|
uint32_t InputDevice; /* Audio Input Device */
|
|
Jerome Coutant
0:146cf26a9bbb
|
60
|
uint32_t Interface; /* Audio Input Interface */
|
|
Jerome Coutant
0:146cf26a9bbb
|
61
|
uint32_t MultiBuffMode; /* Multi buffer mode selection */
|
|
Jerome Coutant
0:146cf26a9bbb
|
62
|
}AUDIOIN_ContextTypeDef;
|
|
Jerome Coutant
0:146cf26a9bbb
|
63
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
64
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
65
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
66
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
67
|
/** @defgroup STM32H747I_DISCOVERY_AUDIO_Exported_Constants Exported Constants
|
|
Jerome Coutant
0:146cf26a9bbb
|
68
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
69
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
70
|
#define BSP_AUDIO_FREQUENCY_96K SAI_AUDIO_FREQUENCY_96K
|
|
Jerome Coutant
0:146cf26a9bbb
|
71
|
#define BSP_AUDIO_FREQUENCY_48K SAI_AUDIO_FREQUENCY_48K
|
|
Jerome Coutant
0:146cf26a9bbb
|
72
|
#define BSP_AUDIO_FREQUENCY_44K SAI_AUDIO_FREQUENCY_44K
|
|
Jerome Coutant
0:146cf26a9bbb
|
73
|
#define BSP_AUDIO_FREQUENCY_32K SAI_AUDIO_FREQUENCY_32K
|
|
Jerome Coutant
0:146cf26a9bbb
|
74
|
#define BSP_AUDIO_FREQUENCY_22K SAI_AUDIO_FREQUENCY_22K
|
|
Jerome Coutant
0:146cf26a9bbb
|
75
|
#define BSP_AUDIO_FREQUENCY_16K SAI_AUDIO_FREQUENCY_16K
|
|
Jerome Coutant
0:146cf26a9bbb
|
76
|
#define BSP_AUDIO_FREQUENCY_11K SAI_AUDIO_FREQUENCY_11K
|
|
Jerome Coutant
0:146cf26a9bbb
|
77
|
#define BSP_AUDIO_FREQUENCY_8K SAI_AUDIO_FREQUENCY_8K
|
|
Jerome Coutant
0:146cf26a9bbb
|
78
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
79
|
/*------------------------------------------------------------------------------
|
|
Jerome Coutant
0:146cf26a9bbb
|
80
|
USER SAI defines parameters
|
|
Jerome Coutant
0:146cf26a9bbb
|
81
|
-----------------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
82
|
/** In W8994 codec the Audio frame contains 4 slots : TDM Mode
|
|
Jerome Coutant
0:146cf26a9bbb
|
83
|
* TDM format :
|
|
Jerome Coutant
0:146cf26a9bbb
|
84
|
* +------------------|------------------|--------------------|-------------------+
|
|
Jerome Coutant
0:146cf26a9bbb
|
85
|
* | CODEC_SLOT0 Left | CODEC_SLOT1 Left | CODEC_SLOT0 Right | CODEC_SLOT1 Right |
|
|
Jerome Coutant
0:146cf26a9bbb
|
86
|
* +------------------------------------------------------------------------------+
|
|
Jerome Coutant
0:146cf26a9bbb
|
87
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
88
|
/* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */
|
|
Jerome Coutant
0:146cf26a9bbb
|
89
|
#define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3
|
|
Jerome Coutant
0:146cf26a9bbb
|
90
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
91
|
/* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */
|
|
Jerome Coutant
0:146cf26a9bbb
|
92
|
#define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2
|
|
Jerome Coutant
0:146cf26a9bbb
|
93
|
/* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */
|
|
Jerome Coutant
0:146cf26a9bbb
|
94
|
#define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3
|
|
Jerome Coutant
0:146cf26a9bbb
|
95
|
/* To have an audio stream in SAI PDM input Slot 0 must be activated */
|
|
Jerome Coutant
0:146cf26a9bbb
|
96
|
#define CODEC_AUDIOFRAME_SLOT_0 SAI_SLOTACTIVE_0
|
|
Jerome Coutant
0:146cf26a9bbb
|
97
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
98
|
/*------------------------------------------------------------------------------
|
|
Jerome Coutant
0:146cf26a9bbb
|
99
|
AUDIO OUT CONFIGURATION
|
|
Jerome Coutant
0:146cf26a9bbb
|
100
|
------------------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
101
|
/* SAI peripheral configuration defines */
|
|
Jerome Coutant
0:146cf26a9bbb
|
102
|
#define AUDIO_OUT_SAIx SAI1_Block_A
|
|
Jerome Coutant
0:146cf26a9bbb
|
103
|
#define AUDIO_OUT_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
104
|
#define AUDIO_OUT_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
105
|
#define AUDIO_OUT_SAIx_AF GPIO_AF6_SAI1
|
|
Jerome Coutant
0:146cf26a9bbb
|
106
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
107
|
#define AUDIO_OUT_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
108
|
#define AUDIO_OUT_SAIx_MCLK_GPIO_PORT GPIOG
|
|
Jerome Coutant
0:146cf26a9bbb
|
109
|
#define AUDIO_OUT_SAIx_MCLK_PIN GPIO_PIN_7
|
|
Jerome Coutant
0:146cf26a9bbb
|
110
|
#define AUDIO_OUT_SAIx_SD_FS_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
111
|
#define AUDIO_OUT_SAIx_SD_FS_SCK_GPIO_PORT GPIOE
|
|
Jerome Coutant
0:146cf26a9bbb
|
112
|
#define AUDIO_OUT_SAIx_FS_PIN GPIO_PIN_4
|
|
Jerome Coutant
0:146cf26a9bbb
|
113
|
#define AUDIO_OUT_SAIx_SCK_PIN GPIO_PIN_5
|
|
Jerome Coutant
0:146cf26a9bbb
|
114
|
#define AUDIO_OUT_SAIx_SD_PIN GPIO_PIN_6
|
|
Jerome Coutant
0:146cf26a9bbb
|
115
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
116
|
/* SAI DMA Stream definitions */
|
|
Jerome Coutant
0:146cf26a9bbb
|
117
|
#define AUDIO_OUT_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
118
|
#define AUDIO_OUT_SAIx_DMAx_STREAM DMA2_Stream1
|
|
Jerome Coutant
0:146cf26a9bbb
|
119
|
#define AUDIO_OUT_SAIx_DMAx_REQUEST DMA_REQUEST_SAI1_A
|
|
Jerome Coutant
0:146cf26a9bbb
|
120
|
#define AUDIO_OUT_SAIx_DMAx_IRQ DMA2_Stream1_IRQn
|
|
Jerome Coutant
0:146cf26a9bbb
|
121
|
#define AUDIO_OUT_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
|
Jerome Coutant
0:146cf26a9bbb
|
122
|
#define AUDIO_OUT_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
|
Jerome Coutant
0:146cf26a9bbb
|
123
|
#define AUDIO_OUT_SAIx_DMAx_IRQHandler DMA2_Stream1_IRQHandler
|
|
Jerome Coutant
0:146cf26a9bbb
|
124
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
125
|
/* Select the interrupt preemption priority and subpriority for the DMA interrupt */
|
|
Jerome Coutant
0:146cf26a9bbb
|
126
|
#define AUDIO_OUT_IRQ_PREPRIO ((uint32_t)0x0E)
|
|
Jerome Coutant
0:146cf26a9bbb
|
127
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
128
|
/*------------------------------------------------------------------------------
|
|
Jerome Coutant
0:146cf26a9bbb
|
129
|
AUDIO IN CONFIGURATION
|
|
Jerome Coutant
0:146cf26a9bbb
|
130
|
------------------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
131
|
/* SAI peripheral configuration defines */
|
|
Jerome Coutant
0:146cf26a9bbb
|
132
|
#define AUDIO_IN_SAIx SAI1_Block_B
|
|
Jerome Coutant
0:146cf26a9bbb
|
133
|
#define AUDIO_IN_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
134
|
#define AUDIO_IN_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
135
|
#define AUDIO_IN_SAIx_AF GPIO_AF6_SAI1
|
|
Jerome Coutant
0:146cf26a9bbb
|
136
|
#define AUDIO_IN_SAIx_SD_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
137
|
#define AUDIO_IN_SAIx_SD_GPIO_PORT GPIOE
|
|
Jerome Coutant
0:146cf26a9bbb
|
138
|
#define AUDIO_IN_SAIx_SD_PIN GPIO_PIN_3
|
|
Jerome Coutant
0:146cf26a9bbb
|
139
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
140
|
/* SAI DMA Stream definitions */
|
|
Jerome Coutant
0:146cf26a9bbb
|
141
|
#define AUDIO_IN_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
142
|
#define AUDIO_IN_SAIx_DMAx_STREAM DMA2_Stream4
|
|
Jerome Coutant
0:146cf26a9bbb
|
143
|
#define AUDIO_IN_SAIx_DMAx_REQUEST DMA_REQUEST_SAI1_B
|
|
Jerome Coutant
0:146cf26a9bbb
|
144
|
#define AUDIO_IN_SAIx_DMAx_IRQ DMA2_Stream4_IRQn
|
|
Jerome Coutant
0:146cf26a9bbb
|
145
|
#define AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
|
Jerome Coutant
0:146cf26a9bbb
|
146
|
#define AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
|
Jerome Coutant
0:146cf26a9bbb
|
147
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
148
|
#define AUDIO_IN_SAIx_DMAx_IRQHandler DMA2_Stream4_IRQHandler
|
|
Jerome Coutant
0:146cf26a9bbb
|
149
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
150
|
#define AUDIO_IN_INT_GPIO_ENABLE() __HAL_RCC_GPIOJ_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
151
|
#define AUDIO_IN_INT_GPIO_PORT GPIOJ
|
|
Jerome Coutant
0:146cf26a9bbb
|
152
|
#define AUDIO_IN_INT_GPIO_PIN GPIO_PIN_15
|
|
Jerome Coutant
0:146cf26a9bbb
|
153
|
#define AUDIO_IN_INT_IRQ EXTI15_10_IRQn
|
|
Jerome Coutant
0:146cf26a9bbb
|
154
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
155
|
/* SAI PDM input definitions */
|
|
Jerome Coutant
0:146cf26a9bbb
|
156
|
#define AUDIO_IN_SAI_PDMx SAI4_Block_A
|
|
Jerome Coutant
0:146cf26a9bbb
|
157
|
#define AUDIO_IN_SAI_PDMx_CLK_ENABLE() __HAL_RCC_SAI4_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
158
|
#define AUDIO_IN_SAI_PDMx_CLK_DISABLE() __HAL_RCC_SAI4_CLK_DISABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
159
|
#define AUDIO_IN_SAI_PDMx_FS_SCK_AF GPIO_AF8_SAI4
|
|
Jerome Coutant
0:146cf26a9bbb
|
160
|
#define AUDIO_IN_SAI_PDMx_FS_SCK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
161
|
#define AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT GPIOE
|
|
Jerome Coutant
0:146cf26a9bbb
|
162
|
#define AUDIO_IN_SAI_PDMx_FS_PIN GPIO_PIN_4
|
|
Jerome Coutant
0:146cf26a9bbb
|
163
|
#define AUDIO_IN_SAI_PDMx_SCK_PIN GPIO_PIN_5
|
|
Jerome Coutant
0:146cf26a9bbb
|
164
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
165
|
#define AUDIO_IN_SAI_PDMx_CLK_IN_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
166
|
#define AUDIO_IN_SAI_PDMx_CLK_IN_PIN GPIO_PIN_2
|
|
Jerome Coutant
0:146cf26a9bbb
|
167
|
#define AUDIO_IN_SAI_PDMx_CLK_IN_PORT GPIOE
|
|
Jerome Coutant
0:146cf26a9bbb
|
168
|
#define AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
169
|
#define AUDIO_IN_SAI_PDMx_DATA_IN_PIN GPIO_PIN_1
|
|
Jerome Coutant
0:146cf26a9bbb
|
170
|
#define AUDIO_IN_SAI_PDMx_DATA_IN_PORT GPIOC
|
|
Jerome Coutant
0:146cf26a9bbb
|
171
|
#define AUDIO_IN_SAI_PDMx_DATA_CLK_AF GPIO_AF10_SAI4
|
|
Jerome Coutant
0:146cf26a9bbb
|
172
|
#define AUDIO_IN_SAI_PDMx_IRQHandler SAI4_IRQHandler
|
|
Jerome Coutant
0:146cf26a9bbb
|
173
|
#define AUDIO_IN_SAI_PDMx_IRQ SAI4_IRQn
|
|
Jerome Coutant
0:146cf26a9bbb
|
174
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
175
|
/* SAI PDM DMA Stream definitions */
|
|
Jerome Coutant
0:146cf26a9bbb
|
176
|
#define AUDIO_IN_SAI_PDMx_DMAx_CLK_ENABLE() __HAL_RCC_BDMA_CLK_ENABLE()
|
|
Jerome Coutant
0:146cf26a9bbb
|
177
|
#define AUDIO_IN_SAI_PDMx_DMAx_STREAM BDMA_Channel1
|
|
Jerome Coutant
0:146cf26a9bbb
|
178
|
#define AUDIO_IN_SAI_PDMx_DMAx_REQUEST BDMA_REQUEST_SAI4_A
|
|
Jerome Coutant
0:146cf26a9bbb
|
179
|
#define AUDIO_IN_SAI_PDMx_DMAx_IRQ BDMA_Channel1_IRQn
|
|
Jerome Coutant
0:146cf26a9bbb
|
180
|
#define AUDIO_IN_SAI_PDMx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
|
Jerome Coutant
0:146cf26a9bbb
|
181
|
#define AUDIO_IN_SAI_PDMx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
|
Jerome Coutant
0:146cf26a9bbb
|
182
|
#define AUDIO_IN_SAI_PDMx_DMAx_IRQHandler BDMA_Channel1_IRQHandler
|
|
Jerome Coutant
0:146cf26a9bbb
|
183
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
184
|
/* Select the interrupt preemption priority and subpriority for the DMA interrupt */
|
|
Jerome Coutant
0:146cf26a9bbb
|
185
|
#define AUDIO_IN_IRQ_PREPRIO ((uint32_t)0x0F)
|
|
Jerome Coutant
0:146cf26a9bbb
|
186
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
187
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
188
|
/*------------------------------------------------------------------------------
|
|
Jerome Coutant
0:146cf26a9bbb
|
189
|
CONFIGURATION: Audio Driver Configuration parameters
|
|
Jerome Coutant
0:146cf26a9bbb
|
190
|
------------------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
191
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
192
|
#define AUDIODATA_SIZE ((uint32_t)2) /* 16-bits audio data size */
|
|
Jerome Coutant
0:146cf26a9bbb
|
193
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
194
|
/* Audio status definition */
|
|
Jerome Coutant
0:146cf26a9bbb
|
195
|
#define AUDIO_OK ((uint8_t)0)
|
|
Jerome Coutant
0:146cf26a9bbb
|
196
|
#define AUDIO_ERROR ((uint8_t)1)
|
|
Jerome Coutant
0:146cf26a9bbb
|
197
|
#define AUDIO_TIMEOUT ((uint8_t)2)
|
|
Jerome Coutant
0:146cf26a9bbb
|
198
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
199
|
/* Audio In default settings */
|
|
Jerome Coutant
0:146cf26a9bbb
|
200
|
#define DEFAULT_AUDIO_IN_FREQ BSP_AUDIO_FREQUENCY_16K
|
|
Jerome Coutant
0:146cf26a9bbb
|
201
|
#define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16)
|
|
Jerome Coutant
0:146cf26a9bbb
|
202
|
#define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2)
|
|
Jerome Coutant
0:146cf26a9bbb
|
203
|
#define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64)
|
|
Jerome Coutant
0:146cf26a9bbb
|
204
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
205
|
/*------------------------------------------------------------------------------
|
|
Jerome Coutant
0:146cf26a9bbb
|
206
|
OUTPUT DEVICES definition
|
|
Jerome Coutant
0:146cf26a9bbb
|
207
|
------------------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
208
|
/* Alias on existing output devices to adapt for 2 headphones output */
|
|
Jerome Coutant
0:146cf26a9bbb
|
209
|
#define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE
|
|
Jerome Coutant
0:146cf26a9bbb
|
210
|
#define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER /* Headphone2 is connected to Speaker output of the wm8994 */
|
|
Jerome Coutant
0:146cf26a9bbb
|
211
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
212
|
/*------------------------------------------------------------------------------
|
|
Jerome Coutant
0:146cf26a9bbb
|
213
|
INPUT DEVICES definition
|
|
Jerome Coutant
0:146cf26a9bbb
|
214
|
------------------------------------------------------------------------------*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
215
|
/* Analog microphone input from 3.5 audio jack connector */
|
|
Jerome Coutant
0:146cf26a9bbb
|
216
|
#define INPUT_DEVICE_ANALOG_MIC ((uint32_t)0x00000001)
|
|
Jerome Coutant
0:146cf26a9bbb
|
217
|
/* MP34DT01TR digital microphone on PCB top side */
|
|
Jerome Coutant
0:146cf26a9bbb
|
218
|
#define INPUT_DEVICE_DIGITAL_MIC1 ((uint32_t)0x00000010)
|
|
Jerome Coutant
0:146cf26a9bbb
|
219
|
#define INPUT_DEVICE_DIGITAL_MIC2 ((uint32_t)0x00000020)
|
|
Jerome Coutant
0:146cf26a9bbb
|
220
|
#define INPUT_DEVICE_DIGITAL_MIC ((uint32_t)(INPUT_DEVICE_DIGITAL_MIC1 | INPUT_DEVICE_DIGITAL_MIC2))
|
|
Jerome Coutant
0:146cf26a9bbb
|
221
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
222
|
/* Audio In interface for Digital mic */
|
|
Jerome Coutant
0:146cf26a9bbb
|
223
|
#define AUDIO_IN_INTERFACE_SAI ((uint16_t)0)
|
|
Jerome Coutant
0:146cf26a9bbb
|
224
|
#define AUDIO_IN_INTERFACE_PDM ((uint16_t)1)
|
|
Jerome Coutant
0:146cf26a9bbb
|
225
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
226
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
227
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
228
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
229
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
230
|
/** @defgroup STM32H747I_DISCOVERY_AUDIO_Exported_Macros Exported Macros
|
|
Jerome Coutant
0:146cf26a9bbb
|
231
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
232
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
233
|
#define DMA_MAX_SIZE 0xFFFF
|
|
Jerome Coutant
0:146cf26a9bbb
|
234
|
#define DMA_MAX(x) (((x) <= DMA_MAX_SIZE)? (x):DMA_MAX_SIZE)
|
|
Jerome Coutant
0:146cf26a9bbb
|
235
|
#define POS_VAL(VAL) (POSITION_VAL(VAL) - 4)
|
|
Jerome Coutant
0:146cf26a9bbb
|
236
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
237
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
238
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
239
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
240
|
/** @addtogroup STM32H747I_DISCOVERY_AUDIO_OUT_Exported_Functions
|
|
Jerome Coutant
0:146cf26a9bbb
|
241
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
242
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
243
|
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
|
|
Jerome Coutant
0:146cf26a9bbb
|
244
|
void BSP_AUDIO_OUT_DeInit(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
245
|
uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size);
|
|
Jerome Coutant
0:146cf26a9bbb
|
246
|
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size);
|
|
Jerome Coutant
0:146cf26a9bbb
|
247
|
uint8_t BSP_AUDIO_OUT_Pause(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
248
|
uint8_t BSP_AUDIO_OUT_Resume(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
249
|
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option);
|
|
Jerome Coutant
0:146cf26a9bbb
|
250
|
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume);
|
|
Jerome Coutant
0:146cf26a9bbb
|
251
|
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq);
|
|
Jerome Coutant
0:146cf26a9bbb
|
252
|
void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot);
|
|
Jerome Coutant
0:146cf26a9bbb
|
253
|
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd);
|
|
Jerome Coutant
0:146cf26a9bbb
|
254
|
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output);
|
|
Jerome Coutant
0:146cf26a9bbb
|
255
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
256
|
/* User Callbacks: user has to implement these functions in his code if they are needed. */
|
|
Jerome Coutant
0:146cf26a9bbb
|
257
|
/* This function is called when the requested data has been completely transferred.*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
258
|
void BSP_AUDIO_OUT_TransferComplete_CallBack(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
259
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
260
|
/* This function is called when half of the requested buffer has been transferred. */
|
|
Jerome Coutant
0:146cf26a9bbb
|
261
|
void BSP_AUDIO_OUT_HalfTransfer_CallBack(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
262
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
263
|
/* This function is called when an Interrupt due to transfer error on or peripheral
|
|
Jerome Coutant
0:146cf26a9bbb
|
264
|
error occurs. */
|
|
Jerome Coutant
0:146cf26a9bbb
|
265
|
void BSP_AUDIO_OUT_Error_CallBack(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
266
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
267
|
/* These function can be modified in case the current settings (e.g. DMA stream)
|
|
Jerome Coutant
0:146cf26a9bbb
|
268
|
need to be changed for specific application needs */
|
|
Jerome Coutant
0:146cf26a9bbb
|
269
|
void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params);
|
|
Jerome Coutant
0:146cf26a9bbb
|
270
|
void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params);
|
|
Jerome Coutant
0:146cf26a9bbb
|
271
|
void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params);
|
|
Jerome Coutant
0:146cf26a9bbb
|
272
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
273
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
274
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
275
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
276
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
277
|
/** @addtogroup STM32H747I_DISCOVERY_AUDIO_IN_Exported_Functions
|
|
Jerome Coutant
0:146cf26a9bbb
|
278
|
* @{
|
|
Jerome Coutant
0:146cf26a9bbb
|
279
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
280
|
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
|
|
Jerome Coutant
0:146cf26a9bbb
|
281
|
uint8_t BSP_AUDIO_IN_InitEx(uint16_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
|
|
Jerome Coutant
0:146cf26a9bbb
|
282
|
uint8_t BSP_AUDIO_IN_AllocScratch (int32_t *pScratch, uint32_t size);
|
|
Jerome Coutant
0:146cf26a9bbb
|
283
|
uint8_t BSP_AUDIO_IN_Record(uint16_t *pBuf, uint32_t Size);
|
|
Jerome Coutant
0:146cf26a9bbb
|
284
|
uint8_t BSP_AUDIO_IN_RecordEx(uint32_t *pBuf, uint32_t Size);
|
|
Jerome Coutant
0:146cf26a9bbb
|
285
|
uint8_t BSP_AUDIO_IN_SetFrequency(uint32_t AudioFreq);
|
|
Jerome Coutant
0:146cf26a9bbb
|
286
|
uint8_t BSP_AUDIO_IN_Stop(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
287
|
uint8_t BSP_AUDIO_IN_StopEx(uint32_t InputDevice);
|
|
Jerome Coutant
0:146cf26a9bbb
|
288
|
uint8_t BSP_AUDIO_IN_Pause(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
289
|
uint8_t BSP_AUDIO_IN_PauseEx(uint32_t InputDevice);
|
|
Jerome Coutant
0:146cf26a9bbb
|
290
|
uint8_t BSP_AUDIO_IN_Resume(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
291
|
uint8_t BSP_AUDIO_IN_ResumeEx(uint32_t *pBuf, uint32_t InputDevice);
|
|
Jerome Coutant
0:146cf26a9bbb
|
292
|
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume);
|
|
Jerome Coutant
0:146cf26a9bbb
|
293
|
void BSP_AUDIO_IN_DeInit(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
294
|
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf);
|
|
Jerome Coutant
0:146cf26a9bbb
|
295
|
uint8_t BSP_AUDIO_IN_PDMToPCM_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut);
|
|
Jerome Coutant
0:146cf26a9bbb
|
296
|
void BSP_AUDIO_IN_SelectInterface(uint32_t Interface);
|
|
Jerome Coutant
0:146cf26a9bbb
|
297
|
uint32_t BSP_AUDIO_IN_GetInterface(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
298
|
uint8_t BSP_AUDIO_IN_OUT_Init(uint32_t InputDevice, uint32_t OutputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
|
|
Jerome Coutant
0:146cf26a9bbb
|
299
|
uint8_t BSP_AUDIO_IN_GetChannelNumber(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
300
|
void BSP_AUDIO_IN_Error_Callback(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
301
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
302
|
/* User Callbacks: user has to implement these functions in his code if they are needed. */
|
|
Jerome Coutant
0:146cf26a9bbb
|
303
|
/* This function should be implemented by the user application.
|
|
Jerome Coutant
0:146cf26a9bbb
|
304
|
It is called into this driver when the current buffer is filled to prepare the next
|
|
Jerome Coutant
0:146cf26a9bbb
|
305
|
buffer pointer and its size. */
|
|
Jerome Coutant
0:146cf26a9bbb
|
306
|
void BSP_AUDIO_IN_TransferComplete_CallBack(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
307
|
void BSP_AUDIO_IN_HalfTransfer_CallBack(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
308
|
void BSP_AUDIO_IN_TransferComplete_CallBackEx(uint32_t InputDevice);
|
|
Jerome Coutant
0:146cf26a9bbb
|
309
|
void BSP_AUDIO_IN_HalfTransfer_CallBackEx(uint32_t InputDevice);
|
|
Jerome Coutant
0:146cf26a9bbb
|
310
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
311
|
/* This function is called when an Interrupt due to transfer error on or peripheral
|
|
Jerome Coutant
0:146cf26a9bbb
|
312
|
error occurs. */
|
|
Jerome Coutant
0:146cf26a9bbb
|
313
|
void BSP_AUDIO_IN_Error_CallBack(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
314
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
315
|
/* These function can be modified in case the current settings (e.g. DMA stream)
|
|
Jerome Coutant
0:146cf26a9bbb
|
316
|
need to be changed for specific application needs */
|
|
Jerome Coutant
0:146cf26a9bbb
|
317
|
void BSP_AUDIO_IN_ClockConfig(uint32_t AudioFreq, void *Params);
|
|
Jerome Coutant
0:146cf26a9bbb
|
318
|
void BSP_AUDIO_IN_MspInit(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
319
|
void BSP_AUDIO_IN_MspDeInit(void);
|
|
Jerome Coutant
0:146cf26a9bbb
|
320
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
321
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
322
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
323
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
324
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
325
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
326
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
327
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
328
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
329
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
330
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
331
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
332
|
/**
|
|
Jerome Coutant
0:146cf26a9bbb
|
333
|
* @}
|
|
Jerome Coutant
0:146cf26a9bbb
|
334
|
*/
|
|
Jerome Coutant
0:146cf26a9bbb
|
335
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
336
|
#ifdef __cplusplus
|
|
Jerome Coutant
0:146cf26a9bbb
|
337
|
}
|
|
Jerome Coutant
0:146cf26a9bbb
|
338
|
#endif
|
|
Jerome Coutant
0:146cf26a9bbb
|
339
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
340
|
#endif /* __STM32H747I_DISCOVERY_AUDIO_H */
|
|
Jerome Coutant
0:146cf26a9bbb
|
341
|
|
|
Jerome Coutant
0:146cf26a9bbb
|
342
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|