1 /* 2 * Copyright (c) 2017 Oticon A/S 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * This is a fake HW device model which is used by the k_busy_wait() function 9 * replacement. It is a timer which will awake the CPU even if interrupts are 10 * locked (it does not have an associated irq vector, it simply awakes the CPU) 11 */ 12 13 #include "bs_types.h" 14 #include "irq_ctrl.h" 15 #include "NRF_HW_model_top.h" 16 17 bs_time_t Timer_fake_timer = TIME_NEVER; 18 fake_timer_init()19void fake_timer_init() 20 { 21 Timer_fake_timer = TIME_NEVER; 22 } 23 fake_timer_cleanup(void)24void fake_timer_cleanup(void) 25 { 26 27 } 28 29 /** 30 * The timer HW will awake the CPU (without an interrupt) at least when <time> 31 * comes (it may awake it earlier) 32 * 33 * If there was a previous request for an earlier time, the old one will prevail 34 * 35 * This is meant for k_busy_wait() like functionality 36 */ fake_timer_wake_in_time(bs_time_t time)37void fake_timer_wake_in_time(bs_time_t time) 38 { 39 if (Timer_fake_timer > time) { 40 Timer_fake_timer = time; 41 nrf_hw_find_next_timer_to_trigger(); 42 } 43 } 44 fake_timer_triggered(void)45void fake_timer_triggered(void) 46 { 47 Timer_fake_timer = TIME_NEVER; 48 nrf_hw_find_next_timer_to_trigger(); 49 hw_irq_ctrl_set_irq(PHONY_HARD_IRQ); 50 } 51