1 /*-----------------------------------------------------------------------------
3 * Purpose: CMSIS CORE validation tests implementation
4 *-----------------------------------------------------------------------------
5 * Copyright (c) 2017 ARM Limited. All rights reserved.
6 *----------------------------------------------------------------------------*/
8 #include "cmsis_compiler.h"
10 #include "CV_Framework.h"
13 /*-----------------------------------------------------------------------------
15 *----------------------------------------------------------------------------*/
17 /*-----------------------------------------------------------------------------
19 *----------------------------------------------------------------------------*/
22 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
23 void TC_GenTimer_CNTFRQ(void) {
24 const uint32_t cntfrq1 = __get_CNTFRQ();
25 __set_CNTFRQ(cntfrq1 + 1U);
26 const uint32_t cntfrq2 = __get_CNTFRQ();
28 ASSERT_TRUE((cntfrq1 + 1U) == cntfrq2);
30 __set_CNTFRQ(cntfrq1);
33 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
34 void TC_GenTimer_CNTP_TVAL(void) {
35 const uint32_t cntp_tval1 = __get_CNTP_TVAL();
36 __set_CNTP_TVAL(cntp_tval1 + 1U);
37 const uint32_t cntp_tval2 = __get_CNTP_TVAL();
39 ASSERT_TRUE((cntp_tval2 - cntp_tval1) >= 1ULL);
42 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
43 void TC_GenTimer_CNTP_CTL(void) {
44 static const uint32_t CNTP_CTL_ENABLE = 0x01U;
45 const uint32_t cntp_ctl = __get_CNTP_CTL();
46 const uint32_t cntp_ctl_toggled = (cntp_ctl & (~CNTP_CTL_ENABLE)) | ((~cntp_ctl) & CNTP_CTL_ENABLE);
47 __set_CNTP_CTL(cntp_ctl_toggled);
49 const uint32_t cntp_ctl_new = __get_CNTP_CTL();
51 ASSERT_TRUE((cntp_ctl_toggled & CNTP_CTL_ENABLE) == (cntp_ctl_new & CNTP_CTL_ENABLE));
53 __set_CNTP_CTL(cntp_ctl);
56 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
57 void TC_GenTimer_CNTPCT(void) {
58 const uint64_t cntpct1 = __get_CNTPCT();
59 for(int i=0; i<10; i++);
60 const uint64_t cntpct2 = __get_CNTPCT();
62 ASSERT_TRUE((cntpct2 - cntpct1) <= 120ULL);
65 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
66 void TC_GenTimer_CNTP_CVAL(void) {
67 const uint64_t cntp_cval1 = __get_CNTP_CVAL();
68 __set_CNTP_CVAL(cntp_cval1 + 1ULL);
69 const uint64_t cntp_cval2 = __get_CNTP_CVAL();
71 ASSERT_TRUE((cntp_cval2 - cntp_cval1) >= 1ULL);