1 /* 2 * Copyright (c) 2024, Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_DEBUG_CPU_LOAD_H_ 8 #define ZEPHYR_INCLUDE_DEBUG_CPU_LOAD_H_ 9 10 #include <stdbool.h> 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 /** @defgroup cpu_load CPU load monitor 17 * @ingroup os_services 18 * @brief Module for monitoring CPU Load 19 * 20 * This module allow monitoring of the CPU load. 21 * @{ 22 */ 23 24 /** @brief Hook called by the application specific hook on entering CPU idle. */ 25 void cpu_load_on_enter_idle(void); 26 27 /** @brief Hook called by the application specific hook on exiting CPU idle. */ 28 void cpu_load_on_exit_idle(void); 29 30 /** @brief Get CPU load. 31 * 32 * CPU load is measured using a timer which tracks amount of time spent in the 33 * CPU idle. Since it is a software tracking there is some small overhead. 34 * Precision depends on the frequency of the timer in relation to the CPU frequency. 35 * 36 * @param reset Reset the measurement after reading. 37 * 38 * @retval Positive number - CPU load in per mille. 39 * @retval Negative number - error code. 40 */ 41 int cpu_load_get(bool reset); 42 43 /** @brief Control periodic CPU statistics report. 44 * 45 * Report logging is by default enabled. 46 * 47 * @param enable true to enable report logging and false to disable. 48 */ 49 void cpu_load_log_control(bool enable); 50 51 /** 52 * @} 53 */ 54 55 #ifdef __cplusplus 56 } 57 #endif 58 59 60 #endif /* ZEPHYR_INCLUDE_DEBUG_CPU_LOAD_H_ */ 61