/**
  @page NVIC_IRQMask  NVIC IRQ Mask example
  
  @verbatim
  ******************** (C) COPYRIGHT 2015 STMicroelectronics *******************
  * @file    NVIC/NVIC_IRQMask/readme.txt 
  * @author  MCD Application Team
  * @version V1.1.3
  * @date    15-December-2021
  * @brief   Description of the NVIC IRQ Mask example.
  ******************************************************************************
  *
  * Copyright (c) 2015 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
   @endverbatim

@par  Example Description 

This example demonstrates the use of the Nested Vectored Interrupt Controller (NVIC)
IRQ Channels configuration and how to mask/activate different IRQs: 

- Configuration of 3 TIM (TIM2..TIM4) timers to generate an interrupt on each 
  counter update event.

- The three timers are linked to their correspondent Update IRQ channel.

- Assignment of a ascendant IRQ priority for each IRQ channel :
     - TIM2 has a preemption priority of 0
     - TIM3 has a preemption priority of 1
     - TIM4 has a preemption priority of 2
- In each interrupt routine: 
   - TIM2 toggles a LED1 each 1s 
   - TIM3 toggles a LED2 each 2s 
   - TIM4 toggles a LED3 each 3s 

- The KEY and SEL buttons are used to boost the execution priority as follows:

  - The KEY button is used in GPIO mode and at each KEY button press, the execution 
    priority is raised to 0 and turn LED4 ON. This prevents all exceptions with 
    configurable priority from activating, other than through the HardFault fault 
    escalation mechanism. As consequence, all LEDs stop toggling as TIM2, TIM3 
    and TIM4 IRQs are prevented from activation. 
    
    Pressing again the KEY button will release the priority boosting, turn LED4 
    OFF and will allow all exceptions with configurable priority to be activated 
    and TIM2, TIM3 and TIM4 can be generated again and the LEDs restart toggling.
    
    This execution priority is made using the CMSIS functions "__disable_irq()" 
    and "__enable_irq()". 
    These two functions are managing the Cortex-M4 PRIMASK special register.

  - The SEL button is used in EXTI mode and at each SEL button press, the
    execution priority is masked to 0x40 using the BASEPRI register. 
    A non-zero value will act as a priority mask, affecting the execution priority 
    when the priority defined by BASEPRI is the same or higher than the current 
    executing priority. 
    As consequence, LED2 and LED3 stop toggling as TIM3 and TIM4 IRQs are 
    prevented from activation. 
    Pressing again the SEL button will configure the BASEPRI register to 0, 
    thus it has no effect on the current priority and TIM3 and TIM4 can be 
    generated again and LED2 and LED3 restart toggling.
    
    This execution priority is made using the CMSIS functions "__set_BASEPRI()". 
    This function is managing the Cortex-M4 BASEPRI special register.
    Setting the BASEPRI register has no effect when the execution priority is
    raised to 0 using the "__disable_irq()" function.

@note These mechanisms only affect the group priority. They have no effect on 
      the sub-priority. The sub-priority is only used to sort pending exception 
      priorities, and does not affect active exceptions.


@par Directory contents 

  - NVIC/NVIC_IRQMask/stm32f30x_conf.h     Library Configuration file
  - NVIC/NVIC_IRQMask/stm32f30x_it.c       Interrupt handlers  
  - NVIC/NVIC_IRQMask/stm32f30x_it.h       Interrupt handlers header file
  - NVIC/NVIC_IRQMask/main.c               Main program
  - NVIC/NVIC_IRQMask/main.h               header file Main program
  - NVIC/NVIC_IRQMask/system_stm32f30x.c   STM32F30x system source file
  
@note The "system_stm32f30x.c" is generated by an automatic clock configuration 
      system and can be easily customized to your own configuration. 
      To select different clock setup, use the "STM32F30x_Clock_Configuration_V1.0.0.xls" 
      provided with the AN4152 package available on <a href="http://www.st.com/internet/mcu/family/141.jsp">  ST Microcontrollers </a>
         
@par Hardware and Software environment

  - This example runs on STM32F303xC and STM32F303xE Devices.
  
  - This example has been tested with STMicroelectronics STM32303C-EVAL (STM32F30x)
    evaluation board and can be easily tailored to any other supported device 
    and development board.

  - STM32303C-EVAL Set-up
    - Use LED1, LED2, LED3 and LED4
    - Use the KEY and SEL push-button
    
    
In order to make the program work, you must do the following :
 - Copy all source files from this example folder to the template folder under
   Projects\STM32F30x_StdPeriph_Templates
 - Open your preferred toolchain
 - Add the following files to the project source list
   - Utilities\STM32_EVAL\STM32303C_EVAL\stm32303c_eval.c 
 - Rebuild all files and load your image into target memory
 - Run the example


 */
