/********************** (C) COPYRIGHT 1393 XXXXXXXXXXXXXXXXXXX *****************
* File Name : main.c
* Author : ------ ----
* Date First Issued : 92/09/09 : Version 1.0
* Description : Main program body
********************************************************************************
* History:
* Ver Who Date Changes
* ------ -------- -------- --------------------------------------------------
* 1.0 -.------ 92/09/09 First release
********************************************************************************
* A very simple example that blinks the on-board LED.
*******************************************************************************/
/*---------------------------- Include Files ---------------------------------*/
#include "STM32F4xx.h" /* STM32F4xx.h definitions */
/*--------------------------- Type Definitions -------------------------------*/
/*------------------------- Constant Definitions -----------------------------*/
/*---------------- Macros (Inline Functions) Definitions ---------------------*/
/*------------------------- Variable Definitions -----------------------------*/
/*------------------------- Function Prototypes ------------------------------*/
static void Delay(u32 nCount);
/*--------------------------- Private Functions ------------------------------*/
/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main()
{
/* Setup System --------------------------------------------------------------*/
/* xxxx Configuration --------------------------------------------------------*/
RCC->AHB1ENR |= (1UL << 3); /* Enable GPIOD clock */
GPIOD->MODER &= ~(3UL << 2*12); /* PD.12 is output */
GPIOD->MODER |= (1UL << 2*12);
GPIOD->OTYPER &= ~(1UL << 12); /* PD.12 is output Push-Pull */
GPIOD->OSPEEDR &= ~(3UL << 2*12); /* PD.12 is 50MHz Fast Speed */
GPIOD->OSPEEDR |= (2UL << 2*12);
GPIOD->PUPDR &= ~(3UL << 2*12); /* PD.12 is Pull-down */
GPIOD->PUPDR |= (1UL << 2*12);
/* ---------------------------------------------------------------------------*/
while(1)
{
GPIOD->BSRRL = (1UL << 12);
// GPIOD -> ODR = (1UL << 12);
Delay(1000000);
GPIOD->BSRRH = (1UL << 12); /* PB.12 clear */
// GPIOD -> ODR = (0UL << 12);
Delay(1000000);
}
}
/*******************************************************************************
* Function Name : Delay
* Description : Inserts a delay time.
* Input : nCount: specifies the delay time length.
* Output : None
* Return : None
*******************************************************************************/
static void Delay(u32 nCount)
{
u32 j = 0;
for(j = nCount; j != 0; j--);
}
/******************* (C) COPYRIGHT 1393 XXXXXXXXXXXXXXXXXXX ****END OF FILE****/