GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_system_error_handler.c Lines: 6 6 100.0 %
Date: 2024-12-12 17:16:36 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** USBX Component                                                        */
16
/**                                                                       */
17
/**   System                                                              */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
/* Include necessary system files.  */
23
24
#define UX_SOURCE_CODE
25
26
#include "ux_api.h"
27
28
29
#ifndef UX_DISABLE_ERROR_HANDLER
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _ux_system_error_handler                            PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Chaoqiong Xiao, Microsoft Corporation                               */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This function saves the last critical error from USBX functions.    */
43
/*    It is mainly used for debugging purpose to trap where error occurred*/
44
/*                                                                        */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*   error_code                                                           */
49
/*                                                                        */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    Application                                                         */
62
/*                                                                        */
63
/*  RELEASE HISTORY                                                       */
64
/*                                                                        */
65
/*    DATE              NAME                      DESCRIPTION             */
66
/*                                                                        */
67
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
68
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
69
/*                                            resulting in version 6.1    */
70
/*                                                                        */
71
/**************************************************************************/
72
18203
VOID   _ux_system_error_handler(UINT system_level, UINT system_context, UINT error_code)
73
{
74
75
    /* Save the last system error code.  */
76
18203
    _ux_system -> ux_system_last_error =  error_code;
77
78
    /* Increment the total number of system errors.  */
79
18203
    _ux_system -> ux_system_error_count++;
80
81
    /* Is there an application call back function to call ? */
82
18203
    if (_ux_system -> ux_system_error_callback_function != UX_NULL)
83
    {
84
85
        /* The callback function is defined, call it.  */
86
18067
        _ux_system -> ux_system_error_callback_function(system_level, system_context, error_code);
87
    }
88
18203
}
89
#endif