/**
  @page PWR_CurrentConsumption PWR Current Consumption example
  
  @verbatim
  ******************** (C) COPYRIGHT 2014 STMicroelectronics *******************
  * @file    PWR_CurrentConsumption/readme.txt 
  * @author  MCD Application Team
  * @version V1.2.0
  * @date    11-April-2014
  * @brief   Description of the PWR Current Consumption example.
  ******************************************************************************
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
   @endverbatim

@par Example Description 

This example shows how to configure the STM32L1xx system to measure different
Ultra Low Power modes current consumption. The Ultra Low Power modes are:
  - Low Power Run Mode from Internal SRAM
  - Low Power Run Mode from Internal FLASH
  - Sleep Mode
  - STOP mode with RTC
  - STANDBY mode with RTC

To run this example, user has to follow the following steps:
 1. Select the Ultra Low power modes to be measured by uncommenting the corresponding
    line inside the stm32l1xx_ulp_modes.h file.
       #define LP_RUN_SRAM_MODE
       #define LP_RUN_FLASH_MODE
       #define SLEEP_MODE
       #define STOP_RTC_LSI_MODE
       #define STANDBY_RTC_LSI_MODE  
  
 2. Use an external amperemeter to measure the IDD current. 
 
 3. This example can not be used in DEBUG mode as the JTAG IOs are disabled to
    reduce power consumption.
    
Here below a detailed description of the example code:

  @verbatim
 1. First, the  code checks if the BOR is disabled or not. If the BOR is ON, the 
    code writes to Option Bytes and launch and Option byte loading phase generating
    a system reset.

 2. After reset, the program waits for Key button connected to the PC.13 to be 
    pressed to enter the selected ultra low power mode.
     - In SLEEP_MODE : initially LED2 is Off, system is in sleep mode, to exit
       press again the USER button (LED2 will toggle in infinity loop).
     - In STOP_MODE : initially LED2 is Off, system is in low power mode,
       the wakeup is automatically generated by the RTC (after ~4s)
       then LED2 will toggle in infinity loop.
     - In STANDBY_RTC_MODE: The wakeup is automatically generated by the RTC (after ~4s)
     
 
 3. Low power modes description:

    - Low Power Run mode:
    ===================== 
      The maximum clock when the system is in Low Power Run mode is ~128KHz.
      This mode can only be entered when Voltage Range 2 is selected. 
        Low Power Run Mode from SRAM:
        -----------------------------
            - System Running at MSI (~32KHz)
            - Flash 0 wait state
            - Voltage Range 2
            - Regulator in LP mode
            - Code running from Internal SRAM
            - All peripherals OFF
            - FLASH switched OFF
            - VDD from 1.65V to 3.6V
            - Wakeup using User button PC.13
            
        Low Power Run Mode from FLASH:
        ------------------------------
            - System Running at MSI (~32KHz)
            - Flash 0 wait state
            - Voltage Range 2
            - Regulator in LP mode
            - Code running from Internal FLASH
            - All peripherals OFF
            - VDD from 1.65V to 3.6V 
            - Wakeup using User button PC.13
                        
    - Sleep Mode
    ============  
             - System Running at HSI (16MHz)
             - Flash 1 wait state
             - Voltage Range 2
             - Code running from Internal FLASH
             - Wakeup using EXTI Line (User button PC.13)
                         
    - STOP Mode with RTC clocked by LSI
    ===================================  
            - RTC Clocked by LSI
            - Regulator in LP mode
            - VREFINT OFF
            - HSI and HSE OFF
            - No IWDG
            - Automatic Wakeup using RTC on LSI (after ~4s)
            
    - STANDBY Mode with RTC clocked by LSI
    ======================================   
            - RTC Clocked by LSI
            - IWDG OFF
            - VREFINT OFF            
            - Automatic Wakeup using RTC on LSI (after ~4s)                                   
                         
  4. After reset the system clock frequency is configured to MSI Range 1 (~131KHz)
     and Voltage range 2 and then according to each low power mode the system
     frequency is reconfigured again.

   @endverbatim

@par Directory contents 

  - stm32l1xx_conf.h              Library Configuration file
  - stm32l1xx_it.c                Interrupt handlers
  - stm32l1xx_it.h                Interrupt handlers header file
  - main.c                        Main program
  - system_stm32l1xx.c            STM32L1xx system source file
  - stm32l1xx_lp_modes.c          STM32L1xx Ultra Low Power Modes source file
  - stm32l1xx_lp_modes.h          STM32L1xx Ultra Low Power Modes header file
  - stm32l1xx_lowpowerrun_sram.c  STM32L1xx Low Power Run Mode from Internal SRAM source file  
           
@par Hardware and Software environment

  - This example runs on STM32L152xx Devices.
  
  - This example has been tested with STMicroelectronics STM32NUCLEO kit(MB1136) Rev C
    and can be easily tailored to any other supported device and development board.

  - STM32NUCLEO Set-up
    - Use LED2 connected  to PA.05 pin.
    - Use User button connected to PC.13 pin.
    - Connect an amperemeter to JP6 to measure the IDD current
      
@par How to use it ? 

In order to make the program work, you must do the following :

 + EWARM
    - Open the PWR_CurrentConsumption.eww workspace 
    - Rebuild all files: Project->Rebuild all
    - Load project image: Project->Debug
    - Run program: Debug->Go(F5)

 + MDK-ARM
    - Open the PWR_CurrentConsumption.uvproj project
    - Rebuild all files: Project->Rebuild all target files
    - Load project image: Debug->Start/Stop Debug Session
    - Run program: Debug->Run (F5) 

 + TrueSTUDIO:
    - Open the TrueSTUDIO toolchain.
    - Click on File->Switch Workspace->Other and browse to TrueSTUDIO workspace directory.
    - Click on File->Import, select General->'Existing Projects into Workspace' and then click "Next". 
    - Browse to the TrueSTUDIO workspace directory, select the project PWR_CurrentConsumption.
    - Rebuild all project files: Select the project in the "Project explorer" 
      window then click on Project->build project menu.
    - Run program: Run->Debug (F11) 
            
 * <h3><center>&copy; COPYRIGHT STMicroelectronics</center></h3>
 */


