Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Thu Jun 29 11:01:39 2017 +0000
Revision:
167:1657b442184c
Opencv 3.1 project on GR-PEACH board, 4 apps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 167:1657b442184c 1 #include "mbed_stats.h"
thedo 167:1657b442184c 2 #include <string.h>
thedo 167:1657b442184c 3 #include <stdlib.h>
thedo 167:1657b442184c 4 #include "mbed_assert.h"
thedo 167:1657b442184c 5
thedo 167:1657b442184c 6 #if MBED_CONF_RTOS_PRESENT
thedo 167:1657b442184c 7 #include "cmsis_os2.h"
thedo 167:1657b442184c 8 #endif
thedo 167:1657b442184c 9
thedo 167:1657b442184c 10 // note: mbed_stats_heap_get defined in mbed_alloc_wrappers.cpp
thedo 167:1657b442184c 11
thedo 167:1657b442184c 12 void mbed_stats_stack_get(mbed_stats_stack_t *stats)
thedo 167:1657b442184c 13 {
thedo 167:1657b442184c 14 memset(stats, 0, sizeof(mbed_stats_stack_t));
thedo 167:1657b442184c 15
thedo 167:1657b442184c 16 #if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT
thedo 167:1657b442184c 17 uint32_t thread_n = osThreadGetCount();
thedo 167:1657b442184c 18 unsigned i;
thedo 167:1657b442184c 19 osThreadId_t *threads;
thedo 167:1657b442184c 20
thedo 167:1657b442184c 21 threads = malloc(sizeof(osThreadId_t) * thread_n);
thedo 167:1657b442184c 22 MBED_ASSERT(threads != NULL);
thedo 167:1657b442184c 23
thedo 167:1657b442184c 24 osKernelLock();
thedo 167:1657b442184c 25 thread_n = osThreadEnumerate(threads, thread_n);
thedo 167:1657b442184c 26
thedo 167:1657b442184c 27 for(i = 0; i < thread_n; i++) {
thedo 167:1657b442184c 28 uint32_t stack_size = osThreadGetStackSize(threads[i]);
thedo 167:1657b442184c 29 stats->max_size += stack_size - osThreadGetStackSpace(threads[i]);
thedo 167:1657b442184c 30 stats->reserved_size += stack_size;
thedo 167:1657b442184c 31 stats->stack_cnt++;
thedo 167:1657b442184c 32 }
thedo 167:1657b442184c 33 osKernelUnlock();
thedo 167:1657b442184c 34
thedo 167:1657b442184c 35 free(threads);
thedo 167:1657b442184c 36 #endif
thedo 167:1657b442184c 37 }
thedo 167:1657b442184c 38
thedo 167:1657b442184c 39 size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count)
thedo 167:1657b442184c 40 {
thedo 167:1657b442184c 41 memset(stats, 0, count*sizeof(mbed_stats_stack_t));
thedo 167:1657b442184c 42 size_t i = 0;
thedo 167:1657b442184c 43
thedo 167:1657b442184c 44 #if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT
thedo 167:1657b442184c 45 osThreadId_t *threads;
thedo 167:1657b442184c 46
thedo 167:1657b442184c 47 threads = malloc(sizeof(osThreadId_t) * count);
thedo 167:1657b442184c 48 MBED_ASSERT(threads != NULL);
thedo 167:1657b442184c 49
thedo 167:1657b442184c 50 osKernelLock();
thedo 167:1657b442184c 51 count = osThreadEnumerate(threads, count);
thedo 167:1657b442184c 52
thedo 167:1657b442184c 53 for(i = 0; i < count; i++) {
thedo 167:1657b442184c 54 uint32_t stack_size = osThreadGetStackSize(threads[i]);
thedo 167:1657b442184c 55 stats[i].max_size = stack_size - osThreadGetStackSpace(threads[i]);
thedo 167:1657b442184c 56 stats[i].reserved_size = stack_size;
thedo 167:1657b442184c 57 stats[i].thread_id = (uint32_t)threads[i];
thedo 167:1657b442184c 58 stats[i].stack_cnt = 1;
thedo 167:1657b442184c 59 }
thedo 167:1657b442184c 60 osKernelUnlock();
thedo 167:1657b442184c 61
thedo 167:1657b442184c 62 free(threads);
thedo 167:1657b442184c 63 #endif
thedo 167:1657b442184c 64
thedo 167:1657b442184c 65 return i;
thedo 167:1657b442184c 66 }
thedo 167:1657b442184c 67
thedo 167:1657b442184c 68 #if MBED_STACK_STATS_ENABLED && !MBED_CONF_RTOS_PRESENT
thedo 167:1657b442184c 69 #warning Stack statistics are currently not supported without the rtos.
thedo 167:1657b442184c 70 #endif
thedo 167:1657b442184c 71