AM263x Motor Control SDK  09.02.00
dcl_error.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _DCL_ERROR_H_
34 #define _DCL_ERROR_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
48 #include "../dcl_common.h"
49 
50 //--- Error handling ---------------------------------------------------------
51 
55 typedef enum dcl_error_codes
56 {
57  dcl_none = 0U,
58  dcl_param_range_err = (1U << 0),
59  dcl_param_invalid_err = (1U << 1),
60  dcl_param_warn_err = (1U << 2),
61  dcl_input_range_err = (1U << 3),
62  dcl_overflow_err = (1U << 4),
63  dcl_underflow_err = (1U << 5),
64  dcl_controller_err = (1U << 6),
65  dcl_timing_err = (1U << 7),
66  dcl_comp_err = (1U << 8)
68 
73 #define DCL_clearError(ptr) ((ptr)->css->err = dcl_none)
74 
80 #define DCL_setError(ptr,code) ((ptr)->css->err |= code)
81 
86 #define DCL_getErrorLine(ptr) ((ptr)->css->err_line = ((ptr)->css->err) ? __LINE__ : 0)
87 
92 #define DCL_getErrorFunc(ptr) ((ptr)->css->err_func = ((ptr)->css->err) ? __FUNCTION__ : NULL)
93 
98 #define DCL_getErrorInfo(ptr) \
99 { \
100  DCL_getErrorLine(ptr); \
101  DCL_getErrorFunc(ptr); \
102 }
103 
108 #define DCL_runErrorHandler(ptr) \
109 { \
110  if(ptr->css->err != dcl_none)\
111  { \
112  DCL_setBreakPoint(); \
113  DCL_clearError(ptr); \
114  } \
115 }
116 
119 #ifdef __cplusplus
120 }
121 #endif // extern "C"
122 
123 #endif // _DCL_ERROR_H_
dcl_none
@ dcl_none
No error.
Definition: dcl_error.h:57
DCL_error_codes
DCL_error_codes
Defines the library enumerated error codes. These will be applied as bit masks in the error handler.
Definition: dcl_error.h:56
dcl_controller_err
@ dcl_controller_err
Controller operation not completed.
Definition: dcl_error.h:64
dcl_timing_err
@ dcl_timing_err
Timing error.
Definition: dcl_error.h:65
dcl_underflow_err
@ dcl_underflow_err
Numerical underflow
Definition: dcl_error.h:63
dcl_param_range_err
@ dcl_param_range_err
Parameter range exceeded.
Definition: dcl_error.h:58
dcl_param_warn_err
@ dcl_param_warn_err
Parameter warning.
Definition: dcl_error.h:60
dcl_input_range_err
@ dcl_input_range_err
Input range exceeded.
Definition: dcl_error.h:61
dcl_param_invalid_err
@ dcl_param_invalid_err
Parameter not valid.
Definition: dcl_error.h:59
dcl_comp_err
@ dcl_comp_err
Computation error.
Definition: dcl_error.h:66
dcl_overflow_err
@ dcl_overflow_err
Numerical overflow.
Definition: dcl_error.h:62