-
Notifications
You must be signed in to change notification settings - Fork 15
/
RV2_Kernel.c
709 lines (608 loc) · 22.6 KB
/
RV2_Kernel.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
/*
* Copyright (C) 2022 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cmsis_rv2.h"
/*-----------------------------------------------------------------------------
* Test implementation
*----------------------------------------------------------------------------*/
void Th_osKernelSuspend_1 (void *arg) __NO_RETURN;
void Th_osKernelResume_1 (void *arg) __NO_RETURN;
void Irq_osKernelInitialize (void);
void Irq_osKernelGetInfo (void);
void Irq_osKernelGetState (void);
void Irq_osKernelStart (void);
void Irq_osKernelLock (void);
void Irq_osKernelUnlock (void);
void Irq_osKernelRestoreLock (void);
void Irq_osKernelSuspend (void);
void Irq_osKernelResume (void);
void Irq_osKernelGetTickCount (void);
void Irq_osKernelGetTickFreq (void);
void Irq_osKernelGetSysTimerCount (void);
void Irq_osKernelGetSysTimerFreq (void);
/*-----------------------------------------------------------------------------
* Test cases
*----------------------------------------------------------------------------*/
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\defgroup kernel_funcs Kernel Functions
\brief Kernel Information and Control Test Cases
\details
The Kernel Information and Control function group in CMSIS-RTOS provides means for obtain information about the system, the
underlying kernel and the CMSIS-RTOS API. The test cases check the functions return values and calls from an ISR.
@{
*/
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelInitialize_1
\details
- Call osKernelInitialize when the kernel is already initialized
- Call osKernelInitialize from ISR
*/
void TC_osKernelInitialize_1 (void) {
#if (TC_OSKERNELINITIALIZE_1_EN)
/* Call osKernelInitialize when the kernel is already initialized */
ASSERT_TRUE (osKernelInitialize() == osError);
/* Call osKernelInitialize from ISR */
TST_IRQHandler = Irq_osKernelInitialize;
Isr_osStatus = osOK;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_osStatus == osErrorISR);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelInitialize_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELINITIALIZE_1_EN)
void Irq_osKernelInitialize (void) {
Isr_osStatus = osKernelInitialize();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetInfo_1
\details
- Call osKernelGetInfo and check that returned structures are populated
- Call osKernelGetInfo with argument version equal to NULL
- Call osKernelGetInfo with argument id_buf equal to NULL
- Call osKernelGetInfo with argument id_size equal to 0
- Call osKernelGetInfo from ISR
*/
void TC_osKernelGetInfo_1 (void) {
#if (TC_OSKERNELGETINFO_1_EN)
char id[100U];
osVersion_t os_version;
os_version.api = 0U;
os_version.kernel = 0U;
id[0] = '\0';
/* Call osKernelGetInfo and check that returned structures are populated */
ASSERT_TRUE (osKernelGetInfo(&os_version, id, sizeof(id)) == osOK);
ASSERT_TRUE (os_version.api != 0U);
ASSERT_TRUE (os_version.kernel != 0U);
ASSERT_TRUE (id[0] != '\0');
/* Call osKernelGetInfo with argument version equal to NULL */
id[0] = '\0';
ASSERT_TRUE (osKernelGetInfo(NULL, id, sizeof(id)) == osOK);
ASSERT_TRUE (id[0] != '\0');
/* Call osKernelGetInfo with argument id_buf equal to NULL */
os_version.api = 0U;
os_version.kernel = 0U;
ASSERT_TRUE (osKernelGetInfo(&os_version, NULL, sizeof(id)) == osOK);
ASSERT_TRUE (os_version.api != 0U);
ASSERT_TRUE (os_version.kernel != 0U);
/* Call osKernelGetInfo with argument id_size equal to 0 */
os_version.api = 0U;
os_version.kernel = 0U;
id[0] = '\0';
ASSERT_TRUE (osKernelGetInfo(&os_version, id, 0U) == osOK);
ASSERT_TRUE (os_version.api != 0U);
ASSERT_TRUE (os_version.kernel != 0U);
ASSERT_TRUE (id[0] == '\0');
/* Call osKernelGetInfo from ISR */
TST_IRQHandler = Irq_osKernelGetInfo;
Isr_osStatus = osError;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_osStatus == osOK);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelGetInfo_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELGETINFO_1_EN)
void Irq_osKernelGetInfo (void) {
char id[100U];
osVersion_t os_version;
os_version.api = 0U;
os_version.kernel = 0U;
id[0] = '\0';
Isr_osStatus = osKernelGetInfo (&os_version, id, sizeof(id));
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetState_1
\details
- Call osKernelGetState when the kernel is running
- Call osKernelGetState when the kernel is locked
- Call osKernelGetState after the kernel is unlocked
- Call osKernelGetState from ISR
*/
void TC_osKernelGetState_1 (void) {
#if (TC_OSKERNELGETSTATE_1_EN)
/* Call osKernelGetState when the kernel is running */
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Call osKernelGetState when the kernel is locked */
osKernelLock();
ASSERT_TRUE (osKernelGetState() == osKernelLocked);
/* Call osKernelGetState after the kernel is unlocked */
osKernelUnlock();
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Call osKernelGetState from ISR */
TST_IRQHandler = Irq_osKernelGetState;
Isr_osKernelState = osKernelError;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_osKernelState == osKernelRunning);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelGetState_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELGETSTATE_1_EN)
void Irq_osKernelGetState (void) {
Isr_osKernelState = osKernelGetState();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetState_2
\details
- Call osKernelGetState when the kernel is suspended
- Call osKernelGetState after resuming the kernel
*/
void TC_osKernelGetState_2 (void) {
#if (TC_OSKERNELGETSTATE_2_EN)
/* Call osKernelGetState when the kernel is suspended */
osKernelSuspend ();
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
/* Call osKernelGetState after resuming the kernel */
osKernelResume (0);
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
#endif
}
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelStart_1
\details
- Call osKernelStart when the kernel is already running
- Call osKernelStart from ISR
*/
void TC_osKernelStart_1 (void) {
#if (TC_OSKERNELSTART_1_EN)
/* Check the kernel is running */
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Call osKernelStart when the kernel is already running */
ASSERT_TRUE (osKernelStart() == osError);
/* Call osKernelStart from ISR */
TST_IRQHandler = Irq_osKernelStart;
Isr_osStatus = osOK;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_osStatus == osErrorISR);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelStart_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELSTART_1_EN)
void Irq_osKernelStart (void) {
Isr_osStatus = osKernelStart();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelLock_1
\details
- Call osKernelLock to try lock already locked kernel
- Call osKernelLock from ISR
*/
void TC_osKernelLock_1 (void) {
#if (TC_OSKERNELLOCK_1_EN)
/* Lock kernel */
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
ASSERT_TRUE (osKernelLock() == 0U);
ASSERT_TRUE (osKernelGetState() == osKernelLocked);
/* Call osKernelLock to try lock already locked kernel */
ASSERT_TRUE (osKernelLock() == 1U);
ASSERT_TRUE (osKernelGetState() == osKernelLocked);
/* Unlock kernel */
osKernelUnlock();
/* Call osKernelLock from ISR */
TST_IRQHandler = Irq_osKernelLock;
Isr_s32 = 0;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_s32 == (int32_t)osErrorISR);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelLock_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELLOCK_1_EN)
void Irq_osKernelLock (void) {
Isr_s32 = osKernelLock();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelLock_2
\details
- Call osKernelLock to try lock suspended kernel
*/
void TC_osKernelLock_2 (void) {
#if (TC_OSKERNELLOCK_2_EN)
/* Call osKernelLock to try lock suspended kernel */
osKernelSuspend ();
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
ASSERT_TRUE (osKernelLock() == osError);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
osKernelResume (0);
#endif
}
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelUnlock_1
\details
- Call osKernelUnlock to try unlock running kernel
- Call osKernelUnlock from ISR
*/
void TC_osKernelUnlock_1 (void) {
#if (TC_OSKERNELUNLOCK_1_EN)
/* Lock kernel */
osKernelLock();
/* Unlock kernel */
ASSERT_TRUE (osKernelGetState() == osKernelLocked);
ASSERT_TRUE (osKernelUnlock() == 1U);
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Call osKernelUnlock to try unlock running kernel */
ASSERT_TRUE (osKernelUnlock() == 0U);
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Call osKernelUnlock from ISR */
TST_IRQHandler = Irq_osKernelUnlock;
Isr_s32 = 0;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_s32 == (int32_t)osErrorISR);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelUnlock_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELUNLOCK_1_EN)
void Irq_osKernelUnlock (void) {
Isr_s32 = osKernelUnlock();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelUnlock_2
\details
- Call osKernelUnlock to try unlock suspended kernel
*/
void TC_osKernelUnlock_2 (void) {
#if (TC_OSKERNELUNLOCK_2_EN)
/* Call osKernelUnlock to try unlock suspended kernel */
osKernelSuspend ();
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
ASSERT_TRUE (osKernelUnlock() == osError);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
osKernelResume (0);
#endif
}
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelRestoreLock_1
\details
- Call osKernelRestoreLock to lock kernel
- Call osKernelRestoreLock to unlock kernel
- Call osKernelRestoreLock from ISR
*/
void TC_osKernelRestoreLock_1 (void) {
#if (TC_OSKERNELRESTORELOCK_1_EN)
/* Call osKernelRestoreLock to lock kernel */
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
ASSERT_TRUE (osKernelRestoreLock(1U) == 1U);
ASSERT_TRUE (osKernelGetState() == osKernelLocked);
/* Call osKernelRestoreLock to unlock kernel */
ASSERT_TRUE (osKernelRestoreLock(0U) == 0U);
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Call osKernelRestoreLock from ISR */
TST_IRQHandler = Irq_osKernelRestoreLock;
Isr_s32 = 0;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_s32 == (int32_t)osErrorISR);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelRestoreLock_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELRESTORELOCK_1_EN)
void Irq_osKernelRestoreLock (void) {
Isr_s32 = osKernelRestoreLock(0U);
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelSuspend_1
\details
- Call osKernelSuspend to suspend the kernel when no other RTOS objects are active
- Call osKernelSuspend when the kernel is already suspended
- Call osKernelSuspend to suspend the kernel with other RTOS objects active
- Call osKernelSuspend from ISR
*/
void TC_osKernelSuspend_1 (void) {
#if (TC_OSKERNELSUSPEND_1_EN)
osThreadAttr_t attr = { NULL, osThreadDetached, NULL, 0U, NULL, 0U, osPriorityAboveNormal, 0U, 0U};
osThreadId_t id;
uint32_t arg;
/* Call osKernelSuspend to suspend the kernel when no other RTOS objects are active */
ASSERT_TRUE (osKernelSuspend() == osWaitForever);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
/* Call osKernelSuspend when the kernel is already suspended */
ASSERT_TRUE (osKernelSuspend() == 0U);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
/* Resume the kernel */
osKernelResume(0U);
/* Create higher priority thread */
arg = 0U;
id = osThreadNew(Th_osKernelSuspend_1, &arg, &attr);
/* Call osKernelSuspend to suspend the kernel with other RTOS objects active */
ASSERT_TRUE (osKernelSuspend() == 50U);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
/* Check execution counter */
ASSERT_TRUE (arg == 1U);
/* Resume kernel */
osKernelResume(50U);
/* Check execution counter */
ASSERT_TRUE (arg > 1U);
/* Terminate the thread */
ASSERT_TRUE (osThreadTerminate (id) == osOK);
/* Call osKernelSuspend from ISR */
TST_IRQHandler = Irq_osKernelSuspend;
Isr_u32 = osWaitForever;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_u32 == 0U);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelSuspend_1: Helper thread
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELSUSPEND_1_EN)
void Th_osKernelSuspend_1 (void *arg) {
uint32_t *cnt = (uint32_t *)arg;
for (;;) {
/* Increment execution counter */
(*cnt)++;
/* Delay the thread for 50 ticks */
osDelay(50U);
}
}
#endif
/*-----------------------------------------------------------------------------
* TC_osKernelSuspend_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELSUSPEND_1_EN)
void Irq_osKernelSuspend (void) {
Isr_u32 = osKernelSuspend();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelResume_1
\details
- Call osKernelResume to resume suspended kernel
- Call osKernelResume from ISR
*/
void TC_osKernelResume_1 (void) {
#if (TC_OSKERNELRESUME_1_EN)
osThreadAttr_t attr = { NULL, osThreadDetached, NULL, 0U, NULL, 0U, osPriorityAboveNormal, 0U, 0U};
osThreadId_t id;
uint32_t arg;
uint32_t cnt;
/* Synchronize tick */
osDelay(1U);
/* Create a higher priority child thread that sets a variable and calls osDelay with 50 ticks */
arg = 0U;
id = osThreadNew(Th_osKernelResume_1, &arg, &attr);
ASSERT_TRUE (id != NULL);
ASSERT_TRUE (arg == 1U);
/* Suspend kernel and check its state */
ASSERT_TRUE (osKernelSuspend () == 50U);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
cnt = osKernelGetTickCount();
/* Call osKernelResume to resume suspended kernel */
osKernelResume(50U);
cnt = osKernelGetTickCount() - cnt;
ASSERT_TRUE (osKernelGetState() == osKernelRunning);
/* Check the tick count's difference */
ASSERT_TRUE (cnt == 50U);
/* Check whether child thread has been dispatched */
ASSERT_TRUE (arg == 2U);
/* Terminate the thread */
ASSERT_TRUE (osThreadTerminate (id) == osOK);
/* Suspend the kernel */
ASSERT_TRUE (osKernelSuspend () > 0U);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
/* Call osKernelResume from ISR */
TST_IRQHandler = Irq_osKernelResume;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (osKernelGetState() == osKernelSuspended);
/* Resume suspended kernel */
osKernelResume(0U);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelResume_1: Helper thread
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELRESUME_1_EN)
void Th_osKernelResume_1 (void *arg) {
uint32_t *cnt = (uint32_t *)arg;
for (;;) {
/* Increment execution counter */
(*cnt)++;
/* Delay the thread for 50 ticks */
osDelay(50U);
}
}
#endif
/*-----------------------------------------------------------------------------
* TC_osKernelResume_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELRESUME_1_EN)
void Irq_osKernelResume (void) {
osKernelResume(0U);
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetTickCount_1
\details
- Call osKernelGetTickCount and check that returned value is non-zero
- Call osKernelGetTickCount twice with an osDelay of 100 ticks in between
- Call osKernelGetTickCount from ISR
*/
void TC_osKernelGetTickCount_1 (void) {
#if (TC_OSKERNELGETTICKCOUNT_EN)
uint32_t cnt;
/* Synchronize tick */
osDelay(1U);
/* Call osKernelGetTickCount and check that returned value is non-zero */
ASSERT_TRUE (osKernelGetTickCount() > 0U);
/* Synchronize tick */
osDelay(1U);
/* Call osKernelGetTickCount twice with an osDelay of 100 ticks in between */
cnt = osKernelGetTickCount();
osDelay(100U);
cnt = osKernelGetTickCount() - cnt;
ASSERT_TRUE (cnt == 100U);
/* Call osKernelGetTickCount from ISR */
TST_IRQHandler = Irq_osKernelGetTickCount;
Isr_u32 = 0U;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_u32 > 0);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelGetTickCount_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELGETTICKCOUNT_EN)
void Irq_osKernelGetTickCount (void) {
Isr_u32 = osKernelGetTickCount();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetTickFreq_1
\details
- Call osKernelGetTickFreq and check that returned value is non-zero
- Call osKernelGetTickFreq and check that returned value equals to predefine tick frequency
- Call osKernelGetTickFreq from ISR
*/
void TC_osKernelGetTickFreq_1 (void) {
#if (TC_OSKERNELGETTICKFREQ_EN)
/* Call osKernelGetTickFreq and check that returned value is non-zero */
ASSERT_TRUE (osKernelGetTickFreq() > 0U);
/* Call osKernelGetTickFreq and check that returned value equals to predefine tick frequency */
ASSERT_TRUE (osKernelGetTickFreq() == RTOS2_TICK_FREQ);
/* Call osKernelGetTickFreq from ISR */
TST_IRQHandler = Irq_osKernelGetTickFreq;
Isr_u32 = 0U;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_u32 > 0);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelGetTickFreq_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELGETTICKFREQ_EN)
void Irq_osKernelGetTickFreq (void) {
Isr_u32 = osKernelGetTickFreq();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetSysTimerCount_1
\details
- Call osKernelGetSysTimerCount and check that returned value is non-zero
- Call osKernelGetSysTimerCount twice with an osDelay of 100 ticks in between
- Call osKernelGetSysTimerCount from ISR
*/
void TC_osKernelGetSysTimerCount_1 (void) {
#if (TC_OSKERNELGETSYSTIMERCOUNT_EN)
uint32_t cnt;
/* Synchronize tick */
osDelay(1U);
/* Call osKernelGetSysTimerCount and check that returned value is non-zero */
ASSERT_TRUE (osKernelGetSysTimerCount() > 0);
/* Call osKernelGetSysTimerCount twice with an osDelay of 100 ticks in between */
cnt = osKernelGetSysTimerCount();
osDelay(100U);
cnt = osKernelGetSysTimerCount() - cnt;
cnt /= (osKernelGetSysTimerFreq()/RTOS2_TICK_FREQ);
ASSERT_TRUE (cnt >= 99U);
ASSERT_TRUE (cnt <= 101U);
/* Call osKernelGetSysTimerCount from ISR */
TST_IRQHandler = Irq_osKernelGetSysTimerCount;
Isr_u32 = 0U;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_u32 > 0);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelGetSysTimerCount_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELGETSYSTIMERCOUNT_EN)
void Irq_osKernelGetSysTimerCount (void) {
Isr_u32 = osKernelGetSysTimerCount();
}
#endif
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\brief Test case: TC_osKernelGetSysTimerFreq_1
\details
- Call osKernelGetSysTimerFreq and check that returned value is non-zero
- Call osKernelGetSysTimerFreq from ISR
*/
void TC_osKernelGetSysTimerFreq_1 (void) {
#if (TC_OSKERNELGETSYSTIMERFREQ_EN)
/* Call osKernelGetSysTimerFreq and check that returned value is non-zero */
ASSERT_TRUE (osKernelGetSysTimerFreq() > 0U);
/* Call osKernelGetSysTimerFreq from ISR */
TST_IRQHandler = Irq_osKernelGetSysTimerFreq;
Isr_u32 = 0U;
SetPendingIRQ(IRQ_A);
ASSERT_TRUE (Isr_u32 > 0);
#endif
}
/*-----------------------------------------------------------------------------
* TC_osKernelGetSysTimerFreq_1: ISR handler
*----------------------------------------------------------------------------*/
#if (TC_OSKERNELGETSYSTIMERFREQ_EN)
void Irq_osKernelGetSysTimerFreq (void) {
Isr_u32 = osKernelGetSysTimerFreq();
}
#endif
/**
@}
*/
// end of group genwait_funcs