]> begriffs open source - cmsis/blob - CMSIS/Driver/Include/Driver_ETH_PHY.h
CMSIS Driver: Updated CAN API V1.2 (issue #179: added Bus-off state)
[cmsis] / CMSIS / Driver / Include / Driver_ETH_PHY.h
1 /*
2  * Copyright (c) 2013-2017 ARM Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * $Date:        2. Feb 2017
19  * $Revision:    V2.1
20  *
21  * Project:      Ethernet PHY (Physical Transceiver) Driver definitions
22  */
23
24 /* History:
25  *  Version 2.1
26  *    ARM_ETH_LINK_INFO made volatile
27  *  Version 2.0
28  *    changed parameter "mode" in function ARM_ETH_PHY_SetMode
29  *    Changed prefix ARM_DRV -> ARM_DRIVER
30  *    Changed return values of some functions to int32_t
31  *  Version 1.10
32  *    Namespace prefix ARM_ added
33  *  Version 1.00
34  *    Initial release
35  */
36
37 #ifndef DRIVER_ETH_PHY_H_
38 #define DRIVER_ETH_PHY_H_
39
40 #ifdef  __cplusplus
41 extern "C"
42 {
43 #endif
44
45 #include "Driver_ETH.h"
46
47 #define ARM_ETH_PHY_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2,1)  /* API version */
48
49
50 #define _ARM_Driver_ETH_PHY_(n)      Driver_ETH_PHY##n
51 #define  ARM_Driver_ETH_PHY_(n) _ARM_Driver_ETH_PHY_(n)
52
53
54 /****** Ethernet PHY Mode *****/
55 #define ARM_ETH_PHY_SPEED_Pos            0
56 #define ARM_ETH_PHY_SPEED_Msk           (3UL                 << ARM_ETH_PHY_SPEED_Pos)
57 #define ARM_ETH_PHY_SPEED_10M           (ARM_ETH_SPEED_10M   << ARM_ETH_PHY_SPEED_Pos)  ///< 10 Mbps link speed
58 #define ARM_ETH_PHY_SPEED_100M          (ARM_ETH_SPEED_100M  << ARM_ETH_PHY_SPEED_Pos)  ///< 100 Mbps link speed
59 #define ARM_ETH_PHY_SPEED_1G            (ARM_ETH_SPEED_1G    << ARM_ETH_PHY_SPEED_Pos)  ///< 1 Gpbs link speed
60 #define ARM_ETH_PHY_DUPLEX_Pos           2
61 #define ARM_ETH_PHY_DUPLEX_Msk          (1UL                 << ARM_ETH_PHY_DUPLEX_Pos)
62 #define ARM_ETH_PHY_DUPLEX_HALF         (ARM_ETH_DUPLEX_HALF << ARM_ETH_PHY_DUPLEX_Pos) ///< Half duplex link
63 #define ARM_ETH_PHY_DUPLEX_FULL         (ARM_ETH_DUPLEX_FULL << ARM_ETH_PHY_DUPLEX_Pos) ///< Full duplex link
64 #define ARM_ETH_PHY_AUTO_NEGOTIATE      (1UL << 3)                                      ///< Auto Negotiation mode
65 #define ARM_ETH_PHY_LOOPBACK            (1UL << 4)                                      ///< Loop-back test mode
66 #define ARM_ETH_PHY_ISOLATE             (1UL << 5)                                      ///< Isolate PHY from MII/RMII interface
67
68
69 // Function documentation
70 /**
71   \fn          ARM_DRIVER_VERSION ARM_ETH_PHY_GetVersion (void)
72   \brief       Get driver version.
73   \return      \ref ARM_DRIVER_VERSION
74 */
75 /**
76   \fn          int32_t ARM_ETH_PHY_Initialize (ARM_ETH_PHY_Read_t  fn_read,
77                                                ARM_ETH_PHY_Write_t fn_write)
78   \brief       Initialize Ethernet PHY Device.
79   \param[in]   fn_read   Pointer to \ref ARM_ETH_MAC_PHY_Read
80   \param[in]   fn_write  Pointer to \ref ARM_ETH_MAC_PHY_Write
81   \return      \ref execution_status
82 */
83 /**
84   \fn          int32_t ARM_ETH_PHY_Uninitialize (void)
85   \brief       De-initialize Ethernet PHY Device.
86   \return      \ref execution_status
87 */
88 /**
89   \fn          int32_t ARM_ETH_PHY_PowerControl (ARM_POWER_STATE state)
90   \brief       Control Ethernet PHY Device Power.
91   \param[in]   state  Power state
92   \return      \ref execution_status
93 */
94 /**
95   \fn          int32_t ARM_ETH_PHY_SetInterface (uint32_t interface)
96   \brief       Set Ethernet Media Interface.
97   \param[in]   interface  Media Interface type
98   \return      \ref execution_status
99 */
100 /**
101   \fn          int32_t ARM_ETH_PHY_SetMode (uint32_t mode)
102   \brief       Set Ethernet PHY Device Operation mode.
103   \param[in]   mode  Operation Mode
104   \return      \ref execution_status
105 */
106 /**
107   \fn          ARM_ETH_LINK_STATE ARM_ETH_PHY_GetLinkState (void)
108   \brief       Get Ethernet PHY Device Link state.
109   \return      current link status \ref ARM_ETH_LINK_STATE
110 */
111 /**
112   \fn          ARM_ETH_LINK_INFO ARM_ETH_PHY_GetLinkInfo (void)
113   \brief       Get Ethernet PHY Device Link information.
114   \return      current link parameters \ref ARM_ETH_LINK_INFO
115 */
116
117
118 typedef int32_t (*ARM_ETH_PHY_Read_t)  (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data); ///< Pointer to \ref ARM_ETH_MAC_PHY_Read : Read Ethernet PHY Register.
119 typedef int32_t (*ARM_ETH_PHY_Write_t) (uint8_t phy_addr, uint8_t reg_addr, uint16_t  data); ///< Pointer to \ref ARM_ETH_MAC_PHY_Write : Write Ethernet PHY Register.
120
121
122 /**
123 \brief Access structure of the Ethernet PHY Driver
124 */
125 typedef struct _ARM_DRIVER_ETH_PHY {
126   ARM_DRIVER_VERSION (*GetVersion)   (void);                          ///< Pointer to \ref ARM_ETH_PHY_GetVersion : Get driver version.
127   int32_t            (*Initialize)   (ARM_ETH_PHY_Read_t  fn_read,
128                                       ARM_ETH_PHY_Write_t fn_write);  ///< Pointer to \ref ARM_ETH_PHY_Initialize : Initialize PHY Device.
129   int32_t            (*Uninitialize) (void);                          ///< Pointer to \ref ARM_ETH_PHY_Uninitialize : De-initialize PHY Device.
130   int32_t            (*PowerControl) (ARM_POWER_STATE state);         ///< Pointer to \ref ARM_ETH_PHY_PowerControl : Control PHY Device Power.
131   int32_t            (*SetInterface) (uint32_t interface);            ///< Pointer to \ref ARM_ETH_PHY_SetInterface : Set Ethernet Media Interface.
132   int32_t            (*SetMode)      (uint32_t mode);                 ///< Pointer to \ref ARM_ETH_PHY_SetMode : Set Ethernet PHY Device Operation mode.
133   ARM_ETH_LINK_STATE (*GetLinkState) (void);                          ///< Pointer to \ref ARM_ETH_PHY_GetLinkState : Get Ethernet PHY Device Link state.
134   ARM_ETH_LINK_INFO  (*GetLinkInfo)  (void);                          ///< Pointer to \ref ARM_ETH_PHY_GetLinkInfo : Get Ethernet PHY Device Link information.
135 } const ARM_DRIVER_ETH_PHY;
136
137 #ifdef  __cplusplus
138 }
139 #endif
140
141 #endif /* DRIVER_ETH_PHY_H_ */