app_drv_error.h
Go to the documentation of this file.
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 "stdint.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 0x00E1 /**< Hal internal error. */
69 #define APP_DRV_ERR_BUSY 0x00E2 /**< Driver is busy. */
70 #define APP_DRV_ERR_TIMEOUT 0x00E3 /**< Timeout occurred. */
71 #define APP_DRV_ERR_INVALID_PARAM 0x00E4 /**< Invalid parameter. */
72 #define APP_DRV_ERR_POINTER_NULL 0x00E5 /**< Invalid pointer. */
73 #define APP_DRV_ERR_INVALID_TYPE 0x00E6 /**< Invalid type. */
74 #define APP_DRV_ERR_INVALID_MODE 0x00E7 /**< Invalid mode. */
75 #define APP_DRV_ERR_INVALID_ID 0x00E8 /**< Invalid ID. */
76 #define APP_DRV_ERR_NOT_INIT 0x00E9 /**< Driver not init. */
77 #define APP_DRV_ERR_INVALID_INIT 0x00EA /**< Invalid init, deinit firstly. */
78 /** @} */
79 
80 /**@addtogroup APP_DRV_ERR_CODE_CHECK App Driver error code check
81  * @{
82  */
83 /**@brief App Driver error code check. */
84 #ifndef APP_DRV_ERR_CODE_CHECK
85 #define APP_DRV_ERR_CODE_CHECK(err_code) \
86  do \
87  { \
88  if (APP_DRV_SUCCESS != err_code) \
89  { \
90  return err_code; \
91  } \
92  } while(0)
93 #endif
94 /** @} */
95 
96 /**@addtogroup HAL_DRV_ERR_CODE_CHECK Hal Driver error code check
97  * @{
98  */
99  /**@brief Hal Driver error code check. */
100 #ifndef HAL_ERR_CODE_CHECK
101 #define HAL_ERR_CODE_CHECK(err_code) \
102  do \
103  { \
104  if (HAL_OK != err_code) \
105  { \
106  return (uint16_t)err_code; \
107  } \
108  } while(0)
109 #endif
110 /** @} */
111 /** @} */
112 
113 /**
114  * @defgroup APP_DRV_ERROR_TYPEDEF Type definitions
115  * @{
116  */
117 /**@brief APP driver error type. */
118 typedef uint16_t app_drv_err_t;
119 /**@} */
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif
126 
127 /** @} */
128 /** @} */
129 /** @} */
130 
app_drv_err_t
uint16_t app_drv_err_t
APP driver error type.
Definition: app_drv_error.h:118