]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_errno.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / include / drv_errno.h
1 /*
2  * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /******************************************************************************
17  * @file     drv_errno.h
18  * @brief    header file for error num
19  * @version  V1.0
20  * @date     02. June 2017
21  ******************************************************************************/
22
23 /******************************************************************************
24  * @file
25  * @details     Error code field difination
26  *              Error number is devided into 4 field:
27  *              0x8******* : 8  : means < 0
28  *              0x*A****** : A  : means type number: bsp(1), driver(2), hal(3), app(4)...
29  *              0x**AB**** : AB : means module number: timer(1), rtc(2), ....
30  *              0x****AB** : AB : means API number: module API's definition
31  *              0x******AB : AB : means sub error number
32  *                                  0 ~ 0x80 is common error such as EPERM, refer to errno.h
33  *                                  0x80 ~ 0xFF is specific error, can difine in module
34  *
35  *              For example 0x81020113 means:
36  *                  1. 0x8*******: value < 0, means error happened
37  *                  2. 0x*1******: type number is 1, means bsp error
38  *                  3. 0x**02****: module number is 02, means RTC error
39  *                  4. 0x****01**: module API is 01, means RTC's init
40  *                  5. 0x******13: specific error is 0x13=19=ENODEV, means no such device
41  *
42  *              For special bsp module example, you can return:
43  *                  (BSP_ERRNO_TIMER_BASE | BSP_API_RTC_INIT | EPERM)    for rtc init error
44  *                  (BSP_ERRNO_TIMER_BASE | BSP_API_RTC_SETTIME | ENXIO) for rtc settime error
45  *
46  *              Here list the common sub error number (0x******AB) below(0~127 defined in errno.h as standard err code):
47  *              Code          Hex    Deci   Meaning
48  *              -------------------------------------------------------
49  *              EPERM         0x01    1   Operation not permitted
50  *              EIO           0x05    5   I/O error
51  *              ENXIO         0x06    6   No such device or address
52  *              ENOMEM        0x0C   12   Out of memory
53  *              EACCES        0x0D   13   Permission denied
54  *              EINVAL        0x16   22      Invalid argument
55  *              ...
56  *              SPEC_ERR_BASE 0x80  128   module special error number base
57  *              ...
58  *              ERRNO_MAX     0xFF   --   Max sub error number
59  ******************************************************************************/
60
61 #ifndef _DRV_ERRNO_H_
62 #define _DRV_ERRNO_H_
63
64
65 #include <errno.h>
66
67 #define ERRNO_DRV_START 0X80
68
69 /* drvier General return codes */
70 typedef enum {
71     EDRV = ERRNO_DRV_START,   ///< Unspecified error
72     EDRV_BUSY,                ///< Driver is busy
73     EDRV_TIMEOUT,             ///< Timeout occurred
74     EDRV_UNSUPPORTED,         ///< Operation not supported
75     EDRV_PARAMETER,           ///< Parameter error
76     EDRV_SPECIFIC             ///< Start of driver specific errors
77 } drv_common_err_e;
78
79
80 /** Get error type */
81 #define GET_ERROR_TYPE(errno) \
82     (error & 0xFF000000 >> 24)
83 /** Get error module */
84 #define GET_ERROR_MODULE(error) \
85     (error & 0x00FF0000 >> 16)
86 /** Get error API */
87 #define GET_ERROR_API(error) \
88     (error & 0x0000FF00 >> 8)
89 /** Get errno */
90 #define GET_ERROR_NUM(error) \
91     (error & 0x000000FF)
92
93 #ifndef CSI_DRV_ERRNO_BASE
94 /** means bsp errors */
95 #define CSI_DRV_ERRNO_BASE          0x81000000
96 #endif
97
98 /** driver module id definition*/
99 #define CSI_DRV_ERRNO_GPIO_BASE     0x81010000
100 #define CSI_DRV_ERRNO_USART_BASE    0x81020000
101 #define CSI_DRV_ERRNO_SPI_BASE      0x81030000
102 #define CSI_DRV_ERRNO_I2C_BASE      0x81040000
103 #define CSI_DRV_ERRNO_FLASH_BASE    0x81050000
104 #define CSI_DRV_ERRNO_PWM_BASE      0x81060000
105 #define CSI_DRV_ERRNO_RTC_BASE      0x81070000
106 #define CSI_DRV_ERRNO_TIMER_BASE    0x81080000
107 #define CSI_DRV_ERRNO_WDT_BASE      0x81090000
108 #define CSI_DRV_ERRNO_AES_BASE      0x810A0000
109 #define CSI_DRV_ERRNO_CRC_BASE      0x810B0000
110 #define CSI_DRV_ERRNO_RSA_BASE      0x810C0000
111 #define CSI_DRV_ERRNO_SHA_BASE      0x810D0000
112 #define CSI_DRV_ERRNO_TRNG_BASE     0x810E0000
113 #define CSI_DRV_ERRNO_EFLASH_BASE   0x810F0000
114 #define CSI_DRV_ERRNO_DMA_BASE      0x81100000
115 #define CSI_DRV_ERRNO_NORFLASH_BASE 0x81110000
116 #define CSI_DRV_ERRNO_INTC_BASE     0x81120000
117 #define CSI_DRV_ERRNO_SPU_BASE      0x81110000
118 #define CSI_DRV_ERRNO_TEE_BASE      0x81130000
119 #define CSI_DRV_ERRNO_PMU_BASE      0x81140000
120
121 #endif /* CSI_DRV_ERRNO_H */