A little code consolidation -- M0APP IRQ.

This commit is contained in:
Jared Boone 2016-01-04 10:12:18 -08:00
parent cd17f414b7
commit 778e2d2381
6 changed files with 31 additions and 87 deletions

View File

@ -125,7 +125,6 @@ CSRC = $(PORTSRC) \
CPPSRC = main.cpp \ CPPSRC = main.cpp \
message_queue.cpp \ message_queue.cpp \
event_m4.cpp \ event_m4.cpp \
irq_ipc_m4.cpp \
gpdma.cpp \ gpdma.cpp \
baseband_dma.cpp \ baseband_dma.cpp \
portapack_shared_memory.cpp \ portapack_shared_memory.cpp \

View File

@ -21,6 +21,9 @@
#include "event_m4.hpp" #include "event_m4.hpp"
#include "lpc43xx_cpp.hpp"
using namespace lpc43xx;
#include "ch.h" #include "ch.h"
Thread* thread_event_loop = nullptr; Thread* thread_event_loop = nullptr;
@ -28,3 +31,19 @@ Thread* thread_event_loop = nullptr;
void events_initialize(Thread* const event_loop_thread) { void events_initialize(Thread* const event_loop_thread) {
thread_event_loop = event_loop_thread; thread_event_loop = event_loop_thread;
} }
extern "C" {
CH_IRQ_HANDLER(MAPP_IRQHandler) {
CH_IRQ_PROLOGUE();
chSysLockFromIsr();
events_flag_isr(EVT_MASK_BASEBAND);
chSysUnlockFromIsr();
creg::m0apptxevent::clear();
CH_IRQ_EPILOGUE();
}
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
*
* This file is part of PortaPack.
*
* 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, 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "irq_ipc_m4.hpp"
#include "ch.h"
#include "hal.h"
#include "event_m4.hpp"
#include "lpc43xx_cpp.hpp"
using namespace lpc43xx;
void m0apptxevent_interrupt_enable() {
nvicEnableVector(M0CORE_IRQn, CORTEX_PRIORITY_MASK(LPC43XX_M0APPTXEVENT_IRQ_PRIORITY));
}
void m0apptxevent_interrupt_disable() {
nvicDisableVector(M0CORE_IRQn);
}
extern "C" {
CH_IRQ_HANDLER(MAPP_IRQHandler) {
CH_IRQ_PROLOGUE();
chSysLockFromIsr();
events_flag_isr(EVT_MASK_BASEBAND);
chSysUnlockFromIsr();
creg::m0apptxevent::clear();
CH_IRQ_EPILOGUE();
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
*
* This file is part of PortaPack.
*
* 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, 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef __IRQ_IPC_M4_H__
#define __IRQ_IPC_M4_H__
void m0apptxevent_interrupt_enable();
void m0apptxevent_interrupt_disable();
#endif/*__IRQ_IPC_M4_H__*/

View File

@ -30,8 +30,6 @@
#include "event_m4.hpp" #include "event_m4.hpp"
#include "irq_ipc_m4.hpp"
#include "touch_dma.hpp" #include "touch_dma.hpp"
#include "baseband_thread.hpp" #include "baseband_thread.hpp"
@ -123,7 +121,7 @@ class EventDispatcher {
public: public:
void run() { void run() {
events_initialize(chThdSelf()); events_initialize(chThdSelf());
m0apptxevent_interrupt_enable(); lpc43xx::creg::m0apptxevent::enable();
baseband_thread.thread_main = chThdSelf(); baseband_thread.thread_main = chThdSelf();
baseband_thread.thread_rssi = rssi_thread.start(NORMALPRIO + 10); baseband_thread.thread_rssi = rssi_thread.start(NORMALPRIO + 10);
@ -134,7 +132,7 @@ public:
dispatch(events); dispatch(events);
} }
m0apptxevent_interrupt_disable(); lpc43xx::creg::m0apptxevent::disable();
} }
void request_stop() { void request_stop() {

View File

@ -57,6 +57,16 @@ inline void clear() {
namespace m0apptxevent { namespace m0apptxevent {
#if defined(LPC43XX_M4)
inline void enable() {
nvicEnableVector(M0CORE_IRQn, CORTEX_PRIORITY_MASK(LPC43XX_M0APPTXEVENT_IRQ_PRIORITY));
}
inline void disable() {
nvicDisableVector(M0CORE_IRQn);
}
#endif
#if defined(LPC43XX_M0) #if defined(LPC43XX_M0)
inline void assert() { inline void assert() {
__SEV(); __SEV();