1 /** 2 **************************************************************************************** 3 * 4 * @file app_drv_error.h 5 * @author BLE Driver Team 6 * @brief Header file of app driver error code. 7 * 8 **************************************************************************************** 9 * @attention 10 #####Copyright (c) 2019 GOODIX 11 All rights reserved. 12 13 Redistribution and use in source and binary forms, with or without 14 modification, are permitted provided that the following conditions are met: 15 * Redistributions of source code must retain the above copyright 16 notice, this list of conditions and the following disclaimer. 17 * Redistributions in binary form must reproduce the above copyright 18 notice, this list of conditions and the following disclaimer in the 19 documentation and/or other materials provided with the distribution. 20 * Neither the name of GOODIX nor the names of its contributors may be used 21 to endorse or promote products derived from this software without 22 specific prior written permission. 23 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 POSSIBILITY OF SUCH DAMAGE. 35 **************************************************************************************** 36 */ 37 38 /** @addtogroup PERIPHERAL Peripheral Driver 39 * @{ 40 */ 41 42 /** @addtogroup APP_DRIVER APP DRIVER 43 * @{ 44 */ 45 46 /** @defgroup APP_DRIVER_ERROR ERROR DEFINE 47 * @brief APP ERROR DEFINE 48 * @{ 49 */ 50 51 52 #ifndef _APP_DRV_ERROR_H_ 53 #define _APP_DRV_ERROR_H_ 54 55 #include "gr55xx_hal.h" 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 61 /**@addtogroup APP_DRV_ERR Defines 62 * @{ 63 */ 64 /**@addtogroup APP_DRV_ERR_CODE App Driver error codes 65 * @{ 66 */ 67 #define APP_DRV_SUCCESS 0x0000 /**< Successful. */ 68 #define APP_DRV_ERR_HAL 0x0001 /**< Hal internal error. */ 69 #define APP_DRV_ERR_BUSY 0x0002 /**< Driver is busy. */ 70 #define APP_DRV_ERR_TIMEOUT 0x0003 /**< Timeout occurred. */ 71 #define APP_DRV_ERR_INVALID_PARAM 0x0004 /**< Invalid parameter supplied. */ 72 #define APP_DRV_ERR_POINTER_NULL 0x0005 /**< Invalid pointer supplied. */ 73 #define APP_DRV_ERR_INVALID_TYPE 0x0006 /**< Invalid type suplied. */ 74 #define APP_DRV_ERR_INVALID_MODE 0x0007 /**< Invalid mode suplied. */ 75 #define APP_DRV_ERR_INVALID_ID 0x0008 /**< Invalid ID suplied. */ 76 /** @} */ 77 78 /**@addtogroup APP_DRV_ERR_CODE_CHECK App Driver error code check 79 * @{ 80 */ 81 /**@brief App Driver error code check. */ 82 #define APP_DRV_ERR_CODE_CHECK(err_code) \ 83 do \ 84 { \ 85 if ((err_code) != APP_DRV_SUCCESS) \ 86 { \ 87 return err_code; \ 88 } \ 89 } while (0) 90 /** @} */ 91 92 /**@addtogroup HAL_DRV_ERR_CODE_CHECK Hal Driver error code check 93 * @{ 94 */ 95 /**@brief Hal Driver error code check. */ 96 #define HAL_ERR_CODE_CHECK(err_code) \ 97 do \ 98 { \ 99 if ((err_code) != HAL_OK) \ 100 { \ 101 return (uint16_t)(err_code); \ 102 } \ 103 } while (0) 104 /** @} */ 105 /** @} */ 106 107 /** 108 * @defgroup APP_DRV_ERROR_TYPEDEF Typedefs 109 * @{ 110 */ 111 /**@brief APP driver error type. */ 112 typedef uint16_t app_drv_err_t; 113 /**@} */ 114 115 #ifdef __cplusplus 116 } 117 #endif 118 119 #endif 120 121 /** @} */ 122 /** @} */ 123 /** @} */ 124 125