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