1 //*****************************************************************************
2 //
3 //! @file am_hal_fault.h
4 //!
5 //! @brief Functions for interfacing with the fault control.
6 //!
7 //! @addtogroup fault_4p Fault - CPU Fault Control
8 //! @ingroup apollo4p_hal
9 //! @{
10 //
11 //*****************************************************************************
12 
13 //*****************************************************************************
14 //
15 // Copyright (c) 2023, Ambiq Micro, Inc.
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are met:
20 //
21 // 1. Redistributions of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
23 //
24 // 2. Redistributions in binary form must reproduce the above copyright
25 // notice, this list of conditions and the following disclaimer in the
26 // documentation and/or other materials provided with the distribution.
27 //
28 // 3. Neither the name of the copyright holder nor the names of its
29 // contributors may be used to endorse or promote products derived from this
30 // software without specific prior written permission.
31 //
32 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
36 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 // POSSIBILITY OF SUCH DAMAGE.
43 //
44 // This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
45 //
46 //*****************************************************************************
47 #ifndef AM_HAL_FAULT_H
48 #define AM_HAL_FAULT_H
49 
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 //*****************************************************************************
56 //
57 //! CPU Fault Status structure
58 //
59 //*****************************************************************************
60 typedef struct
61 {
62     //
63     //! ICODE bus fault occurred.
64     //
65     bool bICODE;
66 
67     //
68     //! ICODE bus fault address.
69     //
70     uint32_t ui32ICODE;
71 
72     //
73     //! DCODE bus fault occurred.
74     //
75     bool bDCODE;
76 
77     //
78     //! DCODE bus fault address.
79     //
80     uint32_t ui32DCODE;
81 
82     //
83     //! SYS bus fault occurred.
84     //
85     bool bSYS;
86 
87     //
88     //! SYS bus fault address.
89     //
90     uint32_t ui32SYS;
91 }
92 am_hal_fault_status_t;
93 
94 // ****************************************************************************
95 //
96 //! @brief Enable Fault Capture.
97 //!
98 //! This function is used to enable fault capture on the CPU block.
99 //!
100 //! @return status      - generic or interface specific status.
101 //
102 // ****************************************************************************
103 extern uint32_t am_hal_fault_capture_enable(void);
104 
105 // ****************************************************************************
106 //
107 //! @brief Disable Fault Capture.
108 //!
109 //! This function is used to disable fault capture on the CPU block.
110 //!
111 //! @return status      - generic or interface specific status.
112 //
113 // ****************************************************************************
114 extern uint32_t am_hal_fault_capture_disable(void);
115 
116 // ****************************************************************************
117 //
118 //! @brief Get fault information from the CPU.
119 //!
120 //! This function returns current fault status as obtained from the CPU block
121 //! in Apollo4.
122 //!
123 //! @param pFaultStatus - A pointer to a structure to receive the fault data.
124 //!
125 //! @return status      - generic or interface specific status.
126 //
127 // ****************************************************************************
128 extern uint32_t am_hal_fault_status_get(am_hal_fault_status_t *pFaultStatus);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif // AM_HAL_FAULT_H
135 
136 //*****************************************************************************
137 //
138 // End Doxygen group.
139 //! @}
140 //
141 //*****************************************************************************
142 
143