AudioRecord and FFT/MSE comparison. Call AudioRecord_demo for control record and AudioSample for subsequent recordings.
Dependencies: CMSIS_DSP_401 STM32L4xx_HAL_Driver
Fork of OneHopeOnePrayer by
main.h@5:f6afbd3fc47a, 2015-12-05 (annotated)
- Committer:
- EricLew
- Date:
- Sat Dec 05 16:17:25 2015 +0000
- Revision:
- 5:f6afbd3fc47a
- Parent:
- 4:652cb54276d0
Ported to Nucleo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 0:d4e5ad7ad71c | 1 | /** |
EricLew | 0:d4e5ad7ad71c | 2 | ****************************************************************************** |
EricLew | 0:d4e5ad7ad71c | 3 | * @file BSP/Inc/main.h |
EricLew | 0:d4e5ad7ad71c | 4 | * @author MCD Application Team |
EricLew | 0:d4e5ad7ad71c | 5 | * @version V1.1.0 |
EricLew | 0:d4e5ad7ad71c | 6 | * @date 16-September-2015 |
EricLew | 0:d4e5ad7ad71c | 7 | * @brief Header for main.c module |
EricLew | 0:d4e5ad7ad71c | 8 | ****************************************************************************** |
EricLew | 0:d4e5ad7ad71c | 9 | * @attention |
EricLew | 0:d4e5ad7ad71c | 10 | * |
EricLew | 0:d4e5ad7ad71c | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
EricLew | 0:d4e5ad7ad71c | 12 | * |
EricLew | 0:d4e5ad7ad71c | 13 | * Redistribution and use in source and binary forms, with or without modification, |
EricLew | 0:d4e5ad7ad71c | 14 | * are permitted provided that the following conditions are met: |
EricLew | 0:d4e5ad7ad71c | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
EricLew | 0:d4e5ad7ad71c | 16 | * this list of conditions and the following disclaimer. |
EricLew | 0:d4e5ad7ad71c | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
EricLew | 0:d4e5ad7ad71c | 18 | * this list of conditions and the following disclaimer in the documentation |
EricLew | 0:d4e5ad7ad71c | 19 | * and/or other materials provided with the distribution. |
EricLew | 0:d4e5ad7ad71c | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
EricLew | 0:d4e5ad7ad71c | 21 | * may be used to endorse or promote products derived from this software |
EricLew | 0:d4e5ad7ad71c | 22 | * without specific prior written permission. |
EricLew | 0:d4e5ad7ad71c | 23 | * |
EricLew | 0:d4e5ad7ad71c | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
EricLew | 0:d4e5ad7ad71c | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
EricLew | 0:d4e5ad7ad71c | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
EricLew | 0:d4e5ad7ad71c | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
EricLew | 0:d4e5ad7ad71c | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
EricLew | 0:d4e5ad7ad71c | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
EricLew | 0:d4e5ad7ad71c | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 0:d4e5ad7ad71c | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
EricLew | 0:d4e5ad7ad71c | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
EricLew | 0:d4e5ad7ad71c | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
EricLew | 0:d4e5ad7ad71c | 34 | * |
EricLew | 0:d4e5ad7ad71c | 35 | ****************************************************************************** |
EricLew | 0:d4e5ad7ad71c | 36 | */ |
EricLew | 0:d4e5ad7ad71c | 37 | |
EricLew | 0:d4e5ad7ad71c | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
EricLew | 0:d4e5ad7ad71c | 39 | #ifndef __MAIN_H |
EricLew | 0:d4e5ad7ad71c | 40 | #define __MAIN_H |
EricLew | 0:d4e5ad7ad71c | 41 | |
EricLew | 0:d4e5ad7ad71c | 42 | /* Includes ------------------------------------------------------------------*/ |
EricLew | 0:d4e5ad7ad71c | 43 | #include "stdio.h" |
EricLew | 0:d4e5ad7ad71c | 44 | #include "string.h" |
EricLew | 0:d4e5ad7ad71c | 45 | #include "stm32l4xx_hal.h" |
EricLew | 5:f6afbd3fc47a | 46 | #include "stm32l4xx_nucleo.h" |
EricLew | 0:d4e5ad7ad71c | 47 | |
EricLew | 4:652cb54276d0 | 48 | #include "arm_math.h" |
EricLew | 4:652cb54276d0 | 49 | #include "arm_const_structs.h" |
EricLew | 4:652cb54276d0 | 50 | #include "math.h" |
EricLew | 4:652cb54276d0 | 51 | #include "core_cm4.h" |
EricLew | 4:652cb54276d0 | 52 | #include "core_cm4_simd.h" |
EricLew | 4:652cb54276d0 | 53 | #include "core_cmFunc.h" |
EricLew | 4:652cb54276d0 | 54 | #include "core_cmInstr.h" |
EricLew | 4:652cb54276d0 | 55 | #include "stdint.h" |
EricLew | 0:d4e5ad7ad71c | 56 | |
EricLew | 5:f6afbd3fc47a | 57 | #include "stm32l4xx_nucleo_audio.h" |
EricLew | 0:d4e5ad7ad71c | 58 | |
EricLew | 0:d4e5ad7ad71c | 59 | /* Exported constants --------------------------------------------------------*/ |
EricLew | 0:d4e5ad7ad71c | 60 | #define DEMO_NAME_CHAR_NB 20 |
EricLew | 0:d4e5ad7ad71c | 61 | |
EricLew | 0:d4e5ad7ad71c | 62 | /* Defines for the Audio playing process */ |
EricLew | 0:d4e5ad7ad71c | 63 | #define PAUSE_STATUS ((uint32_t)0x00) /* Audio Player in Pause Status */ |
EricLew | 0:d4e5ad7ad71c | 64 | #define RESUME_STATUS ((uint32_t)0x01) /* Audio Player in Resume Status */ |
EricLew | 0:d4e5ad7ad71c | 65 | #define IDLE_STATUS ((uint32_t)0x02) /* Audio Player in Idle Status */ |
EricLew | 0:d4e5ad7ad71c | 66 | |
EricLew | 0:d4e5ad7ad71c | 67 | /* Exported types ------------------------------------------------------------*/ |
EricLew | 0:d4e5ad7ad71c | 68 | typedef enum |
EricLew | 0:d4e5ad7ad71c | 69 | { |
EricLew | 0:d4e5ad7ad71c | 70 | IDD_RUN = 0x00, |
EricLew | 0:d4e5ad7ad71c | 71 | IDD_SLEEP = 0x01, |
EricLew | 0:d4e5ad7ad71c | 72 | IDD_LPR_2MHZ = 0x02, |
EricLew | 0:d4e5ad7ad71c | 73 | IDD_LPR_SLEEP = 0x03, |
EricLew | 0:d4e5ad7ad71c | 74 | IDD_STOP2 = 0x04, |
EricLew | 0:d4e5ad7ad71c | 75 | IDD_STANDBY = 0x05, |
EricLew | 0:d4e5ad7ad71c | 76 | IDD_SHUTDOWN = 0x06, |
EricLew | 0:d4e5ad7ad71c | 77 | IDD_TEST_NB = 0x07, |
EricLew | 0:d4e5ad7ad71c | 78 | } Idd_StateTypeDef; |
EricLew | 0:d4e5ad7ad71c | 79 | |
EricLew | 0:d4e5ad7ad71c | 80 | typedef struct |
EricLew | 0:d4e5ad7ad71c | 81 | { |
EricLew | 0:d4e5ad7ad71c | 82 | void (*DemoFunc)(void); |
EricLew | 0:d4e5ad7ad71c | 83 | uint8_t DemoName[DEMO_NAME_CHAR_NB]; |
EricLew | 0:d4e5ad7ad71c | 84 | uint32_t DemoIndex; |
EricLew | 0:d4e5ad7ad71c | 85 | }BSP_DemoTypedef; |
EricLew | 0:d4e5ad7ad71c | 86 | |
EricLew | 0:d4e5ad7ad71c | 87 | typedef enum { |
EricLew | 0:d4e5ad7ad71c | 88 | AUDIO_DEMO_NONE = 0, |
EricLew | 0:d4e5ad7ad71c | 89 | AUDIO_DEMO_PLAYBACK, |
EricLew | 0:d4e5ad7ad71c | 90 | AUDIO_DEMO_RECORD |
EricLew | 0:d4e5ad7ad71c | 91 | } Audio_DemoTypeDef; |
EricLew | 0:d4e5ad7ad71c | 92 | |
EricLew | 0:d4e5ad7ad71c | 93 | /* Exported variables --------------------------------------------------------*/ |
EricLew | 0:d4e5ad7ad71c | 94 | /* Variable indicating which audio demo is currently running (playback v.s. record) */ |
EricLew | 0:d4e5ad7ad71c | 95 | extern Audio_DemoTypeDef AudioDemo; |
EricLew | 0:d4e5ad7ad71c | 96 | |
EricLew | 0:d4e5ad7ad71c | 97 | /* Flag indicating that audio playback must be paused or resumed */ |
EricLew | 0:d4e5ad7ad71c | 98 | extern __IO uint32_t PauseResumeStatus; |
EricLew | 0:d4e5ad7ad71c | 99 | |
EricLew | 0:d4e5ad7ad71c | 100 | /* Flag indicating that audio playback must be exited */ |
EricLew | 0:d4e5ad7ad71c | 101 | extern __IO uint8_t AudioPlaybackExit; |
EricLew | 0:d4e5ad7ad71c | 102 | |
EricLew | 0:d4e5ad7ad71c | 103 | /* Flag indicating that audio playback volume level must be changed */ |
EricLew | 0:d4e5ad7ad71c | 104 | extern __IO uint8_t VolumeChange; |
EricLew | 0:d4e5ad7ad71c | 105 | |
EricLew | 0:d4e5ad7ad71c | 106 | /* Actual audio playback volume level */ |
EricLew | 0:d4e5ad7ad71c | 107 | extern __IO uint8_t Volume; |
EricLew | 0:d4e5ad7ad71c | 108 | |
EricLew | 0:d4e5ad7ad71c | 109 | /* Flag indicating that audio record must be exited */ |
EricLew | 0:d4e5ad7ad71c | 110 | extern __IO uint8_t AudioRecordExit; |
EricLew | 0:d4e5ad7ad71c | 111 | |
EricLew | 0:d4e5ad7ad71c | 112 | /* Flag indicating that record sample rate has been selected */ |
EricLew | 0:d4e5ad7ad71c | 113 | extern __IO uint8_t AudioRecordSampleRateSelected; |
EricLew | 0:d4e5ad7ad71c | 114 | |
EricLew | 0:d4e5ad7ad71c | 115 | /* Flag indicating that record sample rate must be changed changed */ |
EricLew | 0:d4e5ad7ad71c | 116 | extern __IO uint8_t AudioRecordSampleRateChange; |
EricLew | 0:d4e5ad7ad71c | 117 | |
EricLew | 0:d4e5ad7ad71c | 118 | /* Index within SamplesRates[] */ |
EricLew | 0:d4e5ad7ad71c | 119 | extern __IO uint8_t SampleRateIndex; |
EricLew | 0:d4e5ad7ad71c | 120 | |
EricLew | 0:d4e5ad7ad71c | 121 | /* Exported macro ------------------------------------------------------------*/ |
EricLew | 0:d4e5ad7ad71c | 122 | #define COUNT_OF_EXAMPLE(x) (sizeof(x)/sizeof(BSP_DemoTypedef)) |
EricLew | 0:d4e5ad7ad71c | 123 | #define ABS(x) (x < 0) ? (-x) : x |
EricLew | 0:d4e5ad7ad71c | 124 | |
EricLew | 0:d4e5ad7ad71c | 125 | /* Exported functions ------------------------------------------------------- */ |
EricLew | 0:d4e5ad7ad71c | 126 | void AudioPlay_demo(void); |
EricLew | 0:d4e5ad7ad71c | 127 | void AudioRecord_demo(void); |
EricLew | 0:d4e5ad7ad71c | 128 | void Idd_demo(void); |
EricLew | 0:d4e5ad7ad71c | 129 | void Gyro_demo(void); |
EricLew | 0:d4e5ad7ad71c | 130 | void Joystick_demo (void); |
EricLew | 0:d4e5ad7ad71c | 131 | void LCDGlass_demo(void); |
EricLew | 0:d4e5ad7ad71c | 132 | void Led_demo(void); |
EricLew | 0:d4e5ad7ad71c | 133 | void QSPI_demo(void); |
EricLew | 0:d4e5ad7ad71c | 134 | uint8_t CheckForUserInput(void); |
EricLew | 0:d4e5ad7ad71c | 135 | void SystemClock_Config(void); |
EricLew | 0:d4e5ad7ad71c | 136 | void SystemLowClock_Config(void); |
EricLew | 0:d4e5ad7ad71c | 137 | void SystemHardwareInit(void); |
EricLew | 0:d4e5ad7ad71c | 138 | void SystemHardwareDeInit(void); |
EricLew | 0:d4e5ad7ad71c | 139 | uint32_t SystemRtcBackupRead(void); |
EricLew | 0:d4e5ad7ad71c | 140 | void SystemRtcBackupWrite(uint32_t SaveIndex); |
EricLew | 0:d4e5ad7ad71c | 141 | void fibonacci_flash(int n); |
EricLew | 0:d4e5ad7ad71c | 142 | |
EricLew | 0:d4e5ad7ad71c | 143 | void Error_Handler(void); |
EricLew | 0:d4e5ad7ad71c | 144 | void Convert_IntegerIntoChar(uint32_t number, uint16_t *p_tab); |
EricLew | 0:d4e5ad7ad71c | 145 | |
EricLew | 0:d4e5ad7ad71c | 146 | #endif /* __MAIN_H */ |
EricLew | 0:d4e5ad7ad71c | 147 | |
EricLew | 0:d4e5ad7ad71c | 148 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
EricLew | 0:d4e5ad7ad71c | 149 |