ARMEBS4  revision-26.06.2015
stm32_audio_synchprocess.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file stm32_audio_synchprocess.h
4  * @author MCD Application Team
5  * @version V1.1.0
6  * @date 14-January-2013
7  * @brief This file contains all the functions prototypes for the audio correction.
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
12  *
13  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14  * You may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at:
16  *
17  * http://www.st.com/software_license_agreement_liberty_v2
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  ******************************************************************************
26  */
27 
28 #ifndef __STM32_AUDIO_SYNCHPROCESS_H
29 #define __STM32_AUDIO_SYNCHPROCESS_H
30 
31 /* Includes ------------------------------------------------------------------*/
32 #include "stm32f4xx.h"
33 #include "stm32_audio_correction.h"
34 
35 /** @addtogroup STM32_Audio_Utilities
36  * @{
37  */
38 
39 /** @defgroup AUDIO_SYNCHPROCESS
40  * @brief This file is the Header file for stm32_audio_synchprocess.c
41  * @{
42  */
43 
44 /** @defgroup AUDIO_SYNCHPROCESS_Exported_Defines
45  * @{
46  */
47 /* ----------------------------------------------------------------------------
48 
49  All the commented configuration parameters are gathered into audio_app_conf.h
50  file. If you already set them in audio_app_conf.h file, there is no need
51  to reconfigure them here.
52 
53 -----------------------------------------------------------------------------*/
54 
55 /* Set the relative define to 0 to disable a synchronization method or to 1 to
56  enable that method.
57  You can disable all methods: In this case no correction method is selected
58  and the streaming will not be synchronized.
59 
60  Add-Remove samples synchronization method. This method doesn't require
61  additional hardware. */
62 /* #define AUDIO_SYNCHRO_ADDREM_ENABLED 1 */
63 
64 /* External Dynamic PLL with clock synthesizer. This method uses the clock
65  synthesizer component implemented in STM322xG-EVAL revB board. */
66 /* #define AUDIO_SYNCHRO_CLKSYNTH_ENABLED 1 */
67 
68 /* Feedback pipe synchronization method. This method doesn't require
69  additional hardware. */
70 /* #define AUDIO_SYNCHRO_FEEDBACK_ENABLED 1 */
71 
72 /* Dynamic Audio recording clock adjustment using Timer auto reload register udpate. */
73 /* #define USB_AUDIO_IN_SYNCHRO_CLKUPDT_ENABLED 1 */
74 
75 /* Correction timing parameters: Make sure these parameters are set to suitable
76  values depending on the allowed error and the application requirements. */
77 /*-------------------- SYNCH_NONE -------------------------------------------*/
78 /* #define SYNCH_NONE_PERIOD 300 *//* Used as indicative way only */
79 /* #define SYNCH_NONE_STEP 0 *//* Not used in this case */
80 
81 /*-------------------- SYNCH_EXTCLK -----------------------------------------*/
82 /* Period of time between corrections in ms (This value must be multiple of 10 ms).
83  This constraint (multiple of 10 ms) is only to avoid intensive entrance into
84  interrupt routine (save CPU load). If higher granularity is required you can
85  disable the option AUDIO_CORR_INERR_MULT_10 by commenting the define. */
86 /* This is the case when clock shift is less than 100ppm */
87 /* #define SYNCH_EXTCLK_PERIOD 200 */
88 /* Step for ppm adjustment */
89 /* #define SYNCH_EXTCLK_STEP 1 */
90 /* This is the case when clock shift is higher than 100ppm and less than 500ppm */
91 /* #define SYNCH_EXTCLK_PERIOD_ALT 200 */
92 /* Step for ppm adjustment */
93 /* #define SYNCH_EXTCLK_STEP_ALT 5 */
94 /* External Clock synchro threshold not used here, keep it at 0 */
95 /* #define SYNCH_EXTCLK_THRESHOLD 0 */
96 
97 /*-------------------- SYNCH_FEEDBACK ---------------------------------------*/
98  /* Period of time between corrections in ms (This value must be multiple of 10 ms).
99  This constraint (multiple of 10 ms) is only to avoid intensive entrance into
100  interrupt routine (save CPU load). If higher granularity is required you can
101  disable the option AUDIO_CORR_INERR_MULT_10 by commenting the define. */
102 /* #define SYNCH_FEEDBACK_PERIOD 500 */
103  /* Fractional part to be added/removed to/from original frame size (fractional
104  format is 10.10 (or 10.14), refer to USB 2.0 specification for more details).
105  when the define FEEDBACK_EXTENDED_PRECISION_10_14 is enabled, the used format
106  is 10.14. Else it is 10.10 */
107 /* #define SYNCH_FEEDBACK_STEP 1 */
108  /* Feedback pipe refresh value. This value indicates the rate at which the host
109  should request for the updated feedback value. Min = 1, Max = 9.
110  The refresh period = 2^FEEDBACK_REFRESH.
111  e.g. FEEDBACK_REFRESH = 5: bRefresh = 2^5 = 32 */
112 /* #define FEEDBACK_REFRESH 8 */
113  /* Feedback threshold is the maximum number of corrections in one direction.
114  This parameter defines the dynamic of the feedback value update.
115  e.g if FEEDBACK_THRESHOLD = 30: if the feedback value is decremented 30 times
116  then it is reset to the orginal value.
117  You can set this value to 0xFFFFFFF to see the effect of not limiting the
118  dynamics of feedback by a threshold value: correction will go too far in
119  one direction before going in the opposite one. */
120 /* #define SYNCH_FEEDBACK_THRESHOLD 30 */
121 
122 /*-------------------- SYNCH_ADDREM -----------------------------------------*/
123  /* Period of time between corrections in ms (This value must be multiple of 10 ms).
124  This constraint (multiple of 10 ms) is only to avoid intensive entrance into
125  interrupt routine (save CPU load). If higher granularity is required you can
126  disable the option AUDIO_CORR_INERR_MULT_10 by commenting the define. */
127 /* #define SYNCH_ADDREM_PERIOD 50*/
128  /* Number of samples to be removed or added each time an overrun/underrun
129  condition is detected. */
130 /* #define SYNCH_ADDREM_STEP 4 */
131 
132 /*-------------------- SYNCH_CLKUPDT ----------------------------------------*/
133  /* Period of time between corrections in ms (This value must be multiple of 10 ms).
134  This constraint (multiple of 10 ms) is only to avoid intensive entrance into
135  interrupt routine (save CPU load). If higher granularity is required you can
136  disable the option AUDIO_CORR_INERR_MULT_10 by commenting the define. */
137 /* #define SYNCH_CLKUPDT_PERIOD 50 *//* 50 ms */
138  /* Step value for the input clock update. */
139 /* #define SYNCH_CLKUPDT_STEP 2 */
140 
141 /*-------------------- Optional adjustment Parameters -----------------------*/
142 /* If higher granularity is required for CORRECTION_PERIOD you can disable the option
143  AUDIO_CORR_INERR_MULT_10 by commenting this define.
144  In this case the CORRECTION_PERIOD value can be non multiple of 10.
145  WARNING: Uncommenting this define will lead to increasing CPU load since the periodic
146  correction interrupt will be exected at higher frequency. */
147 /* #define AUDIO_CORR_INERR_MULT_10 */
148 
149 /* Uncomment this define to extend the precision of the feedback value from 10.10 to 10.14
150  format. This means that the lower 4 bits of the fractional part will be used.*/
151 /* #define FEEDBACK_EXTENDED_PRECISION_10_14 */
152 
153 /* Uncomment these defines to enable the Dynamic Adjustment Factor: that means
154  the correction step will be increased/decreased depending on the error value.
155  This method is available only with external clock synthesizer correction enabled. */
156 /* #define USE_DYNAMIC_ADJUSTMENT_FACTOR 0 */
157 /* #define DYNAMIC_ADJUSTMENT_FACTOR_MAX 4 */
158 
159 
160 /*----------------------
161  DO NOT MODIFY THESE DEFINES
162  ------------------------------------*/
163 
164 /* Security check: bRefresh value must be in range [1,9] */
165 #ifdef AUDIO_SYNCHRO_FEEDBACK_ENABLED
166  #if (FEEDBACK_REFRESH > 9)
167  #error "ERROR: Feedabck refresh value out of spec ! (FEEDBACK_REFRESH in usbd_audio_synchprocess.h)"
168  #endif
169 #endif /* AUDIO_SYNCHRO_FEEDBACK_ENABLED */
170 
171 /* Do not modify this define */
172 #ifdef FEEDBACK_EXTENDED_PRECISION_10_14
173  #define MAX_FRACTION 0x3FFF
174 #else
175  #define MAX_FRACTION 0x3FF
176 #endif /* FEEDBACK_EXTENDED_PRECISION_10_14 */
177 /*----------------------------------------------------------------------------*/
178 /**
179  * @}
180  */
181 
182 
183 /** @defgroup AUDIO_SYNCHPROCESS_Exported_TypesDefinitions
184  * @{
185  */
186 /**
187  * @}
188  */
189 
190 /** @defgroup AUDIO_SYNCHPROCESS_Exported_Macros
191  * @{
192  */
193 
194 /**
195  * @}
196  */
197 
198 /** @defgroup AUDIO_SYNCHPROCESS_Exported_Variables
199  * @{
200  */
201 /**
202  * @}
203  */
204 
205 /** @defgroup AUDIO_SYNCHPROCESS_Exported_Functions
206  * @{
207  */
208 extern SynchStruct_TypeDef* OutMethTab[];
209 extern SynchStruct_TypeDef* InMethTab[];
210 /**
211  * @}
212  */
213 #endif /* __STM32_AUDIO_SYNCHPROCESS_H */
214 
215 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...