STM32F0xx Standard Peripherals Firmware Library: main.c Source File

STM32F0xx Standard Peripherals Library

STM32F0xx_StdPeriph_Examples/PWR/PWR_CurrentConsumption/main.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    PWR/PWR_CurrentConsumption/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>&copy; 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 PWR_CurrentConsumption
00036   * @{
00037   */
00038 
00039 /* Private typedef -----------------------------------------------------------*/
00040 /* Private define ------------------------------------------------------------*/
00041 /* Private macro -------------------------------------------------------------*/
00042 /* Private variables ---------------------------------------------------------*/
00043 __IO uint32_t i = 0;
00044 
00045 /* Private function prototypes -----------------------------------------------*/
00046 /* Private functions ---------------------------------------------------------*/
00047 
00048 /**
00049   * @brief  Main program.
00050   * @param  None
00051   * @retval None
00052   */
00053 int main(void)
00054 {
00055   /*!< At this stage the microcontroller clock setting is already configured, 
00056        this is done through SystemInit() function which is called from startup
00057        file (startup_stm32f0xx.s) before to branch to application main.
00058        To reconfigure the default setting of SystemInit() function, refer to
00059        system_stm32f0xx.c file
00060      */ 
00061   /* Configure Tamper Button */
00062   STM_EVAL_PBInit(BUTTON_TAMPER,BUTTON_MODE_GPIO);
00063     
00064   /* Loop while Tamper button is maintained pressed */
00065   while(STM_EVAL_PBGetState(BUTTON_TAMPER) == RESET)
00066   {
00067   }
00068     
00069   /* Enable PWR APB1 Clock */
00070   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
00071     
00072   /* Allow access to Backup */
00073   PWR_BackupAccessCmd(ENABLE);
00074     
00075   /* Reset RTC Domain */
00076   RCC_BackupResetCmd(ENABLE);
00077   RCC_BackupResetCmd(DISABLE);
00078   /* Loop while Tamper button is maintained pressed */
00079   while(STM_EVAL_PBGetState(BUTTON_TAMPER) != RESET)
00080   {
00081   } 
00082   /* Loop while Tamper button is maintained pressed */
00083   while(STM_EVAL_PBGetState(BUTTON_TAMPER) == RESET)
00084   {
00085   }
00086   
00087 #if defined (SLEEP_MODE)
00088   /* Sleep Mode Entry 
00089       - System Running at PLL (48MHz)
00090       - Flash 3 wait state
00091       - Prefetch and Cache enabled
00092       - Code running from Internal FLASH
00093       - All peripherals disabled.
00094       - Wakeup using EXTI Line (Joystick SEL Button PA.00)
00095    */  
00096   SleepMode_Measure();
00097 #elif defined (STOP_MODE)
00098   /* STOP Mode Entry 
00099       - RTC Clocked by LSI
00100       - Regulator in LP mode
00101       - HSI, HSE OFF and LSI OFF if not used as RTC Clock source  
00102       - No IWDG
00103       - FLASH in deep power down mode
00104       - Automatic Wakeup using RTC clocked by LSI 
00105    */
00106   StopMode_Measure();
00107 #elif defined (STANDBY_MODE)
00108   /* STANDBY Mode Entry 
00109       - RTC OFF
00110       - IWDG and LSI OFF
00111       - Wakeup using WakeUp Pin 2(PC.13)
00112    */
00113   StandbyMode_Measure();
00114 #elif defined (STANDBY_RTC_MODE)
00115   /* STANDBY Mode with RTC on LSI Entry 
00116       - RTC Clocked by LSI
00117       - IWDG OFF and LSI OFF if not used as RTC Clock source
00118       - Automatic Wakeup using RTC clocked by LSI 
00119    */
00120 
00121   StandbyRTCMode_Measure();
00122 #else
00123 
00124   /* Initialize LED3 on EVAL board */
00125   STM_EVAL_LEDInit(LED3);
00126   
00127   /* Infinite loop */
00128   while (1)
00129   {
00130     /* Toggle The LED3 */
00131     STM_EVAL_LEDToggle(LED3);
00132 
00133     /* Inserted Delay */
00134     for(i = 0; i < 0x7FFF; i++);
00135   }
00136 #endif
00137 }
00138 
00139 #ifdef  USE_FULL_ASSERT
00140 
00141 /**
00142   * @brief  Reports the name of the source file and the source line number
00143   *         where the assert_param error has occurred.
00144   * @param  file: pointer to the source file name
00145   * @param  line: assert_param error line source number
00146   * @retval None
00147   */
00148 void assert_failed(uint8_t* file, uint32_t line)
00149 { 
00150   /* User can add his own implementation to report the file name and line number,
00151      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00152 
00153   /* Infinite loop */
00154   while (1)
00155   {
00156   }
00157 }
00158 #endif
00159 
00160 /**
00161   * @}
00162   */
00163 
00164 /**
00165   * @}
00166   */
00167 
00168 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM32L1xx Standard Peripherals Library: Footer

 

 

 For complete documentation on STM32 Microcontrollers visit www.st.com/STM32