From fa465c14c4f4e4725daeaaa1ca1ff9721da9f19a Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Fri, 14 Aug 2015 20:57:40 -0700 Subject: [PATCH] Extract RTC interrupt handler into separate files. --- firmware/application/Makefile | 1 + firmware/application/irq_rtc.cpp | 50 ++++++++++++++++++++++++++++++++ firmware/application/irq_rtc.hpp | 27 +++++++++++++++++ firmware/application/main.cpp | 23 ++------------- 4 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 firmware/application/irq_rtc.cpp create mode 100644 firmware/application/irq_rtc.hpp diff --git a/firmware/application/Makefile b/firmware/application/Makefile index aeb55a32..879c2501 100755 --- a/firmware/application/Makefile +++ b/firmware/application/Makefile @@ -121,6 +121,7 @@ CPPSRC = main.cpp \ irq_ipc.cpp \ irq_lcd_frame.cpp \ irq_controls.cpp \ + irq_rtc.cpp \ event.cpp \ message_queue.cpp \ hackrf_hal.cpp \ diff --git a/firmware/application/irq_rtc.cpp b/firmware/application/irq_rtc.cpp new file mode 100644 index 00000000..f393d0f4 --- /dev/null +++ b/firmware/application/irq_rtc.cpp @@ -0,0 +1,50 @@ +/* + * 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_rtc.hpp" + +#include "ch.h" + +#include "lpc43xx_cpp.hpp" +using namespace lpc43xx; + +#include "event.hpp" + +void rtc_interrupt_enable() { + rtc::interrupt::enable_second_inc(); + nvicEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(LPC_RTC_IRQ_PRIORITY)); +} + +extern "C" { + +CH_IRQ_HANDLER(RTC_IRQHandler) { + CH_IRQ_PROLOGUE(); + + chSysLockFromIsr(); + events_flag_isr(EVT_MASK_RTC_TICK); + chSysUnlockFromIsr(); + + rtc::interrupt::clear_all(); + + CH_IRQ_EPILOGUE(); +} + +} diff --git a/firmware/application/irq_rtc.hpp b/firmware/application/irq_rtc.hpp new file mode 100644 index 00000000..b2b67f81 --- /dev/null +++ b/firmware/application/irq_rtc.hpp @@ -0,0 +1,27 @@ +/* + * 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 __IPC_RTC_H__ +#define __IPC_RTC_H__ + +void rtc_interrupt_enable(); + +#endif/*__IPC_RTC_H__*/ diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 3d5c621d..e1a1724a 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -22,9 +22,6 @@ #include "ch.h" #include "test.h" -#include "lpc43xx_cpp.hpp" -using namespace lpc43xx; - #include "portapack.hpp" #include "portapack_shared_memory.hpp" @@ -40,6 +37,7 @@ using namespace lpc43xx; #include "irq_ipc.hpp" #include "irq_lcd_frame.hpp" #include "irq_controls.hpp" +#include "irq_rtc.hpp" #include "event.hpp" @@ -98,22 +96,6 @@ static spi_bus_t ssp0 = { }; #endif -extern "C" { - -CH_IRQ_HANDLER(RTC_IRQHandler) { - CH_IRQ_PROLOGUE(); - - chSysLockFromIsr(); - events_flag_isr(EVT_MASK_RTC_TICK); - chSysUnlockFromIsr(); - - rtc::interrupt::clear_all(); - - CH_IRQ_EPILOGUE(); -} - -} - static bool ui_dirty = true; void ui::dirty_event() { @@ -438,8 +420,7 @@ int main(void) { sdcStart(&SDCD1, nullptr); - rtc::interrupt::enable_second_inc(); - nvicEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(LPC_RTC_IRQ_PRIORITY)); + rtc_interrupt_enable(); controls_init();