comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Project/STM32F10x_StdPeriph_Examples/GPIO/IOToggle/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 GPIO/IOToggle/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 GPIO_IOToggle
31 * @{
32 */
33
34 /* Private typedef -----------------------------------------------------------*/
35 /* Private define ------------------------------------------------------------*/
36 /* Private macro -------------------------------------------------------------*/
37 /* Private variables ---------------------------------------------------------*/
38 GPIO_InitTypeDef GPIO_InitStructure;
39
40 /* Private function prototypes -----------------------------------------------*/
41 /* Private functions ---------------------------------------------------------*/
42
43 /**
44 * @brief Main program.
45 * @param None
46 * @retval None
47 */
48 int main(void)
49 {
50 /*!< At this stage the microcontroller clock setting is already configured,
51 this is done through SystemInit() function which is called from startup
52 file (startup_stm32f10x_xx.s) before to branch to application main.
53 To reconfigure the default setting of SystemInit() function, refer to
54 system_stm32f10x.c file
55 */
56
57 /* GPIOD Periph clock enable */
58 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
59
60 /* Configure PD0 and PD2 in output pushpull mode */
61 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_2;
62 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
63 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
64 GPIO_Init(GPIOD, &GPIO_InitStructure);
65
66 /* To achieve GPIO toggling maximum frequency, the following sequence is mandatory.
67 You can monitor PD0 or PD2 on the scope to measure the output signal.
68 If you need to fine tune this frequency, you can add more GPIO set/reset
69 cycles to minimize more the infinite loop timing.
70 This code needs to be compiled with high speed optimization option. */
71 while (1)
72 {
73 /* Set PD0 and PD2 */
74 GPIOD->BSRR = 0x00000005;
75 /* Reset PD0 and PD2 */
76 GPIOD->BRR = 0x00000005;
77
78 /* Set PD0 and PD2 */
79 GPIOD->BSRR = 0x00000005;
80 /* Reset PD0 and PD2 */
81 GPIOD->BRR = 0x00000005;
82
83 /* Set PD0 and PD2 */
84 GPIOD->BSRR = 0x00000005;
85 /* Reset PD0 and PD2 */
86 GPIOD->BRR = 0x00000005;
87
88 /* Set PD0 and PD2 */
89 GPIOD->BSRR = 0x00000005;
90 /* Reset PD0 and PD2 */
91 GPIOD->BRR = 0x00000005;
92
93 /* Set PD0 and PD2 */
94 GPIOD->BSRR = 0x00000005;
95 /* Reset PD0 and PD2 */
96 GPIOD->BRR = 0x00000005;
97
98 /* Set PD0 and PD2 */
99 GPIOD->BSRR = 0x00000005;
100 /* Reset PD0 and PD2 */
101 GPIOD->BRR = 0x00000005;
102
103 /* Set PD0 and PD2 */
104 GPIOD->BSRR = 0x00000005;
105 /* Reset PD0 and PD2 */
106 GPIOD->BRR = 0x00000005;
107
108 /* Set PD0 and PD2 */
109 GPIOD->BSRR = 0x00000005;
110 /* Reset PD0 and PD2 */
111 GPIOD->BRR = 0x00000005;
112
113 /* Set PD0 and PD2 */
114 GPIOD->BSRR = 0x00000005;
115 /* Reset PD0 and PD2 */
116 GPIOD->BRR = 0x00000005;
117
118 /* Set PD0 and PD2 */
119 GPIOD->BSRR = 0x00000005;
120 /* Reset PD0 and PD2 */
121 GPIOD->BRR = 0x00000005;
122 }
123 }
124
125 #ifdef USE_FULL_ASSERT
126
127 /**
128 * @brief Reports the name of the source file and the source line number
129 * where the assert_param error has occurred.
130 * @param file: pointer to the source file name
131 * @param line: assert_param error line source number
132 * @retval None
133 */
134 void assert_failed(uint8_t* file, uint32_t line)
135 {
136 /* User can add his own implementation to report the file name and line number,
137 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
138
139 /* Infinite loop */
140 while (1)
141 {
142 }
143 }
144
145 #endif
146
147 /**
148 * @}
149 */
150
151 /**
152 * @}
153 */
154
155 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/