在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

以太網PHY硬件連接 以太網PHY驅動軟件配置介紹

瑞薩MCU小百科 ? 來源:瑞薩嵌入式小百科 ? 作者:瑞薩嵌入式小百科 ? 2024-02-20 12:18 ? 次閱讀

以太網PHY驅動軟件配置

這里以Renesas提供的RZ/T2M工程樣例“RZT2M_EtherCAT_RSK_rev0100”為例對PHY驅動的軟件配置流程進行說明。此工程樣例可以在Renesas提供的開發版上運行和調試。開發套件的使用文件《r20ut4939eg0050-rskrzt2m-usermanual_c.pdf》可以上Renesas官方網站上獲取,開發板也可以申請購買或者是借用。

驅動配置的入口

void hal_entry (void)
{
  fsp_err_t err;
  /* TODO: add your own code here */
  /* Initialize EtherCAT SSC Port */
  err = RM_ETHERCAT_SSC_PORT_Open(gp_ethercat_ssc_port->p_ctrl, gp_ethercat_ssc_port->p_cfg);
  if(FSP_SUCCESS != err)
  {
    __BKPT(0); /* Can't continue the stack */
  }
  ...
}

進入RM_ETHERCAT_SSC_PORT_Open(), 這個EtherCAT接口配置函數之后,可以看到EtherCAT Slave Controller的一些初始化配置,其中就包括了PHY的初始化:

/* Open Ether-Phy Driver */
for (i = 0; BSP_FEATURE_ESC_MAX_PORTS > i; i++)
{
  p_ether_PHY_instance = (ether_PHY_instance_t *) p_extend->p_ether_PHY_instance[i];
  if (NULL != p_ether_PHY_instance)
  {
    err = p_ether_PHY_instance->p_api->open(p_ether_PHY_instance->p_ctrl, p_ether_PHY_instance->p_cfg);
  }
  if (FSP_SUCCESS == err)
  {
    opened_PHY[i] = 1;
  }
  else
  {
    break;
  }
}

PHY驅動配置相關數據結構解析

這里初始化的一個PHY實例是:

p_ether_PHY_instance,它是一個ether_PHY_instance_t類型的變量。

typedef struct st_ether_PHY_instance
{
  ether_PHY_ctrl_t   * p_ctrl;  ///< Pointer to the control structure for this instance
 ? ?ether_PHY_cfg_t const * p_cfg; ? ? ///< Pointer to the configuration structure for this instance
 ? ?ether_PHY_api_t const * p_api; ? ? ///< Pointer to the API structure for this instance
} ether_PHY_instance_t;

其中ether_PHY_ctrl_t是指向PHY實例的控制結構體;

ether_PHY_cfg_t是指向實例配置的結構體指針;

ether_PHY_api_t是實例配置過程中需要調用到的函數方法所組成的結構體指針;

這個PHY的實例是在調用RM_ETHERCAT_SSC_PORT_Open()函數的時候形參傳遞進來的,也就是gp_ethercat_ssc_port。

ethercat_ssc_port_instance_t const * gp_ethercat_ssc_port = &g_ethercat_ssc_port0;

而gp_ethercat_ssc_port這個ethercat_ssc_port_instance_t類型的全局指針是指向一個常量,也就是下面代碼中的g_ethercat_ssc_port0。

/* Instance structure to use this module. */
const ethercat_ssc_port_instance_t g_ethercat_ssc_port0 =
{
  .p_ctrl    = &g_ethercat_ssc_port0_ctrl,
  .p_cfg     = &g_ethercat_ssc_port0_cfg,
  .p_api     = &g_ethercat_ssc_port_on_ethercat_ssc_port
};

可以看到g_ethercat_ssc_port0是一個常量結構體,它的成員變量分別是:

g_ethercat_ssc_port0_ctrl指向ethercat_ssc_port0控制結構體指針;

g_ethercat_ssc_port0_cfg指向ethercat_ssc_port0配置結構體指針;

g_ethercat_ssc_port_on_ethercat_ssc_port指向ethercat_ssc_port0配置方法的結構指針。

看到這里是不是有一種似成相識的感覺?g_ethercat_ssc_port0是對ethercat_ssc_port0這個外設的驅動的描述體,與前面PHY驅運的描述體“p_ether_PHY_instance”結構上很相似,其實工程樣例中所有的外設驅動都可以使用類似的結構體去完成相應的初始化。比如說timer驅動描述結構體:

/** This structure encompasses everything that is needed to use an instance of this interface. */
typedef struct st_timer_instance
{
  timer_ctrl_t   * p_ctrl;    ///< Pointer to the control structure for this instance
 ? ?timer_cfg_t const * p_cfg; ? ? ? ? ///< Pointer to the configuration structure for this instance
 ? ?timer_api_t const * p_api; ? ? ? ? ///< Pointer to the API structure for this instance
} timer_instance_t;

這種相似的驅動描述體其實就是工程樣例驅動代碼部分的大致框架所在,撐握了這個脈絡即可以方便的看懂其它外設驅動的代碼,也可以在以后的驅動開發過程中參考這種框架,提升代的通用性和可讀性。

我們知道PHY的驅動是ethercat_ssc_port0外設驅動的子模塊。因為要在RZ/T2M這個芯片上使能EtherCAT功能塊,除了要完成芯片本身相關外設的初始化之外,還要完成與之對應的PHY的初始化。那么兩者是如何關聯在一起的呢?我們繼續解讀g_ethercat_ssc_port0這個全局結構體。可以看到g_ethercat_ssc_port0_cfg所指向的內容是配置ethercat_ssc_port0的描述體,如下所示:

/** Configuration parameters. */
typedef struct st_ethercat_ssc_port_cfg
{
  uint32_t reset_hold_time;                    ///< PHY Reset signal hold time (ms)
 ? ?uint32_t reset_wait_time; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?///< Wait time after PHY reset relase (us)
 ? ?uint32_t offset_address; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< PHY offset PHYsical address


 ? ?IRQn_Type esc_cat_irq; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< EtherCAT IRQ interrupt number
 ? ?uint8_t ? esc_cat_ipl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< EtherCAT interrupt priority


 ? ?IRQn_Type esc_sync0_irq; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?///< EtherCAT Sync0 IRQ interrupt number
 ? ?uint8_t ? esc_sync0_ipl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< EtherCAT Sync0 interrupt priority


 ? ?IRQn_Type esc_sync1_irq; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?///< EtherCAT Sync1 IRQ interrupt number
 ? ?uint8_t ? esc_sync1_ipl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< EtherCAT Sync1 interrupt priority
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?///< Callback provided when an ISR occurs
 ? ?void (* p_callback)(ethercat_ssc_port_callback_args_t * p_args); 


 ? ?timer_instance_t const * p_timer_instance; ? ? ? ? ? ? ? ? ? ///< Pointer to Timer instance


 ? ?/** Placeholder for user data. ?Passed to the user callback in ethercat_ssc_port_callback_args_t. */
 ? ?void const * p_context;
 ? ?void const * p_extend; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< Placeholder for user extension.
} ethercat_ssc_port_cfg_t;

對PHY的復位信號保持時間有描述,還有對EtherCAT中斷有作描述,在此不展開討論。其中p_extend成員是用戶用于擴展控制的占位符。這也正是PHY驅動與ethercat_ssc_port0驅動關聯的關鍵所在。代碼賦于這個占位符是一個指向擴展配置的結構體指針。具體可以看看這個結構體的內容如下:

/** Extended configuration */
typedef struct s_ethercat_ssc_port_extend_cfg
{
  ethercat_ssc_port_eeprom_size_t eeprom_size;             ///< EEPROM memory size
 ? ?ethercat_ssc_port_txc_delay_t ? txc0; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< Port 0 TXC delay time
 ? ?ethercat_ssc_port_txc_delay_t ? txc1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< Port 1 TXC delay time
 ? ?ethercat_ssc_port_txc_delay_t ? txc2; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ///< Port 2 TXC delay time


 ? ?ether_PHY_instance_t const * p_ether_PHY_instance[BSP_FEATURE_ESC_MAX_PORTS]; 
///< Pointer to ETHER_PHY instance
} ethercat_ssc_port_extend_cfg_t;
const ethercat_ssc_port_extend_cfg_t g_ethercat_ssc_port0_ext_cfg =
{
 ? ?.eeprom_size ? ? ? ? ? ? = ETHERCAT_SSC_PORT_EEPROM_SIZE_UNDER_32KBIT,
 ? ?.txc0 ? ? ? ? ? ? ? ? ? ?= ETHERCAT_SSC_PORT_TXC_DELAY_00NS,
 ? ?.txc1 ? ? ? ? ? ? ? ? ? ?= ETHERCAT_SSC_PORT_TXC_DELAY_00NS,
 ? ?.txc2 ? ? ? ? ? ? ? ? ? ?= ETHERCAT_SSC_PORT_TXC_DELAY_00NS,
 ? ?.p_ether_PHY_instance[0] =
#define FSP_NOT_DEFINED (1)
#if (FSP_NOT_DEFINED == g_ether_PHY0)
 ? ? ? ? ? ? ? ? ? ?NULL,
#else
 ? ? ? ? ? ? ? ? ? ?&g_ether_PHY0,
#endif
 ? ?.p_ether_PHY_instance[1] =
#if (FSP_NOT_DEFINED == g_ether_PHY1)
 ? ? ? ? ? ? ? ? ? ?NULL,
#else
 ? ? ? ? ? ? ? ? ? ?&g_ether_PHY1,
#endif
 ? ?.p_ether_PHY_instance[2] =
#if (FSP_NOT_DEFINED == FSP_NOT_DEFINED)
 ? ? ? ? ? ? ? ? ? ?NULL,
#else
 ? ? ? ? ? ? ? ? ? ?&FSP_NOT_DEFINED,
#endif
};

里面就對應有ether_PHY_instance_t類體的初始化值,這值的類型正好是PHY實例所對應的描體結構體如下代碼所示,所以關聯就產生了。

typedef struct st_ether_PHY_instance
{
  ether_PHY_ctrl_t   * p_ctrl;  ///< Pointer to the control structure for this instance
 ? ?ether_PHY_cfg_t const * p_cfg; ? ? ///< Pointer to the configuration structure for this instance
 ? ?ether_PHY_api_t const * p_api; ? ? ///< Pointer to the API structure for this instance
} wh wether_PHY_instance_t;





審核編輯:劉清

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 驅動器
    +關注

    關注

    53

    文章

    8272

    瀏覽量

    147074
  • PHY
    PHY
    +關注

    關注

    2

    文章

    305

    瀏覽量

    51865
  • 工業以太網
    +關注

    關注

    10

    文章

    624

    瀏覽量

    42423
  • ssc
    ssc
    +關注

    關注

    0

    文章

    25

    瀏覽量

    11243
  • ethercat
    +關注

    關注

    19

    文章

    736

    瀏覽量

    38878

原文標題:工業以太網PHY驅動適配參考文檔(4)

文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關注!文章轉載請注明出處。

收藏 人收藏

    評論

    相關推薦

    PHY芯片向高速多端口發展,車載以太網PHY正在迅速起量

    進行處理,在通信系統中起著舉足輕重的作用。 ? 物理層PHY芯片指定了電信號類型、信號速度、介質和連接器類型以及網絡拓撲,根據應用的通信標準包括了以太網、USB、CAN、PCIe等等不同應用,最熟悉的還是
    的頭像 發表于 02-15 10:35 ?5904次閱讀
    <b class='flag-5'>PHY</b>芯片向高速多端口發展,車載<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>正在迅速起量

    AN4754-將Microchip橋接控制器與外部以太網PHY搭配使用

    電子發燒友網站提供《AN4754-將Microchip橋接控制器與外部以太網PHY搭配使用.pdf》資料免費下載
    發表于 01-21 13:54 ?0次下載
    AN4754-將Microchip橋接控制器與外部<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>搭配使用

    EE-315:更改Blackfin處理器以太網驅動程序中的PHY

    電子發燒友網站提供《EE-315:更改Blackfin處理器以太網驅動程序中的PHY.pdf》資料免費下載
    發表于 01-07 14:15 ?0次下載
    EE-315:更改Blackfin處理器<b class='flag-5'>以太網</b><b class='flag-5'>驅動</b>程序中的<b class='flag-5'>PHY</b>

    用于汽車以太網PHY附加板的AM2x評估模塊用戶指南

    電子發燒友網站提供《用于汽車以太網PHY附加板的AM2x評估模塊用戶指南.pdf》資料免費下載
    發表于 11-05 09:23 ?0次下載
    用于汽車<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>附加板的AM2x評估模塊用戶指南

    用于工業以太網PHY的AM2x評估模塊附加板用戶指南

    電子發燒友網站提供《用于工業以太網PHY的AM2x評估模塊附加板用戶指南.pdf》資料免費下載
    發表于 11-05 09:20 ?0次下載
    用于工業<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>的AM2x評估模塊附加板用戶指南

    以太網PHY PCB設計布局檢查清單

    電子發燒友網站提供《以太網PHY PCB設計布局檢查清單.pdf》資料免費下載
    發表于 09-24 11:09 ?1次下載
    <b class='flag-5'>以太網</b><b class='flag-5'>PHY</b> PCB設計布局檢查清單

    適用于工業應用的使用MDIO的以太網PHY配置

    電子發燒友網站提供《適用于工業應用的使用MDIO的以太網PHY配置.pdf》資料免費下載
    發表于 09-21 10:24 ?0次下載
    適用于工業應用的使用MDIO的<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b><b class='flag-5'>配置</b>

    利用DP83TC812-Q1以太網物理層 (PHY) 的完整汽車以太網系統中的設置和測量

    電子發燒友網站提供《利用DP83TC812-Q1以太網物理層 (PHY) 的完整汽車以太網系統中的設置和測量.pdf》資料免費下載
    發表于 09-09 09:28 ?0次下載
    利用DP83TC812-Q1<b class='flag-5'>以太網</b>物理層 (<b class='flag-5'>PHY</b>) 的完整汽車<b class='flag-5'>以太網</b>系統中的設置和測量

    使用C2000 EtherCAT從站控制器的SMI進行以太網PHY配置

    電子發燒友網站提供《使用C2000 EtherCAT從站控制器的SMI進行以太網PHY配置.pdf》資料免費下載
    發表于 09-07 10:37 ?0次下載
    使用C2000 EtherCAT從站控制器的SMI進行<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b><b class='flag-5'>配置</b>

    如何以及何時在PROFINET系統中使用以太網PHY

    電子發燒友網站提供《如何以及何時在PROFINET系統中使用以太網PHY.pdf》資料免費下載
    發表于 08-31 10:15 ?0次下載
    如何以及何時在PROFINET系統中使用<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>

    X1G004481000300低功耗晶振以太網PHY芯片的關鍵核心

    在射頻拉遠單元(RRU)設計中,一般需要用到以太網PHY芯片發送和接收以太網的數據幀,與主控芯片進行網絡數據交互,為保證以太網PHY芯片
    發表于 08-05 13:59 ?0次下載

    以太網要怎么連接

    以太網連接是現代計算機網絡通信中最為基礎和重要的環節之一。它利用以太網電纜和網卡等硬件設備,將計算機或其他設備連接到網絡交換機或路由器上,從
    的頭像 發表于 07-09 10:28 ?1320次閱讀

    車載以太網硬件接口VN5620設備展示與介紹#車載以太網

    車載以太網
    北匯信息POLELINK
    發布于 :2024年05月31日 10:27:03

    以太網PHY寄存器分析 以太網PHY驅動軟件配置

    我們對g_ethercat_ssc_port0_ext_cfg這個全局變量深入追蹤,其成員變量 g_ether_PHY0,正好是一個PHY實例的詳細描述體。
    的頭像 發表于 02-22 12:17 ?2755次閱讀
    <b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>寄存器分析 <b class='flag-5'>以太網</b><b class='flag-5'>PHY</b><b class='flag-5'>驅動</b><b class='flag-5'>軟件</b><b class='flag-5'>配置</b>

    一文詳解以太網MAC芯片與PHY芯片

    MII即媒體獨立接口,它是IEEE-802.3定義的以太網行業標準."媒體獨立"表明在不對MAC硬件重新設計或替換的情況下,任何類型的PHY設備都可以正常工作.它包括一個數據接口,以及一個MAC和
    發表于 02-19 10:47 ?4787次閱讀
    一文詳解<b class='flag-5'>以太網</b>MAC芯片與<b class='flag-5'>PHY</b>芯片
    主站蜘蛛池模板: 天堂网在线www资源在线 | 3344在线观看永久免费 | 国产区一区二区三区 | 国产精品久久婷婷六月丁香 | 丁香花小说 | 日韩一级片在线免费观看 | 国模欢欢大尺度 | 夜夜操网| 天天躁夜夜躁狠狠躁2024 | 色哥网站 | 日韩欧美一区二区三区视频 | 亚洲欧美日韩特级毛片 | 六月色播| 久久性久久性久久久爽 | 特级毛片免费看 | 最好看免费中文字幕2018视频 | japanese色系国产在线高清 | 侵犯希崎中文字幕在线 | 亚洲性人人天天夜夜摸 | 狠狠色噜噜狠狠狠 | 亚洲爱爱网站 | 国产主播在线看 | 精品久久久久国产免费 | 三级理论手机在线观看视频 | 久色国产| 天堂中文字幕 | 久久天天 | 新天堂| 午夜精品久久久 | 美女视频黄免费 | 久久综合九色综合精品 | 热久久综合这里只有精品电影 | 欧美a色爱欧美综合v | 亚洲精品亚洲人成毛片不卡 | 黄网在线免费看 | 色婷婷色| 日本黄色录像 | 精品一区二区三区自拍图片区 | 亚洲精品456人成在线 | 天天曰天天干天天操 | 国产一区中文字幕在线观看 |