TEST

Dependencies:   max32630fthr Adafruit_FeatherOLED USBDevice

Committer:
wwwarunraj
Date:
Sun Apr 19 11:19:57 2020 +0000
Revision:
4:291477e8690d
Parent:
1:f60eafbf009a
19/04

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gmehmet 1:f60eafbf009a 1 /*******************************************************************************
gmehmet 1:f60eafbf009a 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
gmehmet 1:f60eafbf009a 3 *
gmehmet 1:f60eafbf009a 4 * Permission is hereby granted, free of charge, to any person obtaining a
gmehmet 1:f60eafbf009a 5 * copy of this software and associated documentation files (the "Software"),
gmehmet 1:f60eafbf009a 6 * to deal in the Software without restriction, including without limitation
gmehmet 1:f60eafbf009a 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
gmehmet 1:f60eafbf009a 8 * and/or sell copies of the Software, and to permit persons to whom the
gmehmet 1:f60eafbf009a 9 * Software is furnished to do so, subject to the following conditions:
gmehmet 1:f60eafbf009a 10 *
gmehmet 1:f60eafbf009a 11 * The above copyright notice and this permission notice shall be included
gmehmet 1:f60eafbf009a 12 * in all copies or substantial portions of the Software.
gmehmet 1:f60eafbf009a 13 *
gmehmet 1:f60eafbf009a 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
gmehmet 1:f60eafbf009a 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
gmehmet 1:f60eafbf009a 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
gmehmet 1:f60eafbf009a 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
gmehmet 1:f60eafbf009a 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
gmehmet 1:f60eafbf009a 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
gmehmet 1:f60eafbf009a 20 * OTHER DEALINGS IN THE SOFTWARE.
gmehmet 1:f60eafbf009a 21 *
gmehmet 1:f60eafbf009a 22 * Except as contained in this notice, the name of Maxim Integrated
gmehmet 1:f60eafbf009a 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
gmehmet 1:f60eafbf009a 24 * Products, Inc. Branding Policy.
gmehmet 1:f60eafbf009a 25 *
gmehmet 1:f60eafbf009a 26 * The mere transfer of this software does not imply any licenses
gmehmet 1:f60eafbf009a 27 * of trade secrets, proprietary technology, copyrights, patents,
gmehmet 1:f60eafbf009a 28 * trademarks, maskwork rights, or any other form of intellectual
gmehmet 1:f60eafbf009a 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
gmehmet 1:f60eafbf009a 30 * ownership rights.
gmehmet 1:f60eafbf009a 31 *******************************************************************************
gmehmet 1:f60eafbf009a 32 */
gmehmet 1:f60eafbf009a 33
gmehmet 1:f60eafbf009a 34 #include "mbed.h"
gmehmet 1:f60eafbf009a 35
gmehmet 1:f60eafbf009a 36 #if defined(MBED_MEM_TRACING_ENABLED )
gmehmet 1:f60eafbf009a 37 #include "mbed_mem_trace.h"
gmehmet 1:f60eafbf009a 38 #endif /* MBED_MEM_TRACING_ENABLED */
gmehmet 1:f60eafbf009a 39
gmehmet 1:f60eafbf009a 40 #if defined(MBED_HEAP_STATS_ENABLED)
gmehmet 1:f60eafbf009a 41 #include "mbed_stats.h"
gmehmet 1:f60eafbf009a 42 #endif /* MBED_HEAP_STATS_ENABLED */
gmehmet 1:f60eafbf009a 43
gmehmet 1:f60eafbf009a 44 #if defined(MBED_STACK_STATS_ENABLED)
gmehmet 1:f60eafbf009a 45 #include "cmsis_os.h"
gmehmet 1:f60eafbf009a 46 #endif /* MBED_STACK_STATS_ENABLED */
gmehmet 1:f60eafbf009a 47
gmehmet 1:f60eafbf009a 48
gmehmet 1:f60eafbf009a 49 void mbed_mem_debug_init()
gmehmet 1:f60eafbf009a 50 {
gmehmet 1:f60eafbf009a 51 #if defined(MBED_MEM_TRACING_ENABLED )
gmehmet 1:f60eafbf009a 52 mbed_mem_trace_set_callback(mbed_mem_trace_default_callback);
gmehmet 1:f60eafbf009a 53 #endif /* MBED_MEM_TRACING_ENABLED */
gmehmet 1:f60eafbf009a 54 }
gmehmet 1:f60eafbf009a 55
gmehmet 1:f60eafbf009a 56 #if defined(MBED_HEAP_STATS_ENABLED)
gmehmet 1:f60eafbf009a 57 void mbed_heap_stats(const char* func, int line)
gmehmet 1:f60eafbf009a 58 {
gmehmet 1:f60eafbf009a 59 mbed_stats_heap_t heap_stats;
gmehmet 1:f60eafbf009a 60 mbed_stats_heap_get(&heap_stats);
gmehmet 1:f60eafbf009a 61 printf(" HEAP current: %lu, max: %lu, cumulative: %lu bytes (%s:%d)\n",
gmehmet 1:f60eafbf009a 62 heap_stats.current_size,
gmehmet 1:f60eafbf009a 63 heap_stats.max_size,
gmehmet 1:f60eafbf009a 64 heap_stats.total_size,
gmehmet 1:f60eafbf009a 65 func, line);
gmehmet 1:f60eafbf009a 66 }
gmehmet 1:f60eafbf009a 67 #endif /* MBED_HEAP_STATS_ENABLED */
gmehmet 1:f60eafbf009a 68
gmehmet 1:f60eafbf009a 69 #if defined(MBED_STACK_STATS_ENABLED)
gmehmet 1:f60eafbf009a 70 void mbed_stack_stats(const char* func, int line)
gmehmet 1:f60eafbf009a 71 {
gmehmet 1:f60eafbf009a 72 osThreadId main_id = osThreadGetId();
gmehmet 1:f60eafbf009a 73
gmehmet 1:f60eafbf009a 74 osEvent info;
gmehmet 1:f60eafbf009a 75 info = _osThreadGetInfo(main_id, osThreadInfoStackSize);
gmehmet 1:f60eafbf009a 76 if (info.status != osOK) {
gmehmet 1:f60eafbf009a 77 printf("Could not get stack size (%s:%d)\n", func, line);
gmehmet 1:f60eafbf009a 78 }
gmehmet 1:f60eafbf009a 79 uint32_t stack_size = (uint32_t)info.value.v;
gmehmet 1:f60eafbf009a 80 info = _osThreadGetInfo(main_id, osThreadInfoStackMax);
gmehmet 1:f60eafbf009a 81 if (info.status != osOK) {
gmehmet 1:f60eafbf009a 82 printf("Could not get max stack (%s:%d)\n", func, line);
gmehmet 1:f60eafbf009a 83 }
gmehmet 1:f60eafbf009a 84 uint32_t max_stack = (uint32_t)info.value.v;
gmehmet 1:f60eafbf009a 85
gmehmet 1:f60eafbf009a 86 printf(" STACK used: %li, max: %li bytes (%s:%d)\n",
gmehmet 1:f60eafbf009a 87 max_stack,
gmehmet 1:f60eafbf009a 88 stack_size,
gmehmet 1:f60eafbf009a 89 func, line);
gmehmet 1:f60eafbf009a 90 }
gmehmet 1:f60eafbf009a 91 #endif /* MBED_STACK_STATS_ENABLED */