How to use and customize the library
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOE, &GPIO_InitStructure);
4. Configure the peripheral in the desired mode:
/* Configure EXTI line 6 */
EXTI_InitStructure.EXTI_Line = EXTI_Line6;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable and set EXTI line 6 nterrupt to the lowest
priority */
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
5. Insert the code below to use the evaluation board HAL to drive the LEDs:
/* Initialize LED1 and LED2 mounted on STM32303C-EVAL board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
while (1)
{
/* Toggle LD1 */
STM_EVAL_LEDToggle(LED1);
/* Insert some delay */
Delay(0xFFFFF);
}
}
/**
* @brief Inserts a delay time.
* @param nCount: specifies the delay time length.
* @retval None
*/
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
2.6.5 stm32f30x_it.c
The stm32f30x_it.c file can be used to implement the EXTI Line2 interrupt service routine
(ISR) in which LED2 toggles each time the ISR is executed.
1. In “STM32F30xx Peripherals Interrupt Handlers“ section, add the following code:
/**************************************************************
***/
/* STM32F30xx Peripherals Interrupt Handlers
*/
/* Add here the Interrupt Handler for the used peripheral(s)
(PPP), */
/* for the available peripheral interrupt handler's name
please */
/* refer to the startup file (startup_stm32f30x.s).
*/