comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Project/STM32F10x_StdPeriph_Examples/PWR/PVD/main.c @ 0:c59513fd84fb

Initial commit of STM32 test code.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 03 Oct 2011 21:19:15 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c59513fd84fb
1 /**
2 ******************************************************************************
3 * @file PWR/PVD/main.c
4 * @author MCD Application Team
5 * @version V3.5.0
6 * @date 08-April-2011
7 * @brief Main program body.
8 ******************************************************************************
9 * @attention
10 *
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 *
18 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
20 */
21
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x.h"
24 #include "stm32_eval.h"
25
26 /** @addtogroup STM32F10x_StdPeriph_Examples
27 * @{
28 */
29
30 /** @addtogroup PWR_PVD
31 * @{
32 */
33
34 /* Private typedef -----------------------------------------------------------*/
35 /* Private define ------------------------------------------------------------*/
36 /* Private macro -------------------------------------------------------------*/
37 /* Private variables ---------------------------------------------------------*/
38 /* Private function prototypes -----------------------------------------------*/
39 void EXTI_Configuration(void);
40 void NVIC_Configuration(void);
41
42 /* Private functions ---------------------------------------------------------*/
43
44 /**
45 * @brief Main program.
46 * @param None
47 * @retval None
48 */
49 int main(void)
50 {
51 /*!< At this stage the microcontroller clock setting is already configured,
52 this is done through SystemInit() function which is called from startup
53 file (startup_stm32f10x_xx.s) before to branch to application main.
54 To reconfigure the default setting of SystemInit() function, refer to
55 system_stm32f10x.c file
56 */
57
58 /* Initialize LEDs and Key Button mounted on STM3210X-EVAL board */
59 STM_EVAL_LEDInit(LED1);
60
61 /* Enable PWR and BKP clock */
62 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
63
64 /* Configure EXTI Line to generate an interrupt on falling edge */
65 EXTI_Configuration();
66
67 /* NVIC configuration */
68 NVIC_Configuration();
69
70 /* Configure the PVD Level to 2.9V */
71 PWR_PVDLevelConfig(PWR_PVDLevel_2V9);
72
73 /* Enable the PVD Output */
74 PWR_PVDCmd(ENABLE);
75
76 while (1)
77 {
78 }
79 }
80
81 /**
82 * @brief Configures EXTI Lines.
83 * @param None
84 * @retval None
85 */
86 void EXTI_Configuration(void)
87 {
88 EXTI_InitTypeDef EXTI_InitStructure;
89
90 /* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and
91 falling edges */
92 EXTI_ClearITPendingBit(EXTI_Line17);
93 EXTI_InitStructure.EXTI_Line = EXTI_Line17;
94 EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
95 EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
96 EXTI_InitStructure.EXTI_LineCmd = ENABLE;
97 EXTI_Init(&EXTI_InitStructure);
98 }
99
100 /**
101 * @brief Configures NVIC and Vector Table base location.
102 * @param None
103 * @retval None
104 */
105 void NVIC_Configuration(void)
106 {
107 NVIC_InitTypeDef NVIC_InitStructure;
108
109 /* Configure one bit for preemption priority */
110 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
111
112 /* Enable the PVD Interrupt */
113 NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
114 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
115 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
116 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
117 NVIC_Init(&NVIC_InitStructure);
118 }
119
120 #ifdef USE_FULL_ASSERT
121
122 /**
123 * @brief Reports the name of the source file and the source line number
124 * where the assert_param error has occurred.
125 * @param file: pointer to the source file name
126 * @param line: assert_param error line source number
127 * @retval None
128 */
129 void assert_failed(uint8_t* file, uint32_t line)
130 {
131 /* User can add his own implementation to report the file name and line number,
132 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
133
134 /* Infinite loop */
135 while (1)
136 {
137 }
138 }
139
140 #endif
141
142 /**
143 * @}
144 */
145
146 /**
147 * @}
148 */
149
150 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/