mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
Anna Bridge
Date:
Fri Jun 22 16:45:37 2018 +0100
Revision:
186:707f6e361f3e
Parent:
178:79309dc6340a
Child:
187:0387e8f68319
mbed-dev library. Release version 162

Who changed what in which revision?

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