![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/platform/mbed_stats.h@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | |
kadonotakashi | 0:8fdf9a60065b | 2 | /** \addtogroup platform */ |
kadonotakashi | 0:8fdf9a60065b | 3 | /** @{*/ |
kadonotakashi | 0:8fdf9a60065b | 4 | /** |
kadonotakashi | 0:8fdf9a60065b | 5 | * \defgroup platform_stats stats functions |
kadonotakashi | 0:8fdf9a60065b | 6 | * @{ |
kadonotakashi | 0:8fdf9a60065b | 7 | */ |
kadonotakashi | 0:8fdf9a60065b | 8 | /* mbed Microcontroller Library |
kadonotakashi | 0:8fdf9a60065b | 9 | * Copyright (c) 2016-2018 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 10 | * |
kadonotakashi | 0:8fdf9a60065b | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 12 | * you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 13 | * You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 14 | * |
kadonotakashi | 0:8fdf9a60065b | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 16 | * |
kadonotakashi | 0:8fdf9a60065b | 17 | * Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 20 | * See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 21 | * limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 22 | */ |
kadonotakashi | 0:8fdf9a60065b | 23 | #ifndef MBED_STATS_H |
kadonotakashi | 0:8fdf9a60065b | 24 | #define MBED_STATS_H |
kadonotakashi | 0:8fdf9a60065b | 25 | #include <stdint.h> |
kadonotakashi | 0:8fdf9a60065b | 26 | #include <stddef.h> |
kadonotakashi | 0:8fdf9a60065b | 27 | #include "hal/ticker_api.h" |
kadonotakashi | 0:8fdf9a60065b | 28 | |
kadonotakashi | 0:8fdf9a60065b | 29 | #ifdef __cplusplus |
kadonotakashi | 0:8fdf9a60065b | 30 | extern "C" { |
kadonotakashi | 0:8fdf9a60065b | 31 | #endif |
kadonotakashi | 0:8fdf9a60065b | 32 | |
kadonotakashi | 0:8fdf9a60065b | 33 | #ifdef MBED_ALL_STATS_ENABLED |
kadonotakashi | 0:8fdf9a60065b | 34 | #define MBED_SYS_STATS_ENABLED 1 |
kadonotakashi | 0:8fdf9a60065b | 35 | #define MBED_STACK_STATS_ENABLED 1 |
kadonotakashi | 0:8fdf9a60065b | 36 | #define MBED_CPU_STATS_ENABLED 1 |
kadonotakashi | 0:8fdf9a60065b | 37 | #define MBED_HEAP_STATS_ENABLED 1 |
kadonotakashi | 0:8fdf9a60065b | 38 | #define MBED_THREAD_STATS_ENABLED 1 |
kadonotakashi | 0:8fdf9a60065b | 39 | #endif |
kadonotakashi | 0:8fdf9a60065b | 40 | |
kadonotakashi | 0:8fdf9a60065b | 41 | /** |
kadonotakashi | 0:8fdf9a60065b | 42 | * struct mbed_stats_heap_t definition |
kadonotakashi | 0:8fdf9a60065b | 43 | */ |
kadonotakashi | 0:8fdf9a60065b | 44 | typedef struct { |
kadonotakashi | 0:8fdf9a60065b | 45 | uint32_t current_size; /**< Bytes allocated currently. */ |
kadonotakashi | 0:8fdf9a60065b | 46 | uint32_t max_size; /**< Max bytes allocated at a given time. */ |
kadonotakashi | 0:8fdf9a60065b | 47 | uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */ |
kadonotakashi | 0:8fdf9a60065b | 48 | uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */ |
kadonotakashi | 0:8fdf9a60065b | 49 | uint32_t alloc_cnt; /**< Current number of allocations. */ |
kadonotakashi | 0:8fdf9a60065b | 50 | uint32_t alloc_fail_cnt; /**< Number of failed allocations. */ |
kadonotakashi | 0:8fdf9a60065b | 51 | uint32_t overhead_size; /**< Overhead added to heap for stats. */ |
kadonotakashi | 0:8fdf9a60065b | 52 | } mbed_stats_heap_t; |
kadonotakashi | 0:8fdf9a60065b | 53 | |
kadonotakashi | 0:8fdf9a60065b | 54 | /** |
kadonotakashi | 0:8fdf9a60065b | 55 | * Fill the passed in heap stat structure with heap stats. |
kadonotakashi | 0:8fdf9a60065b | 56 | * |
kadonotakashi | 0:8fdf9a60065b | 57 | * @param stats A pointer to the mbed_stats_heap_t structure to fill |
kadonotakashi | 0:8fdf9a60065b | 58 | */ |
kadonotakashi | 0:8fdf9a60065b | 59 | void mbed_stats_heap_get(mbed_stats_heap_t *stats); |
kadonotakashi | 0:8fdf9a60065b | 60 | |
kadonotakashi | 0:8fdf9a60065b | 61 | /** |
kadonotakashi | 0:8fdf9a60065b | 62 | * struct mbed_stats_stack_t definition |
kadonotakashi | 0:8fdf9a60065b | 63 | */ |
kadonotakashi | 0:8fdf9a60065b | 64 | typedef struct { |
kadonotakashi | 0:8fdf9a60065b | 65 | uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */ |
kadonotakashi | 0:8fdf9a60065b | 66 | uint32_t max_size; /**< Maximum number of bytes used on the stack. */ |
kadonotakashi | 0:8fdf9a60065b | 67 | uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */ |
kadonotakashi | 0:8fdf9a60065b | 68 | uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */ |
kadonotakashi | 0:8fdf9a60065b | 69 | } mbed_stats_stack_t; |
kadonotakashi | 0:8fdf9a60065b | 70 | |
kadonotakashi | 0:8fdf9a60065b | 71 | /** |
kadonotakashi | 0:8fdf9a60065b | 72 | * Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0 |
kadonotakashi | 0:8fdf9a60065b | 73 | * and stack_cnt will represent number of threads. |
kadonotakashi | 0:8fdf9a60065b | 74 | * |
kadonotakashi | 0:8fdf9a60065b | 75 | * @param stats A pointer to the mbed_stats_stack_t structure to fill |
kadonotakashi | 0:8fdf9a60065b | 76 | */ |
kadonotakashi | 0:8fdf9a60065b | 77 | void mbed_stats_stack_get(mbed_stats_stack_t *stats); |
kadonotakashi | 0:8fdf9a60065b | 78 | |
kadonotakashi | 0:8fdf9a60065b | 79 | /** |
kadonotakashi | 0:8fdf9a60065b | 80 | * Fill the passed array of stat structures with the stack stats for each available thread. |
kadonotakashi | 0:8fdf9a60065b | 81 | * |
kadonotakashi | 0:8fdf9a60065b | 82 | * @param stats A pointer to an array of mbed_stats_stack_t structures to fill |
kadonotakashi | 0:8fdf9a60065b | 83 | * @param count The number of mbed_stats_stack_t structures in the provided array |
kadonotakashi | 0:8fdf9a60065b | 84 | * @return The number of mbed_stats_stack_t structures that have been filled, |
kadonotakashi | 0:8fdf9a60065b | 85 | * this is equal to the number of stacks on the system. |
kadonotakashi | 0:8fdf9a60065b | 86 | */ |
kadonotakashi | 0:8fdf9a60065b | 87 | size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count); |
kadonotakashi | 0:8fdf9a60065b | 88 | |
kadonotakashi | 0:8fdf9a60065b | 89 | /** |
kadonotakashi | 0:8fdf9a60065b | 90 | * struct mbed_stats_cpu_t definition |
kadonotakashi | 0:8fdf9a60065b | 91 | */ |
kadonotakashi | 0:8fdf9a60065b | 92 | typedef struct { |
kadonotakashi | 0:8fdf9a60065b | 93 | us_timestamp_t uptime; /**< Time since system is up and running */ |
kadonotakashi | 0:8fdf9a60065b | 94 | us_timestamp_t idle_time; /**< Time spent in idle thread since system is up and running */ |
kadonotakashi | 0:8fdf9a60065b | 95 | us_timestamp_t sleep_time; /**< Time spent in sleep since system is up and running */ |
kadonotakashi | 0:8fdf9a60065b | 96 | us_timestamp_t deep_sleep_time; /**< Time spent in deep sleep since system is up and running */ |
kadonotakashi | 0:8fdf9a60065b | 97 | } mbed_stats_cpu_t; |
kadonotakashi | 0:8fdf9a60065b | 98 | |
kadonotakashi | 0:8fdf9a60065b | 99 | /** |
kadonotakashi | 0:8fdf9a60065b | 100 | * Fill the passed in CPU stat structure with CPU statistics. |
kadonotakashi | 0:8fdf9a60065b | 101 | * |
kadonotakashi | 0:8fdf9a60065b | 102 | * @param stats A pointer to the mbed_stats_cpu_t structure to fill |
kadonotakashi | 0:8fdf9a60065b | 103 | */ |
kadonotakashi | 0:8fdf9a60065b | 104 | void mbed_stats_cpu_get(mbed_stats_cpu_t *stats); |
kadonotakashi | 0:8fdf9a60065b | 105 | |
kadonotakashi | 0:8fdf9a60065b | 106 | /** |
kadonotakashi | 0:8fdf9a60065b | 107 | * struct mbed_stats_thread_t definition |
kadonotakashi | 0:8fdf9a60065b | 108 | */ |
kadonotakashi | 0:8fdf9a60065b | 109 | typedef struct { |
kadonotakashi | 0:8fdf9a60065b | 110 | uint32_t id; /**< Thread Object Identifier */ |
kadonotakashi | 0:8fdf9a60065b | 111 | uint32_t state; /**< Thread Object State */ |
kadonotakashi | 0:8fdf9a60065b | 112 | uint32_t priority; /**< Thread Priority */ |
kadonotakashi | 0:8fdf9a60065b | 113 | uint32_t stack_size; /**< Thread Stack Size */ |
kadonotakashi | 0:8fdf9a60065b | 114 | uint32_t stack_space; /**< Thread remaining stack size */ |
kadonotakashi | 0:8fdf9a60065b | 115 | const char *name; /**< Thread Object name */ |
kadonotakashi | 0:8fdf9a60065b | 116 | } mbed_stats_thread_t; |
kadonotakashi | 0:8fdf9a60065b | 117 | |
kadonotakashi | 0:8fdf9a60065b | 118 | /** |
kadonotakashi | 0:8fdf9a60065b | 119 | * Fill the passed array of stat structures with the thread stats for each available thread. |
kadonotakashi | 0:8fdf9a60065b | 120 | * |
kadonotakashi | 0:8fdf9a60065b | 121 | * @param stats A pointer to an array of mbed_stats_thread_t structures to fill |
kadonotakashi | 0:8fdf9a60065b | 122 | * @param count The number of mbed_stats_thread_t structures in the provided array |
kadonotakashi | 0:8fdf9a60065b | 123 | * @return The number of mbed_stats_thread_t structures that have been filled, |
kadonotakashi | 0:8fdf9a60065b | 124 | * this is equal to the number of threads on the system. |
kadonotakashi | 0:8fdf9a60065b | 125 | */ |
kadonotakashi | 0:8fdf9a60065b | 126 | size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count); |
kadonotakashi | 0:8fdf9a60065b | 127 | |
kadonotakashi | 0:8fdf9a60065b | 128 | /** |
kadonotakashi | 0:8fdf9a60065b | 129 | * enum mbed_compiler_id_t definition |
kadonotakashi | 0:8fdf9a60065b | 130 | */ |
kadonotakashi | 0:8fdf9a60065b | 131 | typedef enum { |
kadonotakashi | 0:8fdf9a60065b | 132 | ARM = 1, /**< ARM */ |
kadonotakashi | 0:8fdf9a60065b | 133 | GCC_ARM, /**< GNU ARM */ |
kadonotakashi | 0:8fdf9a60065b | 134 | IAR /**< IAR */ |
kadonotakashi | 0:8fdf9a60065b | 135 | } mbed_compiler_id_t; |
kadonotakashi | 0:8fdf9a60065b | 136 | |
kadonotakashi | 0:8fdf9a60065b | 137 | /** |
kadonotakashi | 0:8fdf9a60065b | 138 | * struct mbed_stats_sys_t definition |
kadonotakashi | 0:8fdf9a60065b | 139 | */ |
kadonotakashi | 0:8fdf9a60065b | 140 | typedef struct { |
kadonotakashi | 0:8fdf9a60065b | 141 | uint32_t os_version; /**< Mbed OS Version (Release only) */ |
kadonotakashi | 0:8fdf9a60065b | 142 | uint32_t cpu_id; /**< CPUID Register data (Cortex-M only supported) */ |
kadonotakashi | 0:8fdf9a60065b | 143 | mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */ |
kadonotakashi | 0:8fdf9a60065b | 144 | uint32_t compiler_version; /**< Compiler version */ |
kadonotakashi | 0:8fdf9a60065b | 145 | } mbed_stats_sys_t; |
kadonotakashi | 0:8fdf9a60065b | 146 | |
kadonotakashi | 0:8fdf9a60065b | 147 | /** |
kadonotakashi | 0:8fdf9a60065b | 148 | * Fill the passed in sys stat structure with system stats. |
kadonotakashi | 0:8fdf9a60065b | 149 | * |
kadonotakashi | 0:8fdf9a60065b | 150 | * @param stats A pointer to the mbed_stats_sys_t structure to fill |
kadonotakashi | 0:8fdf9a60065b | 151 | */ |
kadonotakashi | 0:8fdf9a60065b | 152 | void mbed_stats_sys_get(mbed_stats_sys_t *stats); |
kadonotakashi | 0:8fdf9a60065b | 153 | |
kadonotakashi | 0:8fdf9a60065b | 154 | #ifdef __cplusplus |
kadonotakashi | 0:8fdf9a60065b | 155 | } |
kadonotakashi | 0:8fdf9a60065b | 156 | #endif |
kadonotakashi | 0:8fdf9a60065b | 157 | |
kadonotakashi | 0:8fdf9a60065b | 158 | #endif |
kadonotakashi | 0:8fdf9a60065b | 159 | |
kadonotakashi | 0:8fdf9a60065b | 160 | /** @}*/ |
kadonotakashi | 0:8fdf9a60065b | 161 | |
kadonotakashi | 0:8fdf9a60065b | 162 | /** @}*/ |