BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:a607cd9655d7 1 /**************************************************************************/
yihui 1:a607cd9655d7 2 /*!
yihui 1:a607cd9655d7 3 @file compiler.h
yihui 1:a607cd9655d7 4 @author hathach (tinyusb.org)
yihui 1:a607cd9655d7 5
yihui 1:a607cd9655d7 6 @section LICENSE
yihui 1:a607cd9655d7 7
yihui 1:a607cd9655d7 8 Software License Agreement (BSD License)
yihui 1:a607cd9655d7 9
yihui 1:a607cd9655d7 10 Copyright (c) 2013, K. Townsend (microBuilder.eu)
yihui 1:a607cd9655d7 11 All rights reserved.
yihui 1:a607cd9655d7 12
yihui 1:a607cd9655d7 13 Redistribution and use in source and binary forms, with or without
yihui 1:a607cd9655d7 14 modification, are permitted provided that the following conditions are met:
yihui 1:a607cd9655d7 15 1. Redistributions of source code must retain the above copyright
yihui 1:a607cd9655d7 16 notice, this list of conditions and the following disclaimer.
yihui 1:a607cd9655d7 17 2. Redistributions in binary form must reproduce the above copyright
yihui 1:a607cd9655d7 18 notice, this list of conditions and the following disclaimer in the
yihui 1:a607cd9655d7 19 documentation and/or other materials provided with the distribution.
yihui 1:a607cd9655d7 20 3. Neither the name of the copyright holders nor the
yihui 1:a607cd9655d7 21 names of its contributors may be used to endorse or promote products
yihui 1:a607cd9655d7 22 derived from this software without specific prior written permission.
yihui 1:a607cd9655d7 23
yihui 1:a607cd9655d7 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
yihui 1:a607cd9655d7 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
yihui 1:a607cd9655d7 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
yihui 1:a607cd9655d7 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
yihui 1:a607cd9655d7 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
yihui 1:a607cd9655d7 29 INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
yihui 1:a607cd9655d7 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
yihui 1:a607cd9655d7 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
yihui 1:a607cd9655d7 32 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
yihui 1:a607cd9655d7 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
yihui 1:a607cd9655d7 34 */
yihui 1:a607cd9655d7 35 /**************************************************************************/
yihui 1:a607cd9655d7 36
yihui 1:a607cd9655d7 37 /** \file
yihui 1:a607cd9655d7 38 * \brief GCC Header
yihui 1:a607cd9655d7 39 */
yihui 1:a607cd9655d7 40
yihui 1:a607cd9655d7 41 /** \ingroup Group_Compiler
yihui 1:a607cd9655d7 42 * \defgroup Group_GCC GNU GCC
yihui 1:a607cd9655d7 43 * @{
yihui 1:a607cd9655d7 44 */
yihui 1:a607cd9655d7 45
yihui 1:a607cd9655d7 46 #ifndef _COMPILER_GCC_H_
yihui 1:a607cd9655d7 47 #define _COMPILER_GCC_H_
yihui 1:a607cd9655d7 48
yihui 1:a607cd9655d7 49 #ifdef __cplusplus
yihui 1:a607cd9655d7 50 extern "C" {
yihui 1:a607cd9655d7 51 #endif
yihui 1:a607cd9655d7 52
yihui 1:a607cd9655d7 53 #include "projectconfig.h"
yihui 1:a607cd9655d7 54
yihui 1:a607cd9655d7 55 //#ifndef __GNUC__
yihui 1:a607cd9655d7 56 // #define ATTR_ALWAYS_INLINE
yihui 1:a607cd9655d7 57 // #define ATTR_CONST
yihui 1:a607cd9655d7 58 //#else
yihui 1:a607cd9655d7 59
yihui 1:a607cd9655d7 60 #ifdef _TEST_
yihui 1:a607cd9655d7 61 #define ATTR_ALWAYS_INLINE
yihui 1:a607cd9655d7 62 #define STATIC_
yihui 1:a607cd9655d7 63 #define INLINE_
yihui 1:a607cd9655d7 64 #else
yihui 1:a607cd9655d7 65 #define STATIC_ static
yihui 1:a607cd9655d7 66 #define INLINE_ inline
yihui 1:a607cd9655d7 67
yihui 1:a607cd9655d7 68 #if CFG_DEBUG == 3
yihui 1:a607cd9655d7 69 #define ATTR_ALWAYS_INLINE // no inline for debug = 3
yihui 1:a607cd9655d7 70 #endif
yihui 1:a607cd9655d7 71 #endif
yihui 1:a607cd9655d7 72
yihui 1:a607cd9655d7 73 #define ALIGN_OF(x) __alignof__(x)
yihui 1:a607cd9655d7 74
yihui 1:a607cd9655d7 75 /// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
yihui 1:a607cd9655d7 76 #define ATTR_SECTION(section) __attribute__ ((#section))
yihui 1:a607cd9655d7 77
yihui 1:a607cd9655d7 78 /// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error that includes message is diagnosed. This is useful for compile-time checking
yihui 1:a607cd9655d7 79 #define ATTR_ERROR(Message) __attribute__ ((error(Message)))
yihui 1:a607cd9655d7 80
yihui 1:a607cd9655d7 81 /// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking
yihui 1:a607cd9655d7 82 #define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
yihui 1:a607cd9655d7 83
yihui 1:a607cd9655d7 84 /**
yihui 1:a607cd9655d7 85 * \defgroup Group_VariableAttr Variable Attributes
yihui 1:a607cd9655d7 86 * @{
yihui 1:a607cd9655d7 87 */
yihui 1:a607cd9655d7 88
yihui 1:a607cd9655d7 89 /// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
yihui 1:a607cd9655d7 90 #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
yihui 1:a607cd9655d7 91
yihui 1:a607cd9655d7 92 /// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute
yihui 1:a607cd9655d7 93 #define ATTR_PACKED __attribute__ ((packed))
yihui 1:a607cd9655d7 94
yihui 1:a607cd9655d7 95 #define ATTR_PREPACKED
yihui 1:a607cd9655d7 96
yihui 1:a607cd9655d7 97 #define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
yihui 1:a607cd9655d7 98 /** @} */
yihui 1:a607cd9655d7 99
yihui 1:a607cd9655d7 100 /**
yihui 1:a607cd9655d7 101 * \defgroup Group_FuncAttr Function Attributes
yihui 1:a607cd9655d7 102 * @{
yihui 1:a607cd9655d7 103 */
yihui 1:a607cd9655d7 104
yihui 1:a607cd9655d7 105 #ifndef ATTR_ALWAYS_INLINE
yihui 1:a607cd9655d7 106 /// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
yihui 1:a607cd9655d7 107 #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
yihui 1:a607cd9655d7 108 #endif
yihui 1:a607cd9655d7 109
yihui 1:a607cd9655d7 110 /// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
yihui 1:a607cd9655d7 111 #define ATTR_NON_NULL __attribute__ ((nonull))
yihui 1:a607cd9655d7 112
yihui 1:a607cd9655d7 113 /// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure
yihui 1:a607cd9655d7 114 #define ATTR_PURE __attribute__ ((pure))
yihui 1:a607cd9655d7 115
yihui 1:a607cd9655d7 116 /// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.
yihui 1:a607cd9655d7 117 /// Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void
yihui 1:a607cd9655d7 118 #define ATTR_CONST __attribute__ ((const))
yihui 1:a607cd9655d7 119
yihui 1:a607cd9655d7 120 /// The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses
yihui 1:a607cd9655d7 121 #define ATTR_DEPRECATED __attribute__ ((deprecated))
yihui 1:a607cd9655d7 122
yihui 1:a607cd9655d7 123 /// Same as the deprecated attribute with optional message in the warning
yihui 1:a607cd9655d7 124 #define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
yihui 1:a607cd9655d7 125
yihui 1:a607cd9655d7 126 /// The weak attribute causes the declaration to be emitted as a weak symbol rather than a global. This is primarily useful in defining library functions that can be overridden in user code
yihui 1:a607cd9655d7 127 #define ATTR_WEAK __attribute__ ((weak))
yihui 1:a607cd9655d7 128
yihui 1:a607cd9655d7 129 /// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
yihui 1:a607cd9655d7 130 #define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
yihui 1:a607cd9655d7 131
yihui 1:a607cd9655d7 132 /// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
yihui 1:a607cd9655d7 133 #define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
yihui 1:a607cd9655d7 134
yihui 1:a607cd9655d7 135 /// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug
yihui 1:a607cd9655d7 136 #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
yihui 1:a607cd9655d7 137
yihui 1:a607cd9655d7 138 /// This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced. This is useful, for example, when the function is referenced only in inline assembly.
yihui 1:a607cd9655d7 139 #define ATTR_USED __attribute__ ((used))
yihui 1:a607cd9655d7 140
yihui 1:a607cd9655d7 141 /// This attribute, attached to a function, means that the function is meant to be possibly unused. GCC does not produce a warning for this function.
yihui 1:a607cd9655d7 142 #define ATTR_UNUSED __attribute__ ((unused))
yihui 1:a607cd9655d7 143
yihui 1:a607cd9655d7 144 /** @} */
yihui 1:a607cd9655d7 145
yihui 1:a607cd9655d7 146 #ifdef __cplusplus
yihui 1:a607cd9655d7 147 }
yihui 1:a607cd9655d7 148 #endif
yihui 1:a607cd9655d7 149
yihui 1:a607cd9655d7 150 #endif /* _COMPILER_GCC_H_ */
yihui 1:a607cd9655d7 151
yihui 1:a607cd9655d7 152 /// @}