1 /* 2 * Copyright (c) 2019-2021, Arm Limited. All rights reserved. 3 * Copyright (c) 2020 Nuvoton Technology Corp. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 */ 8 9 #include "timer_cmsdk_drv.h" 10 #include "tfm_plat_defs.h" 11 #include "tfm_plat_test.h" 12 #include "device_definition.h" 13 14 #define TIMER_RELOAD_VALUE (12000000) 15 tfm_plat_test_non_secure_timer_start(void)16void tfm_plat_test_non_secure_timer_start(void) 17 { 18 if(!timer_cmsdk_is_initialized(&CMSDK_TIMER2_DEV_NS)) { 19 timer_cmsdk_init(&CMSDK_TIMER2_DEV_NS); 20 } 21 22 timer_cmsdk_set_reload_value(&CMSDK_TIMER2_DEV_NS, TIMER_RELOAD_VALUE); 23 timer_cmsdk_enable(&CMSDK_TIMER2_DEV_NS); 24 timer_cmsdk_enable_interrupt(&CMSDK_TIMER2_DEV_NS); 25 } 26 tfm_plat_test_non_secure_timer_stop(void)27void tfm_plat_test_non_secure_timer_stop(void) 28 { 29 timer_cmsdk_disable(&CMSDK_TIMER2_DEV_NS); 30 timer_cmsdk_disable_interrupt(&CMSDK_TIMER2_DEV_NS); 31 timer_cmsdk_clear_interrupt(&CMSDK_TIMER2_DEV_NS); 32 } 33 tfm_plat_test_secure_timer_start(void)34void tfm_plat_test_secure_timer_start(void) 35 { 36 if (!timer_cmsdk_is_initialized(&CMSDK_TIMER0_DEV_S)) { 37 timer_cmsdk_init(&CMSDK_TIMER0_DEV_S); 38 } 39 timer_cmsdk_set_reload_value(&CMSDK_TIMER0_DEV_S, TIMER_RELOAD_VALUE); 40 timer_cmsdk_enable(&CMSDK_TIMER0_DEV_S); 41 timer_cmsdk_enable_interrupt(&CMSDK_TIMER0_DEV_S); 42 } 43 tfm_plat_test_secure_timer_stop(void)44void tfm_plat_test_secure_timer_stop(void) 45 { 46 timer_cmsdk_disable(&CMSDK_TIMER0_DEV_S); 47 timer_cmsdk_disable_interrupt(&CMSDK_TIMER0_DEV_S); 48 timer_cmsdk_clear_interrupt(&CMSDK_TIMER0_DEV_S); 49 } 50