Eliminate duplicate code between event_m4.hpp, event.hpp.

event.* is common code, _m0 and _m4 contain specific event mask definitions.
This commit is contained in:
Jared Boone 2016-01-04 12:54:05 -08:00
parent 229c1e9a3c
commit c1e5577669
9 changed files with 19 additions and 38 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -19,12 +19,16 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include "event_m4.hpp" #ifndef __EVENT_M0_H__
#define __EVENT_M0_H__
#include "ch.h" #include "event.hpp"
Thread* thread_event_loop = nullptr; constexpr auto EVT_MASK_RTC_TICK = EVENT_MASK(0);
constexpr auto EVT_MASK_LCD_FRAME_SYNC = EVENT_MASK(1);
constexpr auto EVT_MASK_SWITCHES = EVENT_MASK(3);
constexpr auto EVT_MASK_ENCODER = EVENT_MASK(4);
constexpr auto EVT_MASK_TOUCH = EVENT_MASK(5);
constexpr auto EVT_MASK_APPLICATION = EVENT_MASK(6);
void events_initialize(Thread* const event_loop_thread) { #endif/*__EVENT_M0_H__*/
thread_event_loop = event_loop_thread;
}

View file

@ -24,7 +24,7 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "event.hpp" #include "event_m0.hpp"
#include "touch.hpp" #include "touch.hpp"
#include "touch_adc.hpp" #include "touch_adc.hpp"

View file

@ -21,7 +21,7 @@
#include "irq_lcd_frame.hpp" #include "irq_lcd_frame.hpp"
#include "event.hpp" #include "event_m0.hpp"
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"

View file

@ -26,7 +26,7 @@
#include "lpc43xx_cpp.hpp" #include "lpc43xx_cpp.hpp"
using namespace lpc43xx; using namespace lpc43xx;
#include "event.hpp" #include "event_m0.hpp"
void rtc_interrupt_enable() { void rtc_interrupt_enable() {
rtc::interrupt::enable_second_inc(); rtc::interrupt::enable_second_inc();

View file

@ -37,7 +37,7 @@
#include "irq_controls.hpp" #include "irq_controls.hpp"
#include "irq_rtc.hpp" #include "irq_rtc.hpp"
#include "event.hpp" #include "event_m0.hpp"
#include "m4_startup.hpp" #include "m4_startup.hpp"
#include "spi_image.hpp" #include "spi_image.hpp"

View file

@ -124,7 +124,7 @@ CSRC = $(PORTSRC) \
# setting. # setting.
CPPSRC = main.cpp \ CPPSRC = main.cpp \
message_queue.cpp \ message_queue.cpp \
event_m4.cpp \ event.cpp \
gpdma.cpp \ gpdma.cpp \
baseband_dma.cpp \ baseband_dma.cpp \
portapack_shared_memory.cpp \ portapack_shared_memory.cpp \

View file

@ -22,25 +22,9 @@
#ifndef __EVENT_M4_H__ #ifndef __EVENT_M4_H__
#define __EVENT_M4_H__ #define __EVENT_M4_H__
#include "ch.h" #include "event.hpp"
constexpr auto EVT_MASK_BASEBAND = EVENT_MASK(0); constexpr auto EVT_MASK_BASEBAND = EVENT_MASK(0);
constexpr auto EVT_MASK_SPECTRUM = EVENT_MASK(1); constexpr auto EVT_MASK_SPECTRUM = EVENT_MASK(1);
void events_initialize(Thread* const event_loop_thread);
extern Thread* thread_event_loop;
inline void events_flag(const eventmask_t events) {
if( thread_event_loop ) {
chEvtSignal(thread_event_loop, events);
}
}
inline void events_flag_isr(const eventmask_t events) {
if( thread_event_loop ) {
chEvtSignalI(thread_event_loop, events);
}
}
#endif/*__EVENT_M4_H__*/ #endif/*__EVENT_M4_H__*/

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -24,13 +24,6 @@
#include "ch.h" #include "ch.h"
constexpr auto EVT_MASK_RTC_TICK = EVENT_MASK(0);
constexpr auto EVT_MASK_LCD_FRAME_SYNC = EVENT_MASK(1);
constexpr auto EVT_MASK_SWITCHES = EVENT_MASK(3);
constexpr auto EVT_MASK_ENCODER = EVENT_MASK(4);
constexpr auto EVT_MASK_TOUCH = EVENT_MASK(5);
constexpr auto EVT_MASK_APPLICATION = EVENT_MASK(6);
void events_initialize(Thread* const event_loop_thread); void events_initialize(Thread* const event_loop_thread);
extern Thread* thread_event_loop; extern Thread* thread_event_loop;