高级
30 分钟

使用 XP1001000-05R 和 ATmega328P 为您的嵌入式项目添加 10/100BASE-TX 以太网功能

面向现代嵌入式应用的可靠且紧凑的网络连接解决方案

XPort ETH Click - XE with Arduino UNO Rev3

已发布 6月 18, 2025

点击板

XPort ETH Click - XE

开发板

Arduino UNO Rev3

编译器

NECTO Studio

微控制器单元

ATmega328P

稳定可靠的以太网连接,集成 Web 服务器与 TCP/IP 协议栈

A

A

硬件概览

它是如何工作的?

XPort ETH Click - XE 基于 Lantronix 推出的 XP1001000-05R XPort 模块,专为嵌入式系统中需要以太网连接的应用而设计。该模块体积小巧但功能强大,集成了 10BASE-T/100BASE-TX 以太网接口、嵌入式 Web 服务器、存储于闪存中的稳定操作系统,以及完整的 TCP/IP 协议栈,所有功能均封装于一个 RJ45 以太网连接器中,非常适合在各类嵌入式应用中快速集成可靠的网络通信能力。XPort 模块采用 DSTni EX 控制器,内置 256KB SRAM、16KB 启动 ROM,以及一个集成 10/100BASE-TX PHY 的 MAC 控制器。处理核心工作在由内部稳压器提供的 1.8V 电压下,整套模块工作电压为 3.3V。模块还内

建电压监控电路,当电源电压低于 2.7V 时会自动触发复位,保障系统稳定运行。与主控设备的通信通过 UART 接口进行,此外还提供三个可配置的通用 I/O 引脚(CP1、CP2 和 CP3),可用作流控/调制解调器控制线或通用信号线。模块配备 512KB 闪存,用于存储固件与网页内容,支持远程管理与功能定制。正如前文所述,该模块通过 RJ45 接口直接连接至以太网,前面板上集成两个双色 LED 指示灯,用于实时显示连接状态。当两灯均不亮时表示无连接或活动;左侧指示灯(Link LED)在 10Mbps 连接时为琥珀色,在 100Mbps 时为绿色;右侧指示灯(Activity LED)在半双工模式下为琥珀色,全双工模式下为绿

色。XPort ETH Click - XE 易于进行机电集成,并符合 Class B 电磁辐射标准。在配置与控制方面,支持基于 Windows 的 Device Installer 工具和串口重定向器(Com Port Redirector),兼容 x86 与 x64 架构的 Windows 系统,包括 XP、Vista、Windows 7、Windows 8、2003 Server 和 2008 Server。本 Click board™ 仅支持 3.3V 逻辑电压工作。在与其他逻辑电平的 MCU 搭配使用时,需进行适当的电平转换。产品还附带软件库,包含易于使用的函数及示例代码,供进一步开发参考使用。

XPort ETH Click - XE hardware overview image

功能概述

开发板

Arduino UNO 是围绕 ATmega328P 芯片构建的多功能微控制器板。它为各种项目提供了广泛的连接选项,具有 14 个数字输入/输出引脚,其中六个支持 PWM 输出,以及六个模拟输入。其核心组件包括一个 16MHz 的陶瓷谐振器、一个 USB 连接器、一个电

源插孔、一个 ICSP 头和一个复位按钮,提供了为板 子供电和编程所需的一切。UNO 可以通过 USB 连接到计算机,也可以通过 AC-to-DC 适配器或电池供电。作为第一个 USB Arduino 板,它成为 Arduino 平台的基准,"Uno" 符号化其作为系列首款产品的地

位。这个名称选择,意为意大利语中的 "一",是为了 纪念 Arduino Software(IDE)1.0 的推出。最初与 Arduino Software(IDE)版本1.0 同时推出,Uno 自此成为后续 Arduino 发布的基础模型,体现了该平台的演进。

Arduino UNO Rev3 double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

AVR

MCU 内存 (KB)

32

硅供应商

Microchip

引脚数

28

RAM (字节)

2048

你完善了我!

配件

Click Shield for Arduino UNO 具有两个专有的 mikroBUS™ 插座,使所有 Click board™ 设备能够轻松与 Arduino UNO 板进行接口连接。Arduino UNO 是一款基于 ATmega328P 的微控制器开发板,为用户提供了一种经济实惠且灵活的方式来测试新概念并构建基于 ATmega328P 微控制器的原型系统,结合了性能、功耗和功能的多种配置选择。Arduino UNO 具有 14 个数字输入/输出引脚(其中 6 个可用作 PWM 输出)、6 个模拟输入、16 MHz 陶瓷谐振器(CSTCE16M0V53-R0)、USB 接口、电源插座、ICSP 头和复位按钮。大多数 ATmega328P 微控制器的引脚都连接到开发板左右两侧的 IO 引脚,然后再连接到两个 mikroBUS™ 插座。这款 Click Shield 还配备了多个开关,可执行各种功能,例如选择 mikroBUS™ 插座上模拟信号的逻辑电平,以及选择 mikroBUS™ 插座本身的逻辑电压电平。此外,用户还可以通过现有的双向电平转换电压转换器使用任何 Click board™,无论 Click board™ 运行在 3.3V 还是 5V 逻辑电压电平。一旦将 Arduino UNO 板与 Click Shield for Arduino UNO 连接,用户即可访问数百种 Click board™,并兼容 3.3V 或 5V 逻辑电压电平的设备。

Click Shield for Arduino UNO accessories 1 image

RJ45 UTP(非屏蔽双绞线)电缆是一种广泛应用于家庭和商用场景中的以太网连接线缆。该电缆两端配有 RJ45 接头,可直接连接路由器、交换机、计算机及其他网络设备。UTP 电缆由四对铜线组成,每对线缆经过扭绞处理,有效降低电磁干扰,无需额外屏蔽层。根据性能标准不同,常见类型包括 Cat5e、Cat6 和 Cat6a,分别支持不同的数据传输速率与带宽需求。RJ45 UTP 电缆广泛应用于有线网络接入、数据传输和 VoIP 系统,是实现高速网络通信的可靠选择。其即插即用的设计简化了安装流程,而双绞结构则保障了中等距离内的信号完整性。非常适合结构化布线和局域网(LAN)搭建,RJ45 UTP 电缆依然是现代网络基础设施中的关键组成部分。

XPort ETH Click - XE accessories 1 image

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
ID SEL
PD2
RST
General-Purpose I/O / ID COMM
PB2
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
General-Purpose I/O
PD6
PWM
General-Purpose I/O
PC3
INT
UART TX
PD0
TX
UART RX
PD1
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

XPort ETH Click - XE Schematic schematic

一步一步来

项目组装

Click Shield for Arduino UNO front image hardware assembly

从选择您的开发板和Click板™开始。以Arduino UNO Rev3作为您的开发板开始。

Click Shield for Arduino UNO front image hardware assembly
Arduino UNO Rev3 front image hardware assembly
Charger 27 Click front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Board mapper by product8 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Arduino UNO MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

实时跟踪您的结果

应用程序输出

1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持

库描述

XPort ETH Click - XE 演示应用程序使用 NECTO Studio开发,确保与 mikroSDK 的开源库和工具兼容。该演示设计为即插即用,可与所有具有 mikroBUS™ 插座的 开发板、入门板和 mikromedia 板完全兼容,用于快速实现和测试。

示例描述
本示例演示如何使用 XPort ETH Click - XE 板进行以太网通信。应用程序初始化 XPort ETH XE 模块,获取固件版本、MAC 地址和网络状态等关键信息,并展示发送 ping 命令的操作。同时,该示例支持 USB UART 与 XPort ETH XE 模块 UART 之间的双向通信。

关键功能:

  • xportethxe_cfg_setup - 初始化 Click 配置结构体为默认值。

  • xportethxe_init - 初始化该 Click 板所需的全部引脚和外设。

  • xportethxe_reset_device - 通过切换 RST 引脚状态实现设备复位。

  • xportethxe_send_cmd - 通过 UART 串口发送命令字符串。

  • xportethxe_send_enter - 通过 UART 串口发送回车(换行符)。

应用初始化
初始化 UART 通信,记录关键信息,配置 XPort ETH XE 模块,并读取固件版本、MAC 地址和网络状态。同时演示了基础命令操作,例如对特定 IP 地址(8.8.8.8)发送 ping 命令。

应用任务
持续读取来自 USB UART 的数据并转发至 XPort ETH XE 模块,同时接收模块返回的数据并将其发送回 USB UART。这种方式允许用户通过 UART 终端实时与设备交互,用于配置和诊断。

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * @file main.c
 * @brief XPort ETH XE Click Example.
 *
 * # Description
 * This example demonstrates the use of the XPort ETH XE Click board for Ethernet communication. 
 * The application initializes the XPort ETH XE module, retrieves essential information such as 
 * firmware version, MAC address, and network status, and demonstrates sending a ping command. 
 * It also allows for bidirectional UART communication between the USB UART and the XPort ETH XE UART.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the UART communication, logs essential information, configures the XPort ETH XE module, 
 * and retrieves the firmware version, MAC address, and network status. It also demonstrates basic 
 * command operations such as pinging the specific IP address (8.8.8.8).
 *
 * ## Application Task
 * Continuously reads data from the USB UART and forwards it to the XPort ETH XE module, 
 * while also capturing responses from the module and forwarding them back to the USB UART.
 * This allows real-time interaction with the device through the UART Terminal for
 * configuration and diagnostics.
 *
 * ## Additional Function
 * - static void xportethxe_clear_app_buf ( void )
 * - static err_t xportethxe_process ( xportethxe_t *ctx )
 * - static err_t xportethxe_read_response ( xportethxe_t *ctx )
 *
 * @note
 * Ensure the XPort ETH XE Click board is properly connected to the network.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "xportethxe.h"

// Application buffer size
#define APP_BUFFER_SIZE             300
#define PROCESS_BUFFER_SIZE         100

static xportethxe_t xportethxe;
static log_t logger;

static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief XPort ETH XE clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void xportethxe_clear_app_buf ( void );

/**
 * @brief XPort ETH XE data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #xportethxe_t object definition for detailed explanation.
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t xportethxe_process ( xportethxe_t *ctx );

/**
 * @brief XPort ETH XE read response function.
 * @details This function waits for a response message, reads and displays it on the USB UART.
 * @param[in] ctx : Click context object.
 * See #xportethxe_t object definition for detailed explanation.
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t xportethxe_read_response ( xportethxe_t *ctx );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    xportethxe_cfg_t xportethxe_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    xportethxe_cfg_setup( &xportethxe_cfg );
    XPORTETHXE_MAP_MIKROBUS( xportethxe_cfg, MIKROBUS_1 );
    if ( UART_ERROR == xportethxe_init( &xportethxe, &xportethxe_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    log_printf( &logger, ">>> Reset Device to Monitor Mode <<<\r\n" );
    xportethxe_reset_device ( &xportethxe );
    xportethxe_send_enter ( &xportethxe );
    xportethxe_send_cmd ( &xportethxe, XPORTETHXE_CMD_MODE_MONITOR_WITH_NET );
    xportethxe_read_response ( &xportethxe );

    log_printf( &logger, "\r\n-----------------------------\r\n" );
    log_printf( &logger, ">>> Query Firmware Version <<<\r\n" );
    xportethxe_send_cmd ( &xportethxe, XPORTETHXE_CMD_QUERY_FW_VERSION );
    xportethxe_read_response ( &xportethxe );

    log_printf( &logger, "\r\n-----------------------------\r\n" );
    log_printf( &logger, ">>> Get MAC Address <<<\r\n" );
    xportethxe_send_cmd ( &xportethxe, XPORTETHXE_CMD_GET_MAC_ADDRESS );
    xportethxe_read_response ( &xportethxe );

    log_printf( &logger, "\r\n-----------------------------\r\n" );
    log_printf( &logger, ">>> Get Network Status and IP Address <<<\r\n" );
    log_printf( &logger, ">>> Send QU Command to Exit Monitor Mode and Connect to Listed <<<\r\n" );
    log_printf( &logger, ">>> IP Address Through Web Browser to Access Web Interface <<<\r\n" );
    xportethxe_send_cmd ( &xportethxe, XPORTETHXE_CMD_NET_STAT );
    xportethxe_read_response ( &xportethxe );

    log_printf( &logger, "\r\n-----------------------------\r\n" );
    log_printf( &logger, ">>> Ping 8.8.8.8 and Switch to UART Terminal Commands Input <<<\r\n" );
    xportethxe_send_cmd ( &xportethxe, XPORTETHXE_CMD_PING( "8.8.8.8" ) );
    xportethxe_send_enter ( &xportethxe );
    xportethxe_read_response ( &xportethxe );
}

void application_task ( void ) 
{
    app_buf_len = uart_read( &logger.uart, app_buf, PROCESS_BUFFER_SIZE );
    if ( app_buf_len > 0 ) 
    {
        uart_write ( &xportethxe.uart, app_buf, app_buf_len );
        xportethxe_clear_app_buf ( );
    }
    app_buf_len = uart_read( &xportethxe.uart, app_buf, PROCESS_BUFFER_SIZE );
    if ( app_buf_len > 0 ) 
    {
        uart_write ( &logger.uart, app_buf, app_buf_len );
        xportethxe_clear_app_buf ( );
    }
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static void xportethxe_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static void xportethxe_log_app_buf ( void )
{
    for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
    {
        log_printf( &logger, "%c", app_buf[ buf_cnt ] );
    }
}

static err_t xportethxe_process ( xportethxe_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = xportethxe_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) ) 
    {
        if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE ) 
        {
            overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
            app_buf_len = APP_BUFFER_SIZE - rx_size;
            memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
            memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
        }
        for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
                log_printf( &logger, "%c", rx_buf[ rx_cnt ] );
            }
        }
        return XPORTETHXE_OK;
    }
    return XPORTETHXE_ERROR;
}

static err_t xportethxe_read_response ( xportethxe_t *ctx )
{
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 30000;
    xportethxe_clear_app_buf ( );
    while ( ( 0 == strstr( app_buf, XPORTETHXE_RSP_OK ) ) && 
            ( 0 == strstr( app_buf, XPORTETHXE_RSP_NO_ANSWER ) ) && 
            ( 0 == strstr( app_buf, XPORTETHXE_RSP_NO_REACH ) ) && 
            ( 0 == strstr( app_buf, XPORTETHXE_RSP_WRONG_PAR ) ) && 
            ( 0 == strstr( app_buf, XPORTETHXE_RSP_INVALID_CMD ) ) )
    {
        Delay_ms ( 1 );
        xportethxe_process( ctx );
        if ( timeout_cnt++ > timeout )
        {
            return XPORTETHXE_ERROR_TIMEOUT;
        }
    }
    timeout_cnt = 0;
    timeout = 50;
    xportethxe_clear_app_buf ( );
    while ( timeout_cnt++ < timeout )
    {
        if ( XPORTETHXE_OK == xportethxe_process( ctx ) )
        {
            timeout_cnt = 0;
        }
        Delay_ms ( 1 );
    }
    xportethxe_clear_app_buf ( );
    return XPORTETHXE_OK;
}

// ------------------------------------------------------------------------ END

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。

想查看更多

类似项目