From a27489eb21fe28f116a434d14388604aeb6adfd2 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 4 Jan 2016 12:00:52 -0800 Subject: [PATCH] Consolidating M4-specific saturation flag code. --- firmware/baseband/baseband_stats_collector.cpp | 6 +++--- firmware/common/lpc43xx_cpp.hpp | 15 +++++++++++++++ firmware/common/utility_m4.hpp | 9 --------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/firmware/baseband/baseband_stats_collector.cpp b/firmware/baseband/baseband_stats_collector.cpp index 91a1bcf3..8eec12c5 100644 --- a/firmware/baseband/baseband_stats_collector.cpp +++ b/firmware/baseband/baseband_stats_collector.cpp @@ -21,7 +21,7 @@ #include "baseband_stats_collector.hpp" -#include "utility_m4.hpp" +#include "lpc43xx_cpp.hpp" bool BasebandStatsCollector::process(const buffer_c8_t& buffer) { samples += buffer.count; @@ -50,8 +50,8 @@ BasebandStatistics BasebandStatsCollector::capture_statistics() { statistics.baseband_ticks = (baseband_ticks - last_baseband_ticks); last_baseband_ticks = baseband_ticks; - statistics.saturation = m4_flag_saturation(); - clear_m4_flag_saturation(); + statistics.saturation = lpc43xx::m4::flag_saturation(); + lpc43xx::m4::clear_flag_saturation(); samples_last_report = samples; diff --git a/firmware/common/lpc43xx_cpp.hpp b/firmware/common/lpc43xx_cpp.hpp index f1578192..d2917f9b 100644 --- a/firmware/common/lpc43xx_cpp.hpp +++ b/firmware/common/lpc43xx_cpp.hpp @@ -30,6 +30,21 @@ namespace lpc43xx { +#if defined(LPC43XX_M4) +namespace m4 { + +static inline bool flag_saturation() { + return __get_APSR() & (1U << 27); +} + +static inline void clear_flag_saturation() { + uint32_t flags = 1; + __asm volatile ("MSR APSR_nzcvqg, %0" : : "r" (flags)); +} + +} /* namespace m4 */ +#endif + namespace creg { static_assert(offsetof(LPC_CREG_Type, CREG0) == 0x004, "CREG0 offset wrong"); diff --git a/firmware/common/utility_m4.hpp b/firmware/common/utility_m4.hpp index 2516f12a..c0868081 100644 --- a/firmware/common/utility_m4.hpp +++ b/firmware/common/utility_m4.hpp @@ -26,15 +26,6 @@ #include -static inline bool m4_flag_saturation() { - return __get_APSR() & (1U << 27); -} - -static inline void clear_m4_flag_saturation() { - uint32_t flags = 1; - __asm volatile ("MSR APSR_nzcvqg, %0" : : "r" (flags)); -} - static inline complex32_t multiply_conjugate_s16_s32(const complex16_t::rep_type a, const complex16_t::rep_type b) { // conjugate: conj(a + bj) = a - bj // multiply: (a + bj) * (c + dj) = (ac - bd) + (bc + ad)j