Commit e022f08a authored by Projects's avatar Projects

buttons: Moved OS-related irq handling to irq_dispatcher.c.

parent 14dc9df6
......@@ -25,8 +25,8 @@
*/
#include "buttons.h"
#include "irq_dispatcher.h"
__attribute__((weak))
void GPIO_EVEN_IRQHandler(void)
{
uint32_t iflags;
......@@ -36,10 +36,9 @@ void GPIO_EVEN_IRQHandler(void)
// Clean only even interrupts
GPIO_IntClear(iflags);
portEND_SWITCHING_ISR(gpio_irq_dispatcher(iflags));
}
__attribute__((weak))
void GPIO_ODD_IRQHandler(void)
{
uint32_t iflags;
......@@ -49,8 +48,6 @@ void GPIO_ODD_IRQHandler(void)
// Clean only odd interrupts
GPIO_IntClear(iflags);
portEND_SWITCHING_ISR(gpio_irq_dispatcher(iflags));
}
void buttons_init(void)
......
......@@ -25,12 +25,12 @@
* hardware interrupts and operating system.
*/
#include "irq_dispatcher.h"
#include <apps/application.h>
#include <event.h>
portBASE_TYPE gpio_irq_dispatcher(uint32_t flags)
#include <em_gpio.h>
static portBASE_TYPE gpio_irq_dispatcher(uint32_t flags)
{
// We have not woken a task at the start of the ISR
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
......@@ -50,8 +50,34 @@ portBASE_TYPE gpio_irq_dispatcher(uint32_t flags)
}
// Post the byte to the back of the queue
xQueueSendToBackFromISR( appQueue, &evt, &xHigherPriorityTaskWoken );
xQueueSendToBackFromISR(appQueue, &evt, &xHigherPriorityTaskWoken);
return xHigherPriorityTaskWoken;
}
void GPIO_EVEN_IRQHandler(void)
{
uint32_t iflags;
// Get all even interrupts
iflags = GPIO_IntGetEnabled() & 0x00005555;
// Clean only even interrupts
GPIO_IntClear(iflags);
portEND_SWITCHING_ISR(gpio_irq_dispatcher(iflags));
}
void GPIO_ODD_IRQHandler(void)
{
uint32_t iflags;
// Get all odd interrupts
iflags = GPIO_IntGetEnabled() & 0x0000AAAA;
// Clean only odd interrupts
GPIO_IntClear(iflags);
portEND_SWITCHING_ISR(gpio_irq_dispatcher(iflags));
}
/*
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* Interrupt service routines dispatchers. An abstraction layer between
* hardware interrupts and operating system.
*/
#ifndef IRQ_DISPATCHER_H
#define IRQ_DISPATCHER_H
#include <FreeRTOS.h>
#include <stdint.h>
/**
* @brief GPIO interrupt requests dispatcher.
*/
portBASE_TYPE gpio_irq_dispatcher(uint32_t flags);
#endif /* IRQ_DISPATCHER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment