|
| 1 | +/* |
| 2 | +* Copyright (c) 2011 Renesas Electronics Corporation and/or its affiliates |
| 3 | +* |
| 4 | +* SPDX-License-Identifier: BSD-3-Clause |
| 5 | +*/ |
| 6 | +/*********************************************************************************************************************** |
| 7 | +* File Name : r_fsp_error.h |
| 8 | +* Description : The user chooses which MCU and board they are developing for in this file. If the board you are using |
| 9 | +* is not listed below, please add your own or use the default 'User Board'. |
| 10 | +***********************************************************************************************************************/ |
| 11 | +/*********************************************************************************************************************** |
| 12 | +* History : DD.MM.YYYY Version Description |
| 13 | +* : 23.04.2021 1.00 First Release |
| 14 | +* : 26.02.2025 1.01 Changed the disclaimer. |
| 15 | +***********************************************************************************************************************/ |
| 16 | +#ifndef R_FSP_ERROR_H_ |
| 17 | +#define R_FSP_ERROR_H_ |
| 18 | + |
| 19 | + |
| 20 | +/*********************************************************************************************************************** |
| 21 | + * Includes |
| 22 | + **********************************************************************************************************************/ |
| 23 | +#include "fsp_common_api.h" |
| 24 | + |
| 25 | +/*********************************************************************************************************************** |
| 26 | + * Macro definitions |
| 27 | + **********************************************************************************************************************/ |
| 28 | +/** Macro to log and return error without an assertion. */ |
| 29 | +#ifndef FSP_RETURN |
| 30 | + |
| 31 | + #define FSP_RETURN(err) FSP_ERROR_LOG((err)); \ |
| 32 | + return err; |
| 33 | +#endif |
| 34 | + |
| 35 | +/** This function is called before returning an error code. To stop on a runtime error, define fsp_error_log in |
| 36 | + * user code and do required debugging (breakpoints, stack dump, etc) in this function.*/ |
| 37 | + #define FSP_ERROR_LOG(err) |
| 38 | + |
| 39 | +/** Default assertion calls ::FSP_ERROR_RETURN if condition "a" is false. Used to identify incorrect use of API's in FSP |
| 40 | + * functions. */ |
| 41 | + #define FSP_ASSERT(a) FSP_ERROR_RETURN((a), FSP_ERR_ASSERTION) |
| 42 | + |
| 43 | +/** All FSP error codes are returned using this macro. Calls ::FSP_ERROR_LOG function if condition "a" is false. Used |
| 44 | + * to identify runtime errors in FSP functions. */ |
| 45 | + |
| 46 | +#define FSP_ERROR_RETURN(a, err) \ |
| 47 | + { \ |
| 48 | + if ((a)) \ |
| 49 | + { \ |
| 50 | + (void) 0; /* Do nothing */ \ |
| 51 | + } \ |
| 52 | + else \ |
| 53 | + { \ |
| 54 | + FSP_ERROR_LOG(err); \ |
| 55 | + return err; \ |
| 56 | + } \ |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | +#endif /* R_FSP_ERROR_H_ */ |
0 commit comments