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 main.c
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 Main program body
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
EricLew 0:3eee9435dd17 45 /* Includes ------------------------------------------------------------------*/
EricLew 0:3eee9435dd17 46 #include "main.h"
EricLew 0:3eee9435dd17 47
EricLew 0:3eee9435dd17 48 /* Private typedef -----------------------------------------------------------*/
EricLew 0:3eee9435dd17 49 /* Private define ------------------------------------------------------------*/
EricLew 0:3eee9435dd17 50 /* Private macro -------------------------------------------------------------*/
EricLew 0:3eee9435dd17 51 /* Private variables ---------------------------------------------------------*/
EricLew 0:3eee9435dd17 52 /* Private functions ---------------------------------------------------------*/
EricLew 0:3eee9435dd17 53 #include "stm32l4xx_hal_def.h"
EricLew 0:3eee9435dd17 54 #include "stm32l4xx_hal_conf.h"
EricLew 0:3eee9435dd17 55 #include "main.h"
EricLew 0:3eee9435dd17 56
EricLew 0:3eee9435dd17 57
EricLew 0:3eee9435dd17 58 Serial pc(SERIAL_TX, SERIAL_RX);
EricLew 0:3eee9435dd17 59 DigitalIn mybutton(PA_0);
EricLew 0:3eee9435dd17 60 DigitalOut myled(LED1);
EricLew 0:3eee9435dd17 61 //SDFileSystem sd(PC_12, PC_11, PC_10, PD_2, "sd");
EricLew 0:3eee9435dd17 62
EricLew 0:3eee9435dd17 63 /**
EricLew 0:3eee9435dd17 64 * @brief Main program
EricLew 0:3eee9435dd17 65 * @param None
EricLew 0:3eee9435dd17 66 * @retval None
EricLew 0:3eee9435dd17 67 */
EricLew 0:3eee9435dd17 68 extern void RECORD(void);
EricLew 0:3eee9435dd17 69 extern void MSE(void);
EricLew 0:3eee9435dd17 70 extern void COMPARE(void);
EricLew 0:3eee9435dd17 71
EricLew 0:3eee9435dd17 72 extern float32_t CONTROLPWR[1024]; //CONTROL 0 PWR
EricLew 0:3eee9435dd17 73 extern float32_t CONTROLPHS[1024]; //CTONROL 0 PHS
EricLew 0:3eee9435dd17 74 extern float32_t CONTROLPWRMSE;//CONTROL PWR MSE
EricLew 0:3eee9435dd17 75 extern float32_t CONTROLPHSMSE;//CONTROL PHS MSE
EricLew 0:3eee9435dd17 76 extern float32_t POWER[1024];
EricLew 0:3eee9435dd17 77 extern float32_t PHS[1024];
EricLew 0:3eee9435dd17 78 extern float32_t PWRMSE;
EricLew 0:3eee9435dd17 79 extern float32_t PHSMSE;
EricLew 0:3eee9435dd17 80
EricLew 0:3eee9435dd17 81 int main(void)
EricLew 0:3eee9435dd17 82 {
EricLew 0:3eee9435dd17 83
EricLew 0:3eee9435dd17 84 pc.printf("\r\n\r\nEntering AudioRecord_demo()...\r\n");
EricLew 0:3eee9435dd17 85 RECORD(); // RECORD CONTROL 0
EricLew 0:3eee9435dd17 86 uint32_t n;
EricLew 0:3eee9435dd17 87 for(n=0;n<1024;n++)
EricLew 0:3eee9435dd17 88 {CONTROLPWR[n]=POWER[n];}
EricLew 0:3eee9435dd17 89 for(n=0;n<1024;n++)
EricLew 0:3eee9435dd17 90 {CONTROLPHS[n]=PHS[n];}
EricLew 0:3eee9435dd17 91 RECORD(); //RECORD CONTROL 1
EricLew 0:3eee9435dd17 92 MSE(); //MSE BETWEEN CONTROLS
EricLew 0:3eee9435dd17 93 CONTROLPWRMSE=PWRMSE;
EricLew 0:3eee9435dd17 94 CONTROLPHSMSE=PHSMSE;
EricLew 0:3eee9435dd17 95 while (1) {
EricLew 0:3eee9435dd17 96 pc.printf("Prepared to begin recording. Click USER button to continue...\r\n");
EricLew 0:3eee9435dd17 97 while (mybutton);
EricLew 0:3eee9435dd17 98 wait(0.2);
EricLew 0:3eee9435dd17 99 if (!mybutton) {
EricLew 0:3eee9435dd17 100 while (!mybutton);
EricLew 0:3eee9435dd17 101 pc.printf("Recording started...\r\n");
EricLew 0:3eee9435dd17 102 myled = 1;
EricLew 0:3eee9435dd17 103 RECORD();
EricLew 0:3eee9435dd17 104 MSE();
EricLew 0:3eee9435dd17 105 COMPARE();
EricLew 0:3eee9435dd17 106 }
EricLew 0:3eee9435dd17 107 }
EricLew 0:3eee9435dd17 108 }
EricLew 0:3eee9435dd17 109
EricLew 0:3eee9435dd17 110
EricLew 0:3eee9435dd17 111 #ifdef USE_FULL_ASSERT
EricLew 0:3eee9435dd17 112
EricLew 0:3eee9435dd17 113 /**
EricLew 0:3eee9435dd17 114 * @brief Reports the name of the source file and the source line number
EricLew 0:3eee9435dd17 115 * where the assert_param error has occurred.
EricLew 0:3eee9435dd17 116 * @param file: pointer to the source file name
EricLew 0:3eee9435dd17 117 * @param line: assert_param error line source number
EricLew 0:3eee9435dd17 118 * @retval None
EricLew 0:3eee9435dd17 119 */
EricLew 0:3eee9435dd17 120 void assert_failed(uint8_t* file, uint32_t line)
EricLew 0:3eee9435dd17 121 {
EricLew 0:3eee9435dd17 122 /* User can add his own implementation to report the file name and line number,
EricLew 0:3eee9435dd17 123 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
EricLew 0:3eee9435dd17 124
EricLew 0:3eee9435dd17 125 /* Infinite loop */
EricLew 0:3eee9435dd17 126 while (1)
EricLew 0:3eee9435dd17 127 {
EricLew 0:3eee9435dd17 128 }
EricLew 0:3eee9435dd17 129 }
EricLew 0:3eee9435dd17 130 #endif
EricLew 0:3eee9435dd17 131
EricLew 0:3eee9435dd17 132
EricLew 0:3eee9435dd17 133 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
EricLew 0:3eee9435dd17 134