mbed-os
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
platform/mbed_stats.h@0:b74591d5ab33, 2017-12-11 (annotated)
- Committer:
- be_bryan
- Date:
- Mon Dec 11 17:54:04 2017 +0000
- Revision:
- 0:b74591d5ab33
motor ++
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
be_bryan | 0:b74591d5ab33 | 1 | |
be_bryan | 0:b74591d5ab33 | 2 | /** \addtogroup platform */ |
be_bryan | 0:b74591d5ab33 | 3 | /** @{*/ |
be_bryan | 0:b74591d5ab33 | 4 | /** |
be_bryan | 0:b74591d5ab33 | 5 | * \defgroup platform_stats stats functions |
be_bryan | 0:b74591d5ab33 | 6 | * @{ |
be_bryan | 0:b74591d5ab33 | 7 | */ |
be_bryan | 0:b74591d5ab33 | 8 | /* mbed Microcontroller Library |
be_bryan | 0:b74591d5ab33 | 9 | * Copyright (c) 2016-2016 ARM Limited |
be_bryan | 0:b74591d5ab33 | 10 | * |
be_bryan | 0:b74591d5ab33 | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
be_bryan | 0:b74591d5ab33 | 12 | * you may not use this file except in compliance with the License. |
be_bryan | 0:b74591d5ab33 | 13 | * You may obtain a copy of the License at |
be_bryan | 0:b74591d5ab33 | 14 | * |
be_bryan | 0:b74591d5ab33 | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
be_bryan | 0:b74591d5ab33 | 16 | * |
be_bryan | 0:b74591d5ab33 | 17 | * Unless required by applicable law or agreed to in writing, software |
be_bryan | 0:b74591d5ab33 | 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
be_bryan | 0:b74591d5ab33 | 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
be_bryan | 0:b74591d5ab33 | 20 | * See the License for the specific language governing permissions and |
be_bryan | 0:b74591d5ab33 | 21 | * limitations under the License. |
be_bryan | 0:b74591d5ab33 | 22 | */ |
be_bryan | 0:b74591d5ab33 | 23 | #ifndef MBED_STATS_H |
be_bryan | 0:b74591d5ab33 | 24 | #define MBED_STATS_H |
be_bryan | 0:b74591d5ab33 | 25 | #include <stdint.h> |
be_bryan | 0:b74591d5ab33 | 26 | #include <stddef.h> |
be_bryan | 0:b74591d5ab33 | 27 | |
be_bryan | 0:b74591d5ab33 | 28 | #ifdef __cplusplus |
be_bryan | 0:b74591d5ab33 | 29 | extern "C" { |
be_bryan | 0:b74591d5ab33 | 30 | #endif |
be_bryan | 0:b74591d5ab33 | 31 | |
be_bryan | 0:b74591d5ab33 | 32 | /** |
be_bryan | 0:b74591d5ab33 | 33 | * struct mbed_stats_heap_t definition |
be_bryan | 0:b74591d5ab33 | 34 | */ |
be_bryan | 0:b74591d5ab33 | 35 | typedef struct { |
be_bryan | 0:b74591d5ab33 | 36 | uint32_t current_size; /**< Bytes allocated currently. */ |
be_bryan | 0:b74591d5ab33 | 37 | uint32_t max_size; /**< Max bytes allocated at a given time. */ |
be_bryan | 0:b74591d5ab33 | 38 | uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */ |
be_bryan | 0:b74591d5ab33 | 39 | uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */ |
be_bryan | 0:b74591d5ab33 | 40 | uint32_t alloc_cnt; /**< Current number of allocations. */ |
be_bryan | 0:b74591d5ab33 | 41 | uint32_t alloc_fail_cnt; /**< Number of failed allocations. */ |
be_bryan | 0:b74591d5ab33 | 42 | } mbed_stats_heap_t; |
be_bryan | 0:b74591d5ab33 | 43 | |
be_bryan | 0:b74591d5ab33 | 44 | /** |
be_bryan | 0:b74591d5ab33 | 45 | * Fill the passed in heap stat structure with heap stats. |
be_bryan | 0:b74591d5ab33 | 46 | * |
be_bryan | 0:b74591d5ab33 | 47 | * @param stats A pointer to the mbed_stats_heap_t structure to fill |
be_bryan | 0:b74591d5ab33 | 48 | */ |
be_bryan | 0:b74591d5ab33 | 49 | void mbed_stats_heap_get(mbed_stats_heap_t *stats); |
be_bryan | 0:b74591d5ab33 | 50 | |
be_bryan | 0:b74591d5ab33 | 51 | /** |
be_bryan | 0:b74591d5ab33 | 52 | * struct mbed_stats_stack_t definition |
be_bryan | 0:b74591d5ab33 | 53 | */ |
be_bryan | 0:b74591d5ab33 | 54 | typedef struct { |
be_bryan | 0:b74591d5ab33 | 55 | uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */ |
be_bryan | 0:b74591d5ab33 | 56 | uint32_t max_size; /**< Maximum number of bytes used on the stack. */ |
be_bryan | 0:b74591d5ab33 | 57 | uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */ |
be_bryan | 0:b74591d5ab33 | 58 | uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */ |
be_bryan | 0:b74591d5ab33 | 59 | } mbed_stats_stack_t; |
be_bryan | 0:b74591d5ab33 | 60 | |
be_bryan | 0:b74591d5ab33 | 61 | /** |
be_bryan | 0:b74591d5ab33 | 62 | * Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0 |
be_bryan | 0:b74591d5ab33 | 63 | * and stack_cnt will represent number of threads. |
be_bryan | 0:b74591d5ab33 | 64 | * |
be_bryan | 0:b74591d5ab33 | 65 | * @param stats A pointer to the mbed_stats_stack_t structure to fill |
be_bryan | 0:b74591d5ab33 | 66 | */ |
be_bryan | 0:b74591d5ab33 | 67 | void mbed_stats_stack_get(mbed_stats_stack_t *stats); |
be_bryan | 0:b74591d5ab33 | 68 | |
be_bryan | 0:b74591d5ab33 | 69 | /** |
be_bryan | 0:b74591d5ab33 | 70 | * Fill the passed array of stat structures with the stack stats for each available thread. |
be_bryan | 0:b74591d5ab33 | 71 | * |
be_bryan | 0:b74591d5ab33 | 72 | * @param stats A pointer to an array of mbed_stats_stack_t structures to fill |
be_bryan | 0:b74591d5ab33 | 73 | * @param count The number of mbed_stats_stack_t structures in the provided array |
be_bryan | 0:b74591d5ab33 | 74 | * @return The number of mbed_stats_stack_t structures that have been filled, |
be_bryan | 0:b74591d5ab33 | 75 | * this is equal to the number of stacks on the system. |
be_bryan | 0:b74591d5ab33 | 76 | */ |
be_bryan | 0:b74591d5ab33 | 77 | size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count); |
be_bryan | 0:b74591d5ab33 | 78 | |
be_bryan | 0:b74591d5ab33 | 79 | #ifdef __cplusplus |
be_bryan | 0:b74591d5ab33 | 80 | } |
be_bryan | 0:b74591d5ab33 | 81 | #endif |
be_bryan | 0:b74591d5ab33 | 82 | |
be_bryan | 0:b74591d5ab33 | 83 | #endif |
be_bryan | 0:b74591d5ab33 | 84 | |
be_bryan | 0:b74591d5ab33 | 85 | /** @}*/ |
be_bryan | 0:b74591d5ab33 | 86 | |
be_bryan | 0:b74591d5ab33 | 87 | /** @}*/ |