MCU driver/HAL for the Picocell Gateway concentrator board. The firmware implements either a USB CDC protocol or a UART protocol to bridge commands coming from host to the SX1308 SPI interface.

Committer:
dgabino
Date:
Wed Apr 11 14:42:47 2018 +0000
Revision:
0:c76361bd82e8
Initial commit

Who changed what in which revision?

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