]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_eth.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_eth.h
1 /**
2  * Copyright (C) 2016 CSI Project. 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
18 #ifndef _CSI_NET_H_
19 #define _CSI_NET_H_
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #define CSI_ETH_VERSION_MAJOR_MINOR(major,minor) (((major) << 8) | (minor))
26
27 /**
28 \brief Driver Version
29 */
30 typedef struct csi_driver_version {
31     uint16_t api;                         ///< API version
32     uint16_t drv;                         ///< Driver version
33 } csi_drv_version_t;
34
35 /* General return codes */
36 #define CSI_ETH_OK                 0 ///< Operation succeeded
37 #define CSI_ETH_ERROR             CSI_DRV_ERRNO_ETH_BASE+1 ///< Unspecified error
38 #define CSI_ETH_ERROR_BUSY        CSI_DRV_ERRNO_ETH_BASE+2 ///< Driver is busy
39 #define CSI_ETH_ERROR_TIMEOUT     CSI_DRV_ERRNO_ETH_BASE+3 ///< Timeout occurred
40 #define CSI_ETH_ERROR_UNSUPPORTED CSI_DRV_ERRNO_ETH_BASE+4 ///< Operation not supported
41 #define CSI_ETH_ERROR_PARAMETER   CSI_DRV_ERRNO_ETH_BASE+5 ///< Parameter error
42 #define CSI_ETH_ERROR_SPECIFIC    CSI_DRV_ERRNO_ETH_BASE+6 ///< Start of driver specific errors
43
44 /**
45 \brief General power states
46 */
47 typedef enum eth_power_state {
48     CSI_ETH_POWER_OFF,                        ///< Power off: no operation possible
49     CSI_ETH_POWER_LOW,                        ///< Low Power mode: retain state, detect and signal wake-up events
50     CSI_ETH_POWER_FULL                        ///< Power on: full operation at maximum performance
51 } eth_power_state_t;
52
53 /**
54 \brief Ethernet Media Interface type
55 */
56 #define CSI_ETH_INTERFACE_MII           (0)     ///< Media Independent Interface (MII)
57 #define CSI_ETH_INTERFACE_RMII          (1)     ///< Reduced Media Independent Interface (RMII)
58 #define CSI_ETH_INTERFACE_SMII          (2)     ///< Serial Media Independent Interface (SMII)
59
60 /**
61 \brief Ethernet link speed
62 */
63 #define CSI_ETH_SPEED_10M               (0)     ///< 10 Mbps link speed
64 #define CSI_ETH_SPEED_100M              (1)     ///< 100 Mbps link speed
65 #define CSI_ETH_SPEED_1G                (2)     ///< 1 Gpbs link speed
66
67 /**
68 \brief Ethernet duplex mode
69 */
70 #define CSI_ETH_DUPLEX_HALF             (0)     ///< Half duplex link
71 #define CSI_ETH_DUPLEX_FULL             (1)     ///< Full duplex link
72
73 /**
74 \brief Ethernet link state
75 */
76 typedef enum eth_link_state {
77     ETH_LINK_DOWN,                    ///< Link is down
78     ETH_LINK_UP                       ///< Link is up
79 } eth_link_state_t;
80
81 /**
82 \brief Ethernet link information
83 */
84 typedef volatile struct eth_link_info {
85   uint32_t speed              : 2;                ///< Link speed: 0= 10 MBit, 1= 100 MBit, 2= 1 GBit
86   uint32_t duplex             : 1;                ///< Duplex mode: 0= Half, 1= Full
87   uint32_t Autonegotiation    : 1;                ///< Set the interface to Auto Negotiation mode of transmission parameters
88   uint32_t Loopback           : 1;                ///< Set the interface into a Loop-back test mode
89   uint32_t Isolation          : 1;                ///< Set to indicate electrical isolation of PHY interface from MII/RMII interface
90   uint32_t reserved           : 26;
91 } eth_link_info_t;
92
93 /**
94 \brief Ethernet MAC Address
95 */
96 typedef struct eth_mac_addr {
97     uint8_t b[6];                         ///< MAC Address (6 bytes), MSB first
98 } eth_mac_addr_t;
99
100 #ifdef __cplusplus
101 }
102 #endif
103
104 #endif /* CSI_NET_H_ */
105