Library to handle the X-NUCLEO-CCA02M1 MEMS Microphones Expansion Board.

Dependencies:   ST_I2S ST_FREQUENCY_DIVIDER USBDEVICE

Dependents:   HelloWorld_CCA02M1 HelloWorld_CCA02M1_mbedOS HelloWorld_CCA02M1 Karaoke_CCA01M1_CCA02M1_mbedOS

Fork of X_NUCLEO_CCA02M1 by ST Expansion SW Team

MEMS Microphones Library

Library to handle the X-NUCLEO-CCA02M1 MEMS Microphones Expansion Board. A single board allows to record a standard 2-channel stereo signal as an array of PCM samples (16 bit/sample); in principle, it could make use of six additional MEMS microphones to realize a 8-channel audio system.


Microphones configuration

Currently the configurations supported are the following:

  • Stereo@48KHz
  • Stereo@44.1KHz (CD audio quality)
  • Stereo@32KHz
  • Stereo@16KHz
  • Stereo@8KHz
  • Mono@48KHz
  • Mono@44.1KHz
  • Mono@32KHz
  • Mono@16KHz
  • Mono@8KHz

Mono configurations need a Jumper connecting PB_5 and PB_13 on the Morpho connector to properly work.


Platform compatibility

  • This board can be currently used with the Nucleo F4 Family only, please see the ST_I2S library compatibility for further information.
  • The library is compatible both with mbed OS 5.x and mbed classic 2.x (to work with mbed classic, the main application has to import the "events" library, which is not included into the "mbed" library).


I2S Peripheral Usage

By default this board makes use of the I2S peripheral available on Nucleo boards.


Acquiring through the USB

In order to acquire the recorded PCM audio channel with an audio SW on a PC, please connect the expansion board to a USB port of the PC, and the Nucleo board to a USB power supply.

Committer:
Davidroid
Date:
Wed Dec 12 15:44:02 2018 +0000
Revision:
26:53f8b511f2a1
Parent:
25:f2c04f757003
Update LICENSE.txt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davide.aliprandi@st.com 2:9f389fd8fb2e 1 /**
Davidroid 25:f2c04f757003 2 *******************************************************************************
Davidroid 25:f2c04f757003 3 * @file OpenPDMFilter.h
Davidroid 25:f2c04f757003 4 * @author CL
Davidroid 25:f2c04f757003 5 * @version V1.0.0
Davidroid 25:f2c04f757003 6 * @date 9-September-2015
Davidroid 25:f2c04f757003 7 * @brief Header file for Open PDM audio software decoding Library.
Davidroid 25:f2c04f757003 8 * This Library is used to decode and reconstruct the audio signal
Davidroid 25:f2c04f757003 9 * produced by ST MEMS microphone (MP45Dxxx, MP34Dxxx).
Davidroid 25:f2c04f757003 10 *******************************************************************************
Davidroid 25:f2c04f757003 11 * @attention
Davidroid 25:f2c04f757003 12 *
Davidroid 25:f2c04f757003 13 * <h2><center>&copy; COPYRIGHT 2018 STMicroelectronics</center></h2>
Davidroid 25:f2c04f757003 14 *
Davidroid 25:f2c04f757003 15 * Licensed under the Apache License, Version 2.0 (the "License");
Davidroid 25:f2c04f757003 16 * you may not use this file except in compliance with the License.
Davidroid 25:f2c04f757003 17 * You may obtain a copy of the License at
Davidroid 25:f2c04f757003 18 *
Davidroid 25:f2c04f757003 19 * http://www.apache.org/licenses/LICENSE-2.0
Davidroid 25:f2c04f757003 20 *
Davidroid 25:f2c04f757003 21 * Unless required by applicable law or agreed to in writing, software
Davidroid 25:f2c04f757003 22 * distributed under the License is distributed on an "AS IS" BASIS,
Davidroid 25:f2c04f757003 23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Davidroid 25:f2c04f757003 24 * See the License for the specific language governing permissions and
Davidroid 25:f2c04f757003 25 * limitations under the License.
Davidroid 25:f2c04f757003 26 *******************************************************************************
Davidroid 25:f2c04f757003 27 */
Davidroid 25:f2c04f757003 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****/