STM32F10x_StdPeriph_Examples/PWR/PVD/main.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    PWR/PVD/main.c 
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   Main program body.
00008   ******************************************************************************
00009   * @copy
00010   *
00011   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017   *
00018   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00019   */ 
00020 
00021 /* Includes ------------------------------------------------------------------*/
00022 #include "stm32f10x.h"
00023 #include "stm32_eval.h"
00024 
00025 /** @addtogroup STM32F10x_StdPeriph_Examples
00026   * @{
00027   */
00028 
00029 /** @addtogroup PWR_PVD
00030   * @{
00031   */ 
00032 
00033 /* Private typedef -----------------------------------------------------------*/
00034 /* Private define ------------------------------------------------------------*/
00035 /* Private macro -------------------------------------------------------------*/
00036 /* Private variables ---------------------------------------------------------*/
00037 /* Private function prototypes -----------------------------------------------*/
00038 void EXTI_Configuration(void);
00039 void NVIC_Configuration(void);
00040 
00041 /* Private functions ---------------------------------------------------------*/
00042 
00043 /**
00044   * @brief   Main program.
00045   * @param  None
00046   * @retval None
00047   */
00048 int main(void)
00049 {
00050   /*!< At this stage the microcontroller clock setting is already configured, 
00051        this is done through SystemInit() function which is called from startup
00052        file (startup_stm32f10x_xx.s) before to branch to application main.
00053        To reconfigure the default setting of SystemInit() function, refer to
00054        system_stm32f10x.c file
00055      */     
00056 
00057   /* Initialize LEDs and Key Button mounted on STM3210X-EVAL board */
00058   STM_EVAL_LEDInit(LED1);
00059 
00060   /* Enable PWR and BKP clock */
00061   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
00062 
00063   /* Configure EXTI Line to generate an interrupt on falling edge */
00064   EXTI_Configuration();
00065 
00066   /* NVIC configuration */
00067   NVIC_Configuration();
00068  
00069   /* Configure the PVD Level to 2.9V */
00070   PWR_PVDLevelConfig(PWR_PVDLevel_2V9);
00071 
00072   /* Enable the PVD Output */
00073   PWR_PVDCmd(ENABLE);
00074   
00075   while (1)
00076   {
00077   }
00078 }
00079 
00080 /**
00081   * @brief  Configures EXTI Lines.
00082   * @param  None
00083   * @retval None
00084   */
00085 void EXTI_Configuration(void)
00086 {
00087   EXTI_InitTypeDef EXTI_InitStructure;
00088 
00089   /* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and
00090      falling edges */
00091   EXTI_ClearITPendingBit(EXTI_Line17);
00092   EXTI_InitStructure.EXTI_Line = EXTI_Line17;
00093   EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
00094   EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
00095   EXTI_InitStructure.EXTI_LineCmd = ENABLE;
00096   EXTI_Init(&EXTI_InitStructure);
00097 }
00098 
00099 /**
00100   * @brief  Configures NVIC and Vector Table base location.
00101   * @param  None
00102   * @retval None
00103   */
00104 void NVIC_Configuration(void)
00105 {
00106   NVIC_InitTypeDef NVIC_InitStructure;
00107   
00108   /* Configure one bit for preemption priority */
00109   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
00110   
00111   /* Enable the PVD Interrupt */
00112   NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
00113   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
00114   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
00115   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
00116   NVIC_Init(&NVIC_InitStructure);
00117 }
00118 
00119 #ifdef  USE_FULL_ASSERT
00120 /**
00121   * @brief  Reports the name of the source file and the source line number
00122   *         where the assert_param error has occurred.
00123   * @param  file: pointer to the source file name
00124   * @param  line: assert_param error line source number
00125   * @retval None
00126   */
00127 void assert_failed(uint8_t* file, uint32_t line)
00128 { 
00129   /* User can add his own implementation to report the file name and line number,
00130      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00131 
00132   /* Infinite loop */
00133   while (1)
00134   {
00135   }
00136 }
00137 #endif
00138 
00139 /**
00140   * @}
00141   */
00142 
00143 /**
00144   * @}
00145   */
00146 
00147 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32