soc/stm32f1/gpio: implement MCU specific GPIO input interrupt integration

Add necessary integration for supporting interrupts on GPIO input pins
for STM32F1 line of MCUs.

Change-Id: I0526a85cc3fdb96891c93ba4840ef27d613ab31b
Origin: Original
Signed-off-by: Maciej Borzecki <maciek.borzecki@gmail.com>
This commit is contained in:
Maciek Borzecki 2016-03-15 14:55:00 +01:00 committed by Daniel Kalowsky
parent dd583518ee
commit 7c5cb7b85e

View file

@ -171,3 +171,30 @@ int stm32_gpio_get(uint32_t *base, int pin)
return (gpio->idr >> pin) & 0x1;
}
int stm32_gpio_enable_int(int port, int pin)
{
volatile struct stm32f10x_afio *afio =
(struct stm32f10x_afio *)AFIO_BASE;
volatile union __afio_exticr *exticr;
int shift = 0;
if (pin <= 3) {
exticr = &afio->exticr1;
} else if (pin <= 7) {
exticr = &afio->exticr2;
} else if (pin <= 11) {
exticr = &afio->exticr3;
} else if (pin <= 15) {
exticr = &afio->exticr4;
} else {
return -EINVAL;
}
shift = 4 * (pin % 4);
exticr->val &= ~(0xf << shift);
exticr->val |= port << shift;
return 0;
}