@@ -44,12 +44,11 @@ TEST_F(SchedulerTests, TaskRegistration) {
4444TEST_F (SchedulerTests, TaskExecutionShort) {
4545 Scheduler::register_task (10 ,&fake_workload);
4646 Scheduler::start ();
47- // TIM2_BASE->ARR = 500;
48- // TIM2_BASE->generate_update();
47+ TIM2_BASE->PSC = 2 ; // quicker test
4948
5049 constexpr int NUM_TICKS = 1'000 ;
5150 for (int i = 0 ; i < NUM_TICKS; i++){
52- TIM2_BASE->CNT ++ ;
51+ for ( int j = 0 ; j <= TIM2_BASE->PSC ; j++) TIM2_BASE-> inc_cnt_and_check ( 1 ) ;
5352 Scheduler::update ();
5453 }
5554 // 1000 ticks / 10 ticks/task = 100 executions.
@@ -61,10 +60,11 @@ TEST_F(SchedulerTests, TaskExecutionLong) {
6160 Scheduler::start ();
6261 // TIM2_BASE->ARR = 500;
6362 TIM2_BASE->generate_update ();
63+ TIM2_BASE->PSC = 2 ; // quicker test
6464
6565 constexpr int NUM_TICKS = 1'000'000 ;
6666 for (int i = 0 ; i < NUM_TICKS; i++){
67- TIM2_BASE->CNT ++ ;
67+ for ( int j = 0 ; j <= TIM2_BASE->PSC ; j++) TIM2_BASE-> inc_cnt_and_check ( 1 ) ;
6868 Scheduler::update ();
6969 }
7070 EXPECT_EQ (count, 100'000 );
@@ -73,10 +73,11 @@ TEST_F(SchedulerTests, TaskExecutionLong) {
7373TEST_F (SchedulerTests, SetTimeout) {
7474 Scheduler::set_timeout (10 , &fake_workload);
7575 Scheduler::start ();
76-
76+ TIM2_BASE->PSC = 2 ; // quicker test
77+
7778 constexpr int NUM_TICKS = 100 ;
7879 for (int i = 0 ; i < NUM_TICKS; i++){
79- TIM2_BASE->CNT ++ ;
80+ for ( int j = 0 ; j <= TIM2_BASE->PSC ; j++) TIM2_BASE-> inc_cnt_and_check ( 1 ) ;
8081 Scheduler::update ();
8182 }
8283 EXPECT_EQ (count, 1 );
@@ -86,10 +87,12 @@ TEST_F(SchedulerTests, GlobalTickOverflow) {
8687 Scheduler::global_tick_us_ = 0xFFFFFFF0ULL ; // Near 32-bit max
8788 Scheduler::register_task (20 , &fake_workload);
8889 Scheduler::start ();
89-
90+ TIM2_BASE->PSC = 2 ; // quicker test
91+
9092 constexpr int NUM_TICKS = 100 ;
9193 for (int i = 0 ; i < NUM_TICKS; i++){
92- TIM2_BASE->CNT ++;
94+ for (int j = 0 ; j <= TIM2_BASE->PSC ; j++) TIM2_BASE->inc_cnt_and_check (1 );
95+
9396 Scheduler::update ();
9497 }
9598 // 100 ticks /20 ticks/task = 5 executions.
@@ -99,10 +102,11 @@ TEST_F(SchedulerTests, GlobalTickOverflow) {
99102TEST_F (SchedulerTests, TimeoutClearAddTask) {
100103 uint8_t timeout_id = Scheduler::set_timeout (10 , &fake_workload);
101104 Scheduler::start ();
105+ TIM2_BASE->PSC = 2 ; // quicker test
102106
103107 constexpr int NUM_TICKS = 100 ;
104108 for (int i = 0 ; i < NUM_TICKS; i++) {
105- TIM2_BASE->CNT ++ ;
109+ for ( int j = 0 ; j <= TIM2_BASE->PSC ; j++) TIM2_BASE-> inc_cnt_and_check ( 1 ) ;
106110 Scheduler::update ();
107111 }
108112
@@ -135,10 +139,11 @@ TEST_F(SchedulerTests, TaskDe_ReRegistration) {
135139 uint8_t operational_task = 0 ;
136140 uint8_t fault_task = 0 ;
137141 Scheduler::start ();
142+ TIM2_BASE->PSC = 2 ; // quicker test
138143
139144 constexpr int NUM_TICKS = 100 ;
140145 for (int i = 0 ; i < NUM_TICKS; i++) {
141- TIM2_BASE->CNT ++ ;
146+ for ( int j = 0 ; j <= TIM2_BASE->PSC ; j++) TIM2_BASE-> inc_cnt_and_check ( 1 ) ;
142147 if (i == 21 ){
143148 Scheduler::unregister_task (connecting_task);
144149 operational_task = Scheduler::register_task (10 ,operational_cyclic);
0 commit comments