Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed_stats.h
00001 00002 /** \addtogroup platform */ 00003 /** @{*/ 00004 /** 00005 * \defgroup platform_stats stats functions 00006 * @{ 00007 */ 00008 /* mbed Microcontroller Library 00009 * Copyright (c) 2016-2016 ARM Limited 00010 * 00011 * Licensed under the Apache License, Version 2.0 (the "License"); 00012 * you may not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at 00014 * 00015 * http://www.apache.org/licenses/LICENSE-2.0 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, 00019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 */ 00023 #ifndef MBED_STATS_H 00024 #define MBED_STATS_H 00025 #include <stdint.h> 00026 #include <stddef.h> 00027 #include "hal/ticker_api.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #ifdef MBED_ALL_STATS_ENABLED 00034 #define MBED_SYS_STATS_ENABLED 1 00035 #define MBED_STACK_STATS_ENABLED 1 00036 #define MBED_CPU_STATS_ENABLED 1 00037 #define MBED_HEAP_STATS_ENABLED 1 00038 #define MBED_THREAD_STATS_ENABLED 1 00039 #endif 00040 00041 /** 00042 * struct mbed_stats_heap_t definition 00043 */ 00044 typedef struct { 00045 uint32_t current_size; /**< Bytes allocated currently. */ 00046 uint32_t max_size; /**< Max bytes allocated at a given time. */ 00047 uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */ 00048 uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */ 00049 uint32_t alloc_cnt; /**< Current number of allocations. */ 00050 uint32_t alloc_fail_cnt; /**< Number of failed allocations. */ 00051 } mbed_stats_heap_t; 00052 00053 /** 00054 * Fill the passed in heap stat structure with heap stats. 00055 * 00056 * @param stats A pointer to the mbed_stats_heap_t structure to fill 00057 */ 00058 void mbed_stats_heap_get(mbed_stats_heap_t *stats); 00059 00060 /** 00061 * struct mbed_stats_stack_t definition 00062 */ 00063 typedef struct { 00064 uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */ 00065 uint32_t max_size; /**< Maximum number of bytes used on the stack. */ 00066 uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */ 00067 uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */ 00068 } mbed_stats_stack_t; 00069 00070 /** 00071 * Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0 00072 * and stack_cnt will represent number of threads. 00073 * 00074 * @param stats A pointer to the mbed_stats_stack_t structure to fill 00075 */ 00076 void mbed_stats_stack_get(mbed_stats_stack_t *stats); 00077 00078 /** 00079 * Fill the passed array of stat structures with the stack stats for each available thread. 00080 * 00081 * @param stats A pointer to an array of mbed_stats_stack_t structures to fill 00082 * @param count The number of mbed_stats_stack_t structures in the provided array 00083 * @return The number of mbed_stats_stack_t structures that have been filled, 00084 * this is equal to the number of stacks on the system. 00085 */ 00086 size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count); 00087 00088 /** 00089 * struct mbed_stats_cpu_t definition 00090 */ 00091 typedef struct { 00092 us_timestamp_t uptime; /**< Time since system is up and running */ 00093 us_timestamp_t idle_time; /**< Time spent in idle thread since system is up and running */ 00094 us_timestamp_t sleep_time; /**< Time spent in sleep since system is up and running */ 00095 us_timestamp_t deep_sleep_time; /**< Time spent in deep sleep since system is up and running */ 00096 } mbed_stats_cpu_t; 00097 00098 /** 00099 * Fill the passed in CPU stat structure with CPU statistics. 00100 * 00101 * @param stats A pointer to the mbed_stats_cpu_t structure to fill 00102 */ 00103 void mbed_stats_cpu_get(mbed_stats_cpu_t *stats); 00104 00105 /** 00106 * struct mbed_stats_thread_t definition 00107 */ 00108 typedef struct { 00109 uint32_t id; /**< Thread Object Identifier */ 00110 uint32_t state; /**< Thread Object State */ 00111 uint32_t priority; /**< Thread Priority */ 00112 uint32_t stack_size; /**< Thread Stack Size */ 00113 uint32_t stack_space; /**< Thread remaining stack size */ 00114 const char *name; /**< Thread Object name */ 00115 } mbed_stats_thread_t; 00116 00117 /** 00118 * Fill the passed array of stat structures with the thread stats for each available thread. 00119 * 00120 * @param stats A pointer to an array of mbed_stats_thread_t structures to fill 00121 * @param count The number of mbed_stats_thread_t structures in the provided array 00122 * @return The number of mbed_stats_thread_t structures that have been filled, 00123 * this is equal to the number of threads on the system. 00124 */ 00125 size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count); 00126 00127 /** 00128 * enum mbed_compiler_id_t definition 00129 */ 00130 typedef enum { 00131 ARM = 1, /**< ARM */ 00132 GCC_ARM, /**< GNU ARM */ 00133 IAR /**< IAR */ 00134 } mbed_compiler_id_t; 00135 00136 /** 00137 * struct mbed_stats_sys_t definition 00138 */ 00139 typedef struct { 00140 uint32_t os_version; /**< Mbed OS Version (Release only) */ 00141 uint32_t cpu_id; /**< CPUID Register data (Cortex-M only supported) */ 00142 mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */ 00143 uint32_t compiler_version; /**< Compiler version */ 00144 } mbed_stats_sys_t; 00145 00146 /** 00147 * Fill the passed in sys stat structure with system stats. 00148 * 00149 * @param stats A pointer to the mbed_stats_sys_t structure to fill 00150 */ 00151 void mbed_stats_sys_get(mbed_stats_sys_t *stats); 00152 00153 #ifdef __cplusplus 00154 } 00155 #endif 00156 00157 #endif 00158 00159 /** @}*/ 00160 00161 /** @}*/
Generated on Tue Jul 12 2022 12:45:30 by
1.7.2