Il y avait des problèmes dans la libraire...
Dependencies: ST_FREQUENCY_DIVIDER ST_I2S USBDEVICE
Fork of X_NUCLEO_CCA02M1 by
Middlewares/OpenPDM2PCM/OpenPDMFilter.h@20:9952bef19da1, 2017-05-05 (annotated)
- Committer:
- Davidroid
- Date:
- Fri May 05 11:34:10 2017 +0000
- Revision:
- 20:9952bef19da1
- Parent:
- 16:4ab2eac7be21
Simplifying code.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
davide.aliprandi@st.com | 2:9f389fd8fb2e | 1 | /** |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 2 | ****************************************************************************** |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 3 | * @file OpenPDMFilter.h |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 4 | * @author CL |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 5 | * @version V1.0.0 |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 6 | * @date 9-September-2015 |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 7 | * @brief Header file for Open PDM audio software decoding Library. |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 8 | * This Library is used to decode and reconstruct the audio signal |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 9 | * produced by ST MEMS microphone (MP45Dxxx, MP34Dxxx). |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 10 | ****************************************************************************** |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 11 | * @attention |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 12 | * |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 13 | * <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2> |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 14 | * |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 15 | * Licensed under MCD-ST Image SW License Agreement V2, (the "License"); |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 16 | * You may not use this file except in compliance with the License. |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 17 | * You may obtain a copy of the License at: |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 18 | * |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 19 | * http://www.st.com/software_license_agreement_image_v2 |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 20 | * |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 21 | * Unless required by applicable law or agreed to in writing, software |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 22 | * distributed under the License is distributed on an "AS IS" BASIS, |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 24 | * See the License for the specific language governing permissions and |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 25 | * limitations under the License. |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 26 | * |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 27 | ****************************************************************************** |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 28 | */ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 29 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 30 | /* Define to prevent recursive inclusion -------------------------------------*/ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 31 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 32 | #ifndef __OPENPDMFILTER_H |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 33 | #define __OPENPDMFILTER_H |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 34 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 35 | #ifdef __cplusplus |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 36 | extern "C" { |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 37 | #endif |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 38 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 39 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 40 | /* Includes ------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 41 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 42 | #include <stdint.h> |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 43 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 44 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 45 | /* Definitions ---------------------------------------------------------------*/ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 46 | |
davide.aliprandi@st.com | 16:4ab2eac7be21 | 47 | /* |
davide.aliprandi@st.com | 16:4ab2eac7be21 | 48 | * Enable to use a Look-Up Table to improve performances while using more FLASH |
davide.aliprandi@st.com | 16:4ab2eac7be21 | 49 | * and RAM memory. |
Davidroid | 20:9952bef19da1 | 50 | * Note: Without Look-Up Table up to stereo@16KHz configuration is supported. |
davide.aliprandi@st.com | 16:4ab2eac7be21 | 51 | */ |
davide.aliprandi@st.com | 15:17bdadc6aa9c | 52 | #define USE_LUT |
davide.aliprandi@st.com | 15:17bdadc6aa9c | 53 | |
Davidroid | 20:9952bef19da1 | 54 | #define SINCN 3 |
Davidroid | 20:9952bef19da1 | 55 | #define DECIMATION_MAX 128 |
Davidroid | 20:9952bef19da1 | 56 | #define FILTER_GAIN 16 |
Davidroid | 20:9952bef19da1 | 57 | |
Davidroid | 20:9952bef19da1 | 58 | #define HTONS(A) ((((uint16_t)(A) & 0xff00) >> 8) | \ |
Davidroid | 20:9952bef19da1 | 59 | (((uint16_t)(A) & 0x00ff) << 8)) |
Davidroid | 20:9952bef19da1 | 60 | #define RoundDiv(a, b) (((a)>0)?(((a)+(b)/2)/(b)):(((a)-(b)/2)/(b))) |
Davidroid | 20:9952bef19da1 | 61 | #define SaturaLH(N, L, H) (((N)<(L))?(L):(((N)>(H))?(H):(N))) |
Davidroid | 20:9952bef19da1 | 62 | |
davide.aliprandi@st.com | 15:17bdadc6aa9c | 63 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 64 | /* Types ---------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 65 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 66 | typedef struct { |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 67 | /* Public */ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 68 | float LP_HZ; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 69 | float HP_HZ; |
Davidroid | 20:9952bef19da1 | 70 | uint16_t Fs; |
Davidroid | 20:9952bef19da1 | 71 | uint8_t In_MicChannels; |
Davidroid | 20:9952bef19da1 | 72 | uint8_t Out_MicChannels; |
Davidroid | 20:9952bef19da1 | 73 | uint8_t Decimation; |
Davidroid | 20:9952bef19da1 | 74 | uint8_t MaxVolume; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 75 | /* Private */ |
Davidroid | 20:9952bef19da1 | 76 | uint32_t Coef[SINCN]; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 77 | uint16_t FilterLen; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 78 | int64_t OldOut, OldIn, OldZ; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 79 | uint16_t LP_ALFA; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 80 | uint16_t HP_ALFA; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 81 | uint16_t bit[5]; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 82 | uint16_t byte; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 83 | } TPDMFilter_InitStruct; |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 84 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 85 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 86 | /* Exported functions ------------------------------------------------------- */ |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 87 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 88 | void Open_PDM_Filter_Init(TPDMFilter_InitStruct *init_struct); |
Davidroid | 20:9952bef19da1 | 89 | void Open_PDM_Filter_64(uint8_t* data, uint16_t* data_out, uint16_t mic_gain, TPDMFilter_InitStruct *init_struct); |
Davidroid | 20:9952bef19da1 | 90 | void Open_PDM_Filter_128(uint8_t* data, uint16_t* data_out, uint16_t mic_gain, TPDMFilter_InitStruct *init_struct); |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 91 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 92 | #ifdef __cplusplus |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 93 | } |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 94 | #endif |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 95 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 96 | #endif // __OPENPDMFILTER_H |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 97 | |
davide.aliprandi@st.com | 2:9f389fd8fb2e | 98 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |