libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
phy.h
Go to the documentation of this file.
1/** @defgroup ethernet_phy_defines PHY Generic Defines
2 *
3 * @brief <b>Defined Constants and Types for the Ethernet PHY</b>
4 *
5 * @ingroup ETH
6 *
7 * @version 1.0.0
8 *
9 * @author @htmlonly &copy; @endhtmlonly 2013 Frantisek Burian <BuFran@seznam.cz>
10 *
11 * @date 1 September 2013
12 *
13 * LGPL License Terms @ref lgpl_license
14 */
15/*
16 * This file is part of the libopencm3 project.
17 *
18 * Copyright (C) 2013 Frantisek Burian <BuFran@seznam.cz>
19 *
20 * This library is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public License
31 * along with this library. If not, see <http://www.gnu.org/licenses/>.
32 */
33#ifndef LIBOPENCM3_PHY_H
34#define LIBOPENCM3_PHY_H
35
36#include <stdbool.h>
37
38/**@{*/
39
40/*****************************************************************************/
41/* Register definitions */
42/*****************************************************************************/
43
44#define PHY_REG_BCR 0x00
45#define PHY_REG_BSR 0x01
46#define PHY_REG_ID1 0x02
47#define PHY_REG_ID2 0x03
48#define PHY_REG_ANTX 0x04
49#define PHY_REG_ANRX 0x05
50#define PHY_REG_ANEXP 0x06
51#define PHY_REG_ANNPTX 0x07
52#define PHY_REG_ANNPRX 0x08
53
54/*****************************************************************************/
55/* Register values */
56/*****************************************************************************/
57
58#define PHY_REG_BCR_COLTEST (1 << 7)
59#define PHY_REG_BCR_FD (1 << 8)
60#define PHY_REG_BCR_ANRST (1 << 9)
61#define PHY_REG_BCR_ISOLATE (1 << 10)
62#define PHY_REG_BCR_POWERDN (1 << 11)
63#define PHY_REG_BCR_AN (1 << 12)
64#define PHY_REG_BCR_100M (1 << 13)
65#define PHY_REG_BCR_LOOPBACK (1 << 14)
66#define PHY_REG_BCR_RESET (1 << 15)
67
68#define PHY_REG_BSR_JABBER (1 << 1)
69#define PHY_REG_BSR_UP (1 << 2)
70#define PHY_REG_BSR_FAULT (1 << 4)
71#define PHY_REG_BSR_ANDONE (1 << 5)
72
73
74
75/*****************************************************************************/
76/* API definitions */
77/*****************************************************************************/
78
79#define PHY0 0
80#define PHY1 1
81
92};
93
94/*****************************************************************************/
95/* API Functions */
96/*****************************************************************************/
97
99
100void phy_reset(uint8_t phy);
101bool phy_link_isup(uint8_t phy);
102
103enum phy_status phy_link_status(uint8_t phy);
104
105void phy_autoneg_force(uint8_t phy, enum phy_status mode);
106void phy_autoneg_enable(uint8_t phy);
107
109
110/**@}*/
111
112
113#endif /* LIBOPENCM3_PHY_H__ */
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
bool phy_link_isup(uint8_t phy)
Is the link up ?
Definition: phy.c:46
void phy_autoneg_force(uint8_t phy, enum phy_status mode)
Force autonegotiation.
Definition: phy_ksz80x1.c:62
void phy_reset(uint8_t phy)
Reset the PHY.
Definition: phy.c:57
phy_status
Definition: phy.h:82
void phy_autoneg_enable(uint8_t phy)
Enable the autonegotiation.
Definition: phy_ksz80x1.c:86
enum phy_status phy_link_status(uint8_t phy)
Get the current link status.
Definition: phy_ksz80x1.c:49
@ LINK_FD_10M
Definition: phy.h:88
@ LINK_HD_100M
Definition: phy.h:85
@ LINK_FD_1000M
Definition: phy.h:90
@ LINK_FD_10000M
Definition: phy.h:91
@ LINK_DOWN
Definition: phy.h:83
@ LINK_HD_10M
Definition: phy.h:84
@ LINK_FD_100M
Definition: phy.h:89
@ LINK_HD_10000M
Definition: phy.h:87
@ LINK_HD_1000M
Definition: phy.h:86