This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS570LS1227:EMACRxIntISR RX 和 Tx 处理程序 API 引起令人困惑的语句

Guru**** 1785650 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1401163/tms570ls1227-emacrxintisr-rx-and-tx-handlers-api-makes-confusing-statements

器件型号:TMS570LS1227

工具与软件:

您好!

面临的问题或需要帮助

我目前正在致力于将 Mongoose TCP/IP 堆栈与我们的不使用 LWIP 的项目集成。 我正在移植 TX 和 RX 中断处理程序、以便与 Mongoose 兼容。 但我遇到了一些困惑、尤其是在关于 RX 描述符数据访问方面。

我注意到代码中的以下内容:

void EMACRxIntISR (void){
hdkif_t * hdkif;
hdkif =&hdkif_data[0U];emacRxNotification (hdkif);
EMACReceive(hdkif);
EMACCoreIntAck (hdkif->EMAC_BASE、(UINT32) EMAC_INT_CORE0_RX);
}

第1个查询:

emacRxNotification(hdkif)函数中、我们需要处理用户手册中提到的链接列表、还是可以hdkif直接使用变量(如hdkif->rxchptr.active_head->bufptr和)访问完整的缓冲区数据hdkif->rxchptr.active_head->bufoff_len

第2个查询:

当试图理解 LWIP 时emacRxNotification,我观察到它调用lwIPRxIntHandler(0). 在此函数中、EMACReceive(hdkif)除了复制到q = curr_bd缓冲区之外、它执行与函数执行的操作类似的操作。

我是否应该实施完整的链接列表处理并按照 LWIP 中的方法更新描述符、或者是否足够使用EMACReceive(hdkif)

或者、我想将完整的接收缓冲区及其长度传递给 Mongoose 堆栈。 您能否提供一个示例、说明如何接收缓冲区、将其存储在1518字节的本地缓冲区中、或者只是打印接收到的缓冲区、然后在 UART 终端上打印它? 如果这么做、我就可以轻松地理解接收功能、从而将数据传递到 Mongoose 堆栈

此致、
Sandeep C

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我们有关此主题的专家今天不在办公室,请期待下周早些时候的答复,谢谢。

    此致、

    Ralph Jacobi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你好,谢谢你的答复。

    下面是关于我的疑问的最新动态:当emacRxNotification(hdkif)调用回调函数时、我将把接收到的数据更新到 Mongoose 堆栈。 进一步检查 lwIP 代码后、我注意到emacRxNotification会进行检查EMAC_BUF_DESC_SOPEMAC_BUF_DESC_EOP处理最大缓冲数据。 是否必须执行这些检查以确保接收最大缓冲数据?


    此致、

    Sandeep C

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    查询更新:

    接收:Rx 处理程序

    void EMACReceive(hdkif_t *hdkif)
    {
      rxch_t *rxch_int;
      volatile emac_rx_bd_t *curr_bd, *curr_tail, *last_bd;
    
      /* The receive structure that holds data about a particular receive channel */
      rxch_int = &(hdkif->rxchptr);
    
      /* Get the buffer descriptors which contain the earliest filled data */
      /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
      curr_bd = rxch_int->active_head;
      /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
      last_bd = rxch_int->active_tail;
    
      /**
       * Process the descriptors as long as data is available
       * when the DMA is receiving data, SOP flag will be set
      */
      /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
      /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */
      /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
      while((curr_bd->flags_pktlen & EMAC_BUF_DESC_SOP) == EMAC_BUF_DESC_SOP) {
    
          whilecnt1++;
    
        /* Start processing once the packet is loaded */
        /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */
        /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */   
        if((curr_bd->flags_pktlen & EMAC_BUF_DESC_OWNER) != EMAC_BUF_DESC_OWNER) {
    
          /* this bd chain will be freed after processing */
          /*SAFETYMCUSW 71 S MR:17.6 <APPROVED> "Assigned pointer value has required scope." */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */
          rxch_int->free_head = curr_bd;
    
          /* Get the total length of the packet. curr_bd points to the start
           * of the packet.
           */
    
          /* 
           * The loop runs till it reaches the end of the packet.
           */
          /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */          
          while((curr_bd->flags_pktlen & EMAC_BUF_DESC_EOP)!= EMAC_BUF_DESC_EOP)
          {
            /*Update the flags for the descriptor again and the length of the buffer*/
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            curr_bd->flags_pktlen = (uint32)EMAC_BUF_DESC_OWNER;
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            curr_bd->bufoff_len = (uint32)MAX_TRANSFER_UNIT;
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            last_bd = curr_bd;
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            curr_bd = curr_bd->next;
            printf("whilecnt1 =%d\n\r",whilecnt1);
    
            countp++;
    
          }
          mg_tcpip_qwrite((void*)curr_bd->bufptr,curr_bd->bufoff_len, s_ifp);
    
    
          /* Updating the last descriptor (which contained the EOP flag) */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */          
            curr_bd->flags_pktlen = (uint32)EMAC_BUF_DESC_OWNER;
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            curr_bd->bufoff_len = (uint32)MAX_TRANSFER_UNIT;
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            last_bd = curr_bd;
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            curr_bd = curr_bd->next;
    
          /* Acknowledge that this packet is processed */
          /*SAFETYMCUSW 439 S MR:11.3 <APPROVED> "Address stored in pointer is passed as as an int parameter. - Advisory as per MISRA" */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
          EMACRxCPWrite(hdkif->emac_base, (uint32)EMAC_CHANNELNUMBER, (uint32)last_bd);
    
          /* The next buffer descriptor is the new head of the linked list. */
          /*SAFETYMCUSW 71 S MR:17.6 <APPROVED> "Assigned pointer value has required scope." */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
          rxch_int->active_head = curr_bd;
    
          /* The processed descriptor is now the tail of the linked list. */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
          curr_tail = rxch_int->active_tail;
        /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
          curr_tail->next = rxch_int->free_head;
    
          /* The last element in the already processed Rx descriptor chain is now the end of list. */
          /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */     
          last_bd->next = NULL;
    
    
            /**
             * Check if the reception has ended. If the EOQ flag is set, the NULL
             * Pointer is taken by the DMA engine. So we need to write the RX HDP
             * with the next descriptor.
             */
            /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */ 
            /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "LDRA Tool issue" */
          /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */            
            if((curr_tail->flags_pktlen & EMAC_BUF_DESC_EOQ) == EMAC_BUF_DESC_EOQ) {
              /*SAFETYMCUSW 439 S MR:11.3 <APPROVED> "Address stored in pointer is passed as as an int parameter. - Advisory as per MISRA" */
              /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */             
              EMACRxHdrDescPtrWrite(hdkif->emac_base, (uint32)(rxch_int->free_head), (uint32)EMAC_CHANNELNUMBER);
            }
    
            /*SAFETYMCUSW 71 S MR:17.6 <APPROVED> "Assigned pointer value has required scope." */
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */   
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are assigned in this driver" */   
            rxch_int->free_head  = curr_bd;
            rxch_int->active_tail = last_bd;
          }
        }
      whilecnt1=0;
    }
    

    TX 处理程序:

    静态 size_t mg_TCPIP_driver_tms570_tx (const void * buf、size_t len、struct mg_TCPIP_if * ifp)

    sentcnt++;
    pbuf_t tx_data;
    tx_data.len=len;
    tx_data.tot_len=len;
    tx_data.payload=(uint8_t*) buf;
    tx_data.next=NULL;

    printf ("\n\n\r");
    INT I=0;

    if (tx_data.len < 120)
    for (i=0;i<tx_data.len;i++)
    printf ("%#x "、TX_DATA.PAYLOAD[i]);
    printf ("\n\n\r");


    EMACTransmit (&H dkif_data[0]、&TX_data);

    返回长度;
    (无效) IFP;
    }

    当我使用上述代码时、如果 Wireshark 关闭 ping 命令、UDP 停止工作、但只有 Wireshark 捕获数据、则 ping 和 UDP 正常工作。

    是否有任何更新?

    此致、

    Sandeep C

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    更新:  

    ECU 到 PC 帧:

    0xd4 0x81 0xd7 0x6b 0x7f 0xe4 0x2 0xc6 0x7E 0x81 0x6b 0x4b 0x8 0x6 0x0 0x1 0x8 0x0 0x6 0x4 0x0 0x2 0xc6 0x7E 0x81 0x6b 0x4b 0xc0 0xa8 0x

    您能验证吗? 是这样吗?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Sandeep、您好!

    很高兴听到您自己解决了此问题。

    ——
    谢谢、此致、
    Jagadish。