Skip to content

Commit ffe6a9b

Browse files
author
Bogdan Marinescu
committed
Revert "Merge pull request #265 from cfb95/patch-1"
This reverts commit 6b9fca1, reversing changes made to c9167e8.
1 parent 6b9fca1 commit ffe6a9b

File tree

1 file changed

+19
-46
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB

1 file changed

+19
-46
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@
3939
#define EDGE_FALL (2)
4040
#define EDGE_BOTH (3)
4141

42-
#define CHANNEL_NUM (7)
42+
#define CHANNEL_NUM (4)
4343

44-
static uint32_t channel_ids[CHANNEL_NUM] = {0, 0, 0, 0, 0, 0, 0};
45-
static uint32_t channel_gpio[CHANNEL_NUM] = {0, 0, 0, 0, 0, 0, 0};
46-
static uint32_t channel_pin[CHANNEL_NUM] = {0, 0, 0, 0, 0, 0, 0};
44+
static uint32_t channel_ids[CHANNEL_NUM] = {0, 0, 0, 0};
45+
static uint32_t channel_gpio[CHANNEL_NUM] = {0, 0, 0, 0};
46+
static uint32_t channel_pin[CHANNEL_NUM] = {0, 0, 0, 0};
4747

4848
static gpio_irq_handler irq_handler;
4949

5050
static void handle_interrupt_in(uint32_t irq_index) {
5151
// Retrieve the gpio and pin that generate the irq
5252
GPIO_TypeDef *gpio = (GPIO_TypeDef *)(channel_gpio[irq_index]);
5353
uint32_t pin = (uint32_t)(1 << channel_pin[irq_index]);
54-
54+
5555
// Clear interrupt flag
5656
if (EXTI_GetITStatus(pin) != RESET)
5757
{
@@ -70,13 +70,10 @@ static void handle_interrupt_in(uint32_t irq_index) {
7070
}
7171

7272
// The irq_index is passed to the function
73-
static void gpio_irq0(void) {handle_interrupt_in(0);} // EXTI line 0
74-
static void gpio_irq1(void) {handle_interrupt_in(1);} // EXTI line 1
75-
static void gpio_irq2(void) {handle_interrupt_in(2);} // EXTI line 2
76-
static void gpio_irq3(void) {handle_interrupt_in(3);} // EXTI line 3
77-
static void gpio_irq4(void) {handle_interrupt_in(4);} // EXTI line 4
78-
static void gpio_irq5(void) {handle_interrupt_in(5);} // EXTI lines 5 to 9
79-
static void gpio_irq6(void) {handle_interrupt_in(6);} // EXTI lines 10 to 15
73+
static void gpio_irq0(void) {handle_interrupt_in(0);}
74+
static void gpio_irq1(void) {handle_interrupt_in(1);}
75+
static void gpio_irq2(void) {handle_interrupt_in(2);}
76+
static void gpio_irq3(void) {handle_interrupt_in(3);}
8077

8178
extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
8279

@@ -91,53 +88,29 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
9188
uint32_t pin_index = STM_PIN(pin);
9289

9390
// Select irq number and interrupt routine
94-
switch (pin_index) {
95-
case 0:
96-
irq_n = EXTI0_IRQn;
91+
switch (pin) {
92+
case PC_13: // User button
93+
irq_n = EXTI15_10_IRQn;
9794
vector = (uint32_t)&gpio_irq0;
9895
irq_index = 0;
9996
break;
100-
case 1:
101-
irq_n = EXTI1_IRQn;
97+
case PB_3:
98+
irq_n = EXTI3_IRQn;
10299
vector = (uint32_t)&gpio_irq1;
103100
irq_index = 1;
104101
break;
105-
case 2:
106-
irq_n = EXTI2_IRQn;
102+
case PB_4:
103+
irq_n = EXTI4_IRQn;
107104
vector = (uint32_t)&gpio_irq2;
108105
irq_index = 2;
109106
break;
110-
case 3:
111-
irq_n = EXTI3_IRQn;
107+
case PB_5:
108+
irq_n = EXTI9_5_IRQn;
112109
vector = (uint32_t)&gpio_irq3;
113110
irq_index = 3;
114111
break;
115-
case 4:
116-
irq_n = EXTI4_IRQn;
117-
vector = (uint32_t)&gpio_irq4;
118-
irq_index = 4;
119-
break;
120-
case 5:
121-
case 6:
122-
case 7:
123-
case 8:
124-
case 9:
125-
irq_n = EXTI9_5_IRQn;
126-
vector = (uint32_t)&gpio_irq5;
127-
irq_index = 5;
128-
break;
129-
case 10:
130-
case 11:
131-
case 12:
132-
case 13:
133-
case 14:
134-
case 15:
135-
irq_n = EXTI15_10_IRQn;
136-
vector = (uint32_t)&gpio_irq6;
137-
irq_index = 6;
138-
break;
139112
default:
140-
error("InterruptIn error: pin not supported.\n");
113+
error("This pin is not supported with InterruptIn.");
141114
return -1;
142115
}
143116

0 commit comments

Comments
 (0)