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 /** LevelX Component                                                      */
16 /**                                                                       */
17 /**   NOR Flash                                                           */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define LX_SOURCE_CODE
23 
24 
25 /* Disable ThreadX error checking.  */
26 
27 #ifndef LX_DISABLE_ERROR_CHECKING
28 #define LX_DISABLE_ERROR_CHECKING
29 #endif
30 
31 
32 /* Include necessary system files.  */
33 
34 #include "lx_api.h"
35 
36 
37 /**************************************************************************/
38 /*                                                                        */
39 /*  FUNCTION                                               RELEASE        */
40 /*                                                                        */
41 /*    _lx_nor_flash_system_error                          PORTABLE C      */
42 /*                                                           6.2.1       */
43 /*  AUTHOR                                                                */
44 /*                                                                        */
45 /*    William E. Lamie, Microsoft Corporation                             */
46 /*                                                                        */
47 /*  DESCRIPTION                                                           */
48 /*                                                                        */
49 /*    This function handles system errors in the NOR flash.               */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    nor_flash                             NOR flash instance            */
54 /*    error_code                            System error code             */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    None                                                                */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    (lx_nor_flash_driver_system_error)    Driver system error handler   */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Internal LevelX                                                     */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
73 /*  09-30-2020     William E. Lamie         Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*  06-02-2021     Bhupendra Naphade        Modified comment(s),          */
76 /*                                            resulting in version 6.1.7  */
77 /*  03-08-2023     Xiuwen Cai               Modified comment(s),          */
78 /*                                            added new driver interface, */
79 /*                                            resulting in version 6.2.1 */
80 /*                                                                        */
81 /**************************************************************************/
_lx_nor_flash_system_error(LX_NOR_FLASH * nor_flash,UINT error_code)82 VOID  _lx_nor_flash_system_error(LX_NOR_FLASH *nor_flash, UINT error_code)
83 {
84 
85     /* Increment the system error counter.  */
86     nor_flash -> lx_nor_flash_diagnostic_system_errors++;
87 
88     /* Save the most recent system error code.  */
89     nor_flash -> lx_nor_flash_diagnostic_system_error =  error_code;
90 
91     /* Determine if the driver has setup a system error handler.  */
92     if (nor_flash -> lx_nor_flash_driver_system_error)
93     {
94 
95         /* Yes, call the driver's system error handler.  */
96 #ifdef LX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
97         (nor_flash -> lx_nor_flash_driver_system_error)(nor_flash, error_code);
98 #else
99         (nor_flash -> lx_nor_flash_driver_system_error)(error_code);
100 #endif
101     }
102 }
103 
104