interrupt test EXTI stm32 nucleo

Dependencies:   mbed

Committer:
c128
Date:
Sun Oct 25 10:32:26 2015 +0000
Revision:
0:c5e2a50f0d5d
Child:
1:d049e15030ca
EXIT interrupt test stm32 nucleo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
c128 0:c5e2a50f0d5d 1
c128 0:c5e2a50f0d5d 2 #include "mbed.h"
c128 0:c5e2a50f0d5d 3 #include "stm32f4xx.h"
c128 0:c5e2a50f0d5d 4 #include "stm32f4xx_hal_tim_ex.h"
c128 0:c5e2a50f0d5d 5 #include "stm32f4xx_hal_conf.h"
c128 0:c5e2a50f0d5d 6
c128 0:c5e2a50f0d5d 7
c128 0:c5e2a50f0d5d 8
c128 0:c5e2a50f0d5d 9 int16_t count1 = 10;
c128 0:c5e2a50f0d5d 10
c128 0:c5e2a50f0d5d 11
c128 0:c5e2a50f0d5d 12 void EXTI0_IRQHandler(void)
c128 0:c5e2a50f0d5d 13 {
c128 0:c5e2a50f0d5d 14 HAL_NVIC_ClearPendingIRQ(EXTI0_IRQn);
c128 0:c5e2a50f0d5d 15 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
c128 0:c5e2a50f0d5d 16 }
c128 0:c5e2a50f0d5d 17
c128 0:c5e2a50f0d5d 18 void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
c128 0:c5e2a50f0d5d 19 {
c128 0:c5e2a50f0d5d 20 if (GPIO_Pin == GPIO_PIN_0) {
c128 0:c5e2a50f0d5d 21 count1 = 0;
c128 0:c5e2a50f0d5d 22 }
c128 0:c5e2a50f0d5d 23 }
c128 0:c5e2a50f0d5d 24
c128 0:c5e2a50f0d5d 25 int main()
c128 0:c5e2a50f0d5d 26 {
c128 0:c5e2a50f0d5d 27 HAL_Init();
c128 0:c5e2a50f0d5d 28
c128 0:c5e2a50f0d5d 29 GPIO_InitTypeDef GPIO_InitStruct;
c128 0:c5e2a50f0d5d 30 __GPIOA_CLK_ENABLE();
c128 0:c5e2a50f0d5d 31 GPIO_InitStruct.Pin = GPIO_PIN_0; //PA0 as interrupt test
c128 0:c5e2a50f0d5d 32 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
c128 0:c5e2a50f0d5d 33 GPIO_InitStruct.Pull = GPIO_PULLDOWN;
c128 0:c5e2a50f0d5d 34 GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
c128 0:c5e2a50f0d5d 35 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
c128 0:c5e2a50f0d5d 36 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
c128 0:c5e2a50f0d5d 37 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 1);
c128 0:c5e2a50f0d5d 38 HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 1);
c128 0:c5e2a50f0d5d 39 HAL_NVIC_EnableIRQ(EXTI0_IRQn);
c128 0:c5e2a50f0d5d 40
c128 0:c5e2a50f0d5d 41
c128 0:c5e2a50f0d5d 42 while (1) {
c128 0:c5e2a50f0d5d 43
c128 0:c5e2a50f0d5d 44 printf("loop%d\r\n", count1);
c128 0:c5e2a50f0d5d 45 wait(1);
c128 0:c5e2a50f0d5d 46
c128 0:c5e2a50f0d5d 47
c128 0:c5e2a50f0d5d 48 }
c128 0:c5e2a50f0d5d 49
c128 0:c5e2a50f0d5d 50 }