2 ******************************************************************************
3 * @file IO_Toggle/main.c
4 * @author MCD Application Team
6 * @date 19-September-2011
7 * @brief Main program body
8 ******************************************************************************
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.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
21 /* Includes ------------------------------------------------------------------*/
22 #include "stm32f4_discovery.h"
23 #include "stm32f4xx_conf.h"
25 /** @addtogroup STM32F4_Discovery_Peripheral_Examples
29 /** @addtogroup IO_Toggle
33 /* Private typedef -----------------------------------------------------------*/
34 GPIO_InitTypeDef GPIO_InitStructure;
36 /* Private define ------------------------------------------------------------*/
37 /* Private macro -------------------------------------------------------------*/
38 /* Private variables ---------------------------------------------------------*/
39 /* Private function prototypes -----------------------------------------------*/
40 void Delay(__IO uint32_t nCount);
41 /* Private functions ---------------------------------------------------------*/
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_stm32f4xx.s) before to branch to application main.
53 To reconfigure the default setting of SystemInit() function, refer to
54 system_stm32f4xx.c file
57 /* GPIOD Periph clock enable */
58 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
60 /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
61 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
62 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
63 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
64 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
65 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
66 GPIO_Init(GPIOD, &GPIO_InitStructure);
70 /* PD12 to be toggled */
71 GPIO_SetBits(GPIOD, GPIO_Pin_12);
76 /* PD13 to be toggled */
77 GPIO_SetBits(GPIOD, GPIO_Pin_13);
82 /* PD14 to be toggled */
83 GPIO_SetBits(GPIOD, GPIO_Pin_14);
88 /* PD15 to be toggled */
89 GPIO_SetBits(GPIOD, GPIO_Pin_15);
94 GPIO_ResetBits(GPIOD, GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
102 * @brief Delay Function.
103 * @param nCount:specifies the Delay time length.
106 void Delay(__IO uint32_t nCount)
113 #ifdef USE_FULL_ASSERT
116 * @brief Reports the name of the source file and the source line number
117 * where the assert_param error has occurred.
118 * @param file: pointer to the source file name
119 * @param line: assert_param error line source number
122 void assert_failed(uint8_t* file, uint32_t line)
124 /* User can add his own implementation to report the file name and line number,
125 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
142 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/