for dissembly

Dependencies:   X_NUCLEO_CCA02M1 ST_Events-old mbed

Fork of HelloWorld_CCA02M1 by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

Go to the documentation of this file.
00001 /**
00002  ******************************************************************************
00003  * @file    main.cpp
00004  * @author  Davide Aliprandi, STMicroelectronics
00005  * @version V1.0.0
00006  * @date    October 28th, 2016
00007  * @brief   mbed test application for the STMicroelectronics X-NUCLEO-CCA02M1
00008  *          MEMS Microphones Expansion Board.
00009  ******************************************************************************
00010  * @attention
00011  *
00012  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
00013  *
00014  * Redistribution and use in source and binary forms, with or without modification,
00015  * are permitted provided that the following conditions are met:
00016  *   1. Redistributions of source code must retain the above copyright notice,
00017  *      this list of conditions and the following disclaimer.
00018  *   2. Redistributions in binary form must reproduce the above copyright notice,
00019  *      this list of conditions and the following disclaimer in the documentation
00020  *      and/or other materials provided with the distribution.
00021  *   3. Neither the name of STMicroelectronics nor the names of its contributors
00022  *      may be used to endorse or promote products derived from this software
00023  *      without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00028  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00029  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00031  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00033  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  ******************************************************************************
00037  */
00038 
00039 
00040 /* Includes ------------------------------------------------------------------*/
00041 
00042 /* mbed specific header files. */
00043 #include "mbed.h"
00044 
00045 
00046 #if DEVICE_I2S
00047 
00048 /* Expansion Board specific header files. */
00049 #include "XNucleoCCA02M1.h"
00050 
00051 
00052 /* Variables -----------------------------------------------------------------*/
00053 
00054 /*
00055  * Initialization parameters.
00056  * Note: put a jumper to connect PB_5 and PB_13 on the MORPHO connector when
00057  *       running a mono configuration.
00058  */
00059 XNucleoCCA02M1_init_t init =
00060 {
00061     44100,  /* Default Sampling Frequency [Hz]. */
00062     2       /* Default number of channels. */
00063 };
00064 
00065 
00066 /* Functions -----------------------------------------------------------------*/
00067 
00068 /**
00069  * @brief  Entry point function of mbedOS.
00070  * @param  None
00071  * @retval None
00072  */
00073 int main(void)
00074 {
00075     /*----- Initialization. -----*/
00076 
00077     /* Initializing MEMS Microphones Expansion Board on the I2S1 interface. */
00078     XNucleoCCA02M1 *microphones = new XNucleoCCA02M1(PB_15, PB_13);
00079     if (microphones->init(&init) != COMPONENT_OK)
00080     {
00081         error("Initialization of the MEMS Microphones Expansion Board failed.\r\n");
00082         exit(EXIT_FAILURE);
00083     }
00084 
00085     /* Enabling transmission via USB. */
00086     microphones->enable_usb();
00087 
00088     /* Printing to the console. */
00089     printf("MEMS Microphones Application Example\r\n\n");
00090 
00091 
00092     /*----- Recording. -----*/
00093 
00094     /* Printing to the console. */
00095     printf("--> Recording...\r\n");
00096     microphones->record();
00097 
00098     /* Dispatching forever the I2S queue. */
00099     I2S::i2s_bh_queue.dispatch_forever();
00100 }
00101 
00102 #else // DEVICE_I2S
00103 
00104 int main(void)
00105 {
00106     printf("The target does not support I2S API.\r\n");
00107 }
00108 
00109 #endif // DEVICE_I2S