Skip to content

Commit

Permalink
update core module
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Oct 16, 2023
1 parent 904a7e9 commit d95a433
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 86 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/core
Submodule core updated from c9e166 to 15b4a4
8 changes: 5 additions & 3 deletions scripts/gen/gen_mcu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ then
exit 1
fi

echo "Generating project MCU definitions..."

source "$script_dir"/mcu/main.sh
if [[ $mcu != "stub" ]]
then
echo "Generating project MCU definitions..."
source "$script_dir"/mcu/main.sh
fi
4 changes: 3 additions & 1 deletion scripts/gen/mcu/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} \"\")"
Expand Down
4 changes: 2 additions & 2 deletions src/firmware/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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" "$<TARGET_FILE:application>.bin" "${SYSEXGEN_FW_NAME_RAW_SYSEX}"
)
Expand Down
6 changes: 3 additions & 3 deletions src/firmware/application/io/analog/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.

#include <stdio.h>
#include <stdlib.h>
#include "core/Timing.h"
#include "core/MCU.h"
#include "application/io/analog/Analog.h"
#include "core/util/Util.h"
#include "core/util/Filters.h"
Expand Down Expand Up @@ -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<uint32_t>(_lastStableValue[index]),
static_cast<uint32_t>(ADC_MIN_VALUE),
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/firmware/application/io/buttons/Buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions src/firmware/application/io/encoders/Encoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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++)
{
Expand Down
16 changes: 8 additions & 8 deletions src/firmware/application/io/i2c/peripherals/display/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -306,15 +306,15 @@ 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)
{
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<eventType_t>(i));
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/firmware/application/io/leds/LEDs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/firmware/application/io/touchscreen/Touchscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
#include <stdio.h>
#include <string.h>
#include "Nextion.h"
#include "core/Timing.h"
#include "core/MCU.h"
#include "application/io/touchscreen/Touchscreen.h"

using namespace io;
Expand All @@ -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");
Expand Down
9 changes: 4 additions & 5 deletions src/firmware/application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/firmware/application/protocol/midi/MIDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/firmware/application/system/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/firmware/application/util/cinfo/CInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<size_t>(block)]) > COMPONENT_INFO_TIMEOUT)
if ((core::mcu::timing::ms() - _lastCinfoMsgTime[static_cast<size_t>(block)]) > COMPONENT_INFO_TIMEOUT)
{
if (_handler != nullptr)
{
_handler(static_cast<size_t>(block), index);
}

_lastCinfoMsgTime[static_cast<size_t>(block)] = core::timing::ms();
_lastCinfoMsgTime[static_cast<size_t>(block)] = core::mcu::timing::ms();
}
}
6 changes: 3 additions & 3 deletions src/firmware/application/util/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
*/

#include "Scheduler.h"
#include "core/Timing.h"
#include "core/MCU.h"

using namespace util;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion src/firmware/board/src/arch/arm/common/NVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit d95a433

Please sign in to comment.