STM32F0xx Standard Peripherals Firmware Library
|
STM32F0xx_StdPeriph_Examples/NVIC/NVIC_WFI_Mode/main.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file NVIC/NVIC_WFI_Mode/main.c 00004 * @author MCD Application Team 00005 * @version V1.4.0 00006 * @date 24-July-2014 00007 * @brief Main program body 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> 00012 * 00013 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00014 * You may not use this file except in compliance with the License. 00015 * You may obtain a copy of the License at: 00016 * 00017 * http://www.st.com/software_license_agreement_liberty_v2 00018 * 00019 * Unless required by applicable law or agreed to in writing, software 00020 * distributed under the License is distributed on an "AS IS" BASIS, 00021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00022 * See the License for the specific language governing permissions and 00023 * limitations under the License. 00024 * 00025 ****************************************************************************** 00026 */ 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "main.h" 00030 00031 /** @addtogroup STM32F0xx_StdPeriph_Examples 00032 * @{ 00033 */ 00034 00035 /** @addtogroup NVIC_WFI_Mode 00036 * @{ 00037 */ 00038 00039 /* Private typedef -----------------------------------------------------------*/ 00040 /* Private define ------------------------------------------------------------*/ 00041 /* Private macro -------------------------------------------------------------*/ 00042 /* Private variables ---------------------------------------------------------*/ 00043 __IO uint32_t LowPowerMode = 0; 00044 00045 /* Private function prototypes -----------------------------------------------*/ 00046 void Delay(__IO uint32_t nCount); 00047 00048 /* Private functions ---------------------------------------------------------*/ 00049 00050 00051 /** 00052 * @brief Main program. 00053 * @param None 00054 * @retval None 00055 */ 00056 int main(void) 00057 { 00058 /*!< At this stage the microcontroller clock setting is already configured, 00059 this is done through SystemInit() function which is called from startup 00060 file (startup_stm32f0xx.s) before to branch to application main. 00061 To reconfigure the default setting of SystemInit() function, refer to 00062 system_stm32f0xx.c file 00063 */ 00064 /* Initialize Led and KEY Button mounted on STM320518-EVAL */ 00065 STM_EVAL_LEDInit(LED3); 00066 00067 STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI); 00068 00069 while (1) 00070 { 00071 if(LowPowerMode == 1) 00072 { 00073 /* Turn Off LED3 */ 00074 STM_EVAL_LEDOff(LED3); 00075 00076 /* Request to enter WFI mode */ 00077 __WFI(); 00078 LowPowerMode = 0; 00079 } 00080 00081 Delay(0xFFFFF); 00082 STM_EVAL_LEDToggle(LED3); 00083 } 00084 } 00085 00086 /** 00087 * @brief Inserts a delay time. 00088 * @param nCount: specifies the delay time length. 00089 * @retval None 00090 */ 00091 void Delay(__IO uint32_t nCount) 00092 { 00093 for(; nCount != 0; nCount--); 00094 } 00095 00096 #ifdef USE_FULL_ASSERT 00097 00098 /** 00099 * @brief Reports the name of the source file and the source line number 00100 * where the assert_param error has occurred. 00101 * @param file: pointer to the source file name 00102 * @param line: assert_param error line source number 00103 * @retval None 00104 */ 00105 void assert_failed(uint8_t* file, uint32_t line) 00106 { 00107 /* User can add his own implementation to report the file name and line number, 00108 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 00109 00110 /* Infinite loop */ 00111 while (1) 00112 { 00113 } 00114 } 00115 #endif 00116 00117 /** 00118 * @} 00119 */ 00120 00121 /** 00122 * @} 00123 */ 00124 00125 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/