mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-13 22:59:22 +08:00
2. 在IMXRT的Libraries中增加了peripherals目录,用于具体型号的设备驱动相关的代码的实现,不应与MCU的平台相关,实现PHY的设备对象中的相关接口。 3. 修改了BSP中的Sconstruct文件,增加了peripherals目录的构建 4. 修改了KEIL环境的SCT文件,用于实现以太网功能
80 lines
1.6 KiB
C
80 lines
1.6 KiB
C
|
|
|
|
#ifndef __PHY_H___
|
|
#define __PHY_H___
|
|
|
|
#include <rtthread.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
/* Defines the PHY link speed. This is align with the speed for MAC. */
|
|
enum phy_speed
|
|
{
|
|
PHY_SPEED_10M = 0U, /* PHY 10M speed. */
|
|
PHY_SPEED_100M /* PHY 100M speed. */
|
|
};
|
|
|
|
/* Defines the PHY link duplex. */
|
|
enum phy_duplex
|
|
{
|
|
PHY_HALF_DUPLEX = 0U, /* PHY half duplex. */
|
|
PHY_FULL_DUPLEX /* PHY full duplex. */
|
|
};
|
|
|
|
/*! @brief Defines the PHY loopback mode. */
|
|
enum phy_loop
|
|
{
|
|
PHY_LOCAL_LOOP = 0U, /* PHY local loopback. */
|
|
PHY_REMOTE_LOOP /* PHY remote loopback. */
|
|
};
|
|
|
|
|
|
struct rt_phy_msg
|
|
{
|
|
rt_uint32_t reg;
|
|
rt_uint32_t value;
|
|
};
|
|
|
|
typedef struct rt_phy_msg rt_phy_msg_t;
|
|
|
|
|
|
struct rt_phy_device
|
|
{
|
|
struct rt_device parent;
|
|
struct rt_mdio_bus *bus;
|
|
rt_uint32_t addr;
|
|
struct rt_phy_ops *ops;
|
|
};
|
|
|
|
typedef struct rt_phy_device rt_phy_t;
|
|
|
|
|
|
enum {
|
|
PHY_STATUS_OK = 0,
|
|
PHY_STATUS_FAIL,
|
|
PHY_STATUS_TIMEOUT,
|
|
};
|
|
|
|
typedef rt_int32_t rt_phy_status;
|
|
|
|
struct rt_phy_ops
|
|
{
|
|
rt_phy_status (*init)(void *object, rt_uint32_t phy_addr, rt_uint32_t src_clock_hz);
|
|
rt_phy_status (*read)(rt_uint32_t reg, rt_uint32_t *data);
|
|
rt_phy_status (*write)(rt_uint32_t reg, rt_uint32_t data);
|
|
rt_phy_status (*loopback)(rt_uint32_t mode, rt_uint32_t speed, rt_bool_t enable);
|
|
rt_phy_status (*get_link_status)(rt_bool_t *status);
|
|
rt_phy_status (*get_link_speed_duplex)(rt_uint32_t *speed, rt_uint32_t *duplex);
|
|
};
|
|
|
|
rt_err_t rt_hw_phy_register(struct rt_phy_device *phy, const char *name);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __PHY_H__*/
|