Skip to content

Commit f62d715

Browse files
victor-Lopez25g0nz4I0jorgesg82StefanCostea
authored
Feat/TimerDomain (#547)
* feat: add DSB and ISB intructions in x86_64 * feat: add NVIC * add NVIC logic * feat: use NVIC and remove print * fix: move extern"C" block to allow using <iostream> * add Register class to allow for side effects * feat: use newly created Register class for side effects, neat trick in CNT write * feat: be as realistic as possible in test, by using CNT++ * feat: remove unnecessary include * feat: add an __RBIT impl for x86_64 * fix: compilation * fix: used_bitmap_ -> free_bitmap_ * Added tests check in CI/CD * fix(ci/cd): output folder * Added ARM specific instructions to be able to compile in ARM hosts (Mac) * Fix: compiler barrier for msvc, hopefully works * Fix: Try to fix -Wchanges-meaning warning * Fix typo * Update Inc/MockedDrivers/common.hpp #534 (comment) Co-authored-by: Jorge Sáez <125664643+jorgesg82@users.noreply.github.com> * Actually do the change github didn't do :/ * Fix typo p2 * Fix another typo * Fix unsigned long - 64bit when testing using LL functions * Minor fixes to scheduler Rebased from remotes/origin/MockTim * Fix: uint32_t* cast of a word instead of the ptr * Fix: remove active_task_count_ decrement in pop_front() #534 (comment) * Try fix Wstrict-aliasing in front_id * Try fix Wstrict-aliasing again * Fix typo in allocate_slot * fix: test UsedBitmap -> FreeBitmap * used_bitmap_ -> free_bitmap_ in test part 2 * fixed tests discovery * fix: set_timeout() test * Add a test, fix the error (kind of) * Fix: underflow in schedule_next_interval * Fix: call schedule_next_interval() in start() * Fix: invert condition, that was stupid * feat: add test showcasing possible usage within StateMachine logic * fix: Calculate correct prescaler & add to HALAL.hpp * Try to fix tests * try to fix tests part 2 * Try to fix tests part 3 * part 4 - add the wrapper.c to cmake, will this work? * part 5 - fix cmake stm32h723xx_wrapper.c path * fix: try to fix tests part 6 * fix: volatile warnings * fix: active_PSC is now set when PSC is set * fix: remove outdated comment * fix: tests part 7, should work now * fix: remove unecessary if, return if cancelled in cancel_timeout * Pop all due tasks, several might be due in the same tick * Revert force-push * fix: off by one error + configure_timer_for_interval should use uint32_t * fix: off by one error in schedule_next_interval() * All 15 tasks in MultipleTasks test, and it works * Add SameTaskMultipleTimes test, does all 16 tasks too * larger NUM_TICKS just in case * fix bug mentioned in previous cancel_timeout() * fix: id uint32_t -> uint16_t + bug fix * fix: remove TimerPeripheral::start and Time::start from HALAL::start * try to fix ci/cd * try to fix ci/cd part 2 * try to fix ci/cd part 3 * clean up ci/cd fix * Remove unnecessary warning ignore * fix: use wrapper instead of interface for stm32h7xx_ll_tim.h * fix ci/cd and add the other submodule to be automatically added * fix: actually add stm32h7xx_ll_tim_wrapper.h * try to fix ci/cd warning * try fix warnings again * fix: add ignore Woverflow to stm32h7xx_ll_tim * fix: remove need to ignore Woverflow warnings * fix: Remove tim_register_definitions.hpp We're already including them in stm32h723xx_wrapper * Initial TimerDomain commit, lots of work to do... * Change name to TimerDomain.hpp in comment * feat: Implement getting AnyGeneralPurpose timer with priorities * Make prettier * Remove leftovers * Remove outdated comment * fix: Finish the comment :) * Clean up error messages, add comment * temp: setup to try to compile template_project * Try to get TimerDomain to compile * Add initial implementation of scheduler * Try to fix -Wuninitialized warning * Try to remove Wuninitialized warning temporarily * Remove unnecessary clear of task element * fix: Readability and todo for validation * fix: allocate_slot * Add explenation of sorted_task_ids_, static_assert for the bitmaps * Remove long_wait_remaining_us_ * fix: better get_at * fix: better front_id Compiler would've probably optimized it but it's better to make it explicit * fix: endianness in pop_front * Added unlikely to release_slot conditional * fix: Correct comment explenation * No bit field insert, it annoyed me * No more diagnostic ignore * fix: loss in accuracy by not adding 1: #534 (comment) * fix: Moved active_task_count_ modification * Actually set used_bitmap_ in allocate_slot * fix: used_bitmap_ -> free_bitmap_ * only include sources when cross-compiling * modify CMakeLists inside Tests * feat: use ugly ifdef guards for host testing purposes * add sample tests for Scheduler * add emulated ticking * test for execution count * fix: CI * fix: expected result in test case + explanation * add compiler specific and CoreMacros * copy files from LL and CMSIS for TIM Registers * bridge between LL MMIO Timer and user defined TIMER * reduce the number of ugly macros * compile the new mock file * update test * enable debugging of tests with TestMate C++ extension * feat: add DSB and ISB intructions in x86_64 * feat: add NVIC * add NVIC logic * feat: use NVIC and remove print * fix: move extern"C" block to allow using <iostream> * add Register class to allow for side effects * feat: use newly created Register class for side effects, neat trick in CNT write * feat: be as realistic as possible in test, by using CNT++ * feat: remove unnecessary include * feat: add an __RBIT impl for x86_64 * fix: compilation * Added tests check in CI/CD * fix(ci/cd): output folder * Added ARM specific instructions to be able to compile in ARM hosts (Mac) * Fix: compiler barrier for msvc, hopefully works * Fix: Try to fix -Wchanges-meaning warning * Fix typo * Update Inc/MockedDrivers/common.hpp #534 (comment) Co-authored-by: Jorge Sáez <125664643+jorgesg82@users.noreply.github.com> * Actually do the change github didn't do :/ * Fix typo p2 * Fix another typo * Fix unsigned long - 64bit when testing using LL functions * Fix: uint32_t* cast of a word instead of the ptr * Minor fixes to scheduler Rebased from remotes/origin/MockTim * Fix: remove active_task_count_ decrement in pop_front() #534 (comment) * Try fix Wstrict-aliasing in front_id * Try fix Wstrict-aliasing again * Fix typo in allocate_slot * fix: test UsedBitmap -> FreeBitmap * used_bitmap_ -> free_bitmap_ in test part 2 * fixed tests discovery * fix: set_timeout() test * Add a test, fix the error (kind of) * Fix: underflow in schedule_next_interval * Fix: call schedule_next_interval() in start() * Fix: invert condition, that was stupid * feat: add test showcasing possible usage within StateMachine logic * fix: Calculate correct prescaler & add to HALAL.hpp * Try to fix tests * try to fix tests part 2 * Try to fix tests part 3 * part 4 - add the wrapper.c to cmake, will this work? * part 5 - fix cmake stm32h723xx_wrapper.c path * fix: try to fix tests part 6 * fix: volatile warnings * fix: active_PSC is now set when PSC is set * fix: remove outdated comment * fix: tests part 7, should work now * fix: remove unecessary if, return if cancelled in cancel_timeout * Pop all due tasks, several might be due in the same tick * Revert force-push * fix: off by one error + configure_timer_for_interval should use uint32_t * fix: off by one error in schedule_next_interval() * All 15 tasks in MultipleTasks test, and it works * Add SameTaskMultipleTimes test, does all 16 tasks too * larger NUM_TICKS just in case * fix bug mentioned in previous cancel_timeout() * fix: id uint32_t -> uint16_t + bug fix * fix: remove TimerPeripheral::start and Time::start from HALAL::start * try to fix ci/cd * try to fix ci/cd part 2 * try to fix ci/cd part 3 * clean up ci/cd fix * Remove unnecessary warning ignore * fix: use wrapper instead of interface for stm32h7xx_ll_tim.h * fix ci/cd and add the other submodule to be automatically added * fix: actually add stm32h7xx_ll_tim_wrapper.h * try to fix ci/cd warning * try fix warnings again * fix: add ignore Woverflow to stm32h7xx_ll_tim * fix: remove need to ignore Woverflow warnings * fix: Remove tim_register_definitions.hpp We're already including them in stm32h723xx_wrapper * Initial TimerDomain commit, lots of work to do... * Change name to TimerDomain.hpp in comment * feat: Implement getting AnyGeneralPurpose timer with priorities * Make prettier * Remove leftovers * Remove outdated comment * fix: Finish the comment :) * Clean up error messages, add comment * temp: setup to try to compile template_project * Try to get TimerDomain to compile * Fix all compilation errors (yipee) * Try to fix compile errors when in template_project * Try to fix compile errors... Goodbye ErrorInRequestN I thought it could be used T-T * try fix again * slowly but surely * Fix TimerWrapper constructor * Add timer interrupt callbacks, use XList for TIM_HandleTypeDef definitions * try to choose 16 bit or 32 bit at compile time * Fix compilation issues * Fix overflow calculation and a test * Fix all remaining issues * Change TimerRequest values * Remove temporary function * fix: Remove static assert * fix: Change order of parameters * fix: timer 15 (hopefully?) * fix: Rollback removal of tim15 when getting AnyGeneralPurpose timer * fix: pins are now part of TimerWrapper, not TimerDomain * fix: Split TimerWrapper into a different file: TimerWrapper.hpp * fix: Use new way to add Domain to board * feat: Initial implementation of new PWM class * fix: Make PWM class more private * feat: Use an initializer_list to get the pins without needing a size * fix: Remove prescaler and period from TimerDomain * feat: Add Any32bitTimer to TimerDomain * fix: Rename Any32bitTimer to Any32bit * Fix docker build hopefully * feat: add a macro: get_timer_instance * fix: compile error * fix: revert change to .vscode settings * fix: tim3 is 16 bit, tim5 is 32 bit + start of pin af checking * More timer pin afs * More pins, todo: tim23 and tim24 * tim23, tim24 pins done, now programming time * next step: compile time check_pins * feat: Finish implementing check_pins * Add tests for TimerWrapper, not running them yet * Almost implement all wrappers for TimerDomain tests * Add TimerDomain.cpp to simulator * Further fix compile errors * Fix tests compilation! * NVIC ICER now clears the bit in NVIC ISER --------- Co-authored-by: Gonzalo Sánchez <gonzalosmoya24@gmail.com> Co-authored-by: Jorge Sáez <jorgeesg82@gmail.com> Co-authored-by: Jorge Sáez <125664643+jorgesg82@users.noreply.github.com> Co-authored-by: StefanCostea <stefanxenadu@gmail.com>
1 parent 64ace7d commit f62d715

25 files changed

Lines changed: 1695 additions & 71 deletions

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN apt-get update && apt-get -y install git git-lfs python3-colorama cmake g++
77
git lfs install
88

99
# Install cubeclt
10-
RUN mkdir /temp && cd /temp && git clone https://github.com/HyperloopUPV-H8/cubeclt.git && \
10+
RUN mkdir /temp && cd /temp && git clone https://github.com/Hyperloop-UPV/cubeclt.git && \
1111
cd cubeclt && git lfs pull && chmod +x cubeclt_1.16.0_installer.sh && \
1212
echo | LICENSE_ALREADY_ACCEPTED=1 ./cubeclt_1.16.0_installer.sh

.vscode/settings.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"C_Cpp.clang_format_sortIncludes": true,
88
"C_Cpp.intelliSenseCacheSize": 0,
99
"files.associations": {
10-
"mem.h": "c",
11-
"tinydir.h": "c",
12-
"dirent.h": "c"
10+
"*.embeddedhtml": "html",
11+
"mem.h": "c",
12+
"tinydir.h": "c",
13+
"dirent.h": "c",
14+
"initializer_list": "cpp"
1315
}
14-
}
16+
}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ add_library(${STLIB_LIBRARY} STATIC
242242
$<$<BOOL:${CMAKE_CROSSCOMPILING}>:${CMAKE_CURRENT_LIST_DIR}/Src/ST-LIB.cpp>
243243

244244
$<$<NOT:$<BOOL:${CMAKE_CROSSCOMPILING}>>:${CMAKE_CURRENT_LIST_DIR}/Src/HALAL/Services/Time/Scheduler.cpp>
245+
$<$<NOT:$<BOOL:${CMAKE_CROSSCOMPILING}>>:${CMAKE_CURRENT_LIST_DIR}/Src/HALAL/Models/TimerDomain/TimerDomain.cpp>
245246
$<$<NOT:$<BOOL:${CMAKE_CROSSCOMPILING}>>:${CMAKE_CURRENT_LIST_DIR}/Src/MockedDrivers/mocked_ll_tim.cpp>
246247
$<$<NOT:$<BOOL:${CMAKE_CROSSCOMPILING}>>:${CMAKE_CURRENT_LIST_DIR}/Src/MockedDrivers/mocked_system_stm32h7xx.c>
247248
$<$<NOT:$<BOOL:${CMAKE_CROSSCOMPILING}>>:${CMAKE_CURRENT_LIST_DIR}/Src/MockedDrivers/stm32h723xx_wrapper.c>

Inc/HALAL/HALAL.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "HALAL/Services/PWM/PhasedPWM/PhasedPWM.hpp"
2121
#include "HALAL/Services/PWM/DualPhasedPWM/DualPhasedPWM.hpp"
2222

23-
#include "HALAL/Services/Time/Time.hpp"
23+
#include "HALAL/Services/Time/TimerWrapper.hpp"
2424
#include "HALAL/Services/Time/Scheduler.hpp"
2525
#include "HALAL/Services/Time/RTC.hpp"
2626

@@ -40,8 +40,6 @@
4040
#include "HALAL/Services/InfoWarning/InfoWarning.hpp"
4141
#include "HALAL/Services/Watchdog/Watchdog.hpp"
4242

43-
#include "HALAL/Models/TimerPeripheral/TimerPeripheral.hpp"
44-
4543
#include "HALAL/Models/BoardID/BoardID.hpp"
4644
#include "HALAL/Models/Concepts/Concepts.hpp"
4745

Inc/HALAL/Models/PinModel/Pin.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct hash<Pin> {
112112
using std::string;
113113

114114
return ((hash<uint16_t>()(k.gpio_pin) ^
115-
(hash<uint32_t>()((uint32_t)(k.port)) << 1)) >>
115+
(hash<uint32_t>()((size_t)(k.port)) << 1)) >>
116116
1);
117117
}
118118
};

0 commit comments

Comments
 (0)