1 //***************************************************************************** 2 // 3 // am_hal_debug.h 4 //! @file 5 //! 6 //! @brief Useful macros for debugging. 7 //! 8 //! These functions and macros were created to assist with debugging. They are 9 //! intended to be as unintrusive as possible and designed to be removed from 10 //! the compilation of a project when they are no longer needed. 11 // 12 //***************************************************************************** 13 14 //***************************************************************************** 15 // 16 // Copyright (c) 2017, Ambiq Micro 17 // All rights reserved. 18 // 19 // Redistribution and use in source and binary forms, with or without 20 // modification, are permitted provided that the following conditions are met: 21 // 22 // 1. Redistributions of source code must retain the above copyright notice, 23 // this list of conditions and the following disclaimer. 24 // 25 // 2. Redistributions in binary form must reproduce the above copyright 26 // notice, this list of conditions and the following disclaimer in the 27 // documentation and/or other materials provided with the distribution. 28 // 29 // 3. Neither the name of the copyright holder nor the names of its 30 // contributors may be used to endorse or promote products derived from this 31 // software without specific prior written permission. 32 // 33 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 34 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 35 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 36 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 37 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 38 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 39 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 40 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 41 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 42 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 43 // POSSIBILITY OF SUCH DAMAGE. 44 // 45 // This is part of revision 1.2.11 of the AmbiqSuite Development Package. 46 // 47 //***************************************************************************** 48 #ifndef AM_HAL_DEBUG_H 49 #define AM_HAL_DEBUG_H 50 51 //***************************************************************************** 52 // 53 // Debug assert macros. 54 // 55 //***************************************************************************** 56 #ifndef AM_HAL_DEBUG_NO_ASSERT 57 58 #define am_hal_debug_assert_msg(bCondition, pcMessage) \ 59 if ( !(bCondition)) am_hal_debug_error(__FILE__, __LINE__, pcMessage) 60 61 #define am_hal_debug_assert(bCondition) \ 62 if ( !(bCondition)) am_hal_debug_error(__FILE__, __LINE__, 0) 63 64 #else 65 66 #define am_hal_debug_assert_msg(bCondition, pcMessage) 67 #define am_hal_debug_assert(bCondition) 68 69 #endif // AM_DEBUG_ASSERT 70 71 #ifdef __cplusplus 72 extern "C" 73 { 74 #endif 75 76 //***************************************************************************** 77 // 78 // External function prototypes. 79 // 80 //***************************************************************************** 81 extern void am_hal_debug_error(const char *pcFile, uint32_t ui32Line, 82 const char *pcMessage); 83 84 #ifdef __cplusplus 85 } 86 #endif 87 88 #endif // AM_HAL_DEBUG_H 89 90