/**
******************************************************************************
* @file External LED
* @author Lee Dyche – Tecsploit.com
* @version V1.0.0
* @date 11/11/2012
* @brief External LED Blinks on and off, along with board leds that blink in a cirle.
* Based on the hello world example with a few more lines of code!
******************************************************************************
* @attention
* This is program is provided as is with no warranty!!
******************************************************************************
*/
/* Includes ——————————————————————*/
#include “stm32f4_discovery.h”
/* Private typedef ———————————————————–*/
GPIO_InitTypeDef GPIO_InitStructure;
/* Private define ————————————————————*/
/* Private macro ————————————————————-*/
/* Private variables ———————————————————*/
/* Private function prototypes ———————————————–*/
void Delay(__IO uint32_t nCount);
/* Private functions ———————————————————*/
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f4xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f4xx.c file
*/
/* GPIOD Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure PD12, PD13, PD14,PD15 and PD5 in output pushpull mode */
/* Note that PD12,13,14 and 15 relate to the on board LEDs, pin PD5 maps to the Pin labelled PD5 on the
* STM board, and this is referrenced in the code below using GPIO_Pin_5 (refering to pin 5). When we actually
* toggle the pin using GPIO_SetBits is when we specify the D part using GPIOD ie GPIO_SetBits(GPIOD, GPIO_Pin_5);
**/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
while (1)
{
/* PD5 to be toggled – this is your extenal pin */
GPIO_SetBits(GPIOD, GPIO_Pin_5);
/* Insert delay */
Delay(0x3FFFFF);
/* PD12 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_12);
/* Insert delay */
Delay(0x3FFFFF);
/* PD13 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_13);
/* Insert delay */
Delay(0x3FFFFF);
/* PD14 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_14);
/* Insert delay */
Delay(0x3FFFFF);
/* PD15 to be toggled */
GPIO_SetBits(GPIOD, GPIO_Pin_15);
/* Insert delay */
Delay(0x7FFFFF);
// This line resets the pins, turning off the LED’s and setting the voltage on pin PD55 to 0
GPIO_ResetBits(GPIOD, GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15 | GPIO_Pin_5);
/* Insert delay */
Delay(0xFFFFFF);
}
}
/**
* @brief Delay Function.
* @param nCount:specifies the Delay time length.
* @retval None
*/
void Delay(__IO uint32_t nCount)
{
while(nCount—)
{
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(“Wrong parameters value: file %s on line %d\r\n”, file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/