David Kester / nRF51822

Dependents:   GonioTrainer

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers softdevice_assert.h Source File

softdevice_assert.h

00001 /* 
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  * 
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  * 
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  * 
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  * 
00019  *   4. This software must only be used in a processor manufactured by Nordic
00020  *   Semiconductor ASA, or in a processor manufactured by a third party that
00021  *   is used in combination with a processor manufactured by Nordic Semiconductor.
00022  * 
00023  * 
00024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00025  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00028  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00031  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  * 
00035  */
00036 
00037 /** @brief Utilities for verifying program logic
00038  */
00039 
00040 #ifndef SOFTDEVICE_ASSERT_H_
00041 #define SOFTDEVICE_ASSERT_H_
00042 
00043 #include <stdint.h>
00044 
00045 /** @brief This function handles assertions.
00046  *
00047  *
00048  * @note
00049  * This function is called when an assertion has triggered.
00050  * 
00051  *
00052  * @param line_num The line number where the assertion is called
00053  * @param file_name Pointer to the file name
00054  */
00055 void assert_softdevice_callback(uint16_t line_num, const uint8_t *file_name);
00056 
00057 
00058 /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ 
00059 /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \
00060 /** @brief Check intended for production code
00061  *
00062  * Check passes if "expr" evaluates to true. */
00063 #define ASSERT(expr) \
00064 if (expr)                                                                     \
00065 {                                                                             \
00066 }                                                                             \
00067 else                                                                          \
00068 {                                                                             \
00069   assert_softdevice_callback((uint16_t)__LINE__, (uint8_t *)__FILE__);        \
00070   /*lint -unreachable */                                                      \
00071 }
00072 
00073 #endif /* SOFTDEVICE_ASSERT_H_ */