helle
@mayliu1Thanks for replay
Based on the example, I tried, but I am unable to receive and transmit the frame.
I modified the code to create a simpler version. using evkbmimxrt1170_enet_txrx_transfer_cm7 example code please guide me what will be need to change. i am attech project file.
#include "fsl_debug_console.h"
#include "fsl_silicon_id.h"
#include "fsl_enet.h"
#include "fsl_phy.h"
#include "board.h"
#include "fsl_phyrtl8201.h"
#include "fsl_enet.h"
#include "board.h"
#define EXAMPLE_ENET ENET
#define EXAMPLE_CLOCK_FREQ CLOCK_GetRootClockFreq(kCLOCK_Root_Bus)
#define ENET_RXBD_NUM 4
#define ENET_TXBD_NUM 4
#define ENET_RXBUFF_SIZE ENET_FRAME_MAX_FRAMELEN
#define ENET_TXBUFF_SIZE ENET_FRAME_MAX_FRAMELEN
#define ENET_DATA_LENGTH 1000
/* Buffer descriptors */
AT_NONCACHEABLE_SECTION_ALIGN(enet_rx_bd_struct_t g_rxBuffDescrip[ENET_RXBD_NUM], ENET_BUFF_ALIGNMENT);
AT_NONCACHEABLE_SECTION_ALIGN(enet_tx_bd_struct_t g_txBuffDescrip[ENET_TXBD_NUM], ENET_BUFF_ALIGNMENT);
/* Data buffers */
SDK_ALIGN(uint8_t g_rxDataBuff[ENET_RXBD_NUM][ENET_RXBUFF_SIZE], ENET_BUFF_ALIGNMENT);
SDK_ALIGN(uint8_t g_txDataBuff[ENET_TXBD_NUM][ENET_TXBUFF_SIZE], ENET_BUFF_ALIGNMENT);
/* MAC address */
uint8_t g_macAddr[6] =
{ 0x02, 0x12, 0x13, 0x14, 0x15, 0x16 };
/* ENET handle */
static enet_handle_t g_handle;
static void BuildTestFrame(uint8_t *frame)
{
/* Destination MAC (broadcast) */
for (int i = 0; i < 6; i++)
{
frame[i] = 0xFF;
}
/* Source MAC */
memcpy(&frame[6], g_macAddr, 6);
/* EtherType/Length */
frame[12] = 0x08; // IPv4
frame[13] = 0x00;
/* Simple payload */
for (int i = 14; i < ENET_DATA_LENGTH; i++)
{
frame[i] = i % 256;
}
}
void InitEthernet(void)
{
enet_config_t config;
/* Prepare buffer configuration */
enet_buffer_config_t buffConfig =
{
ENET_RXBD_NUM,
ENET_TXBD_NUM,
ENET_RXBUFF_SIZE,
ENET_TXBUFF_SIZE, g_rxBuffDescrip, g_txBuffDescrip, &g_rxDataBuff[0][0], &g_txDataBuff[0][0],
true,
true,
NULL };
/* Get default ENET configuration */
ENET_GetDefaultConfig(&config);
config.miiMode = kENET_RmiiMode;
config.miiSpeed = kENET_MiiSpeed100M;
config.miiDuplex = kENET_MiiFullDuplex;
/* Initialize ENET */
ENET_Init(EXAMPLE_ENET, &g_handle, &config, &buffConfig, g_macAddr, EXAMPLE_CLOCK_FREQ);
ENET_ActiveRead(EXAMPLE_ENET);
}
int main(void)
{
uint8_t txFrame[ENET_DATA_LENGTH];
uint8_t rxBuffer[ENET_RXBUFF_SIZE];
/* Initialize hardware */
BOARD_InitHardware();
/* Initialize Ethernet */
InitEthernet();
/* Build test frame */
BuildTestFrame(txFrame);
while (1)
{
uint32_t frameLength = 0;
/* Check for received frames */
if (ENET_GetRxFrameSize(&g_handle, &frameLength, 0) == kStatus_Success)
{
if (frameLength > 0)
{
/* Read the frame */
if (ENET_ReadFrame(EXAMPLE_ENET, &g_handle, rxBuffer, frameLength, 0, NULL) == kStatus_Success)
{
/* Process received frame here */
}
}
}
/* Send test frame */
status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *data, uint32_t length, uint8_t ringId,
bool tsFlag, void *context);
ENET_SendFrame(EXAMPLE_ENET, &g_handle, txFrame, ENET_DATA_LENGTH, 0, false, NULL);
/* Small delay */
for (volatile int i = 0; i < 1000000; i++);
}
}
in that i am getting also error undefined reference to `PHY_LinkStatusChange'