EasyManuals Logo

ST STM32F31xx User Manual

ST STM32F31xx
584 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #43 background imageLoading...
Page #43 background image
UM1581
How to use and customize the library
DocID023800 Rev 1
43/584
2.6.4 main.c
The main.c file calls the library driver functions to configure the EXTI, GPIO and NIVC
peripherals.
Include the library and STM32303C-EVAL-EVAL board resources:
/* Includes -----------------------------------------------------*/
#include "stm32f30x.h" /* The Library entry point */
#include "stm32303C_eval" /* Needed when using STM32303C-EVAL
board*/
Declare three structure variables, used to initialize the EXTI, GPIO and NIVC peripherals:
/* Private typedef ----------------------------------------------*/
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
Declare prototype for a local function:
/* Private function prototypes ----------------------------------*/
void Delay(__IO uint32_t nCount);
The main program will be structured as follow:
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
1. System clock configuration:
/*!< At this stage the microcontroller clock setting is already
configured,
this is done through SystemInit() function which is called from
startup
file (startup_stm32f30x.s) before to branch to application
main.
To reconfigure the default setting of SystemInit() function,
refer to
system_stm32f30x.c file */
2. Enable the clock for the peripheral(s) to be used (EXTI interface clock is always
enabled):
/* Enable GPIOA's AHB interface clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
/* Enable SYSCFG's APB interface clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
3. Configure the peripheral GPIOs:
/* Connect EXTI6 Line to PE6 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource6);
/* Configure PE6 pin in input mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32F31xx and is the answer not in the manual?

ST STM32F31xx Specifications

General IconGeneral
BrandST
ModelSTM32F31xx
CategoryMicrocontrollers
LanguageEnglish

Related product manuals