From d95a4334093a70f7e8e812256ac2b256d076c197 Mon Sep 17 00:00:00 2001 From: paradajz <2544094+paradajz@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:32:21 +0200 Subject: [PATCH] update core module --- CMakeLists.txt | 10 +++++++++- modules/core | 2 +- scripts/gen/gen_mcu.sh | 8 +++++--- scripts/gen/mcu/main.sh | 4 +++- src/firmware/application/CMakeLists.txt | 4 ++-- src/firmware/application/io/analog/Filter.h | 6 +++--- src/firmware/application/io/buttons/Buttons.cpp | 2 +- .../application/io/encoders/Encoders.cpp | 4 ++-- .../io/i2c/peripherals/display/Display.cpp | 16 ++++++++-------- src/firmware/application/io/leds/LEDs.cpp | 14 +++++++------- .../application/io/touchscreen/Touchscreen.cpp | 2 +- .../io/touchscreen/model/nextion/Nextion.cpp | 4 ++-- src/firmware/application/main.cpp | 9 ++++----- src/firmware/application/protocol/midi/MIDI.cpp | 2 +- src/firmware/application/system/System.cpp | 2 +- src/firmware/application/util/cinfo/CInfo.cpp | 6 +++--- .../application/util/scheduler/Scheduler.cpp | 6 +++--- src/firmware/board/src/arch/arm/common/NVM.cpp | 1 - .../src/arch/avr/atmel/common/Bootloader.cpp | 3 +-- .../avr/atmel/common/communication/i2c/I2C.cpp | 3 +-- .../atmel/common/communication/usb/midi/MIDI.cpp | 4 ++-- .../usb/midi_cdc_dual/MIDI_CDC_Dual.cpp | 6 +++--- src/firmware/board/src/common/Bootloader.cpp | 3 +-- src/firmware/board/src/common/Reboot.cpp | 3 +-- src/firmware/board/src/common/Setup.cpp | 13 +------------ .../board/src/common/io/indicators/App.cpp | 5 ++--- .../board/src/common/io/indicators/Boot.cpp | 1 - src/firmware/bootloader/main.cpp | 2 +- src/firmware/usb-link/main.cpp | 5 ++--- tests/src/CMakeLists.txt | 1 + tests/src/main.cpp | 7 +------ tests/src/system/test.cpp | 2 +- 32 files changed, 74 insertions(+), 86 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a12c449e2..75a738de4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,14 @@ check_required_executables( sha256sum ) +# Needed for tools and tests +execute_process( + COMMAND + "${PROJECT_ROOT}/scripts/gen/gen_mcu.sh" + "--mcu=stub" + "--gen-dir=${PROJECT_ROOT}/src/generated/mcu/stub" +) + execute_process( COMMAND "${PROJECT_ROOT}/scripts/gen/gen_target.sh" @@ -97,7 +105,7 @@ add_dependencies(lint merge_firmware_binaries) ExternalProject_Add(tests SOURCE_DIR ${PROJECT_ROOT}/tests CMAKE_ARGS -DTARGET=${TARGET} - CMAKE_ARGS -DMCU_CMAKE_DISABLE_CORE_INCLUSION=1 + CMAKE_ARGS -DCMAKE_USE_STUB_MCU=1 CMAKE_ARGS -DFW_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR} CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/tests diff --git a/modules/core b/modules/core index c9e166e7e..15b4a4afb 160000 --- a/modules/core +++ b/modules/core @@ -1 +1 @@ -Subproject commit c9e166e7e6c65c16e0acc56d165f7073d3db98ab +Subproject commit 15b4a4afb68a857528f4107a601480b2e1fed22a diff --git a/scripts/gen/gen_mcu.sh b/scripts/gen/gen_mcu.sh index 8e44f8cee..f452096f4 100755 --- a/scripts/gen/gen_mcu.sh +++ b/scripts/gen/gen_mcu.sh @@ -34,6 +34,8 @@ then exit 1 fi -echo "Generating project MCU definitions..." - -source "$script_dir"/mcu/main.sh \ No newline at end of file +if [[ $mcu != "stub" ]] +then + echo "Generating project MCU definitions..." + source "$script_dir"/mcu/main.sh +fi \ No newline at end of file diff --git a/scripts/gen/mcu/main.sh b/scripts/gen/mcu/main.sh index fa7d8eaae..6b21d7501 100755 --- a/scripts/gen/mcu/main.sh +++ b/scripts/gen/mcu/main.sh @@ -8,7 +8,9 @@ generated_cmakelists_renamed=$gen_dir/core.cmake mv "$out_cmakelists" "$generated_cmakelists_renamed" { - printf "%s\n" "if(NOT MCU_CMAKE_DISABLE_CORE_INCLUSION)" + printf "%s\n" "if(CMAKE_USE_STUB_MCU)" + printf "%s\n" "include($gen_dir/../stub/CMakeLists.txt)" + printf "%s\n" "else()" printf "%s\n" "include($generated_cmakelists_renamed)" printf "%s\n" "endif()" printf "%s\n" "set(${cmake_mcu_defines_var} \"\")" diff --git a/src/firmware/application/CMakeLists.txt b/src/firmware/application/CMakeLists.txt index fb1d0e6b7..7ccb6e23b 100644 --- a/src/firmware/application/CMakeLists.txt +++ b/src/firmware/application/CMakeLists.txt @@ -115,7 +115,7 @@ if(NOT "PROJECT_TARGET_USB_OVER_SERIAL_HOST" IN_LIST PROJECT_TARGET_DEFINES) ExternalProject_Add(flashgen SOURCE_DIR ${PROJECT_ROOT}/src/tools/flashgen CMAKE_ARGS -DTARGET=${TARGET} - CMAKE_ARGS -DMCU_CMAKE_DISABLE_CORE_INCLUSION=1 + CMAKE_ARGS -DCMAKE_USE_STUB_MCU=1 CMAKE_ARGS -DPROJECT_MCU_FLASH_PAGE_FACTORY=${PROJECT_MCU_FLASH_PAGE_FACTORY} CMAKE_ARGS -DEMU_EEPROM_PAGE_SIZE=${EMU_EEPROM_PAGE_SIZE} BINARY_DIR ${FLASHGEN_BINARY_DIR} @@ -149,7 +149,7 @@ if(NOT "PROJECT_TARGET_USB_OVER_SERIAL_HOST" IN_LIST PROJECT_TARGET_DEFINES) ExternalProject_Add(sysexgen SOURCE_DIR ${PROJECT_ROOT}/src/tools/sysexgen - CMAKE_ARGS -DTARGET=${TARGET} -DMCU_CMAKE_DISABLE_CORE_INCLUSION=1 + CMAKE_ARGS -DTARGET=${TARGET} -DCMAKE_USE_STUB_MCU=1 BINARY_DIR ${SYSEX_BINARY_DIR} INSTALL_COMMAND "./sysexgen" "$.bin" "${SYSEXGEN_FW_NAME_RAW_SYSEX}" ) diff --git a/src/firmware/application/io/analog/Filter.h b/src/firmware/application/io/analog/Filter.h index ee5f1d4d4..95c22ff90 100644 --- a/src/firmware/application/io/analog/Filter.h +++ b/src/firmware/application/io/analog/Filter.h @@ -22,7 +22,7 @@ limitations under the License. #include #include -#include "core/Timing.h" +#include "core/MCU.h" #include "application/io/analog/Analog.h" #include "core/util/Util.h" #include "core/util/Filters.h" @@ -70,7 +70,7 @@ namespace io return true; } - const bool FAST_FILTER = (core::timing::ms() - _lastStableMovementTime[index]) < FAST_FILTER_ENABLE_AFTER_MS; + const bool FAST_FILTER = (core::mcu::timing::ms() - _lastStableMovementTime[index]) < FAST_FILTER_ENABLE_AFTER_MS; const bool DIRECTION = descriptor.value >= _lastStableValue[index]; const auto OLD_MIDI_VALUE = core::util::MAP_RANGE(static_cast(_lastStableValue[index]), static_cast(ADC_MIN_VALUE), @@ -134,7 +134,7 @@ namespace io } else { - _lastStableMovementTime[index] = core::timing::ms(); + _lastStableMovementTime[index] = core::mcu::timing::ms(); } if (descriptor.type == Analog::type_t::FSR) diff --git a/src/firmware/application/io/buttons/Buttons.cpp b/src/firmware/application/io/buttons/Buttons.cpp index 096a589e8..7a6c81d10 100644 --- a/src/firmware/application/io/buttons/Buttons.cpp +++ b/src/firmware/application/io/buttons/Buttons.cpp @@ -24,8 +24,8 @@ limitations under the License. #ifdef BUTTONS_SUPPORTED +#include "core/MCU.h" #include "core/util/Util.h" -#include "core/Timing.h" #include "application/util/conversion/Conversion.h" #include "application/util/configurable/Configurable.h" diff --git a/src/firmware/application/io/encoders/Encoders.cpp b/src/firmware/application/io/encoders/Encoders.cpp index f1ae81425..44cd5beeb 100644 --- a/src/firmware/application/io/encoders/Encoders.cpp +++ b/src/firmware/application/io/encoders/Encoders.cpp @@ -20,7 +20,7 @@ limitations under the License. #ifdef ENCODERS_SUPPORTED -#include "core/Timing.h" +#include "core/MCU.h" #include "core/util/Util.h" #include "application/util/conversion/Conversion.h" #include "application/util/configurable/Configurable.h" @@ -132,7 +132,7 @@ void Encoders::updateSingle(size_t index, bool forceRefresh) return; } - uint32_t currentTime = core::timing::ms(); + uint32_t currentTime = core::mcu::timing::ms(); for (uint8_t reading = 0; reading < numberOfReadings; reading++) { diff --git a/src/firmware/application/io/i2c/peripherals/display/Display.cpp b/src/firmware/application/io/i2c/peripherals/display/Display.cpp index 5381498f1..85ce3edf2 100644 --- a/src/firmware/application/io/i2c/peripherals/display/Display.cpp +++ b/src/firmware/application/io/i2c/peripherals/display/Display.cpp @@ -22,7 +22,7 @@ limitations under the License. #include "Display.h" #include "strings/Strings.h" #include "application/protocol/midi/MIDI.h" -#include "core/Timing.h" +#include "core/MCU.h" #include "core/util/Util.h" #include "application/io/common/Common.h" #include "application/util/conversion/Conversion.h" @@ -270,7 +270,7 @@ void Display::update() return; } - if ((core::timing::ms() - _lastLCDupdateTime) < LCD_REFRESH_TIME) + if ((core::mcu::timing::ms() - _lastLCDupdateTime) < LCD_REFRESH_TIME) { return; // we don't need to update lcd in real time } @@ -306,7 +306,7 @@ void Display::update() _charChange[i] = 0; } - _lastLCDupdateTime = core::timing::ms(); + _lastLCDupdateTime = core::mcu::timing::ms(); // check if in/out messages need to be cleared if (_messageRetentionTime) @@ -314,7 +314,7 @@ void Display::update() for (int i = 0; i < 2; i++) { // 0 = in, 1 = out - if ((core::timing::ms() - _lasMessageDisplayTime[i] > _messageRetentionTime) && _messageDisplayed[i]) + if ((core::mcu::timing::ms() - _lasMessageDisplayTime[i] > _messageRetentionTime) && _messageDisplayed[i]) { clearEvent(static_cast(i)); } @@ -378,8 +378,8 @@ void Display::setRetentionTime(uint32_t retentionTime) _messageRetentionTime = retentionTime; // reset last update time - _lasMessageDisplayTime[eventType_t::IN] = core::timing::ms(); - _lasMessageDisplayTime[eventType_t::OUT] = core::timing::ms(); + _lasMessageDisplayTime[eventType_t::IN] = core::mcu::timing::ms(); + _lasMessageDisplayTime[eventType_t::OUT] = core::mcu::timing::ms(); } /// Adds normalization to a given octave. @@ -442,7 +442,7 @@ void Display::displayWelcomeMessage() writeString(_stringBuilder.string(), startRow); } - core::timing::waitMs(2000); + core::mcu::timing::waitMs(2000); } void Display::displayEvent(eventType_t type, const messaging::event_t& event) @@ -528,7 +528,7 @@ void Display::displayEvent(eventType_t type, const messaging::event_t& event) break; } - _lasMessageDisplayTime[type] = core::timing::ms(); + _lasMessageDisplayTime[type] = core::mcu::timing::ms(); _messageDisplayed[type] = true; } diff --git a/src/firmware/application/io/leds/LEDs.cpp b/src/firmware/application/io/leds/LEDs.cpp index 58196027e..857499555 100644 --- a/src/firmware/application/io/leds/LEDs.cpp +++ b/src/firmware/application/io/leds/LEDs.cpp @@ -22,7 +22,7 @@ limitations under the License. #ifdef LEDS_SUPPORTED -#include "core/Timing.h" +#include "core/MCU.h" #include "core/util/Util.h" #include "application/util/conversion/Conversion.h" #include "application/util/configurable/Configurable.h" @@ -189,12 +189,12 @@ void LEDs::updateAll(bool forceRefresh) { case blinkType_t::TIMER: { - if ((core::timing::ms() - _lastLEDblinkUpdateTime) < LED_BLINK_TIMER_TYPE_CHECK_TIME) + if ((core::mcu::timing::ms() - _lastLEDblinkUpdateTime) < LED_BLINK_TIMER_TYPE_CHECK_TIME) { return; } - _lastLEDblinkUpdateTime = core::timing::ms(); + _lastLEDblinkUpdateTime = core::mcu::timing::ms(); } break; @@ -251,24 +251,24 @@ __attribute__((weak)) void LEDs::startUpAnimation() // turn all leds on first setAllOn(); - core::timing::waitMs(1000); + core::mcu::timing::waitMs(1000); for (size_t i = 0; i < Collection::SIZE(GROUP_DIGITAL_OUTPUTS); i++) { setState(i, brightness_t::OFF); - core::timing::waitMs(35); + core::mcu::timing::waitMs(35); } for (size_t i = 0; i < Collection::SIZE(GROUP_DIGITAL_OUTPUTS); i++) { setState(Collection::SIZE(GROUP_DIGITAL_OUTPUTS) - 1 - i, brightness_t::B100); - core::timing::waitMs(35); + core::mcu::timing::waitMs(35); } for (size_t i = 0; i < Collection::SIZE(GROUP_DIGITAL_OUTPUTS); i++) { setState(i, brightness_t::OFF); - core::timing::waitMs(35); + core::mcu::timing::waitMs(35); } // turn all off again diff --git a/src/firmware/application/io/touchscreen/Touchscreen.cpp b/src/firmware/application/io/touchscreen/Touchscreen.cpp index 1b04a09cb..91b36dce3 100644 --- a/src/firmware/application/io/touchscreen/Touchscreen.cpp +++ b/src/firmware/application/io/touchscreen/Touchscreen.cpp @@ -19,8 +19,8 @@ limitations under the License. #ifdef PROJECT_TARGET_SUPPORT_TOUCHSCREEN #include "Touchscreen.h" +#include "core/MCU.h" #include "core/util/Util.h" -#include "core/Timing.h" #include "application/util/conversion/Conversion.h" #include "application/util/configurable/Configurable.h" diff --git a/src/firmware/application/io/touchscreen/model/nextion/Nextion.cpp b/src/firmware/application/io/touchscreen/model/nextion/Nextion.cpp index 95ede9207..20c6c0e21 100644 --- a/src/firmware/application/io/touchscreen/model/nextion/Nextion.cpp +++ b/src/firmware/application/io/touchscreen/model/nextion/Nextion.cpp @@ -22,7 +22,7 @@ limitations under the License. #include #include #include "Nextion.h" -#include "core/Timing.h" +#include "core/MCU.h" #include "application/io/touchscreen/Touchscreen.h" using namespace io; @@ -40,7 +40,7 @@ bool Nextion::init() if (_hwa.init()) { // add slight delay to ensure display can receive commands after power on - core::timing::waitMs(1000); + core::mcu::timing::waitMs(1000); endCommand(); writeCommand("sendxy=1"); diff --git a/src/firmware/application/main.cpp b/src/firmware/application/main.cpp index 3a6dded78..2cd06c73a 100644 --- a/src/firmware/application/main.cpp +++ b/src/firmware/application/main.cpp @@ -16,7 +16,6 @@ limitations under the License. */ -#include "core/Timing.h" #include "core/MCU.h" #include "board/Board.h" #include "application/io/common/Common.h" @@ -98,7 +97,7 @@ class HWADatabase : public sys::Builder::HWA::Database // It's possible that LED indicators are still on since // this command is most likely given via USB. // Wait until all indicators are turned off - core::timing::waitMs(board::io::indicators::LED_TRAFFIC_INDICATOR_TIMEOUT); + core::mcu::timing::waitMs(board::io::indicators::LED_TRAFFIC_INDICATOR_TIMEOUT); #endif return board::nvm::clear(0, board::nvm::size()); @@ -546,7 +545,7 @@ class HWAMIDIBLE : public sys::Builder::HWA::Protocol::MIDI::BLE uint32_t time() override { - return core::timing::ms(); + return core::mcu::timing::ms(); } } _hwaMIDIBLE; #else @@ -890,7 +889,7 @@ class HWASystem : public sys::Builder::HWA::System static uint32_t lastCheckTime = 0; static bool lastConnectionState = false; - if (core::timing::ms() - lastCheckTime > USB_CONN_CHECK_TIME) + if (core::mcu::timing::ms() - lastCheckTime > USB_CONN_CHECK_TIME) { bool newState = board::usb::isUSBconnected(); @@ -906,7 +905,7 @@ class HWASystem : public sys::Builder::HWA::System } lastConnectionState = newState; - lastCheckTime = core::timing::ms(); + lastCheckTime = core::mcu::timing::ms(); } if (!CDCLocker::locked()) diff --git a/src/firmware/application/protocol/midi/MIDI.cpp b/src/firmware/application/protocol/midi/MIDI.cpp index 9fcb6fff4..fff8ebbc4 100644 --- a/src/firmware/application/protocol/midi/MIDI.cpp +++ b/src/firmware/application/protocol/midi/MIDI.cpp @@ -17,7 +17,7 @@ limitations under the License. */ #include "MIDI.h" -#include "core/Timing.h" +#include "core/MCU.h" #include "application/system/Config.h" #include "application/util/conversion/Conversion.h" #include "application/messaging/Messaging.h" diff --git a/src/firmware/application/system/System.cpp b/src/firmware/application/system/System.cpp index fb49c5315..56df67100 100644 --- a/src/firmware/application/system/System.cpp +++ b/src/firmware/application/system/System.cpp @@ -19,7 +19,7 @@ limitations under the License. #include "System.h" #include "Layout.h" #include "bootloader/FwSelector/FwSelector.h" -#include "core/Timing.h" +#include "core/MCU.h" #include "core/util/Util.h" #include "application/system/Config.h" #include "application/messaging/Messaging.h" diff --git a/src/firmware/application/util/cinfo/CInfo.cpp b/src/firmware/application/util/cinfo/CInfo.cpp index 9dbbeefbc..7ea0af1b5 100644 --- a/src/firmware/application/util/cinfo/CInfo.cpp +++ b/src/firmware/application/util/cinfo/CInfo.cpp @@ -17,7 +17,7 @@ limitations under the License. */ #include "CInfo.h" -#include "core/Timing.h" +#include "core/MCU.h" #include "application/messaging/Messaging.h" using namespace util; @@ -62,13 +62,13 @@ void ComponentInfo::registerHandler(cinfoHandler_t&& handler) void ComponentInfo::send(database::Config::block_t block, size_t index) { - if ((core::timing::ms() - _lastCinfoMsgTime[static_cast(block)]) > COMPONENT_INFO_TIMEOUT) + if ((core::mcu::timing::ms() - _lastCinfoMsgTime[static_cast(block)]) > COMPONENT_INFO_TIMEOUT) { if (_handler != nullptr) { _handler(static_cast(block), index); } - _lastCinfoMsgTime[static_cast(block)] = core::timing::ms(); + _lastCinfoMsgTime[static_cast(block)] = core::mcu::timing::ms(); } } \ No newline at end of file diff --git a/src/firmware/application/util/scheduler/Scheduler.cpp b/src/firmware/application/util/scheduler/Scheduler.cpp index 042bc6f5a..8bec33eee 100644 --- a/src/firmware/application/util/scheduler/Scheduler.cpp +++ b/src/firmware/application/util/scheduler/Scheduler.cpp @@ -17,7 +17,7 @@ limitations under the License. */ #include "Scheduler.h" -#include "core/Timing.h" +#include "core/MCU.h" using namespace util; @@ -43,7 +43,7 @@ void Scheduler::update() { if (_tasks[i].function != nullptr) { - if (core::timing::ms() >= _tasks[i].timeout) + if (core::mcu::timing::ms() >= _tasks[i].timeout) { _tasks[i].function(); _tasks[i].function = nullptr; @@ -72,7 +72,7 @@ bool Scheduler::registerTask(task_t&& task) } _tasks[index].function = std::move(task.function); - _tasks[index].timeout = core::timing::ms() + task.timeout; + _tasks[index].timeout = core::mcu::timing::ms() + task.timeout; return true; } \ No newline at end of file diff --git a/src/firmware/board/src/arch/arm/common/NVM.cpp b/src/firmware/board/src/arch/arm/common/NVM.cpp index 7d2b79fc7..844098ca4 100644 --- a/src/firmware/board/src/arch/arm/common/NVM.cpp +++ b/src/firmware/board/src/arch/arm/common/NVM.cpp @@ -19,7 +19,6 @@ limitations under the License. #include "board/Board.h" #include "Internal.h" #include "EmuEEPROM/EmuEEPROM.h" -#include "core/Timing.h" #include "core/MCU.h" namespace diff --git a/src/firmware/board/src/arch/avr/atmel/common/Bootloader.cpp b/src/firmware/board/src/arch/avr/atmel/common/Bootloader.cpp index a73a0b0a5..34acba8ad 100644 --- a/src/firmware/board/src/arch/avr/atmel/common/Bootloader.cpp +++ b/src/firmware/board/src/arch/avr/atmel/common/Bootloader.cpp @@ -19,9 +19,8 @@ limitations under the License. #include #include "board/Board.h" #include "Internal.h" -#include "core/util/Util.h" -#include "core/Timing.h" #include "core/MCU.h" +#include "core/util/Util.h" namespace board::bootloader { diff --git a/src/firmware/board/src/arch/avr/atmel/common/communication/i2c/I2C.cpp b/src/firmware/board/src/arch/avr/atmel/common/communication/i2c/I2C.cpp index 8cbd079d7..219641042 100644 --- a/src/firmware/board/src/arch/avr/atmel/common/communication/i2c/I2C.cpp +++ b/src/firmware/board/src/arch/avr/atmel/common/communication/i2c/I2C.cpp @@ -20,9 +20,8 @@ limitations under the License. #include "board/Board.h" #include "core/util/Util.h" -#include "core/Timing.h" -#include "core/util/RingBuffer.h" #include "core/MCU.h" +#include "core/util/RingBuffer.h" // note: on AVR, only 1 I2C channel is supported with the index 0 // I2C implementation in core module uses blocking I2C. Here, interrupt diff --git a/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi/MIDI.cpp b/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi/MIDI.cpp index 924827c14..fcd034dee 100644 --- a/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi/MIDI.cpp +++ b/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi/MIDI.cpp @@ -24,7 +24,7 @@ limitations under the License. #include "common/communication/usb/descriptors/midi/Descriptors.h" #include "board/Board.h" #include "Internal.h" -#include "core/Timing.h" +#include "core/MCU.h" namespace { @@ -174,7 +174,7 @@ namespace board // once the transfer fails, wait USB_TX_TIMEOUT_MS ms before trying again if (_txStateMIDI != board::detail::usb::txState_t::DONE) { - if ((core::timing::ms() - timeout) < USB_TX_TIMEOUT_MS) + if ((core::mcu::timing::ms() - timeout) < USB_TX_TIMEOUT_MS) { return false; } diff --git a/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi_cdc_dual/MIDI_CDC_Dual.cpp b/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi_cdc_dual/MIDI_CDC_Dual.cpp index a4783bb71..18fe7d67f 100644 --- a/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi_cdc_dual/MIDI_CDC_Dual.cpp +++ b/src/firmware/board/src/arch/avr/atmel/common/communication/usb/midi_cdc_dual/MIDI_CDC_Dual.cpp @@ -24,7 +24,7 @@ limitations under the License. #include "common/communication/usb/descriptors/midi_cdc_dual/Descriptors.h" #include "board/Board.h" #include "Internal.h" -#include "core/Timing.h" +#include "core/MCU.h" namespace { @@ -205,7 +205,7 @@ namespace board // once the transfer fails, wait USB_TX_TIMEOUT_MS ms before trying again if (_txStateMIDI != board::detail::usb::txState_t::DONE) { - if ((core::timing::ms() - timeout) < USB_TX_TIMEOUT_MS) + if ((core::mcu::timing::ms() - timeout) < USB_TX_TIMEOUT_MS) { return false; } @@ -287,7 +287,7 @@ namespace board // once the transfer fails, wait USB_TX_TIMEOUT_MS ms before trying again if (_txStateCDC != board::detail::usb::txState_t::DONE) { - if ((core::timing::ms() - timeout) < USB_TX_TIMEOUT_MS) + if ((core::mcu::timing::ms() - timeout) < USB_TX_TIMEOUT_MS) { return false; } diff --git a/src/firmware/board/src/common/Bootloader.cpp b/src/firmware/board/src/common/Bootloader.cpp index 5ab24a68b..9cc7c1dc2 100644 --- a/src/firmware/board/src/common/Bootloader.cpp +++ b/src/firmware/board/src/common/Bootloader.cpp @@ -18,7 +18,6 @@ limitations under the License. #include "board/Board.h" #include "Internal.h" -#include "core/Timing.h" #include #ifdef PROJECT_TARGET_SUPPORT_BOOTLOADER_BUTTON @@ -49,7 +48,7 @@ namespace board::bootloader bool isHWtriggerActive() { // add some delay before reading the pins to avoid incorrect state detection - core::timing::waitMs(100); + core::mcu::timing::waitMs(100); return IS_BTLDR_ACTIVE(); } diff --git a/src/firmware/board/src/common/Reboot.cpp b/src/firmware/board/src/common/Reboot.cpp index e797e6015..bdc0302a2 100644 --- a/src/firmware/board/src/common/Reboot.cpp +++ b/src/firmware/board/src/common/Reboot.cpp @@ -18,7 +18,6 @@ limitations under the License. #include "board/Board.h" #include "Internal.h" -#include "core/Timing.h" #include "core/MCU.h" namespace board @@ -50,7 +49,7 @@ namespace board // In case the indicator LEDs were on before this command was issued, this will make sure // they are off before the reboot. // Double the delay time to avoid "sharp" transition between traffic event and bootloader indication. - core::timing::waitMs(io::indicators::LED_TRAFFIC_INDICATOR_TIMEOUT * 2); + core::mcu::timing::waitMs(io::indicators::LED_TRAFFIC_INDICATOR_TIMEOUT * 2); core::mcu::reset(); } diff --git a/src/firmware/board/src/common/Setup.cpp b/src/firmware/board/src/common/Setup.cpp index de4e02113..118e02a12 100644 --- a/src/firmware/board/src/common/Setup.cpp +++ b/src/firmware/board/src/common/Setup.cpp @@ -18,15 +18,8 @@ limitations under the License. #include "board/Board.h" #include "Internal.h" -#include "core/Timing.h" #include "core/MCU.h" -namespace core::timing::detail -{ - /// Implementation of core variable used to keep track of run time in milliseconds. - volatile uint32_t ms; -} // namespace core::timing::detail - namespace { constexpr uint32_t MAIN_TIMER_TIMEOUT_US = 1000; @@ -50,7 +43,6 @@ namespace board core::mcu::timers::allocate(mainTimerIndex, []() { - core::timing::detail::ms++; detail::io::indicators::update(); #ifndef PROJECT_TARGET_USB_OVER_SERIAL_HOST detail::io::digitalIn::update(); @@ -89,7 +81,6 @@ namespace board core::mcu::timers::allocate(mainTimerIndex, []() { - core::timing::detail::ms++; detail::io::indicators::update(); }); @@ -157,7 +148,7 @@ namespace board } } - core::timing::waitMs(50); + core::mcu::timing::waitMs(50); } } #endif @@ -167,7 +158,6 @@ namespace board // partial initialization - init the rest in runBootloader() if it's determined that bootloader should really run core::mcu::init(core::mcu::initType_t::BOOT); - core::mcu::timers::init(); detail::io::init(); #ifdef PROJECT_TARGET_USB_OVER_SERIAL @@ -178,7 +168,6 @@ namespace board void application() { core::mcu::init(core::mcu::initType_t::APP); - core::mcu::timers::init(); #ifdef PROJECT_TARGET_USB_OVER_SERIAL board::uart::init(PROJECT_TARGET_UART_CHANNEL_USB_LINK, board::detail::usb::USB_OVER_SERIAL_BAUDRATE); diff --git a/src/firmware/board/src/common/io/indicators/App.cpp b/src/firmware/board/src/common/io/indicators/App.cpp index 1360535ba..ffc7d015b 100644 --- a/src/firmware/board/src/common/io/indicators/App.cpp +++ b/src/firmware/board/src/common/io/indicators/App.cpp @@ -22,7 +22,6 @@ limitations under the License. #include "board/Board.h" #include "Internal.h" #include "core/util/Util.h" -#include "core/Timing.h" #include #include "Indicators.h" @@ -49,9 +48,9 @@ namespace board::detail::io::indicators for (size_t flash = 0; flash < TOTAL_FLASHES; flash++) { ALL_INDICATORS_ON(); - core::timing::waitMs(LED_INDICATOR_STARTUP_DELAY); + core::mcu::timing::waitMs(LED_INDICATOR_STARTUP_DELAY); ALL_INDICATORS_OFF(); - core::timing::waitMs(LED_INDICATOR_STARTUP_DELAY); + core::mcu::timing::waitMs(LED_INDICATOR_STARTUP_DELAY); } } diff --git a/src/firmware/board/src/common/io/indicators/Boot.cpp b/src/firmware/board/src/common/io/indicators/Boot.cpp index 914551b5c..294e81312 100644 --- a/src/firmware/board/src/common/io/indicators/Boot.cpp +++ b/src/firmware/board/src/common/io/indicators/Boot.cpp @@ -22,7 +22,6 @@ limitations under the License. #include "board/Board.h" #include "Internal.h" #include "core/util/Util.h" -#include "core/Timing.h" #include #include "Indicators.h" diff --git a/src/firmware/bootloader/main.cpp b/src/firmware/bootloader/main.cpp index 4828d8c44..8bb633368 100644 --- a/src/firmware/bootloader/main.cpp +++ b/src/firmware/bootloader/main.cpp @@ -20,7 +20,7 @@ limitations under the License. #include "bootloader/updater/Updater.h" #include "SysExParser/SysExParser.h" #include "FwSelector/FwSelector.h" -#include "core/Timing.h" +#include "core/MCU.h" class BTLDRWriter : public Updater::BTLDRWriter { diff --git a/src/firmware/usb-link/main.cpp b/src/firmware/usb-link/main.cpp index 65abbb91d..976489554 100644 --- a/src/firmware/usb-link/main.cpp +++ b/src/firmware/usb-link/main.cpp @@ -17,7 +17,6 @@ limitations under the License. */ #include "board/Board.h" -#include "core/Timing.h" #include "core/MCU.h" #include "application/protocol/midi/MIDI.h" @@ -39,7 +38,7 @@ namespace static uint32_t lastCheckTime = 0; static bool lastConnectionState = false; - if (core::timing::ms() - lastCheckTime > USB_CONN_CHECK_TIME) + if (core::mcu::timing::ms() - lastCheckTime > USB_CONN_CHECK_TIME) { using namespace board; bool newState = usb::isUSBconnected(); @@ -60,7 +59,7 @@ namespace lastConnectionState = newState; } - lastCheckTime = core::timing::ms(); + lastCheckTime = core::mcu::timing::ms(); } } diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index effb68eb4..ed8721248 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -58,6 +58,7 @@ target_link_libraries(common lessdb-lib sysexconf-lib midi-lib + mcu ) if("PROJECT_MCU_USE_EMU_EEPROM" IN_LIST PROJECT_MCU_DEFINES) diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 927def81d..de558b750 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -1,5 +1,5 @@ #include "tests/Common.h" -#include "core/Timing.h" +#include "core/MCU.h" #include "application/util/logger/Logger.h" #ifdef APP_USE_LOGGER @@ -28,11 +28,6 @@ namespace } } // namespace -namespace core::timing::detail -{ - volatile uint32_t ms; -} // namespace core::timing::detail - int main(int argc, char* argv[]) { FLAGS_logtostderr = 1; diff --git a/tests/src/system/test.cpp b/tests/src/system/test.cpp index 5e0152d2f..4cd2c2c12 100644 --- a/tests/src/system/test.cpp +++ b/tests/src/system/test.cpp @@ -70,7 +70,7 @@ namespace { // preset change will be reported after PRESET_CHANGE_NOTIFY_DELAY ms // fake the passage of time here - core::timing::detail::ms = core::timing::detail::ms + sys::Instance::PRESET_CHANGE_NOTIFY_DELAY; + core::mcu::timing::setMs(core::mcu::timing::ms() + sys::Instance::PRESET_CHANGE_NOTIFY_DELAY); // clear out everything before running to parse with clean state _system._hwaMIDIUSB.clear();