1 //*****************************************************************************
2 //
3 // am_hal_debug.c
4 //! @file
5 //!
6 //! @brief Useful functions 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
49 #include <stdint.h>
50 #include <stdbool.h>
51 #include "am_mcu_apollo.h"
52
53 //*****************************************************************************
54 //
55 //! @brief Default implementation of a failed ASSERT statement.
56 //!
57 //! @param pcFile is the name of the source file where the error occurred.
58 //! @param ui32Line is the line number where the error occurred.
59 //! @param pcMessage is an optional message describing the failure.
60 //!
61 //! This function is called by am_hal_debug_assert() macro when the supplied
62 //! condition is not true. The implementation here simply halts the application
63 //! for further analysis. Individual applications may define their own
64 //! implementations of am_hal_debug_error() to provide more detailed feedback
65 //! about the failed am_hal_debug_assert() statement.
66 //!
67 //! @return
68 //
69 //*****************************************************************************
70 #if defined (__IAR_SYSTEMS_ICC__)
71 __weak void
72 #else
73 void __attribute__((weak))
74 #endif
am_hal_debug_error(const char * pcFile,uint32_t ui32Line,const char * pcMessage)75 am_hal_debug_error(const char *pcFile, uint32_t ui32Line, const char *pcMessage)
76 {
77 //
78 // Halt for analysis.
79 //
80 while(1);
81 }
82