在线观看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;





審核編輯:劉清

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

    關注

    54

    文章

    8646

    瀏覽量

    149293
  • PHY
    PHY
    +關注

    關注

    2

    文章

    316

    瀏覽量

    52577
  • 工業以太網
    +關注

    關注

    10

    文章

    656

    瀏覽量

    42924
  • ssc
    ssc
    +關注

    關注

    0

    文章

    25

    瀏覽量

    11458
  • ethercat
    +關注

    關注

    19

    文章

    1048

    瀏覽量

    39716

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

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

收藏 人收藏

    評論

    相關推薦
    熱點推薦

    Microchip LAN9211-ABZJ 集成 10/100 以太網 PHY以太網控制器

    Microchip LAN9211-ABZJ 集成 10/100 以太網 PHY以太網控制器
    的頭像 發表于 06-04 14:56 ?294次閱讀
    Microchip LAN9211-ABZJ 集成 10/100 <b class='flag-5'>以太網</b> <b class='flag-5'>PHY</b>的<b class='flag-5'>以太網</b>控制器

    愛普生SG2520CAA有源晶振賦能車身以太網 PHY

    隨著汽車智能化與網聯化加速,車身以太網逐步取代傳統CAN總線,成為車內高速通信的核心技術。以太網物理層接口芯片(PHY)作為數據傳輸的底層核心,對時鐘信號的精度和穩定性提出了嚴苛要求。愛普生推出
    的頭像 發表于 03-27 13:55 ?293次閱讀
    愛普生SG2520CAA有源晶振賦能車身<b class='flag-5'>以太網</b> <b class='flag-5'>PHY</b>

    國產芯片替代方案:解析沁恒以太網PHY芯片

    沁恒國產以太網PHY芯片:高性能替代方案助力國產化升級
    的頭像 發表于 03-12 10:40 ?1542次閱讀

    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 ?2次下載
    <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 ?1次下載
    利用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 ?2125次閱讀

    DP83561-SP千兆位以太網PHY數據表

    電子發燒友網站提供《DP83561-SP千兆位以太網PHY數據表.pdf》資料免費下載
    發表于 06-22 10:19 ?0次下載
    DP83561-SP千兆位<b class='flag-5'>以太網</b><b class='flag-5'>PHY</b>數據表
    主站蜘蛛池模板: 你懂的免费在线视频 | 亚洲天堂.com | 日韩美女奶水喂男人在线观看 | 色爱区综合激情五月综合色 | 四虎国产在线观看 | 操熟逼| 偷窥自拍亚洲色图 | 色妞视频资源在线观看 | 欧美一区二区三区黄色 | 国产产一区二区三区久久毛片国语 | 亚洲一区二区中文字5566 | 91精品国产91久久久久青草 | 久久国产乱子伦精品免费强 | 欧美电影一区二区 | 99久久精品费精品国产一区二 | 又粗又大又爽又色又过瘾视频 | 日韩第五页| 又粗又硬又爽又黄毛片 | 美女喷白浆 | 好大好紧好爽好湿润视频 | 成人午夜小视频手机在线看 | 国产农村一级特黄α真人毛片 | 丁香婷婷综合五月综合色啪 | avtom影院永久地址人人影院 | 天天操夜夜操免费视频 | 欧美黄一片 | 97色噜噜 | 日本一区二区三区免费看 | 在线看片成人免费视频 | 国产精品一区二区三区四区 | 护士一级aaaaaa毛片 | 久草免费色站 | 欧美亚洲天堂 | 台湾佬自偷自拍情侣在线 | 日韩综合色 | 啪啪网免费 | 久久久久国产精品免费网站 | 日本三级香港三级三级人!妇久 | 一区二区中文字幕亚洲精品 | 成人爽a毛片在线视频 | 久久大香线蕉综合爱 |