The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 128:9bcdf88f62b0 1
<> 128:9bcdf88f62b0 2 /** \addtogroup platform */
<> 128:9bcdf88f62b0 3 /** @{*/
<> 128:9bcdf88f62b0 4 /* mbed Microcontroller Library
<> 128:9bcdf88f62b0 5 * Copyright (c) 2006-2016 ARM Limited
<> 128:9bcdf88f62b0 6 *
<> 128:9bcdf88f62b0 7 * Licensed under the Apache License, Version 2.0 (the "License");
<> 128:9bcdf88f62b0 8 * you may not use this file except in compliance with the License.
<> 128:9bcdf88f62b0 9 * You may obtain a copy of the License at
<> 128:9bcdf88f62b0 10 *
<> 128:9bcdf88f62b0 11 * http://www.apache.org/licenses/LICENSE-2.0
<> 128:9bcdf88f62b0 12 *
<> 128:9bcdf88f62b0 13 * Unless required by applicable law or agreed to in writing, software
<> 128:9bcdf88f62b0 14 * distributed under the License is distributed on an "AS IS" BASIS,
<> 128:9bcdf88f62b0 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 128:9bcdf88f62b0 16 * See the License for the specific language governing permissions and
<> 128:9bcdf88f62b0 17 * limitations under the License.
<> 128:9bcdf88f62b0 18 */
<> 128:9bcdf88f62b0 19
<> 128:9bcdf88f62b0 20 #ifndef __MBED_MEM_TRACE_H__
<> 128:9bcdf88f62b0 21 #define __MBED_MEM_TRACE_H__
<> 128:9bcdf88f62b0 22
<> 128:9bcdf88f62b0 23 #ifdef __cplusplus
<> 128:9bcdf88f62b0 24 extern "C" {
<> 128:9bcdf88f62b0 25 #endif
<> 128:9bcdf88f62b0 26
<> 128:9bcdf88f62b0 27 #include <stdint.h>
<> 128:9bcdf88f62b0 28 #include <stddef.h>
<> 128:9bcdf88f62b0 29
<> 128:9bcdf88f62b0 30 /* Operation types for tracer */
<> 128:9bcdf88f62b0 31 enum {
<> 128:9bcdf88f62b0 32 MBED_MEM_TRACE_MALLOC,
<> 128:9bcdf88f62b0 33 MBED_MEM_TRACE_REALLOC,
<> 128:9bcdf88f62b0 34 MBED_MEM_TRACE_CALLOC,
<> 128:9bcdf88f62b0 35 MBED_MEM_TRACE_FREE
<> 128:9bcdf88f62b0 36 };
<> 128:9bcdf88f62b0 37
<> 128:9bcdf88f62b0 38 /* Prefix for the output of the default tracer */
<> 128:9bcdf88f62b0 39 #define MBED_MEM_DEFAULT_TRACER_PREFIX "#"
<> 128:9bcdf88f62b0 40
<> 128:9bcdf88f62b0 41 /**
<> 128:9bcdf88f62b0 42 * Type of the callback used by the memory tracer. This callback is called when a memory
<> 128:9bcdf88f62b0 43 * allocation operation (malloc, realloc, calloc, free) is called and tracing is enabled
<> 128:9bcdf88f62b0 44 * for that memory allocation function.
<> 128:9bcdf88f62b0 45 *
<> 128:9bcdf88f62b0 46 * @param op the ID of the operation (MBED_MEM_TRACE_MALLOC, MBED_MEM_TRACE_REALLOC,
<> 128:9bcdf88f62b0 47 * MBED_MEM_TRACE_CALLOC or MBED_MEM_TRACE_FREE).
<> 128:9bcdf88f62b0 48 * @param res the result that the memory operation returned (NULL for 'free').
<> 128:9bcdf88f62b0 49 * @param caller the caller of the memory operation. Note that the value of 'caller' might be
<> 128:9bcdf88f62b0 50 * unreliable.
<> 128:9bcdf88f62b0 51 *
<> 128:9bcdf88f62b0 52 * The rest of the parameters passed 'mbed_mem_trace_cb_t' are the same as the memory operations
<> 128:9bcdf88f62b0 53 * that triggered its call (see 'man malloc' for details):
<> 128:9bcdf88f62b0 54 *
<> 128:9bcdf88f62b0 55 * - for malloc: cb(MBED_MEM_TRACE_MALLOC, res, caller, size).
<> 128:9bcdf88f62b0 56 * - for realloc: cb(MBED_MEM_TRACE_REALLOC, res, caller, ptr, size).
<> 128:9bcdf88f62b0 57 * - for calloc: cb(MBED_MEM_TRACE_CALLOC, res, caller, nmemb, size).
<> 128:9bcdf88f62b0 58 * - for free: cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr).
<> 128:9bcdf88f62b0 59 */
<> 128:9bcdf88f62b0 60 typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void* caller, ...);
<> 128:9bcdf88f62b0 61
<> 128:9bcdf88f62b0 62 /**
<> 128:9bcdf88f62b0 63 * Set the callback used by the memory tracer (use NULL for disable tracing).
<> 128:9bcdf88f62b0 64 *
<> 128:9bcdf88f62b0 65 * @param cb the callback to call on each memory operation.
<> 128:9bcdf88f62b0 66 */
<> 128:9bcdf88f62b0 67 void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb);
<> 128:9bcdf88f62b0 68
<> 128:9bcdf88f62b0 69 /**
<> 128:9bcdf88f62b0 70 * Trace a call to 'malloc'.
<> 128:9bcdf88f62b0 71 * @param res the result of running 'malloc'.
<> 128:9bcdf88f62b0 72 * @param size the 'size' argument given to 'malloc'.
<> 128:9bcdf88f62b0 73 * @param caller the caller of the memory operation.
<> 128:9bcdf88f62b0 74 * @return 'res' (the first argument).
<> 128:9bcdf88f62b0 75 */
<> 128:9bcdf88f62b0 76 void *mbed_mem_trace_malloc(void *res, size_t size, void *caller);
<> 128:9bcdf88f62b0 77
<> 128:9bcdf88f62b0 78 /**
<> 128:9bcdf88f62b0 79 * Trace a call to 'realloc'.
<> 128:9bcdf88f62b0 80 * @param res the result of running 'realloc'.
<> 128:9bcdf88f62b0 81 * @param ptr the 'ptr' argument given to 'realloc'.
<> 128:9bcdf88f62b0 82 * @param size the 'size' argument given to 'realloc'.
<> 128:9bcdf88f62b0 83 *
<> 128:9bcdf88f62b0 84 * @return 'res' (the first argument).
<> 128:9bcdf88f62b0 85 */
<> 128:9bcdf88f62b0 86 void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller);
<> 128:9bcdf88f62b0 87
<> 128:9bcdf88f62b0 88 /**
<> 128:9bcdf88f62b0 89 * Trace a call to 'calloc'.
<> 128:9bcdf88f62b0 90 * @param res the result of running 'calloc'.
<> 128:9bcdf88f62b0 91 * @param nmemb the 'nmemb' argument given to 'calloc'.
<> 128:9bcdf88f62b0 92 * @param size the 'size' argument given to 'calloc'.
<> 128:9bcdf88f62b0 93 * @param caller the caller of the memory operation.
<> 128:9bcdf88f62b0 94 * @Return 'res' (the first argument).
<> 128:9bcdf88f62b0 95 */
<> 128:9bcdf88f62b0 96 void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller);
<> 128:9bcdf88f62b0 97
<> 128:9bcdf88f62b0 98 /**
<> 128:9bcdf88f62b0 99 * Trace a call to 'free'.
<> 128:9bcdf88f62b0 100 * @param ptr the 'ptr' argument given to 'free'.
<> 128:9bcdf88f62b0 101 * @param caller the caller of the memory operation.
<> 128:9bcdf88f62b0 102 */
<> 128:9bcdf88f62b0 103 void mbed_mem_trace_free(void *ptr, void *caller);
<> 128:9bcdf88f62b0 104
<> 128:9bcdf88f62b0 105 /**
<> 128:9bcdf88f62b0 106 * Default memory trace callback. DO NOT CALL DIRECTLY. It is meant to be used
<> 128:9bcdf88f62b0 107 * as the second argument of 'mbed_mem_trace_setup'.
<> 128:9bcdf88f62b0 108 *
<> 128:9bcdf88f62b0 109 * The default callback outputs trace data using 'printf', in a format that's
<> 128:9bcdf88f62b0 110 * easily parsable by an external tool. For each memory operation, the callback
<> 128:9bcdf88f62b0 111 * outputs a line that begins with '#<op>:<0xresult>;<0xcaller>-':
<> 128:9bcdf88f62b0 112 *
<> 128:9bcdf88f62b0 113 * - 'op' identifies the memory operation ('m' for 'malloc', 'r' for 'realloc',
<> 128:9bcdf88f62b0 114 * 'c' for 'calloc' and 'f' for 'free').
<> 128:9bcdf88f62b0 115 * - 'result' (base 16) is the result of the memor operation. This is always NULL
<> 128:9bcdf88f62b0 116 * for 'free', since 'free' doesn't return anything.
<> 128:9bcdf88f62b0 117 * -'caller' (base 16) is the caller of the memory operation. Note that the value
<> 128:9bcdf88f62b0 118 * of 'caller' might be unreliable.
<> 128:9bcdf88f62b0 119 *
<> 128:9bcdf88f62b0 120 * The rest of the output depends on the operation being traced:
<> 128:9bcdf88f62b0 121 *
<> 128:9bcdf88f62b0 122 * - for 'malloc': 'size', where 'size' is the original argument to 'malloc'.
<> 128:9bcdf88f62b0 123 * - for 'realloc': '0xptr;size', where 'ptr' (base 16) and 'size' are the original arguments to 'realloc'.
<> 128:9bcdf88f62b0 124 * - for 'calloc': 'nmemb;size', where 'nmemb' and 'size' are the original arguments to 'calloc'.
<> 128:9bcdf88f62b0 125 * - for 'free': '0xptr', where 'ptr' (base 16) is the original argument to 'free'.
<> 128:9bcdf88f62b0 126 *
<> 128:9bcdf88f62b0 127 * Examples:
<> 128:9bcdf88f62b0 128 *
<> 128:9bcdf88f62b0 129 * - '#m:0x20003240;0x600d-50' encodes a 'malloc' that returned 0x20003240, was called
<> 128:9bcdf88f62b0 130 * by the instruction at 0x600D with a the 'size' argument equal to 50.
<> 128:9bcdf88f62b0 131 * - '#f:0x0;0x602f-0x20003240' encodes a 'free' that was called by the instruction at
<> 128:9bcdf88f62b0 132 * 0x602f with the 'ptr' argument equal to 0x20003240.
<> 128:9bcdf88f62b0 133 */
<> 128:9bcdf88f62b0 134 void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...);
<> 128:9bcdf88f62b0 135
<> 128:9bcdf88f62b0 136 #ifdef __cplusplus
<> 128:9bcdf88f62b0 137 }
<> 128:9bcdf88f62b0 138 #endif
<> 128:9bcdf88f62b0 139
<> 128:9bcdf88f62b0 140 #endif// #ifndef __MBED_MEM_TRACE_H__
<> 128:9bcdf88f62b0 141
<> 128:9bcdf88f62b0 142
<> 128:9bcdf88f62b0 143 /** @}*/