Audio Demo with DISCO Board, takes control samples, waits for user input, samples regularly.

Dependencies:   CMSIS_DSP_401 STM32L4xx_HAL_Driver mbed-src_DISO_AUDIO_DEMO

Committer:
EricLew
Date:
Sun Dec 13 19:12:11 2015 +0000
Revision:
0:3eee9435dd17
Audio Demo using DISCO Board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EricLew 0:3eee9435dd17 1 /**
EricLew 0:3eee9435dd17 2 ******************************************************************************
EricLew 0:3eee9435dd17 3 * @file /Inc/audio_if.h
EricLew 0:3eee9435dd17 4 * @author Central Labs
EricLew 0:3eee9435dd17 5 * @version V1.0.0
EricLew 0:3eee9435dd17 6 * @date 7-May-2015
EricLew 0:3eee9435dd17 7 * @brief Header for audio_if.c file.
EricLew 0:3eee9435dd17 8 ******************************************************************************
EricLew 0:3eee9435dd17 9 @attention
EricLew 0:3eee9435dd17 10 *
EricLew 0:3eee9435dd17 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
EricLew 0:3eee9435dd17 12 *
EricLew 0:3eee9435dd17 13 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
EricLew 0:3eee9435dd17 14 * You may not use this file except in compliance with the License.
EricLew 0:3eee9435dd17 15 * You may obtain a copy of the License at:
EricLew 0:3eee9435dd17 16 *
EricLew 0:3eee9435dd17 17 * http://www.st.com/software_license_agreement_liberty_v2
EricLew 0:3eee9435dd17 18 *
EricLew 0:3eee9435dd17 19 * Redistribution and use in source and binary forms, with or without modification,
EricLew 0:3eee9435dd17 20 * are permitted provided that the following conditions are met:
EricLew 0:3eee9435dd17 21 * 1. Redistributions of source code must retain the above copyright notice,
EricLew 0:3eee9435dd17 22 * this list of conditions and the following disclaimer.
EricLew 0:3eee9435dd17 23 * 2. Redistributions in binary form must reproduce the above copyright notice,
EricLew 0:3eee9435dd17 24 * this list of conditions and the following disclaimer in the documentation
EricLew 0:3eee9435dd17 25 * and/or other materials provided with the distribution.
EricLew 0:3eee9435dd17 26 * 3. Neither the name of STMicroelectronics nor the names of its contributors
EricLew 0:3eee9435dd17 27 * may be used to endorse or promote products derived from this software
EricLew 0:3eee9435dd17 28 * without specific prior written permission.
EricLew 0:3eee9435dd17 29 *
EricLew 0:3eee9435dd17 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
EricLew 0:3eee9435dd17 31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
EricLew 0:3eee9435dd17 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
EricLew 0:3eee9435dd17 33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
EricLew 0:3eee9435dd17 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
EricLew 0:3eee9435dd17 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
EricLew 0:3eee9435dd17 36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
EricLew 0:3eee9435dd17 37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
EricLew 0:3eee9435dd17 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
EricLew 0:3eee9435dd17 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EricLew 0:3eee9435dd17 40 *
EricLew 0:3eee9435dd17 41 ******************************************************************************
EricLew 0:3eee9435dd17 42 */
EricLew 0:3eee9435dd17 43
EricLew 0:3eee9435dd17 44 /* Define to prevent recursive inclusion -------------------------------------*/
EricLew 0:3eee9435dd17 45 #ifndef __AUDIO_IF_H
EricLew 0:3eee9435dd17 46 #define __AUDIO_IF_H
EricLew 0:3eee9435dd17 47
EricLew 0:3eee9435dd17 48 /* Includes ------------------------------------------------------------------*/
EricLew 0:3eee9435dd17 49 #include "main.h"
EricLew 0:3eee9435dd17 50 //#include "x_nucleo_cca02m1_audio_l4.h"
EricLew 0:3eee9435dd17 51 #include "stm32l476g_discovery_audio.h"
EricLew 0:3eee9435dd17 52 #include <cstdint>
EricLew 0:3eee9435dd17 53
EricLew 0:3eee9435dd17 54
EricLew 0:3eee9435dd17 55 /* Exported types ------------------------------------------------------------*/
EricLew 0:3eee9435dd17 56 /* Exported constants --------------------------------------------------------*/
EricLew 0:3eee9435dd17 57 /* Exported macro ------------------------------------------------------------*/
EricLew 0:3eee9435dd17 58 /* Exported functions ------------------------------------------------------- */
EricLew 0:3eee9435dd17 59
EricLew 0:3eee9435dd17 60
EricLew 0:3eee9435dd17 61 extern int8_t Audio_Init(void);
EricLew 0:3eee9435dd17 62 extern int8_t Audio_Record(uint16_t * recbuff);
EricLew 0:3eee9435dd17 63 //extern int8_t Audio_VolumeCtl(int16_t Volume);
EricLew 0:3eee9435dd17 64 //extern int8_t Audio_MuteCtl(uint8_t cmd);
EricLew 0:3eee9435dd17 65 extern int8_t Audio_Stop(void);
EricLew 0:3eee9435dd17 66 //extern int8_t Audio_Pause(void);
EricLew 0:3eee9435dd17 67 //extern int8_t Audio_Resume(void);
EricLew 0:3eee9435dd17 68 //extern int8_t Audio_CommandMgr(uint8_t cmd);
EricLew 0:3eee9435dd17 69 //extern void AudioProcess(uint16_t * pbuf, uint16_t * recbuff);
EricLew 0:3eee9435dd17 70 extern void PrintData(uint16_t * recbuff);
EricLew 0:3eee9435dd17 71 extern void WriteData(uint16_t * recbuff);
EricLew 0:3eee9435dd17 72 //void BSP_AUDIO_IN_HalfTransfer_CallBack(void);
EricLew 0:3eee9435dd17 73
EricLew 0:3eee9435dd17 74 int rec(const char *filename, uint16_t * recbuff, uint16_t size);
EricLew 0:3eee9435dd17 75
EricLew 0:3eee9435dd17 76 /**
EricLew 0:3eee9435dd17 77 * @brief Sampling Frequency enumerator
EricLew 0:3eee9435dd17 78 */
EricLew 0:3eee9435dd17 79 typedef enum
EricLew 0:3eee9435dd17 80 {
EricLew 0:3eee9435dd17 81 SAMPLING_FREQ_16000 = 16000,
EricLew 0:3eee9435dd17 82 SAMPLING_FREQ_32000 = 32000,
EricLew 0:3eee9435dd17 83 SAMPLING_FREQ_48000 = 48000
EricLew 0:3eee9435dd17 84
EricLew 0:3eee9435dd17 85 }OUTPUT_FREQ_TypeDef;
EricLew 0:3eee9435dd17 86
EricLew 0:3eee9435dd17 87
EricLew 0:3eee9435dd17 88 #define RAM_TOTAL 0x1000
EricLew 0:3eee9435dd17 89
EricLew 0:3eee9435dd17 90 #define AUDIO_CHANNELS 1
EricLew 0:3eee9435dd17 91 #define AUDIO_SAMPLING_FREQUENCY 48000
EricLew 0:3eee9435dd17 92
EricLew 0:3eee9435dd17 93 #define PCM_TEMP_BUFF_SIZE AUDIO_SAMPLING_FREQUENCY/1000*1
EricLew 0:3eee9435dd17 94
EricLew 0:3eee9435dd17 95
EricLew 0:3eee9435dd17 96 #if defined(STM32L053xx) || defined(STM32F072xB)
EricLew 0:3eee9435dd17 97 #if (AUDIO_CHANNELS > 2)
EricLew 0:3eee9435dd17 98 #error "Acquisition of more than 2 microphone is not yet supported for STM32L0 and STM32F0"
EricLew 0:3eee9435dd17 99 #elif (AUDIO_SAMPLING_FREQUENCY > 32000)
EricLew 0:3eee9435dd17 100 #error "Acquisition of sampling frequencies above 32 KHz is not yet supported for STM32L0 and STM32F0"
EricLew 0:3eee9435dd17 101 #elif (AUDIO_SAMPLING_FREQUENCY == 32000 && AUDIO_CHANNELS == 2)
EricLew 0:3eee9435dd17 102 #error "These settings are not yet supported for STM32L0 and STM32F0"
EricLew 0:3eee9435dd17 103 #endif
EricLew 0:3eee9435dd17 104 #endif
EricLew 0:3eee9435dd17 105
EricLew 0:3eee9435dd17 106 #endif
EricLew 0:3eee9435dd17 107 /* __AUDIO_IF_H */
EricLew 0:3eee9435dd17 108
EricLew 0:3eee9435dd17 109 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
EricLew 0:3eee9435dd17 110