1 /* 2 * Copyright (c) 2021 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef BUSY_SIM_H__ 7 #define BUSY_SIM_H__ 8 9 typedef void (*busy_sim_cb_t)(void); 10 11 /** 12 * @brief Start busy simulator. 13 * 14 * When started, it is using counter device to generate interrupts at random 15 * intervals and busy loop for random period of time in that interrupt. Interrupt 16 * source and priority is configured in the devicetree. Default entropy source 17 * is used for getting random numbers. System work queue is used to get random 18 * values and keep them in a ring buffer. 19 * 20 * @param active_avg Average time of busy looping in the counter callback (in microseconds). 21 * 22 * @param active_delta Specifies deviation from average time of busy looping (in microseconds). 23 * 24 * @param idle_avg Average time of counter alarm timeout (in microseconds). 25 * 26 * @param idle_delta Specifies deviation from average time of counter alarm (in microseconds). 27 * 28 * @param cb Callback called from the context of the busy simulator timeout. If ZLI interrupt 29 * is used for busy simulator counter then kernel API cannot be used from that callback. 30 * Callback is called before busy waiting. 31 */ 32 void busy_sim_start(uint32_t active_avg, uint32_t active_delta, 33 uint32_t idle_avg, uint32_t idle_delta, busy_sim_cb_t cb); 34 35 /** @brief Stop busy simulator. */ 36 void busy_sim_stop(void); 37 38 #endif /* BUSY_SIM_H__ */ 39