mirror of https://github.com/ARMmbed/mbed-os.git
fix - KL46Z cmsis header (v2.2), shared interrupt PORTCD
- Ports C and D sharing same interrupt vectors - KL46Z CMSIS header update - InterruptIn methods irq_disable/enable comment updatepull/136/head
parent
fba199a9c4
commit
dc19dcbb94
|
@ -108,11 +108,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void mode(PinMode pull);
|
void mode(PinMode pull);
|
||||||
|
|
||||||
/** Enable IRQ
|
/** Enable IRQ. This method depends on hw implementation, might enable one
|
||||||
|
* port interrupts. For further information, check gpio_irq_enable().
|
||||||
*/
|
*/
|
||||||
void enable_irq();
|
void enable_irq();
|
||||||
|
|
||||||
/** Disable IRQ
|
/** Disable IRQ. This method depends on hw implementation, might disable one
|
||||||
|
* port interrupts. For further information, check gpio_irq_disable().
|
||||||
*/
|
*/
|
||||||
void disable_irq();
|
void disable_irq();
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,7 @@
|
||||||
#include "gpio_irq_api.h"
|
#include "gpio_irq_api.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
#define CHANNEL_NUM 64
|
#define CHANNEL_NUM 96
|
||||||
|
|
||||||
static uint32_t channel_ids[CHANNEL_NUM] = {0};
|
static uint32_t channel_ids[CHANNEL_NUM] = {0};
|
||||||
static gpio_irq_handler irq_handler;
|
static gpio_irq_handler irq_handler;
|
||||||
|
@ -37,7 +37,8 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
|
||||||
if (port->ISFR & pmask) {
|
if (port->ISFR & pmask) {
|
||||||
mask |= pmask;
|
mask |= pmask;
|
||||||
uint32_t id = channel_ids[ch_base + i];
|
uint32_t id = channel_ids[ch_base + i];
|
||||||
if (id == 0) continue;
|
if (id == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
FGPIO_Type *gpio;
|
FGPIO_Type *gpio;
|
||||||
gpio_irq_event event = IRQ_NONE;
|
gpio_irq_event event = IRQ_NONE;
|
||||||
|
@ -51,7 +52,13 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRQ_EITHER_EDGE:
|
case IRQ_EITHER_EDGE:
|
||||||
gpio = (port == PORTA) ? (FPTA) : (FPTD);
|
if (port == PORTA) {
|
||||||
|
gpio = FPTA;
|
||||||
|
} else if (port == PORTC) {
|
||||||
|
gpio = FPTC;
|
||||||
|
} else {
|
||||||
|
gpio = FPTD;
|
||||||
|
}
|
||||||
event = (gpio->PDIR & pmask) ? (IRQ_RISE) : (IRQ_FALL);
|
event = (gpio->PDIR & pmask) ? (IRQ_RISE) : (IRQ_FALL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -62,11 +69,19 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
|
||||||
port->ISFR = mask;
|
port->ISFR = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_irqA(void) {handle_interrupt_in(PORTA, 0);}
|
void gpio_irqA(void) {
|
||||||
void gpio_irqD(void) {handle_interrupt_in(PORTD, 32);}
|
handle_interrupt_in(PORTA, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio_irqCD(void) {
|
||||||
|
/* PORTC and PORTD share same vector */
|
||||||
|
handle_interrupt_in(PORTC, 32);
|
||||||
|
handle_interrupt_in(PORTD, 64);
|
||||||
|
}
|
||||||
|
|
||||||
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
|
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
|
||||||
if (pin == NC) return -1;
|
if (pin == NC)
|
||||||
|
return -1;
|
||||||
|
|
||||||
irq_handler = handler;
|
irq_handler = handler;
|
||||||
|
|
||||||
|
@ -80,12 +95,16 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
|
||||||
ch_base = 0; irq_n = PORTA_IRQn; vector = (uint32_t)gpio_irqA;
|
ch_base = 0; irq_n = PORTA_IRQn; vector = (uint32_t)gpio_irqA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PortC:
|
||||||
|
ch_base = 32; irq_n = PORTC_PORTD_IRQn; vector = (uint32_t)gpio_irqCD;
|
||||||
|
break;
|
||||||
|
|
||||||
case PortD:
|
case PortD:
|
||||||
ch_base = 32; irq_n = PORTD_IRQn; vector = (uint32_t)gpio_irqD;
|
ch_base = 64; irq_n = PORTC_PORTD_IRQn; vector = (uint32_t)gpio_irqCD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error("gpio_irq only supported on port A and D\n");
|
error("gpio_irq only supported on port A,C and D\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NVIC_SetVector(irq_n, vector);
|
NVIC_SetVector(irq_n, vector);
|
||||||
|
@ -147,15 +166,15 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) {
|
||||||
void gpio_irq_enable(gpio_irq_t *obj) {
|
void gpio_irq_enable(gpio_irq_t *obj) {
|
||||||
if (obj->port == PortA) {
|
if (obj->port == PortA) {
|
||||||
NVIC_EnableIRQ(PORTA_IRQn);
|
NVIC_EnableIRQ(PORTA_IRQn);
|
||||||
} else if (obj->port == PortD) {
|
} else {
|
||||||
NVIC_EnableIRQ(PORTD_IRQn);
|
NVIC_EnableIRQ(PORTC_PORTD_IRQn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_irq_disable(gpio_irq_t *obj) {
|
void gpio_irq_disable(gpio_irq_t *obj) {
|
||||||
if (obj->port == PortA) {
|
if (obj->port == PortA) {
|
||||||
NVIC_DisableIRQ(PORTA_IRQn);
|
NVIC_DisableIRQ(PORTA_IRQn);
|
||||||
} else if (obj->port == PortD) {
|
} else {
|
||||||
NVIC_DisableIRQ(PORTD_IRQn);
|
NVIC_DisableIRQ(PORTC_PORTD_IRQn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue