Skip to content

Commit fad5c27

Browse files
committed
Add default interrupt handler for Freescale NMI_b pins.
1 parent 7ef411e commit fad5c27

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
3737
if (port->ISFR & pmask) {
3838
mask |= pmask;
3939
uint32_t id = channel_ids[ch_base + i];
40-
if (id == 0) continue;
40+
if (id == 0) {
41+
continue;
42+
}
4143

4244
FGPIO_Type *gpio;
4345
gpio_irq_event event = IRQ_NONE;
@@ -170,3 +172,13 @@ void gpio_irq_disable(gpio_irq_t *obj) {
170172
NVIC_DisableIRQ(PORTB_IRQn);
171173
}
172174
}
175+
176+
// Change the NMI pin to an input. This allows NMI pin to
177+
// be used as a low power mode wakeup. The application will
178+
// need to change the pin back to NMI_b or wakeup only occurs once!
179+
extern void gpio_init(gpio_t *obj, PinName pin, PinDirection direction);
180+
void NMI_Handler(void)
181+
{
182+
gpio_t gpio;
183+
gpio_init(&gpio, PTB5, PIN_INPUT);
184+
}

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
3737
if (port->ISFR & pmask) {
3838
mask |= pmask;
3939
uint32_t id = channel_ids[ch_base + i];
40-
if (id == 0) continue;
40+
if (id == 0) {
41+
continue;
42+
}
4143

4244
FGPIO_Type *gpio;
4345
gpio_irq_event event = IRQ_NONE;
@@ -55,8 +57,9 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
5557
event = (gpio->PDIR & pmask) ? (IRQ_RISE) : (IRQ_FALL);
5658
break;
5759
}
58-
if (event != IRQ_NONE)
60+
if (event != IRQ_NONE) {
5961
irq_handler(id, event);
62+
}
6063
}
6164
}
6265
port->ISFR = mask;
@@ -159,3 +162,13 @@ void gpio_irq_disable(gpio_irq_t *obj) {
159162
NVIC_DisableIRQ(PORTD_IRQn);
160163
}
161164
}
165+
166+
// Change the NMI pin to an input. This allows NMI pin to
167+
// be used as a low power mode wakeup. The application will
168+
// need to change the pin back to NMI_b or wakeup only occurs once!
169+
extern void gpio_init(gpio_t *obj, PinName pin, PinDirection direction);
170+
void NMI_Handler(void)
171+
{
172+
gpio_t gpio;
173+
gpio_init(&gpio, PTA4, PIN_INPUT);
174+
}

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ static void handle_interrupt_in(PORT_Type *port, int ch_base) {
3737
if (port->ISFR & pmask) {
3838
mask |= pmask;
3939
uint32_t id = channel_ids[ch_base + i];
40-
if (id == 0)
40+
if (id == 0) {
4141
continue;
42+
}
4243

4344
FGPIO_Type *gpio;
4445
gpio_irq_event event = IRQ_NONE;
@@ -181,3 +182,13 @@ void gpio_irq_disable(gpio_irq_t *obj) {
181182
NVIC_DisableIRQ(PORTC_PORTD_IRQn);
182183
}
183184
}
185+
186+
// Change the NMI pin to an input. This allows NMI pin to
187+
// be used as a low power mode wakeup. The application will
188+
// need to change the pin back to NMI_b or wakeup only occurs once!
189+
extern void gpio_init(gpio_t *obj, PinName pin, PinDirection direction);
190+
void NMI_Handler(void)
191+
{
192+
gpio_t gpio;
193+
gpio_init(&gpio, PTA4, PIN_INPUT);
194+
}

0 commit comments

Comments
 (0)